Blob Blame History Raw
diff -rup binutils.orig/bfd/elf32-i386.c binutils-2.25.1/bfd/elf32-i386.c
--- binutils.orig/bfd/elf32-i386.c	2018-12-11 16:30:21.750431994 +0000
+++ binutils-2.25.1/bfd/elf32-i386.c	2018-12-11 16:31:17.656964743 +0000
@@ -377,7 +377,7 @@ elf_i386_rtype_to_howto (bfd *abfd, unsi
     {
       (*_bfd_error_handler) (_("%B: invalid relocation type %d"),
 			     abfd, (int) r_type);
-      indx = R_386_NONE;
+      return NULL;
     }
   /* PR 17512: file: 0f67f69d.  */
   if (elf_howto_table [indx].type != r_type)
diff -rup binutils.orig/bfd/elf64-ppc.c binutils-2.25.1/bfd/elf64-ppc.c
--- binutils.orig/bfd/elf64-ppc.c	2018-12-11 16:30:21.764431876 +0000
+++ binutils-2.25.1/bfd/elf64-ppc.c	2018-12-11 16:32:06.729554597 +0000
@@ -2473,9 +2473,12 @@ ppc64_elf_info_to_howto (bfd *abfd ATTRI
     {
       (*_bfd_error_handler) (_("%B: invalid relocation type %d"),
 			     abfd, (int) type);
-      type = R_PPC64_NONE;
+      cache_ptr->howto = NULL;
     }
-  cache_ptr->howto = ppc64_elf_howto_table[type];
+  else
+    cache_ptr->howto = ppc64_elf_howto_table[type];
+  if (cache_ptr->howto == NULL || cache_ptr->howto->name == NULL)
+    _bfd_error_handler (_("%B: invalid relocation type %d"), abfd, type);
 }
 
 /* Handle the R_PPC64_ADDR16_HA and similar relocs.  */
diff -rup binutils.orig/bfd/elf64-s390.c binutils-2.25.1/bfd/elf64-s390.c
--- binutils.orig/bfd/elf64-s390.c	2018-12-11 16:30:21.763431885 +0000
+++ binutils-2.25.1/bfd/elf64-s390.c	2018-12-11 16:33:13.975992568 +0000
@@ -369,9 +369,10 @@ elf_s390_info_to_howto (bfd *abfd ATTRIB
 	{
 	  (*_bfd_error_handler) (_("%B: invalid relocation type %d"),
 				 abfd, (int) r_type);
-	  r_type = R_390_NONE;
+	  cache_ptr->howto = NULL;
 	}
-      cache_ptr->howto = &elf_howto_table[r_type];
+      else
+	cache_ptr->howto = &elf_howto_table[r_type];
     }
 }
 
diff -rup binutils.orig/bfd/elf64-x86-64.c binutils-2.25.1/bfd/elf64-x86-64.c
--- binutils.orig/bfd/elf64-x86-64.c	2018-12-11 16:30:21.754431960 +0000
+++ binutils-2.25.1/bfd/elf64-x86-64.c	2018-12-11 16:34:02.519586839 +0000
@@ -278,7 +278,7 @@ elf_x86_64_rtype_to_howto (bfd *abfd, un
 	{
 	  (*_bfd_error_handler) (_("%B: invalid relocation type %d"),
 				 abfd, (int) r_type);
-	  r_type = R_X86_64_NONE;
+	  return NULL;
 	}
       i = r_type;
     }
@@ -338,7 +338,6 @@ elf_x86_64_info_to_howto (bfd *abfd ATTR
 
   r_type = ELF32_R_TYPE (dst->r_info);
   cache_ptr->howto = elf_x86_64_rtype_to_howto (abfd, r_type);
-  BFD_ASSERT (r_type == cache_ptr->howto->type);
 }
 
 /* Support for core dump NOTE sections.  */
diff -rup binutils.orig/bfd/elfcode.h binutils-2.25.1/bfd/elfcode.h
--- binutils.orig/bfd/elfcode.h	2018-12-11 16:30:21.754431960 +0000
+++ binutils-2.25.1/bfd/elfcode.h	2018-12-11 16:34:43.526244124 +0000
@@ -1458,6 +1458,12 @@ elf_slurp_reloc_table_from_section (bfd
 	(*ebd->elf_info_to_howto) (abfd, relent, &rela);
       else
 	(*ebd->elf_info_to_howto_rel) (abfd, relent, &rela);
+
+      if (relent->howto == NULL)
+	{
+	  bfd_set_error (bfd_error_bad_value);
+	  goto error_return;
+	}
     }
 
   if (allocated != NULL)
diff -rup binutils.orig/binutils/objcopy.c binutils-2.25.1/binutils/objcopy.c
--- binutils.orig/binutils/objcopy.c	2018-12-11 16:30:21.769431834 +0000
+++ binutils-2.25.1/binutils/objcopy.c	2018-12-11 16:35:57.894622568 +0000
@@ -2110,10 +2110,19 @@ copy_object (bfd *ibfd, bfd *obfd, const
 	 haven't been set yet.  mark_symbols_used_in_relocations will
 	 ignore input sections which have no corresponding output
 	 section.  */
+      bfd_set_error (bfd_error_no_error);
       if (strip_symbols != STRIP_ALL)
-	bfd_map_over_sections (ibfd,
-			       mark_symbols_used_in_relocations,
-			       isympp);
+	{
+	  bfd_map_over_sections (ibfd,
+				 mark_symbols_used_in_relocations,
+				 isympp);
+	  if (bfd_get_error () != bfd_error_no_error)
+	    {
+	      status = 1;
+	      return FALSE;
+	    }
+	}
+
       osympp = (asymbol **) xmalloc ((symcount + 1) * sizeof (asymbol *));
       symcount = filter_symbols (ibfd, obfd, osympp, isympp, symcount);
     }