Blame SOURCES/binutils-CVE-2021-20284.patch

d1152b
diff -rup binutils.orig/bfd/elf-bfd.h binutils-2.35.1/bfd/elf-bfd.h
d1152b
--- binutils.orig/bfd/elf-bfd.h	2021-03-12 12:20:04.495125388 +0000
d1152b
+++ binutils-2.35.1/bfd/elf-bfd.h	2021-03-12 12:21:25.696583280 +0000
d1152b
@@ -1562,7 +1562,7 @@ struct elf_backend_data
d1152b
 					       const char *, unsigned int);
d1152b
 
d1152b
   /* Called when after loading the normal relocs for a section.  */
d1152b
-  bfd_boolean (*slurp_secondary_relocs) (bfd *, asection *, asymbol **);
d1152b
+  bfd_boolean (*slurp_secondary_relocs) (bfd *, asection *, asymbol **, bfd_boolean);
d1152b
 
d1152b
   /* Called after writing the normal relocs for a section.  */
d1152b
   bfd_boolean (*write_secondary_relocs) (bfd *, asection *);
d1152b
@@ -2909,7 +2909,7 @@ extern bfd_boolean is_debuginfo_file (bf
d1152b
 extern bfd_boolean _bfd_elf_init_secondary_reloc_section
d1152b
   (bfd *, Elf_Internal_Shdr *, const char *, unsigned int);
d1152b
 extern bfd_boolean _bfd_elf_slurp_secondary_reloc_section
d1152b
-  (bfd *, asection *, asymbol **);
d1152b
+(bfd *, asection *, asymbol **, bfd_boolean);
d1152b
 extern bfd_boolean _bfd_elf_copy_special_section_fields
d1152b
   (const bfd *, bfd *, const Elf_Internal_Shdr *, Elf_Internal_Shdr *);
d1152b
 extern bfd_boolean _bfd_elf_write_secondary_reloc_section
d1152b
diff -rup binutils.orig/bfd/elf.c binutils-2.35.1/bfd/elf.c
d1152b
--- binutils.orig/bfd/elf.c	2021-03-12 12:20:04.496125381 +0000
d1152b
+++ binutils-2.35.1/bfd/elf.c	2021-03-12 12:20:46.032848074 +0000
d1152b
@@ -12513,7 +12513,8 @@ _bfd_elf_init_secondary_reloc_section (b
d1152b
 bfd_boolean
d1152b
 _bfd_elf_slurp_secondary_reloc_section (bfd *      abfd,
d1152b
 					asection * sec,
d1152b
-					asymbol ** symbols)
d1152b
+					asymbol ** symbols,
d1152b
+					bfd_boolean dynamic)
d1152b
 {
d1152b
   const struct elf_backend_data * const ebd = get_elf_backend_data (abfd);
d1152b
   asection * relsec;
d1152b
@@ -12590,7 +12591,10 @@ _bfd_elf_slurp_secondary_reloc_section (
d1152b
 	      continue;
d1152b
 	    }
d1152b
 
d1152b
-	  symcount = bfd_get_symcount (abfd);
d1152b
+         if (dynamic)
d1152b
+           symcount = bfd_get_dynamic_symcount (abfd);
d1152b
+         else
d1152b
+           symcount = bfd_get_symcount (abfd);
d1152b
 
d1152b
 	  for (i = 0, internal_reloc = internal_relocs,
d1152b
 		 native_reloc = native_relocs;
d1152b
diff -rup binutils.orig/bfd/elfcode.h binutils-2.35.1/bfd/elfcode.h
d1152b
--- binutils.orig/bfd/elfcode.h	2021-03-12 12:20:04.533125134 +0000
d1152b
+++ binutils-2.35.1/bfd/elfcode.h	2021-03-12 12:21:59.568357132 +0000
d1152b
@@ -1591,7 +1591,7 @@ elf_slurp_reloc_table (bfd *abfd,
d1152b
 					      symbols, dynamic))
d1152b
     return FALSE;
d1152b
 
d1152b
-  if (!bed->slurp_secondary_relocs (abfd, asect, symbols))
d1152b
+  if (!bed->slurp_secondary_relocs (abfd, asect, symbols, dynamic))
d1152b
     return FALSE;
d1152b
 
d1152b
   asect->relocation = relents;