DT_NEEDED entries for libraries not on the command line.

Kurt Roeckx kurt@roeckx.be
Mon Sep 19 07:34:00 GMT 2005


On Sun, Sep 18, 2005 at 02:19:58PM -0400, Daniel Jacobowitz wrote:
> On Sun, Sep 18, 2005 at 07:17:39PM +0200, Kurt Roeckx wrote:
> > Under what conditions does it add a DT_NEEDED from the
> > DT_NEEDED of an other lib?  Would things break if it
> > didn't do that?  Maybe a short example can help me
> > understand this?
> 
> If you reference the library's exports, you have a direct dependence on
> it.  We don't know whether the interface of libfoo.so is intended to
> re-export all the functionality of libbar.so that it uses, or whether
> the DT_NEEDED of libbar.so is an implementation detail and subject to
> vanish in a new version of libfoo.so.

If I understand you right.  I have a symbol in lib A, I have a
lib B that has a DT_NEEDED for lib A.  Then I make an application
that uses a symbol from A but don't link to it and link to B
instead, it will add a DT_NEEDED for both A and B?  A little test
shows that this is the case indeed.  And only using a symbol from
B (that uses a symbol from A) didn't add the DT_NEEDED for A.

I really didn't expect that kind of behaviour and would have
expected it to fail to link instead and that it would be the
application's error that it's not linking against something it
should.  But I guess changing that behaviour is going to break
lots of things.


Kurt



More information about the Binutils mailing list