Blame SOURCES/binutils-secondary-relocs-speed.patch

34ce9a
diff -rup binutils.orig/bfd/elf-bfd.h binutils-2.35/bfd/elf-bfd.h
34ce9a
--- binutils.orig/bfd/elf-bfd.h	2021-06-23 15:00:33.913477324 +0100
34ce9a
+++ binutils-2.35/bfd/elf-bfd.h	2021-06-23 15:03:42.300235019 +0100
34ce9a
@@ -1748,6 +1748,11 @@ struct bfd_elf_section_data
34ce9a
   /* Link from a text section to its .eh_frame_entry section.  */
34ce9a
   asection *eh_frame_entry;
34ce9a
 
34ce9a
+  /* TRUE if the section has secondary reloc sections associated with it.
34ce9a
+     FIXME: In the future it might be better to change this into a list
34ce9a
+     of secondary reloc sections, making lookup easier and faster.  */
34ce9a
+  bfd_boolean has_secondary_relocs;
34ce9a
+
34ce9a
   /* A pointer used for various section optimizations.  */
34ce9a
   void *sec_info;
34ce9a
 };
34ce9a
diff -rup binutils.orig/bfd/elf.c binutils-2.35/bfd/elf.c
34ce9a
--- binutils.orig/bfd/elf.c	2021-06-23 15:00:33.902477396 +0100
34ce9a
+++ binutils-2.35/bfd/elf.c	2021-06-23 15:02:36.269672347 +0100
34ce9a
@@ -12672,6 +12672,7 @@ _bfd_elf_copy_special_section_fields (co
34ce9a
 {
34ce9a
   asection * isec;
34ce9a
   asection * osec;
34ce9a
+  struct bfd_elf_section_data * esd;
34ce9a
 
34ce9a
   if (isection == NULL)
34ce9a
     return FALSE;
34ce9a
@@ -12687,8 +12688,9 @@ _bfd_elf_copy_special_section_fields (co
34ce9a
   if (osec == NULL)
34ce9a
     return FALSE;
34ce9a
 
34ce9a
-  BFD_ASSERT (elf_section_data (osec)->sec_info == NULL);
34ce9a
-  elf_section_data (osec)->sec_info = elf_section_data (isec)->sec_info;
34ce9a
+  esd = elf_section_data (osec);
34ce9a
+  BFD_ASSERT (esd->sec_info == NULL);
34ce9a
+  esd->sec_info = elf_section_data (isec)->sec_info;
34ce9a
   osection->sh_type = SHT_RELA;
34ce9a
   osection->sh_link = elf_onesymtab (obfd);
34ce9a
   if (osection->sh_link == 0)
34ce9a
@@ -12731,6 +12733,10 @@ _bfd_elf_copy_special_section_fields (co
34ce9a
   osection->sh_info =
34ce9a
     elf_section_data (isection->bfd_section->output_section)->this_idx;
34ce9a
 
34ce9a
+  esd = elf_section_data (isection->bfd_section->output_section);
34ce9a
+  BFD_ASSERT (esd != NULL);
34ce9a
+  osection->sh_info = esd->this_idx;
34ce9a
+  esd->has_secondary_relocs = TRUE;
34ce9a
 #if DEBUG_SECONDARY_RELOCS
34ce9a
   fprintf (stderr, "update header of %s, sh_link = %u, sh_info = %u\n",
34ce9a
 	   osec->name, osection->sh_link, osection->sh_info);
34ce9a
diff -rup binutils.orig/bfd/elfcode.h binutils-2.35/bfd/elfcode.h
34ce9a
--- binutils.orig/bfd/elfcode.h	2021-06-23 15:00:33.910477344 +0100
34ce9a
+++ binutils-2.35/bfd/elfcode.h	2021-06-23 15:04:32.506902070 +0100
34ce9a
@@ -987,7 +987,8 @@ elf_write_relocs (bfd *abfd, asection *s
34ce9a
       (*swap_out) (abfd, &src_rela, dst_rela);
34ce9a
     }
34ce9a
 
34ce9a
-  if (!bed->write_secondary_relocs (abfd, sec))
34ce9a
+  if (elf_section_data (sec)->has_secondary_relocs
34ce9a
+      && !bed->write_secondary_relocs (abfd, sec))
34ce9a
     {
34ce9a
       *failedp = TRUE;
34ce9a
       return;