binutils/
authorAlan Modra <amodra@gmail.com>
Sat, 31 Jan 2009 11:44:38 +0000 (11:44 +0000)
committerAlan Modra <amodra@gmail.com>
Sat, 31 Jan 2009 11:44:38 +0000 (11:44 +0000)
* NEWS: Mention --as-needed change.
ld/
* ld.texinfo (--as-needed): Update.
bfd/
* elflink.c (on_needed_list): New function.
(elf_link_add_object_symbols): Link in --as-needed libs if they
satisfy undefined symbols in other libs.

bfd/ChangeLog
bfd/elflink.c
binutils/ChangeLog
binutils/NEWS
ld/ChangeLog
ld/ld.texinfo

index d47fbe25b01d95e2eabbd58aa94e680c739c3962..ba070189e003448b6ac4e6f730b5bc6a7b213e07 100644 (file)
@@ -1,3 +1,9 @@
+2009-01-31  Alan Modra  <amodra@bigpond.net.au>
+
+       * elflink.c (on_needed_list): New function.
+       (elf_link_add_object_symbols): Link in --as-needed libs if they
+       satisfy undefined symbols in other libs.
+
 2009-01-30  Julian Brown  <julian@codesourcery.com>
 
        * elf32-arm.c (bfd_elf32_arm_vfp11_erratum_scan): Skip BFDs with
index 927f1c481a45fab60cce8e02ffb7149daaf4c036..8685a2fe182e2ac85ecc046cd414bd85742975d4 100644 (file)
@@ -3199,6 +3199,16 @@ elf_add_dt_needed_tag (bfd *abfd,
   return 0;
 }
 
+static bfd_boolean
+on_needed_list (const char *soname, struct bfd_link_needed_list *needed)
+{
+  for (; needed != NULL; needed = needed->next)
+    if (strcmp (soname, needed->name) == 0)
+      return TRUE;
+
+  return FALSE;
+}
+
 /* Sort symbol by value and section.  */
 static int
 elf_sort_symbol (const void *arg1, const void *arg2)
@@ -4434,8 +4444,11 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
 
          if (!add_needed
              && definition
-             && dynsym
-             && h->ref_regular)
+             && ((dynsym
+                  && h->ref_regular)
+                 || (h->ref_dynamic
+                     && (elf_dyn_lib_class (abfd) & DYN_AS_NEEDED) != 0
+                     && !on_needed_list (elf_dt_name (abfd), htab->needed))))
            {
              int ret;
              const char *soname = elf_dt_name (abfd);
index b61784efd47693b2ff072c6d80223b691d308212..c18aa008fa6511448ac65b68eb014c7f8c00ed3b 100644 (file)
@@ -1,3 +1,7 @@
+2009-01-31  Alan Modra  <amodra@bigpond.net.au>
+
+       * NEWS: Mention --as-needed change.
+
 2009-01-29  Alan Modra  <amodra@bigpond.net.au>
 
        PR 9798
index 4cc89e1dff7277691b70104eb4bdf6b3080b5fba..60ea0cd7a1f7847799c8d8590b0a598a351a79ea 100644 (file)
@@ -1,5 +1,10 @@
 -*- text -*-
 
+* --as-needed now links in a dynamic library if it satisfies undefined
+  symbols in regular objects, or in other dynamic libraries.  In the
+  latter case the library is not linked if it is found in a DT_NEEDED
+  entry of one of the libraries already linked.
+
 * Add new option --use-nul-prefixed-import-tables to dlltool to allow fall-
   back to old import table generation with null element prefix.
 
index 6333383cd3d43089f3d88aa0d46a734bbbcfbdc8..13c05c6cf07b8954d850290989e18c62f6be2526 100644 (file)
@@ -1,3 +1,7 @@
+2009-01-31  Alan Modra  <amodra@bigpond.net.au>
+
+       * ld.texinfo (--as-needed): Update.
+
 2009-01-29  Andrew Jenner  <andrew@codesourcery.com>
 
        * emultempl/armelf.em: Correct formatting of help text for
index 1d909897c931509925e64ca48cac4c14cfdb4fc3..ae8e2b7df5e98be8f014d68f41cbd233de921601 100644 (file)
@@ -1093,9 +1093,11 @@ This option affects ELF DT_NEEDED tags for dynamic libraries mentioned
 on the command line after the @option{--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.  @option{--as-needed} causes DT_NEEDED tags to only be emitted
-for libraries that satisfy some symbol reference from regular objects
-which is undefined at the point that the library was linked.
+needed.  @option{--as-needed} causes a DT_NEEDED tag to only be emitted
+for a library that satisfies a symbol reference from regular objects
+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.
 
 @kindex --add-needed
This page took 0.046444 seconds and 4 git commands to generate.