Weak references, --as-needed, and pthreads

Alan Modra amodra@gmail.com
Thu Jun 14 01:12:00 GMT 2018


On Tue, Jun 12, 2018 at 06:21:01PM -0700, Cary Coutant wrote:
> (5) Gold does not record symbol version information gleaned from an
> "as-needed" library that isn't needed. (BFD ld apparently does, or
> else it picks up the version information from the same symbols in
> libc.)

ld.bfd takes a snapshot of the symbol table before attempting to add
an as-needed library, and restores the symbol table if the library
wasn't needed.  That will result in picking up the libc symbol version
for these pthread symbols.

When gold sees duplicate weak symbols defined in shared libraries, I
think gold will set sym->object from the first definition seen.  (I
haven't checked but that seems likely.)  Where we first see a
definition in an as-needed library that isn't needed, sym->object
remains as that library (libpthread in this case), even when a later
definition (libc in this case) is the actual symbol used.  sym->object
really ought to be set to actual defining library, and the version
taken from there.  My 2013 gold patch wasn't correct.

-- 
Alan Modra
Australia Development Lab, IBM



More information about the Binutils mailing list