This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: Support LD_AS_NEEDED


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]