Does ld need to search for DT_NEEDED objects?

Ulrich Drepper
Tue Nov 21 07:59:00 GMT 2006

Ian Lance Taylor wrote:
> And the
> algorithm in ld does not match the one used by anyhow, as it
> ignores ${ORIGIN} and the use of hardware capabilities.

The DSTs need to be supported, the hardware capabilities not.  If this 
would make a different the DSOs are wrong.

Without looking for the dependencies, how can you adequately implement 
-z defs?  Yes, ideally all DSOs with symbols which are referenced should 
be listed on the command line.  Fact is that this isn't the case.  This 
is the reason why back when we added DT_NEEDED tracing support.

Removing it now is problematic.  You would potentially break linking 
programs which today work.  This is with -z defs.  But the worse part 
are the silent errors you create.  If you drop the DT_NEEDED tracing 
program might not get the version information.  Just try this: have code 
which uses thread functions and is linked only against librt (not 
libpthread).  This currently works, the reference (e.g, to 
pthread_create) is annotated with the version information.  If DT_NEEDED 
is not followed (librt has libpthread as a dependency) then you get an 
unversioned reference.  Very bad.

So, leave it in and fix it up.

➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖

More information about the Binutils mailing list