Wireshark mailing list archives
Re: Why are we linking with --as-needed?
From: Jeff Morriss <jeff.morriss.ws () gmail com>
Date: Thu, 21 Jan 2016 22:36:41 -0500
On 01/21/2016 10:17 PM, Guy Harris wrote:
The GNU linker documentation says of the --as-needed flag
--as-needed
--no-as-needed
This option affects ELF DT_NEEDED tags for dynamic libraries mentioned on the command line after the
--as-needed option. Normally the linker will add a DT_NEEDED tag for each dynamic library mentioned on the command
line, regardless of whether the library is actually needed or not. --as-needed causes a DT_NEEDED tag to only be
emitted for a library that at that point in the link satisfies a non-weak undefined symbol reference from a regular
object file or, if the library is not found in the DT_NEEDED lists of other needed libraries, a non-weak undefined
symbol reference from another needed dynamic library. Object files or libraries appearing on the command line after the
library in question do not affect whether the library is seen as needed. This is similar to the rules for extraction of
object files from archives. --no-as-needed restores the default behaviour.
--as-needed was added in this change:
commit b6cffe405019da8259413cfcb829339712a098a7
Author: Jörg Mayer <jmayer () loplof de>
Date: Fri Aug 7 18:49:24 2009 +0000
- Add an AC macro to test linker flags.
- Test whether the linker supports --as-needed and if so,
adds it to LDFLAGS
About all I could find for a reason were bugs such as
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=1677
complaining that Wireshark didn't build with --as-needed.
So why is it useful that it be built - or, at least, buildable - with --as-needed? (It's obviously not *necessary* as
not all platform support that capability.)
I thought I remembered seeing (back around the time of bug 1677) a web page explaining why it was a Good Idea. About all I can find at the moment is this one:
https://wiki.gentoo.org/wiki/Project:Quality_Assurance/As-needed ___________________________________________________________________________ Sent via: Wireshark-dev mailing list <wireshark-dev () wireshark org> Archives: https://www.wireshark.org/lists/wireshark-dev Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev mailto:wireshark-dev-request () wireshark org?subject=unsubscribe
Current thread:
- Why are we linking with --as-needed? Guy Harris (Jan 21)
- Re: Why are we linking with --as-needed? Jeff Morriss (Jan 21)
