ldso dl-hash.c line 187

Joakim Tjernlund joakim.tjernlund at lumentis.se
Thu Sep 22 08:36:28 UTC 2005


> 
> After spending several days looking at this line I've come to the conclusion
> it is bogus and, sure enough, if I change it to something less obscure my
> thumb uclibc build starts working even in the presence of (unresolved) weak
> function definitions...
> 
> I suspect the code termites have been nibbling:
> 
> if (type_class & (sym->st_shndx == SHN_UNDEF))
> 	continue;
> ...
> if (sym->st_value == 0)
> 	continue;

These tests are deduced from glibc and optimized. I think this is what you end up
with if you eliminate all "impossible" combinations. I don't know this stuff good
enough to be sure. Try looking at glibc.

Anyhow, there is minor crisis at work so I can't look into this ATM.

> 
> What's wrong with '0' as the value of a symbol?  And why should dl_find_hash
> be prepared to return (non-zero) values from symbol table entires for
> undefined symbols?  The first "if" test skips undefined symbols only when
> resolving a relocation for a PLT entry, by virtue of the fact that
> ELF_RTYPE_CLASS_PLT is defined as 1.
> 
> The second "if" test looks like a fixup for the broken first line - I
> suspect that should be:
> 
> if (sym->st_shndx == SHN_UNDEF)
> 	continue;
> 
> followed by some test of the general form:
> 
> if ((type_class & ELF_RTYPE_CLASS_PLT) && sym->st_shndx == index-of-the-plt)
> 	continue;
> 
> I don't know how to write the second test (the plt doesn't have a fixed
> index), but it doesn't matter because leaving it out is fine, or at least no
> worse that it was before.
> 
> If this works and no one can see a reason for the weird "if" I'll put it
> into a patch (I have other changes to _dl_find_hash for the implementation
> of thumb support.)
> 
> BTW the problem arises because, for some reason, my gcc/binutils-2.16 combo
> is generating undefined symbol table entries with a value of "1" for
> unresolved weak function references when the reference is compiled in thumb
> mode.  (I suspect this is a consequence of trying to set the low bit on
> STT_FUNC values when the value is for a thumb function.)
> 
> John Bowler <jbowler at acm.org>
> 
> _______________________________________________
> uClibc mailing list
> uClibc at uclibc.org
> http://busybox.net/cgi-bin/mailman/listinfo/uclibc





More information about the uClibc mailing list