aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2018-01-11 15:36:40 -0800
committerH.J. Lu <hjl.tools@gmail.com>2018-01-11 15:36:54 -0800
commitd664fd41e15f058aab41b70c567ad09f2fab1115 (patch)
treea0afc6442dac6e36ef8351cdf17ddcb0d715767c
parent71d378ae60a4f072ce392046878d471255f6c8a1 (diff)
downloadgdb-d664fd41e15f058aab41b70c567ad09f2fab1115.zip
gdb-d664fd41e15f058aab41b70c567ad09f2fab1115.tar.gz
gdb-d664fd41e15f058aab41b70c567ad09f2fab1115.tar.bz2
Ignore dynamic references on forced local symbols
We should ignore dynamic references on forced local symbols during garbage collection since they can never be referenced dynamically. bfd/ PR ld/22649 * elflink.c (bfd_elf_gc_mark_dynamic_ref_symbol): Ignore dynamic references on forced local symbols. ld/ PR ld/22649 * testsuite/ld-elf/pr22649-1.s: New file. * testsuite/ld-elf/pr22649-2a.s: Likewise. * testsuite/ld-elf/pr22649-2b.s: Likewise. * testsuite/ld-elf/pr22649.msg: Likewise. * testsuite/ld-elf/shared.exp: Run ld/22649 tests.
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/elflink.c2
-rw-r--r--ld/ChangeLog9
-rw-r--r--ld/testsuite/ld-elf/pr22649-1.s4
-rw-r--r--ld/testsuite/ld-elf/pr22649-2a.s8
-rw-r--r--ld/testsuite/ld-elf/pr22649-2b.s7
-rw-r--r--ld/testsuite/ld-elf/pr22649.msg1
-rw-r--r--ld/testsuite/ld-elf/shared.exp45
8 files changed, 81 insertions, 1 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 8f2feae..5ceb5a0 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,11 @@
2018-01-11 H.J. Lu <hongjiu.lu@intel.com>
+ PR ld/22649
+ * elflink.c (bfd_elf_gc_mark_dynamic_ref_symbol): Ignore dynamic
+ references on forced local symbols.
+
+2018-01-11 H.J. Lu <hongjiu.lu@intel.com>
+
PR ld/22677
* elflink.c (bfd_elf_gc_sections): Keep all PREINIT_ARRAY,
INIT_ARRAY as well as FINI_ARRAY sections for ld -r --gc-section.
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 4c92a04..e3751fa 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -13277,7 +13277,7 @@ bfd_elf_gc_mark_dynamic_ref_symbol (struct elf_link_hash_entry *h, void *inf)
if ((h->root.type == bfd_link_hash_defined
|| h->root.type == bfd_link_hash_defweak)
- && (h->ref_dynamic
+ && ((h->ref_dynamic && !h->forced_local)
|| ((h->def_regular || ELF_COMMON_DEF_P (h))
&& ELF_ST_VISIBILITY (h->other) != STV_INTERNAL
&& ELF_ST_VISIBILITY (h->other) != STV_HIDDEN
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 34fdb1f..977d779 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,5 +1,14 @@
2018-01-11 H.J. Lu <hongjiu.lu@intel.com>
+ PR ld/22649
+ * testsuite/ld-elf/pr22649-1.s: New file.
+ * testsuite/ld-elf/pr22649-2a.s: Likewise.
+ * testsuite/ld-elf/pr22649-2b.s: Likewise.
+ * testsuite/ld-elf/pr22649.msg: Likewise.
+ * testsuite/ld-elf/shared.exp: Run ld/22649 tests.
+
+2018-01-11 H.J. Lu <hongjiu.lu@intel.com>
+
PR ld/22677
* scripttempl/elf.sc (PREINIT_ARRAY): New.
Don't add .preinit_array for ld -r.
diff --git a/ld/testsuite/ld-elf/pr22649-1.s b/ld/testsuite/ld-elf/pr22649-1.s
new file mode 100644
index 0000000..9a7da7e
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr22649-1.s
@@ -0,0 +1,4 @@
+ .data
+ .globl foo
+foo:
+ .dc.a bar
diff --git a/ld/testsuite/ld-elf/pr22649-2a.s b/ld/testsuite/ld-elf/pr22649-2a.s
new file mode 100644
index 0000000..b5908b0
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr22649-2a.s
@@ -0,0 +1,8 @@
+ .data
+ .hidden foo
+ .hidden bar
+ .globl foo
+ .globl bar
+foo:
+bar:
+ .dc.a foo
diff --git a/ld/testsuite/ld-elf/pr22649-2b.s b/ld/testsuite/ld-elf/pr22649-2b.s
new file mode 100644
index 0000000..999686c
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr22649-2b.s
@@ -0,0 +1,7 @@
+ .data
+ .hidden foo
+ .globl foo
+ .globl bar
+foo:
+bar:
+ .dc.a foo
diff --git a/ld/testsuite/ld-elf/pr22649.msg b/ld/testsuite/ld-elf/pr22649.msg
new file mode 100644
index 0000000..b4e45bd
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr22649.msg
@@ -0,0 +1 @@
+.*: Removing unused section '\.data' in file 'tmpdir/pr22649-2.*\.o'
diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp
index 0c54568..95bac37 100644
--- a/ld/testsuite/ld-elf/shared.exp
+++ b/ld/testsuite/ld-elf/shared.exp
@@ -81,6 +81,51 @@ run_ld_link_tests [list \
{} \
"pr22471" \
] \
+ [list \
+ "Build pr22649-1.so" \
+ "$LFLAGS -shared" \
+ "" \
+ "$AFLAGS_PIC" \
+ {pr22649-1.s} \
+ {} \
+ "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" \
+ ] \
]
run_ld_link_tests [list \