This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PATCH: Support LD_AS_NEEDED
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: binutils at sources dot redhat dot com
- Date: Wed, 6 May 2009 14:27:19 -0700
- Subject: PATCH: Support LD_AS_NEEDED
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
Hi,
I got a request to support LD_AS_NEEDED. OK for trunk?
Thanks.
H.J.
----
2009-05-06 H.J. Lu <hongjiu.lu@intel.com>
* NEWS: Mention LD_AS_NEEDED.
* ld.texinfo: Document LD_AS_NEEDED.
* ldmain.c (main): Handle LD_AS_NEEDED.
--- ld/NEWS.needed 2009-02-09 16:16:43.000000000 -0800
+++ ld/NEWS 2009-02-09 16:16:44.000000000 -0800
@@ -26,6 +26,8 @@
For the switch --enable-runtime-pseudo-reloc it uses for 32-bit
runtime pseudo relocation version one, for 64-bit the version two.
+* ELF: Support environment variable LD_AS_NEEDED for --as-needed.
+
* ELF: Support environment variables, LD_SYMBOLIC for -Bsymbolic and
LD_SYMBOLIC_FUNCTIONS for -Bsymbolic-functions.
--- ld/ld.texinfo.needed 2009-02-09 16:16:43.000000000 -0800
+++ ld/ld.texinfo 2009-02-10 08:32:02.000000000 -0800
@@ -1099,7 +1099,10 @@ for a library that satisfies a symbol re
which is undefined at the point that the library was linked, or, if
the library is not found in the DT_NEEDED lists of other libraries
linked up to that point, a reference from another dynamic library.
-@option{--no-as-needed} restores the default behaviour.
+@option{--no-as-needed} restores the default behaviour. If the
+environment variable @code{LD_AS_NEEDED} is set, the linker will
+behave as if the @option{--as-needed} option is passed to the linker as
+the first command line option.
@kindex --add-needed
@kindex --no-add-needed
--- ld/ldmain.c.needed 2009-02-09 16:16:44.000000000 -0800
+++ ld/ldmain.c 2009-02-09 16:16:44.000000000 -0800
@@ -261,6 +261,9 @@ main (int argc, char **argv)
else if (getenv ("LD_SYMBOLIC_FUNCTIONS") != NULL)
command_line.symbolic = symbolic_functions;
+ if (getenv ("LD_AS_NEEDED") != NULL)
+ as_needed = TRUE;
+
/* We initialize DEMANGLING based on the environment variable
COLLECT_NO_DEMANGLE. The gcc collect2 program will demangle the
output of the linker, unless COLLECT_NO_DEMANGLE is set in the