]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
When assigning symbol version, we should hide debug symbols defined in discarded...
authorNick Clifton <nickc@redhat.com>
Tue, 6 Nov 2018 16:06:52 +0000 (16:06 +0000)
committerNick Clifton <nickc@redhat.com>
Tue, 6 Nov 2018 16:06:52 +0000 (16:06 +0000)
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.

bfd/ChangeLog
bfd/elflink.c
ld/ChangeLog
ld/testsuite/ld-plugin/lto.exp
ld/testsuite/ld-plugin/pr23818.d [new file with mode: 0644]
ld/testsuite/ld-plugin/pr23818.t [new file with mode: 0644]
ld/testsuite/ld-plugin/pr23818a.c [new file with mode: 0644]
ld/testsuite/ld-plugin/pr23818b.c [new file with mode: 0644]

index 401b7f13396f58a17b9d3eddb2764fffc3988cdd..273fbc8b23bdcf37c4df33c8ced3f023d989eea9 100644 (file)
@@ -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
index 02618bed8fea01db1f3e24d92b53aaa6aac1ff4f..46091b63411e6b6220b496afe617eb07163d47a2 100644 (file)
@@ -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);
index fb979d737d331ab08b88aa651eb1e5cb39804299..326f7163047a77e373e3ebfcd57bdcce29f7840f 100644 (file)
@@ -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.
index 7c50b0f1021c95ed25d1aeaf140550575f056faa..4ce74f25878d516ffe48b7f68bebc37b96bf644e 100644 (file)
@@ -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 (file)
index 0000000..5753cd6
--- /dev/null
@@ -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 (file)
index 0000000..45bca55
--- /dev/null
@@ -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 (file)
index 0000000..5b5ccbf
--- /dev/null
@@ -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 (file)
index 0000000..d4be333
--- /dev/null
@@ -0,0 +1,7 @@
+void foo (void);
+
+void
+bar (void)
+{
+  foo ();
+}