Blame SOURCES/binutils-plugin-as-needed-correct.patch

6eaabf
--- binutils.orig/bfd/elf-bfd.h	2021-09-20 16:06:58.320914954 +0100
6eaabf
+++ binutils-2.30/bfd/elf-bfd.h	2021-09-20 16:26:11.307770371 +0100
6eaabf
@@ -180,6 +180,8 @@ struct elf_link_hash_entry
6eaabf
   /* Symbol has a non-weak reference from a non-shared object (other than
6eaabf
      the object in which it is defined).  */
6eaabf
   unsigned int ref_regular_nonweak : 1;
6eaabf
+  /* Symbol has a non-weak reference from a LTO IR object file.  */
6eaabf
+  unsigned int ref_ir_nonweak : 1;
6eaabf
   /* Dynamic symbol has been adjustd.  */
6eaabf
   unsigned int dynamic_adjusted : 1;
6eaabf
   /* Symbol needs a copy reloc.  */
6eaabf
--- binutils.orig/bfd/elflink.c	2021-09-29 14:36:01.294185139 +0100
6eaabf
+++ binutils-2.30/bfd/elflink.c	2021-09-29 14:39:08.113874485 +0100
6eaabf
@@ -4663,7 +4663,12 @@ error_free_dyn:
6eaabf
 
6eaabf
 	  /* Plugin symbols aren't normal.  Don't set def/ref flags.  */
6eaabf
 	  if ((abfd->flags & BFD_PLUGIN) != 0)
6eaabf
-	    ;
6eaabf
+	    {
6eaabf
+	      /* Except for this flag to track nonweak references.  */
6eaabf
+	      if (!definition
6eaabf
+		  && bind != STB_WEAK)
6eaabf
+		h->ref_ir_nonweak = 1;
6eaabf
+	    }
6eaabf
 	  else if (!dynamic)
6eaabf
 	    {
6eaabf
 	      if (! definition)
6eaabf
@@ -4906,11 +4911,13 @@ error_free_dyn:
6eaabf
 	  if (!add_needed
6eaabf
 	      && matched
6eaabf
 	      && definition
6eaabf
+	      && h->root.type != bfd_link_hash_indirect
6eaabf
 	      && ((dynsym
6eaabf
 		   && h->ref_regular_nonweak)
6eaabf
 		  || (old_bfd != NULL
6eaabf
 		      && (old_bfd->flags & BFD_PLUGIN) != 0
6eaabf
-		      && bind != STB_WEAK)
6eaabf
+		      && h->ref_ir_nonweak
6eaabf
+		      && !info->lto_all_symbols_read)
6eaabf
 		  || (h->ref_dynamic_nonweak
6eaabf
 		      && (elf_dyn_lib_class (abfd) & DYN_AS_NEEDED) != 0
6eaabf
 		      && !on_needed_list (elf_dt_name (abfd),