Blame SOURCES/binutils-strip-unknown-relocs.patch

3304a2
diff -rup binutils-2.28.orig/bfd/elf32-i386.c binutils-2.28/bfd/elf32-i386.c
3304a2
--- binutils-2.28.orig/bfd/elf32-i386.c	2018-02-27 16:58:00.319510958 +0000
3304a2
+++ binutils-2.28/bfd/elf32-i386.c	2018-02-27 17:07:59.061934402 +0000
3304a2
@@ -386,7 +386,7 @@ elf_i386_rtype_to_howto (bfd *abfd, unsi
3304a2
       /* xgettext:c-format */
3304a2
       _bfd_error_handler (_("%B: invalid relocation type %d"),
3304a2
 			  abfd, (int) r_type);
3304a2
-      indx = R_386_NONE;
3304a2
+      return NULL;
3304a2
     }
3304a2
   /* PR 17512: file: 0f67f69d.  */
3304a2
   if (elf_howto_table [indx].type != r_type)
3304a2
diff -rup binutils-2.28.orig/bfd/elf64-ppc.c binutils-2.28/bfd/elf64-ppc.c
3304a2
--- binutils-2.28.orig/bfd/elf64-ppc.c	2018-02-27 16:58:00.307511111 +0000
3304a2
+++ binutils-2.28/bfd/elf64-ppc.c	2018-02-27 17:09:15.307974743 +0000
3304a2
@@ -2514,9 +2514,11 @@ ppc64_elf_info_to_howto (bfd *abfd ATTRI
3304a2
       /* xgettext:c-format */
3304a2
       _bfd_error_handler (_("%B: invalid relocation type %d"),
3304a2
 			  abfd, (int) type);
3304a2
-      type = R_PPC64_NONE;
3304a2
+
3304a2
+      cache_ptr->howto = NULL;
3304a2
     }
3304a2
-  cache_ptr->howto = ppc64_elf_howto_table[type];
3304a2
+  else
3304a2
+    cache_ptr->howto = ppc64_elf_howto_table[type];
3304a2
 }
3304a2
 
3304a2
 /* Handle the R_PPC64_ADDR16_HA and similar relocs.  */
3304a2
diff -rup binutils-2.28.orig/bfd/elf64-s390.c binutils-2.28/bfd/elf64-s390.c
3304a2
--- binutils-2.28.orig/bfd/elf64-s390.c	2018-02-27 16:58:00.309511085 +0000
3304a2
+++ binutils-2.28/bfd/elf64-s390.c	2018-02-27 17:09:46.776578668 +0000
3304a2
@@ -371,9 +371,10 @@ elf_s390_info_to_howto (bfd *abfd ATTRIB
3304a2
 	  /* xgettext:c-format */
3304a2
 	  _bfd_error_handler (_("%B: invalid relocation type %d"),
3304a2
 			      abfd, (int) r_type);
3304a2
-	  r_type = R_390_NONE;
3304a2
+	  cache_ptr->howto = NULL;
3304a2
 	}
3304a2
-      cache_ptr->howto = &elf_howto_table[r_type];
3304a2
+      else
3304a2
+	cache_ptr->howto = &elf_howto_table[r_type];
3304a2
     }
3304a2
 }
3304a2
 
3304a2
diff -rup binutils-2.28.orig/bfd/elf64-x86-64.c binutils-2.28/bfd/elf64-x86-64.c
3304a2
--- binutils-2.28.orig/bfd/elf64-x86-64.c	2018-02-27 16:58:00.305511136 +0000
3304a2
+++ binutils-2.28/bfd/elf64-x86-64.c	2018-02-27 17:07:32.052274354 +0000
3304a2
@@ -288,7 +288,7 @@ elf_x86_64_rtype_to_howto (bfd *abfd, un
3304a2
 	  /* xgettext:c-format */
3304a2
 	  _bfd_error_handler (_("%B: invalid relocation type %d"),
3304a2
 			      abfd, (int) r_type);
3304a2
-	  r_type = R_X86_64_NONE;
3304a2
+	  return NULL;
3304a2
 	}
3304a2
       i = r_type;
3304a2
     }
3304a2
@@ -348,7 +348,6 @@ elf_x86_64_info_to_howto (bfd *abfd ATTR
3304a2
 
3304a2
   r_type = ELF32_R_TYPE (dst->r_info);
3304a2
   cache_ptr->howto = elf_x86_64_rtype_to_howto (abfd, r_type);
3304a2
-  BFD_ASSERT (r_type == cache_ptr->howto->type);
3304a2
 }
3304a2
 
3304a2
 /* Support for core dump NOTE sections.  */
3304a2
diff -rup binutils-2.28.orig/bfd/elfcode.h binutils-2.28/bfd/elfcode.h
3304a2
--- binutils-2.28.orig/bfd/elfcode.h	2018-02-27 16:58:00.309511085 +0000
3304a2
+++ binutils-2.28/bfd/elfcode.h	2018-02-27 17:11:03.616611534 +0000
3304a2
@@ -1465,6 +1465,11 @@ elf_slurp_reloc_table_from_section (bfd
3304a2
 	(*ebd->elf_info_to_howto) (abfd, relent, &rela);
3304a2
       else
3304a2
 	(*ebd->elf_info_to_howto_rel) (abfd, relent, &rela);
3304a2
+      if (relent->howto == NULL)
3304a2
+	{
3304a2
+	  bfd_set_error (bfd_error_bad_value);
3304a2
+	  goto error_return;
3304a2
+	}
3304a2
     }
3304a2
 
3304a2
   if (allocated != NULL)
3304a2
diff -rup binutils-2.28.orig/binutils/objcopy.c binutils-2.28/binutils/objcopy.c
3304a2
--- binutils-2.28.orig/binutils/objcopy.c	2018-02-27 16:58:00.322510920 +0000
3304a2
+++ binutils-2.28/binutils/objcopy.c	2018-02-27 17:02:54.240788492 +0000
3304a2
@@ -2720,10 +2720,19 @@ copy_object (bfd *ibfd, bfd *obfd, const
3304a2
 	 haven't been set yet.  mark_symbols_used_in_relocations will
3304a2
 	 ignore input sections which have no corresponding output
3304a2
 	 section.  */
3304a2
+      bfd_set_error (bfd_error_no_error);
3304a2
       if (strip_symbols != STRIP_ALL)
3304a2
-	bfd_map_over_sections (ibfd,
3304a2
-			       mark_symbols_used_in_relocations,
3304a2
-			       isympp);
3304a2
+	{
3304a2
+	  bfd_map_over_sections (ibfd,
3304a2
+				 mark_symbols_used_in_relocations,
3304a2
+				 isympp);
3304a2
+	  if (bfd_get_error () != bfd_error_no_error)
3304a2
+	    {
3304a2
+	      status = 1;
3304a2
+	      return FALSE;
3304a2
+	    }
3304a2
+	}	  
3304a2
+
3304a2
       osympp = (asymbol **) xmalloc ((symcount + add_symbols + 1) * sizeof (asymbol *));
3304a2
       symcount = filter_symbols (ibfd, obfd, osympp, isympp, symcount);
3304a2
     }