d02871
diff -rup binutils.orig/bfd/elflink.c binutils-2.35.2/bfd/elflink.c
d02871
--- binutils.orig/bfd/elflink.c	2022-11-28 16:10:23.919422266 +0000
d02871
+++ binutils-2.35.2/bfd/elflink.c	2022-11-28 16:14:24.308499080 +0000
d02871
@@ -1260,14 +1260,25 @@ _bfd_elf_merge_symbol (bfd *abfd,
d02871
       olddyn = (oldsec->symbol->flags & BSF_DYNAMIC) != 0;
d02871
     }
d02871
 
d02871
-  /* Handle a case where plugin_notice won't be called and thus won't
d02871
-     set the non_ir_ref flags on the first pass over symbols.  */
d02871
   if (oldbfd != NULL
d02871
-      && (oldbfd->flags & BFD_PLUGIN) != (abfd->flags & BFD_PLUGIN)
d02871
-      && newdyn != olddyn)
d02871
+      && (oldbfd->flags & BFD_PLUGIN) != (abfd->flags & BFD_PLUGIN))
d02871
     {
d02871
-      h->root.non_ir_ref_dynamic = TRUE;
d02871
-      hi->root.non_ir_ref_dynamic = TRUE;
d02871
+      if (newdyn != olddyn)
d02871
+	{
d02871
+	  /* Handle a case where plugin_notice won't be called and thus
d02871
+	     won't set the non_ir_ref flags on the first pass over
d02871
+	     symbols.  */
d02871
+	  h->root.non_ir_ref_dynamic = TRUE;
d02871
+	  hi->root.non_ir_ref_dynamic = TRUE;
d02871
+	}
d02871
+
d02871
+      if ((oldbfd->flags & BFD_PLUGIN) != 0
d02871
+	  && hi->root.type == bfd_link_hash_indirect)
d02871
+	{
d02871
+	  /* Change indirect symbol from IR to undefined.  */
d02871
+	  hi->root.type = bfd_link_hash_undefined;
d02871
+	  hi->root.u.undef.abfd = oldbfd;
d02871
+	}
d02871
     }
d02871
 
d02871
   /* NEWDEF and OLDDEF indicate whether the new or old symbol,
d02871
diff -rup binutils.orig/bfd/linker.c binutils-2.35.2/bfd/linker.c
d02871
--- binutils.orig/bfd/linker.c	2022-11-28 16:10:23.822422639 +0000
d02871
+++ binutils-2.35.2/bfd/linker.c	2022-11-28 16:13:28.709712603 +0000
d02871
@@ -1672,7 +1672,7 @@ _bfd_generic_link_add_one_symbol (struct
d02871
 	case MIND:
d02871
 	  /* Multiple indirect symbols.  This is OK if they both point
d02871
 	     to the same symbol.  */
d02871
-	  if (strcmp (h->u.i.link->root.string, string) == 0)
d02871
+	  if (string != NULL && strcmp (h->u.i.link->root.string, string) == 0)
d02871
 	    break;
d02871
 	  /* Fall through.  */
d02871
 	case MDEF:
d02871
--- binutils.orig/bfd/elflink.c	2023-01-10 15:47:50.062668055 +0000
d02871
+++ binutils-2.35.2/bfd/elflink.c	2023-01-10 15:47:59.554659559 +0000
d02871
@@ -1271,8 +1271,7 @@ _bfd_elf_merge_symbol (bfd *abfd,
d02871
 	  h->root.non_ir_ref_dynamic = TRUE;
d02871
 	  hi->root.non_ir_ref_dynamic = TRUE;
d02871
 	}
d02871
-
d02871
-      if ((oldbfd->flags & BFD_PLUGIN) != 0
d02871
+      else if ((oldbfd->flags & BFD_PLUGIN) != 0
d02871
 	  && hi->root.type == bfd_link_hash_indirect)
d02871
 	{
d02871
 	  /* Change indirect symbol from IR to undefined.  */