Override the previous definition from IR object
authorH.J. Lu <hjl.tools@gmail.com>
Fri, 7 Dec 2018 23:39:49 +0000 (15:39 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Fri, 7 Dec 2018 23:40:02 +0000 (15:40 -0800)
Mark the previous definition from IR object as undefined so that the
generic linker will override it.

bfd/

PR ld/23958
* elflink.c (_bfd_elf_add_default_symbol): Override the previous
definition from IR object.

ld/

PR ld/23958
* testsuite/ld-plugin/lto.exp: Run PR ld/23958 test.
* testsuite/ld-plugin/pr23958.c: New file.
* testsuite/ld-plugin/pr23958.t: Likewise.

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

index 85277a15b1d901dfe6403191e03fa4cbef165c72..aa8be343f5ad42a54c0a8a551b05e508909dac6b 100644 (file)
@@ -1,3 +1,9 @@
+2018-12-07  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/23958
+       * elflink.c (_bfd_elf_add_default_symbol): Override the previous
+       definition from IR object.
+
 2018-12-08  Stafford Horne  <shorne@gmail.com>
 
        * elf32-or1k.c (or1k_grok_prstatus): New function.
index 4eca389bd184a2e25dc0bef71bdcc2ef842134ef..8992a5016f7c386cb19d0b0e443519aef81d751f 100644 (file)
@@ -1941,6 +1941,15 @@ _bfd_elf_add_default_symbol (bfd *abfd,
       if (! bfd_link_relocatable (info))
        {
          bh = &hi->root;
+         if (bh->type == bfd_link_hash_defined
+             && (bh->u.def.section->owner->flags & BFD_PLUGIN) != 0)
+           {
+             /* Mark the previous definition from IR object as
+                undefined so that the generic linker will override
+                it.  */
+             bh->type = bfd_link_hash_undefined;
+             bh->u.undef.abfd = bh->u.def.section->owner;
+           }
          if (! (_bfd_generic_link_add_one_symbol
                 (info, abfd, shortname, BSF_INDIRECT,
                  bfd_ind_section_ptr,
index c8c48c5c1a308d68257286b452147eed7fd1374e..75c9c7d11df02a4f4221c86b371469b39abbede2 100644 (file)
@@ -1,3 +1,10 @@
+2018-12-07  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/23958
+       * testsuite/ld-plugin/lto.exp: Run PR ld/23958 test.
+       * testsuite/ld-plugin/pr23958.c: New file.
+       * testsuite/ld-plugin/pr23958.t: Likewise.
+
 2018-12-07  H.J. Lu  <hongjiu.lu@intel.com>
 
        * NEWS: Updated for property change report.
index 008bde79de7733825d43a300d5aa2074d47ba264..b56bd63ef46e2711ac1f4344da18a0057747ce53 100644 (file)
@@ -225,6 +225,12 @@ set lto_link_tests [list \
    {pr23818a.c pr23818b.c} \
    {{"readelf" {-s --wide} "pr23818.d"}} \
    "libpr23818.so"] \
+  [list "Build libpr23958.so" \
+   "-shared -flto -Wl,-version-script,pr23958.t" \
+   "-g -flto $lto_fat" \
+   {pr23958.c} \
+   "" \
+   "libpr23958.so"] \
 ]
 
 if { [at_least_gcc_version 4 7] } {
diff --git a/ld/testsuite/ld-plugin/pr23958.c b/ld/testsuite/ld-plugin/pr23958.c
new file mode 100644 (file)
index 0000000..656dc31
--- /dev/null
@@ -0,0 +1,6 @@
+void
+dwarf_bytesize (void)
+{
+}
+
+asm (".symver dwarf_bytesize,dwarf_bytesize@@@ELFUTILS_0.143");
diff --git a/ld/testsuite/ld-plugin/pr23958.t b/ld/testsuite/ld-plugin/pr23958.t
new file mode 100644 (file)
index 0000000..d3af1ae
--- /dev/null
@@ -0,0 +1,4 @@
+ELFUTILS_0.143 {
+global:
+  dwarf_bytesize;
+};
This page took 0.036257 seconds and 4 git commands to generate.