[PATCH] _dl_iterate_phdr rework

Carmelo AMOROSO carmelo.amoroso at st.com
Wed Jan 23 09:18:48 UTC 2008

Joakim Tjernlund wrote:
> On Tue, 2008-01-22 at 15:44 +0100, Carmelo AMOROSO wrote:
>> Hi All,
>> the attached patch will solve an problem when statically linking
>> a C++ application with gcc configured to use unwind-dw2-fde-glibc 
>> implementation.
>> This needs _dl_iterate_phdr to be included into libc.a instead of libdl.a,
>> and the implementation has been fixed to handle the static case too 
>> (based on glibc code).
>> For the dynamic case, it's still present in ld.so.
>> Moreover, _dl_loaded_modules has been moved too (being used by 
>> _dl_iterate_phdr).
>> This has accomplished in the following way:
>> ldso/ldso/dl-elf.c:           removed _dl_iterate_phdr code and include 
>> "dl-iterate-phdr.c" source
>> ldso/ldso/dl-iterate-phdr.c : new file containing the fixed 
>> _dl_iterate_phdr function
>> ldso/ldso/dl-hash.c:          removed _dl_loaded_modules definition
>> ldso/ldso/dl-symbols.c:       included _dl_loaded_modules defintion
>> ldso/ldso/ldso.c:             include "dl-symbols.c"
>> libc/misc/elf/dl-core.c:      new file including dl-symbols.c and 
>> dl-iterate-phdr.c from ldso directory
>> The idea is to use dl-symbols.c to keep all symbols common among ldso 
>> and libc.a
>> (note that into the nptl branch another file dl-support.c will be added 
>> to keep some
>> TLS specific functionalities that are shared between ldso and libc.a)
>> Thanks to Peter Mazinger for his suggestions on this topic.
>> Any comments are welcome.
>> Carmelo
> Hi Carmelo
> Thanks for working on this.
Hi Jocke,
I had to fix a bug on STLinux :-)
> Got a comment or two:
> 1) I belive the iterate_phdr function has a new impl. in glibc where
>    struct dl_phdr_info has 2 more fields: dlpi_adds and dlpi_subs
yes I know (also another onr TLS related)
>    I guess they are there for a reason 
I think so...
> and that uClibc should perhaps
>    impl. them too?
currently I don't know. I could investigate more, anyway it could be 
fixed later
> 2) Have you looked at impl. this only in libc, like glibc?
>    Would that make the code less complex? 
Yes, it's simpler for sure not needed to include file from ldso 
directory into libc. As first approach
I tried to change as less as possible, but if we agree, I can do this easily
>  Jocke

More information about the uClibc mailing list