bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/26551] A definition referenced by an unneeded (--as-needed) shar


From: matz at suse dot de
Subject: [Bug ld/26551] A definition referenced by an unneeded (--as-needed) shared object should be exported
Date: Wed, 02 Sep 2020 12:34:01 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=26551

--- Comment #9 from Michael Matz <matz at suse dot de> ---
I think ld.bfd is completely fine to not export exe symbols only referenced by
mentioned but not otherwise needed libraries.  It's follows from traditional
behaviour that executables don't export any symbols, which aren't obviously
needed
in a static linking model, which is why -E exists.  I could a libararies that
isn't necessary by anything from the executable containing a back-reference to
the executable to not be obvious.  If you really need to support this situation
you would normally need to use -E, which btw is documented to sometime be
necessary with dlopen games:

       -E
           ...
           If you use "dlopen" to load a dynamic object which needs to refer
           back to the symbols defined by the program, rather than some other
           dynamic object, then you will probably need to use this option when
           linking the program itself.

The more controled way for this is --dynamic-list.

Doing what you suggest would break the following invariant: you can remove any
unneeded as-needed -lxyz arguments from the link command and end up with the
same
binary.  This is basically the set of libraries that 'ldd -u' would print, and
is
why as-needed was implement to start with, to save that manual manual work.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]