[PATCH 5/5] ld: Ignore the new weak definition if needed

H.J. Lu hjl.tools@gmail.com
Wed Oct 21 11:35:11 GMT 2020


Ignore the new weak definition if the old definition comes from the LTO
IR object since plugin_notice will turn it into undefweak.

	PR ld/26262
	* elflink.c (_bfd_elf_merge_symbol): Ignore the new weak
	definition if the old definition comes from the LTO IR object.
---
 bfd/elflink.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/bfd/elflink.c b/bfd/elflink.c
index e23d189b983..d69e69a3794 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -1286,6 +1286,18 @@ _bfd_elf_merge_symbol (bfd *abfd,
 	    && h->root.type != bfd_link_hash_undefweak
 	    && h->root.type != bfd_link_hash_common);
 
+  /* NB: Ignore the new weak definition if the old definition comes
+     from the LTO IR object since plugin_notice will turn it into
+     undefweak.  */
+  if (olddef
+      && oldbfd
+      && (oldbfd->flags & BFD_PLUGIN) != 0
+      && newweak)
+    {
+      *skip = TRUE;
+      return TRUE;
+    }
+
   /* NEWFUNC and OLDFUNC indicate whether the new or old symbol,
      respectively, appear to be a function.  */
 
-- 
2.26.2



More information about the Binutils mailing list