[Patch] PR 26198 Failure to merge read only data of machine code object file and LTO object file on MinGW

Markus Böck markus.boeck02@gmail.com
Thu Jul 9 21:08:51 GMT 2020


Given an object file with a symbol declared in a section with a
".linkonce" directive and

a plugin object file with the same symbol in a
.gnu.linkonce.*.<symbol> section don't

fail with a multiple reference error when the plugin object file
appears after the

native object file.



diff --git a/bfd/coffgen.c b/bfd/coffgen.c
index 3291b693eb..f2360aad31 100644
--- a/bfd/coffgen.c
+++ b/bfd/coffgen.c
@@ -2662,7 +2662,8 @@ _bfd_coff_section_already_linked (bfd *abfd,
    .gnu.linkonce.*.<key>.  */
       if (((s_comdat != NULL) == (l_comdat != NULL)
      && strcmp (name, l->sec->name) == 0)
-    || (l->sec->owner->flags & BFD_PLUGIN) != 0)
+    || (l->sec->owner->flags & BFD_PLUGIN) != 0
+          || (sec->owner->flags & BFD_PLUGIN) != 0)
   {
     /* The section has already been linked.  See if we should
        issue a warning.  */
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 9bb68e6991..9e9c9d145b 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,8 @@
+2020-07-09  Markus Böck  <markus.boeck02@gmail.com>
+
+  * coffgen.c (_bfd_coff_section_already_linked): Allow
+    .gnu.linkonce section to come after an already linked object.
+
 2020-07-09  Alan Modra  <amodra@gmail.com>

   * dlltool.c: Remove powerpc PE support and comments.


More information about the Binutils mailing list