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

381f6c
diff -rup binutils.orig/bfd/elf32-i386.c binutils-2.30/bfd/elf32-i386.c
381f6c
--- binutils.orig/bfd/elf32-i386.c	2018-02-27 17:25:53.961140597 +0000
381f6c
+++ binutils-2.30/bfd/elf32-i386.c	2018-02-27 17:27:14.115133477 +0000
381f6c
@@ -383,7 +383,7 @@ elf_i386_rtype_to_howto (bfd *abfd, unsi
381f6c
       /* xgettext:c-format */
381f6c
       _bfd_error_handler (_("%B: invalid relocation type %d"),
381f6c
 			  abfd, (int) r_type);
381f6c
-      indx = R_386_NONE;
381f6c
+      return NULL;
381f6c
     }
381f6c
   /* PR 17512: file: 0f67f69d.  */
381f6c
   if (elf_howto_table [indx].type != r_type)
381f6c
diff -rup binutils.orig/bfd/elf64-ppc.c binutils-2.30/bfd/elf64-ppc.c
381f6c
--- binutils.orig/bfd/elf64-ppc.c	2018-02-27 17:25:53.969140496 +0000
381f6c
+++ binutils-2.30/bfd/elf64-ppc.c	2018-02-27 17:27:56.213604518 +0000
381f6c
@@ -2516,9 +2516,10 @@ ppc64_elf_info_to_howto (bfd *abfd, arel
381f6c
       /* xgettext:c-format */
381f6c
       _bfd_error_handler (_("%B: invalid relocation type %d"),
381f6c
 			  abfd, (int) type);
381f6c
-      type = R_PPC64_NONE;
381f6c
+      cache_ptr->howto = NULL;
381f6c
     }
381f6c
-  cache_ptr->howto = ppc64_elf_howto_table[type];
381f6c
+  else
381f6c
+    cache_ptr->howto = ppc64_elf_howto_table[type];
381f6c
 }
381f6c
 
381f6c
 /* Handle the R_PPC64_ADDR16_HA and similar relocs.  */
381f6c
diff -rup binutils.orig/bfd/elf64-s390.c binutils-2.30/bfd/elf64-s390.c
381f6c
--- binutils.orig/bfd/elf64-s390.c	2018-02-27 17:25:53.968140509 +0000
381f6c
+++ binutils-2.30/bfd/elf64-s390.c	2018-02-27 17:28:24.632247443 +0000
381f6c
@@ -372,9 +372,10 @@ elf_s390_info_to_howto (bfd *abfd ATTRIB
381f6c
 	  /* xgettext:c-format */
381f6c
 	  _bfd_error_handler (_("%B: invalid relocation type %d"),
381f6c
 			      abfd, (int) r_type);
381f6c
-	  r_type = R_390_NONE;
381f6c
+	  cache_ptr->howto = NULL;
381f6c
 	}
381f6c
-      cache_ptr->howto = &elf_howto_table[r_type];
381f6c
+      else
381f6c
+	cache_ptr->howto = &elf_howto_table[r_type];
381f6c
     }
381f6c
 }
381f6c
 
381f6c
diff -rup binutils.orig/bfd/elf64-x86-64.c binutils-2.30/bfd/elf64-x86-64.c
381f6c
--- binutils.orig/bfd/elf64-x86-64.c	2018-02-27 17:25:53.964140559 +0000
381f6c
+++ binutils-2.30/bfd/elf64-x86-64.c	2018-02-27 17:29:12.554645307 +0000
381f6c
@@ -284,7 +284,7 @@ elf_x86_64_rtype_to_howto (bfd *abfd, un
381f6c
 	  /* xgettext:c-format */
381f6c
 	  _bfd_error_handler (_("%B: invalid relocation type %d"),
381f6c
 			      abfd, (int) r_type);
381f6c
-	  r_type = R_X86_64_NONE;
381f6c
+	  return NULL;
381f6c
 	}
381f6c
       i = r_type;
381f6c
     }
381f6c
@@ -347,8 +347,6 @@ elf_x86_64_info_to_howto (bfd *abfd ATTR
381f6c
       && r_type != (unsigned int) R_X86_64_GNU_VTENTRY)
381f6c
     r_type &= ~R_X86_64_converted_reloc_bit;
381f6c
   cache_ptr->howto = elf_x86_64_rtype_to_howto (abfd, r_type);
381f6c
-
381f6c
-  BFD_ASSERT (r_type == cache_ptr->howto->type || cache_ptr->howto->type == R_X86_64_NONE);
381f6c
 }
381f6c
 
381f6c
 /* Support for core dump NOTE sections.  */
381f6c
diff -rup binutils.orig/bfd/elfcode.h binutils-2.30/bfd/elfcode.h
381f6c
--- binutils.orig/bfd/elfcode.h	2018-02-27 17:25:53.964140559 +0000
381f6c
+++ binutils-2.30/bfd/elfcode.h	2018-02-27 17:26:57.234345581 +0000
381f6c
@@ -1474,6 +1474,12 @@ elf_slurp_reloc_table_from_section (bfd
381f6c
 	(*ebd->elf_info_to_howto) (abfd, relent, &rela);
381f6c
       else
381f6c
 	(*ebd->elf_info_to_howto_rel) (abfd, relent, &rela);
381f6c
+
381f6c
+      if (relent->howto == NULL)
381f6c
+	{
381f6c
+	  bfd_set_error (bfd_error_bad_value);
381f6c
+	  goto error_return;
381f6c
+	}
381f6c
     }
381f6c
 
381f6c
   if (allocated != NULL)
381f6c
diff -rup binutils.orig/binutils/objcopy.c binutils-2.30/binutils/objcopy.c
381f6c
--- binutils.orig/binutils/objcopy.c	2018-02-27 17:25:53.185150347 +0000
381f6c
+++ binutils-2.30/binutils/objcopy.c	2018-02-27 17:30:05.806976202 +0000
381f6c
@@ -3022,10 +3022,19 @@ copy_object (bfd *ibfd, bfd *obfd, const
381f6c
 	 haven't been set yet.  mark_symbols_used_in_relocations will
381f6c
 	 ignore input sections which have no corresponding output
381f6c
 	 section.  */
381f6c
+      bfd_set_error (bfd_error_no_error);
381f6c
       if (strip_symbols != STRIP_ALL)
381f6c
-	bfd_map_over_sections (ibfd,
381f6c
-			       mark_symbols_used_in_relocations,
381f6c
-			       isympp);
381f6c
+	{
381f6c
+	  bfd_map_over_sections (ibfd,
381f6c
+				 mark_symbols_used_in_relocations,
381f6c
+				 isympp);
381f6c
+	  if (bfd_get_error () != bfd_error_no_error)
381f6c
+	    {
381f6c
+	      status = 1;
381f6c
+	      return FALSE;
381f6c
+	    }
381f6c
+	}
381f6c
+
381f6c
       osympp = (asymbol **) xmalloc ((symcount + add_symbols + 1) * sizeof (asymbol *));
381f6c
       symcount = filter_symbols (ibfd, obfd, osympp, isympp, symcount);
381f6c
     }