aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2013-03-18 02:47:03 +0000
committerAlan Modra <amodra@gmail.com>2013-03-18 02:47:03 +0000
commitffa9430db119a35786d64ffa50af9c2c368d210f (patch)
tree5dfa83c0fe14863d865cc98001560a5365108836
parentf7f9535d8d2073ca2040997a16f17944e05ec940 (diff)
downloadgdb-ffa9430db119a35786d64ffa50af9c2c368d210f.zip
gdb-ffa9430db119a35786d64ffa50af9c2c368d210f.tar.gz
gdb-ffa9430db119a35786d64ffa50af9c2c368d210f.tar.bz2
PR ld/12549
bfd/ * elflink.c (elf_link_add_object_symbols): Exclude weak refs when considering whether an --as-needed library is needed. ld/ * ld.texinfo (--as-needed): Update. ld/testsuite/ * ld-elf/pr14862.out: Expect no output.
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/elflink.c4
-rw-r--r--ld/ChangeLog4
-rw-r--r--ld/ld.texinfo13
-rw-r--r--ld/testsuite/ChangeLog4
-rw-r--r--ld/testsuite/ld-elf/pr14862.out1
6 files changed, 24 insertions, 8 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 40bb0a1..b710f3c 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2013-03-18 Alan Modra <amodra@gmail.com>
+
+ PR ld/12549
+ * elflink.c (elf_link_add_object_symbols): Exclude weak refs when
+ considering whether an --as-needed library is needed.
+
2013-03-14 Tom Tromey <tromey@redhat.com>
* opncls.c (bfd_get_debug_link_info): Rename from
diff --git a/bfd/elflink.c b/bfd/elflink.c
index ba65f21..8055d26 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -4482,10 +4482,10 @@ error_free_dyn:
if (!add_needed
&& definition
&& ((dynsym
- && h->ref_regular
+ && h->ref_regular_nonweak
&& (undef_bfd == NULL
|| (undef_bfd->flags & BFD_PLUGIN) == 0))
- || (h->ref_dynamic
+ || (h->ref_dynamic_nonweak
&& (elf_dyn_lib_class (abfd) & DYN_AS_NEEDED) != 0
&& !on_needed_list (elf_dt_name (abfd), htab->needed))))
{
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 1bb67a3..9d5a23d 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,7 @@
+2013-03-18 Alan Modra <amodra@gmail.com>
+
+ * ld.texinfo (--as-needed): Update.
+
2013-03-14 Jakub Jelinek <jakub@redhat.com>
* emulparams/aarch64linux.sh (LIBPATH_SUFFIX): Set to 64 for
diff --git a/ld/ld.texinfo b/ld/ld.texinfo
index cc4e735..1f8e34d 100644
--- a/ld/ld.texinfo
+++ b/ld/ld.texinfo
@@ -1143,11 +1143,14 @@ 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 or not. @option{--as-needed} causes a DT_NEEDED tag to only be
-emitted for a library that satisfies an undefined symbol reference
-from a regular object file or, if the library is not found in the
-DT_NEEDED lists of other libraries linked up to that point, an
-undefined symbol reference from another dynamic library.
-@option{--no-as-needed} restores the default behaviour.
+emitted for a library that @emph{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 libraries, a
+non-weak undefined symbol reference from another dynamic library.
+Object files or libraries appearing on the command line @emph{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. @option{--no-as-needed} restores the default behaviour.
@kindex --add-needed
@kindex --no-add-needed
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index dec9d36..c14d579 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2013-03-18 Alan Modra <amodra@gmail.com>
+
+ * ld-elf/pr14862.out: Expect no output.
+
2013-03-15 Will Newton <will.newton@linaro.org>
* ld-arm/arm-elf.exp: Expand *-*eabi test to cover *-*eabi*.
diff --git a/ld/testsuite/ld-elf/pr14862.out b/ld/testsuite/ld-elf/pr14862.out
index d86bac9..e69de29 100644
--- a/ld/testsuite/ld-elf/pr14862.out
+++ b/ld/testsuite/ld-elf/pr14862.out
@@ -1 +0,0 @@
-OK