[binutils-gdb/binutils-2_31-branch] When assigning symbol version, we should hide debug symbols defined in discarded sections from IR ob
Nick Clifton
nickc@sourceware.org
Tue Nov 6 16:08:00 GMT 2018
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=84fdbf1a2c901965414eafc96e3bd15fc72ac123
commit 84fdbf1a2c901965414eafc96e3bd15fc72ac123
Author: Nick Clifton <nickc@redhat.com>
Date: Tue Nov 6 16:06:52 2018 +0000
When assigning symbol version, we should hide debug symbols defined in discarded sections from IR objects so that they can be removed later.
bfd PR ld/23818
* elflink.c (_bfd_elf_link_assign_sym_version): Hide symbols
defined in discarded input sections.
ld * testsuite/ld-plugin/lto.exp: Run PR ld/23818 test.
* testsuite/ld-plugin/pr23818.d: New file.
* testsuite/ld-plugin/pr23818.t: Likewise.
* testsuite/ld-plugin/pr23818a.c: Likewise.
* testsuite/ld-plugin/pr23818b.c: Likewise.
Diff:
---
bfd/ChangeLog | 6 ++++++
bfd/elflink.c | 11 ++++++++++-
ld/ChangeLog | 9 +++++++++
ld/testsuite/ld-plugin/lto.exp | 6 ++++++
ld/testsuite/ld-plugin/pr23818.d | 4 ++++
ld/testsuite/ld-plugin/pr23818.t | 4 ++++
ld/testsuite/ld-plugin/pr23818a.c | 4 ++++
ld/testsuite/ld-plugin/pr23818b.c | 7 +++++++
8 files changed, 50 insertions(+), 1 deletion(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 401b7f1..273fbc8 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2018-11-06 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/23818
+ * elflink.c (_bfd_elf_link_assign_sym_version): Hide symbols
+ defined in discarded input sections.
+
2018-09-12 H.J. Lu <hongjiu.lu@intel.com>
PR ld/23499
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 02618be..46091b6 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -2358,10 +2358,19 @@ _bfd_elf_link_assign_sym_version (struct elf_link_hash_entry *h, void *data)
return FALSE;
}
+ bed = get_elf_backend_data (info->output_bfd);
+
/* We only need version numbers for symbols defined in regular
objects. */
if (!h->def_regular)
- return TRUE;
+ {
+ /* Hide symbols defined in discarded input sections. */
+ if ((h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ && discarded_section (h->root.u.def.section))
+ (*bed->elf_backend_hide_symbol) (info, h, TRUE);
+ return TRUE;
+ }
hide = FALSE;
bed = get_elf_backend_data (info->output_bfd);
diff --git a/ld/ChangeLog b/ld/ChangeLog
index fb979d7..326f716 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,12 @@
+2018-11-06 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/23818
+ * testsuite/ld-plugin/lto.exp: Run PR ld/23818 test.
+ * testsuite/ld-plugin/pr23818.d: New file.
+ * testsuite/ld-plugin/pr23818.t: Likewise.
+ * testsuite/ld-plugin/pr23818a.c: Likewise.
+ * testsuite/ld-plugin/pr23818b.c: Likewise.
+
2018-08-12 H.J. Lu <hongjiu.lu@intel.com>
* testsuite/ld-x86-64/pr23486b.d: Swap pr23486a.s and pr23486a.s.
diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp
index 7c50b0f..4ce74f2 100644
--- a/ld/testsuite/ld-plugin/lto.exp
+++ b/ld/testsuite/ld-plugin/lto.exp
@@ -219,6 +219,12 @@ set lto_link_tests [list \
[list "Build pr22751.a" \
"$plug_opt" "-flto $lto_no_fat $INT128_CFLAGS" \
{pr22751.c} {} "pr22751.a"] \
+ [list "Build libpr23818.so" \
+ "-shared -flto -g -Wl,-version-script,pr23818.t" \
+ "-g -flto $lto_fat" \
+ {pr23818a.c pr23818b.c} \
+ {{"readelf" {-s --wide} "pr23818.d"}} \
+ "libpr23818.so"] \
]
if { [at_least_gcc_version 4 7] } {
diff --git a/ld/testsuite/ld-plugin/pr23818.d b/ld/testsuite/ld-plugin/pr23818.d
new file mode 100644
index 0000000..5753cd6
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr23818.d
@@ -0,0 +1,4 @@
+#failif
+#...
+.*0+ +[A-Z]+ +GLOBAL +DEFAULT +ABS foo
+#...
diff --git a/ld/testsuite/ld-plugin/pr23818.t b/ld/testsuite/ld-plugin/pr23818.t
new file mode 100644
index 0000000..45bca55
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr23818.t
@@ -0,0 +1,4 @@
+{
+ global: bar;
+ local: *;
+};
diff --git a/ld/testsuite/ld-plugin/pr23818a.c b/ld/testsuite/ld-plugin/pr23818a.c
new file mode 100644
index 0000000..5b5ccbf
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr23818a.c
@@ -0,0 +1,4 @@
+void
+foo ()
+{
+}
diff --git a/ld/testsuite/ld-plugin/pr23818b.c b/ld/testsuite/ld-plugin/pr23818b.c
new file mode 100644
index 0000000..d4be333
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr23818b.c
@@ -0,0 +1,7 @@
+void foo (void);
+
+void
+bar (void)
+{
+ foo ();
+}
More information about the Binutils-cvs
mailing list