Fixes for "Ignore dynamic references on forced local symbols"

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Fixes for "Ignore dynamic references on forced local symbols"

Alan Modra-3
PowerPC64 has its own mark_dynamic_ref, which needs the same change as
made by d664fd41e1 to the generic ELF version.  Some other targets
discard more than just .data, so allow for that too in expected ld
messages.

bfd/
        PR ld/22649
        * elf64-ppc.c (ppc64_elf_gc_mark_dynamic_ref): Ignore dynamic
        references on forced local symbols.
ld/
        PR ld/22649
        * testsuite/ld-elf/pr22649.msg: Allow other messages.
        * testsuite/ld-elf/shared.exp: Check that --gc-sections is
        supported before running ld/22649 tests.

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index fa82d46..ee9ffc4 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2018-01-12  Alan Modra  <[hidden email]>
+
+ PR ld/22649
+ * elf64-ppc.c (ppc64_elf_gc_mark_dynamic_ref): Ignore dynamic
+ references on forced local symbols.
+
 2018-01-11  H.J. Lu  <[hidden email]>
 
  PR ld/22393
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index c548fef..d4016b9 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -6447,7 +6447,7 @@ ppc64_elf_gc_mark_dynamic_ref (struct elf_link_hash_entry *h, void *inf)
 
   if ((eh->elf.root.type == bfd_link_hash_defined
        || eh->elf.root.type == bfd_link_hash_defweak)
-      && (eh->elf.ref_dynamic
+      && ((eh->elf.ref_dynamic && !eh->elf.forced_local)
   || ((eh->elf.def_regular || ELF_COMMON_DEF_P (&eh->elf))
       && ELF_ST_VISIBILITY (eh->elf.other) != STV_INTERNAL
       && ELF_ST_VISIBILITY (eh->elf.other) != STV_HIDDEN
diff --git a/ld/ChangeLog b/ld/ChangeLog
index a2c13c8..39f79fe 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,10 @@
+2018-01-12  Alan Modra  <[hidden email]>
+
+ PR ld/22649
+ * testsuite/ld-elf/pr22649.msg: Allow other messages.
+ * testsuite/ld-elf/shared.exp: Check that --gc-sections is
+ supported before running ld/22649 tests.
+
 2018-01-12  Nick Clifton  <[hidden email]>
 
  * emultempl/elf32.em (_handle_option): Add support for "-z undefs"
diff --git a/ld/testsuite/ld-elf/pr22649.msg b/ld/testsuite/ld-elf/pr22649.msg
index b4e45bd..66b5f25 100644
--- a/ld/testsuite/ld-elf/pr22649.msg
+++ b/ld/testsuite/ld-elf/pr22649.msg
@@ -1 +1,3 @@
+#...
 .*: Removing unused section '\.data' in file 'tmpdir/pr22649-2.*\.o'
+#pass
diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp
index 1247fd2..5c4d78a 100644
--- a/ld/testsuite/ld-elf/shared.exp
+++ b/ld/testsuite/ld-elf/shared.exp
@@ -90,44 +90,49 @@ run_ld_link_tests [list \
  {} \
  "pr22649-1.so" \
     ] \
-    [list \
- "Build pr22649-2a.so" \
- "$LFLAGS -shared -gc-sections -print-gc-sections" \
- "" \
- "$AFLAGS_PIC" \
- {pr22649-2a.s} \
- {{ld pr22649.msg}} \
- "pr22649-2a.so" \
-    ] \
-    [list \
- "Build pr22649-2b.so" \
- "$LFLAGS -shared -gc-sections -print-gc-sections" \
- "tmpdir/pr22649-1.so" \
- "$AFLAGS_PIC" \
- {pr22649-2a.s} \
- {{ld pr22649.msg}} \
- "pr22649-2b.so" \
-    ] \
-    [list \
- "Build pr22649-2c.so" \
- "$LFLAGS -shared -gc-sections -print-gc-sections" \
- "" \
- "$AFLAGS_PIC" \
- {pr22649-2b.s} \
- {} \
- "pr22649-2b.so" \
-    ] \
-    [list \
- "Build pr22649-2d.so" \
- "$LFLAGS -shared -gc-sections -print-gc-sections" \
- "tmpdir/pr22649-1.so" \
- "$AFLAGS_PIC" \
- {pr22649-2b.s} \
- {} \
- "pr22649-2b.so" \
-    ] \
 ]
 
+if { [check_gc_sections_available] } {
+    run_ld_link_tests [list \
+ [list \
+    "Build pr22649-2a.so" \
+    "$LFLAGS -shared -gc-sections -print-gc-sections" \
+    "" \
+    "$AFLAGS_PIC" \
+    {pr22649-2a.s} \
+    {{ld pr22649.msg}} \
+    "pr22649-2a.so" \
+ ] \
+ [list \
+    "Build pr22649-2b.so" \
+    "$LFLAGS -shared -gc-sections -print-gc-sections" \
+    "tmpdir/pr22649-1.so" \
+    "$AFLAGS_PIC" \
+    {pr22649-2a.s} \
+    {{ld pr22649.msg}} \
+    "pr22649-2b.so" \
+ ] \
+ [list \
+    "Build pr22649-2c.so" \
+    "$LFLAGS -shared -gc-sections -print-gc-sections" \
+    "" \
+    "$AFLAGS_PIC" \
+    {pr22649-2b.s} \
+    {} \
+    "pr22649-2b.so" \
+ ] \
+ [list \
+    "Build pr22649-2d.so" \
+    "$LFLAGS -shared -gc-sections -print-gc-sections" \
+    "tmpdir/pr22649-1.so" \
+    "$AFLAGS_PIC" \
+    {pr22649-2b.s} \
+    {} \
+    "pr22649-2b.so" \
+ ] \
+    ]
+}
+
 run_ld_link_tests [list \
     [list \
  "DT_TEXTREL in shared lib" \

--
Alan Modra
Australia Development Lab, IBM