49857a
diff -rup binutils.orig/bfd/elf32-i386.c binutils-2.30/bfd/elf32-i386.c
49857a
--- binutils.orig/bfd/elf32-i386.c	2018-02-27 17:25:53.961140597 +0000
49857a
+++ binutils-2.30/bfd/elf32-i386.c	2018-02-27 17:27:14.115133477 +0000
49857a
@@ -383,7 +383,7 @@ elf_i386_rtype_to_howto (bfd *abfd, unsi
49857a
     {
49857a
       (*_bfd_error_handler) (_("%B: invalid relocation type %d"),
49857a
 			     abfd, (int) r_type);
49857a
-      indx = R_386_NONE;
49857a
+      return NULL;
49857a
     }
49857a
   /* PR 17512: file: 0f67f69d.  */
49857a
   if (elf_howto_table [indx].type != r_type)
49857a
diff -rup binutils.orig/bfd/elf64-ppc.c binutils-2.30/bfd/elf64-ppc.c
49857a
--- binutils.orig/bfd/elf64-ppc.c	2018-02-27 17:25:53.969140496 +0000
49857a
+++ binutils-2.30/bfd/elf64-ppc.c	2018-02-27 17:27:56.213604518 +0000
49857a
@@ -2516,9 +2516,12 @@ ppc64_elf_info_to_howto (bfd *abfd, arel
49857a
     {
49857a
       (*_bfd_error_handler) (_("%B: invalid relocation type %d"),
49857a
 			     abfd, (int) type);
49857a
-      type = R_PPC64_NONE;
49857a
+      cache_ptr->howto = NULL;
49857a
     }
49857a
-  cache_ptr->howto = ppc64_elf_howto_table[type];
49857a
+  else
49857a
+    cache_ptr->howto = ppc64_elf_howto_table[type];
49857a
+  if (cache_ptr->howto == NULL || cache_ptr->howto->name == NULL)
49857a
+    _bfd_error_handler (_("%B: invalid relocation type %d"), abfd, type);
49857a
 }
49857a
 
49857a
 /* Handle the R_PPC64_ADDR16_HA and similar relocs.  */
49857a
diff -rup binutils.orig/bfd/elf64-s390.c binutils-2.30/bfd/elf64-s390.c
49857a
--- binutils.orig/bfd/elf64-s390.c	2018-02-27 17:25:53.968140509 +0000
49857a
+++ binutils-2.30/bfd/elf64-s390.c	2018-02-27 17:28:24.632247443 +0000
49857a
@@ -372,9 +372,10 @@ elf_s390_info_to_howto (bfd *abfd ATTRIB
49857a
 	{
49857a
 	  (*_bfd_error_handler) (_("%B: invalid relocation type %d"),
49857a
 				 abfd, (int) r_type);
49857a
-	  r_type = R_390_NONE;
49857a
+	  cache_ptr->howto = NULL;
49857a
 	}
49857a
-      cache_ptr->howto = &elf_howto_table[r_type];
49857a
+      else
49857a
+	cache_ptr->howto = &elf_howto_table[r_type];
49857a
     }
49857a
 }
49857a
 
49857a
diff -rup binutils.orig/bfd/elf64-x86-64.c binutils-2.30/bfd/elf64-x86-64.c
49857a
--- binutils.orig/bfd/elf64-x86-64.c	2018-02-27 17:25:53.964140559 +0000
49857a
+++ binutils-2.30/bfd/elf64-x86-64.c	2018-02-27 17:29:12.554645307 +0000
49857a
@@ -284,7 +284,7 @@ elf_x86_64_rtype_to_howto (bfd *abfd, un
49857a
 	{
49857a
 	  (*_bfd_error_handler) (_("%B: invalid relocation type %d"),
49857a
 				 abfd, (int) r_type);
49857a
-	  r_type = R_X86_64_NONE;
49857a
+	  return NULL;
49857a
 	}
49857a
       i = r_type;
49857a
     }
49857a
@@ -347,7 +347,6 @@ elf_x86_64_info_to_howto (bfd *abfd ATTR
49857a
 
49857a
   r_type = ELF32_R_TYPE (dst->r_info);
49857a
   cache_ptr->howto = elf_x86_64_rtype_to_howto (abfd, r_type);
49857a
-  BFD_ASSERT (r_type == cache_ptr->howto->type);
49857a
 }
49857a
 
49857a
 /* Support for core dump NOTE sections.  */
49857a
diff -rup binutils.orig/bfd/elfcode.h binutils-2.30/bfd/elfcode.h
49857a
--- binutils.orig/bfd/elfcode.h	2018-02-27 17:25:53.964140559 +0000
49857a
+++ binutils-2.30/bfd/elfcode.h	2018-02-27 17:26:57.234345581 +0000
49857a
@@ -1474,6 +1474,12 @@ elf_slurp_reloc_table_from_section (bfd
49857a
 	(*ebd->elf_info_to_howto) (abfd, relent, &rela);
49857a
       else
49857a
 	(*ebd->elf_info_to_howto_rel) (abfd, relent, &rela);
49857a
+
49857a
+      if (relent->howto == NULL)
49857a
+	{
49857a
+	  bfd_set_error (bfd_error_bad_value);
49857a
+	  goto error_return;
49857a
+	}
49857a
     }
49857a
 
49857a
   if (allocated != NULL)
49857a
diff -rup binutils.orig/binutils/objcopy.c binutils-2.30/binutils/objcopy.c
49857a
--- binutils.orig/binutils/objcopy.c	2018-02-27 17:25:53.185150347 +0000
49857a
+++ binutils-2.30/binutils/objcopy.c	2018-02-27 17:30:05.806976202 +0000
49857a
@@ -3022,10 +3022,19 @@ copy_object (bfd *ibfd, bfd *obfd, const
49857a
 	 haven't been set yet.  mark_symbols_used_in_relocations will
49857a
 	 ignore input sections which have no corresponding output
49857a
 	 section.  */
49857a
+      bfd_set_error (bfd_error_no_error);
49857a
       if (strip_symbols != STRIP_ALL)
49857a
-	bfd_map_over_sections (ibfd,
49857a
-			       mark_symbols_used_in_relocations,
49857a
-			       isympp);
49857a
+	{
49857a
+	  bfd_map_over_sections (ibfd,
49857a
+				 mark_symbols_used_in_relocations,
49857a
+				 isympp);
49857a
+	  if (bfd_get_error () != bfd_error_no_error)
49857a
+	    {
49857a
+	      status = 1;
49857a
+	      return FALSE;
49857a
+	    }
49857a
+	}
49857a
+
49857a
       osympp = (asymbol **) xmalloc ((symcount + add_symbols + 1) * sizeof (asymbol *));
49857a
       symcount = filter_symbols (ibfd, obfd, osympp, isympp, symcount);
49857a
     }
49857a
diff -rup binutils.orig/binutils/testsuite/binutils-all/objcopy.exp binutils-2.27/binutils/testsuite/binutils-all/objcopy.exp
49857a
--- binutils.orig/binutils/testsuite/binutils-all/objcopy.exp	2018-04-11 12:34:04.671683298 +0100
49857a
+++ binutils-2.27/binutils/testsuite/binutils-all/objcopy.exp	2018-04-11 12:36:50.053734109 +0100
49857a
@@ -1083,6 +1083,29 @@ if [is_elf_format] {
49857a
     }
49857a
     run_dump_test "strip-11" $extra_strip11
49857a
 
49857a
+    if { [istarget "mips64*-*-openbsd*"] } {
49857a
+	set reloc_format mips64
49857a
+    } elseif { [istarget "arm-*"] \
49857a
+	       || [istarget "d10v-*"] \
49857a
+	       || [istarget "dlx-*"] \
49857a
+	       || [istarget "i*86-*"] \
49857a
+	       || [istarget "i960-*"] \
49857a
+	       || [istarget "m681*-*"] \
49857a
+	       || [istarget "m68hc1*-*"] \
49857a
+	       || ([istarget "mips*-*"] \
49857a
+		   && ![istarget "mips64*-ps2-elf*"] \
49857a
+		   && ![istarget "*-*-irix6*"] \
49857a
+		   && ![istarget "mips64*-*-freebsd*"] \
49857a
+		   && ![istarget "mips64*-*-kfreebsd*-gnu"] \
49857a
+		   && ![istarget "mips64*-*-linux*"]) \
49857a
+	       || [istarget "score*-*"] \
49857a
+	       || [istarget "xgate-*"] } {
49857a
+	set reloc_format rel
49857a
+    } else {
49857a
+	set reloc_format rela
49857a
+    }
49857a
+    run_dump_test "strip-13" [list [list source strip-13${reloc_format}.s]]
49857a
+    
49857a
     if { [istarget "i*86-*"] || [istarget "x86_64-*-*"] } {
49857a
 	# Check to make sure we don't strip a symbol named in relocations.
49857a
 	set test "objcopy keeps symbols needed by relocs"
49857a
diff -rup binutils.orig/binutils/testsuite/lib/utils-lib.exp binutils-2.27/binutils/testsuite/lib/utils-lib.exp
49857a
--- binutils.orig/binutils/testsuite/lib/utils-lib.exp	2018-04-11 12:34:04.674683263 +0100
49857a
+++ binutils-2.27/binutils/testsuite/lib/utils-lib.exp	2018-04-11 12:54:56.097850613 +0100
49857a
@@ -1,4 +1,4 @@
49857a
-# Copyright (C) 1993-2016 Free Software Foundation, Inc.
49857a
+# Copyright (C) 1993-2018 Free Software Foundation, Inc.
49857a
 
49857a
 # This program is free software; you can redistribute it and/or modify
49857a
 # it under the terms of the GNU General Public License as published by
49857a
@@ -51,12 +51,17 @@ proc binutil_version { prog } {
49857a
 # default_binutils_run
49857a
 #	run a program, returning the output
49857a
 #	sets binutils_run_failed if the program does not exist
49857a
+#	sets binutils_run_status to the exit status of the program
49857a
 #
49857a
 proc default_binutils_run { prog progargs } {
49857a
     global binutils_run_failed
49857a
+    global binutils_run_status
49857a
     global host_triplet
49857a
 
49857a
     set binutils_run_failed 0
49857a
+    if [info exists binutils_run_status] {
49857a
+	unset binutils_run_status
49857a
+    }
49857a
 
49857a
     if ![is_remote host] {
49857a
 	if {[which $prog] == 0} then {
49857a
@@ -83,6 +88,7 @@ proc default_binutils_run { prog progarg
49857a
     regsub -all "\\$" "$progargs" "\\$" progargs
49857a
 
49857a
     set state [remote_exec host $prog $progargs]
49857a
+    set binutils_run_status [lindex $state 0]
49857a
     set exec_output [prune_warnings [lindex $state 1]]
49857a
     if {![string match "" $exec_output]} then {
49857a
 	send_log "$exec_output\n"
49857a
@@ -127,7 +133,6 @@ proc default_binutils_assemble_flags { s
49857a
     } else {
49857a
 	send_log "$exec_output\n"
49857a
 	verbose "$exec_output"
49857a
-	perror "$source: assembly failed"
49857a
 	return 0
49857a
     }
49857a
 }
49857a
@@ -214,6 +219,11 @@ proc exe_ext {} {
49857a
 #	Assemble the file SOURCE.s.  If omitted, this defaults to FILE.s.
49857a
 #       This is useful if several .d files want to share a .s file.
49857a
 #
49857a
+#   dump: DUMP
49857a
+#	Match against DUMP.d.  If omitted, this defaults to FILE.d.  This
49857a
+#	is useful if several .d files differ by options only.  Options are
49857a
+#	always read from FILE.d.
49857a
+#
49857a
 #   target: GLOBS...
49857a
 #       Run this test only on a specified list of targets.  More precisely,
49857a
 #       each glob in the space-separated list is passed to "istarget"; if
49857a
@@ -237,22 +247,22 @@ proc exe_ext {} {
49857a
 #
49857a
 #   error: REGEX
49857a
 #	An error with message matching REGEX must be emitted for the test
49857a
-#	to pass.  The PROG, objdump, nm and objcopy options have no
49857a
-#	meaning and need not supplied if this is present.
49857a
+#	to pass.  The DUMPPROG, addr2line, nm, objdump, readelf and size
49857a
+#	options have no meaning and need not supplied if this is present.
49857a
+#	Multiple "error" directives append to the expected error message.
49857a
+#
49857a
+#   error_output: FILE
49857a
+#	Means the same as 'error', except the regular expression lines
49857a
+#	are contains in FILE.
49857a
 #
49857a
 #   warning: REGEX
49857a
-#	Expect a gas warning matching REGEX.  It is an error to issue
49857a
-#	both "error" and "warning".
49857a
-#
49857a
-#   stderr: FILE
49857a
-#       FILE contains regexp lines to be matched against the diagnostic
49857a
-#       output of the assembler.  This does not preclude the use of
49857a
-#       PROG, nm, objdump, or objcopy.
49857a
-#
49857a
-#   error-output: FILE
49857a
-#       Means the same as 'stderr', but also indicates that the assembler
49857a
-#       is expected to exit unsuccessfully (therefore PROG, objdump, nm,
49857a
-#       and objcopy have no meaning and should not be supplied).
49857a
+#	Expect a warning matching REGEX.  It is an error to issue both
49857a
+#	"error" and "warning".  Multiple "warning" directives append to
49857a
+#	the expected linker warning message.
49857a
+#
49857a
+#   warning_output: FILE
49857a
+#	Means the same as 'warning', except the regular expression
49857a
+#	lines are contains in FILE.
49857a
 #
49857a
 # Each option may occur at most once.
49857a
 #
49857a
@@ -266,6 +276,7 @@ proc run_dump_test { name {extra_options
49857a
     global OBJDUMP NM OBJCOPY READELF STRIP
49857a
     global OBJDUMPFLAGS NMFLAGS OBJCOPYFLAGS READELFFLAGS STRIPFLAGS
49857a
     global ELFEDIT ELFEDITFLAGS
49857a
+    global binutils_run_status
49857a
     global host_triplet
49857a
     global env
49857a
     global copyfile
49857a
@@ -299,6 +310,11 @@ proc run_dump_test { name {extra_options
49857a
     set opts(PROG) {}
49857a
     set opts(DUMPPROG) {}
49857a
     set opts(source) {}
49857a
+    set opts(dump) {}
49857a
+    set opts(error) {}
49857a
+    set opts(warning) {}
49857a
+    set opts(error_output) {}
49857a
+    set opts(warning_output) {}
49857a
     set opts(target) {}
49857a
     set opts(not-target) {}
49857a
     set opts(skip) {}
49857a
@@ -317,12 +333,18 @@ proc run_dump_test { name {extra_options
49857a
 	# directory.
49857a
 	regsub -all "\\\$srcdir" "$opt_val" "$srcdir/$subdir" opt_val
49857a
 
49857a
-	if [string length $opts($opt_name)] {
49857a
-	    perror "option $opt_name multiply set in $file.d"
49857a
-	    unresolved $subdir/$name
49857a
-	    return
49857a
+	switch -- $opt_name {
49857a
+	    warning {}
49857a
+	    error {}
49857a
+	    default {
49857a
+		if [string length $opts($opt_name)] {
49857a
+		    perror "option $opt_name multiply set in $file.d"
49857a
+		    unresolved $subdir/$name
49857a
+		    return
49857a
+		}
49857a
+	    }
49857a
 	}
49857a
-	set opts($opt_name) $opt_val
49857a
+	append opts($opt_name) $opt_val
49857a
     }
49857a
 
49857a
     foreach i $extra_options {
49857a
@@ -340,7 +362,8 @@ proc run_dump_test { name {extra_options
49857a
 
49857a
 	# add extra option to end of existing option, adding space
49857a
 	# if necessary.
49857a
-	if [string length $opts($opt_name)] {
49857a
+	if { ![regexp "warning|error" $opt_name]
49857a
+	     && [string length $opts($opt_name)] } {
49857a
 	    append opts($opt_name) " "
49857a
 	}
49857a
 	append opts($opt_name) $opt_val
49857a
@@ -378,28 +401,35 @@ proc run_dump_test { name {extra_options
49857a
     }
49857a
 
49857a
     set dumpprogram ""
49857a
-    if { $opts(DUMPPROG) != "" } {
49857a
-	switch -- $opts(DUMPPROG) {
49857a
-	    addr2line	{ set dumpprogram addr2line }
49857a
-	    nm		{ set dumpprogram nm }
49857a
-	    objdump	{ set dumpprogram objdump }
49857a
-	    readelf	{ set dumpprogram readelf }
49857a
-	    size	{ set dumpprogram size }
49857a
-	    default	{
49857a
-		perror "unrecognized dump program option $opts(DUMPPROG) in $file.d"
49857a
-		unresolved $testname
49857a
-		return }
49857a
-	}
49857a
-    } else {
49857a
-	# Guess which program to run, by seeing which option was specified.
49857a
-	foreach p {addr2line nm objdump readelf size} {
49857a
-	    if {$opts($p) != ""} {
49857a
-		if {$dumpprogram != ""} {
49857a
-		    perror "more than one possible dump program specified in $file.d"
49857a
+    # It's meaningless to require an output-testing method when we
49857a
+    # expect an error.
49857a
+    if { $opts(error) == "" && $opts(error_output) == "" } {
49857a
+	if { $opts(DUMPPROG) != "" } {
49857a
+	    switch -- $opts(DUMPPROG) {
49857a
+		addr2line	{ set dumpprogram addr2line }
49857a
+		nm		{ set dumpprogram nm }
49857a
+		objdump		{ set dumpprogram objdump }
49857a
+		readelf		{ set dumpprogram readelf }
49857a
+		size		{ set dumpprogram size }
49857a
+		default		{
49857a
+		    perror "unrecognized dump program option $opts(DUMPPROG)\
49857a
+			    in $file.d"
49857a
 		    unresolved $testname
49857a
 		    return
49857a
-		} else {
49857a
-		    set dumpprogram $p
49857a
+		}
49857a
+	    }
49857a
+	} else {
49857a
+	    # Guess which program to run, by seeing which option was specified.
49857a
+	    foreach p {addr2line nm objdump readelf size} {
49857a
+		if {$opts($p) != ""} {
49857a
+		    if {$dumpprogram != ""} {
49857a
+			perror "more than one possible dump program specified\
49857a
+				in $file.d"
49857a
+			unresolved $testname
49857a
+			return
49857a
+		    } else {
49857a
+			set dumpprogram $p
49857a
+		    }
49857a
 		}
49857a
 	    }
49857a
 	}
49857a
@@ -456,6 +486,12 @@ proc run_dump_test { name {extra_options
49857a
 	set srcfile $srcdir/$subdir/$opts(source)
49857a
     }
49857a
 
49857a
+    if { $opts(dump) == "" } {
49857a
+	set dumpfile ${file}.d
49857a
+    } else {
49857a
+	set dumpfile $srcdir/$subdir/$opts(dump)
49857a
+    }
49857a
+
49857a
     if { $opts(as) == "binary" } {
49857a
 	while {[file type $srcfile] eq "link"} {
49857a
 	    set newfile [file readlink $srcfile]
49857a
@@ -464,7 +500,8 @@ proc run_dump_test { name {extra_options
49857a
 	    }
49857a
 	    set srcfile $newfile
49857a
 	}
49857a
-	file copy -force ${srcfile} $tempfile
49857a
+	# Make sure we copy the file if we are doing remote host testing.
49857a
+	remote_download host ${srcfile} $tempfile
49857a
     } else {
49857a
 	set exec_output [binutils_assemble_flags ${srcfile} $tempfile $opts(as)]
49857a
 	if [string match "" $exec_output] then {
49857a
@@ -475,16 +512,95 @@ proc run_dump_test { name {extra_options
49857a
 	}
49857a
     }
49857a
 
49857a
+    if { (($opts(warning) != "") && ($opts(error) != "")) \
49857a
+	 || (($opts(warning) != "") && ($opts(error_output) != "")) \
49857a
+	 || (($opts(warning) != "") && ($opts(warning_output) != "")) \
49857a
+	 || (($opts(error) != "") && ($opts(warning_output) != "")) \
49857a
+	 || (($opts(error) != "") && ($opts(error_output) != "")) \
49857a
+	 || (($opts(warning_output) != "") && ($opts(error_output) != "")) } {
49857a
+	perror "bad mix of warning, error, warning_output, and error_output\
49857a
+		test-directives"
49857a
+	unresolved $testname
49857a
+	return
49857a
+    }
49857a
+
49857a
+    set check_prog(source) ""
49857a
+    set check_prog(terminal) 0
49857a
+    if { $opts(error) != "" \
49857a
+	 || $opts(warning) != "" \
49857a
+	 || $opts(error_output) != "" \
49857a
+	 || $opts(warning_output) != "" } {
49857a
+
49857a
+	if { $opts(error) != "" || $opts(error_output) != "" } {
49857a
+	    set check_prog(terminal) 1
49857a
+	} else {
49857a
+	    set check_prog(terminal) 0
49857a
+	}
49857a
+
49857a
+	if { $opts(error) != "" || $opts(warning) != "" } {
49857a
+	    set check_prog(source) "regex"
49857a
+	    if { $opts(error) != "" } {
49857a
+		set check_prog(regex) $opts(error)
49857a
+	    } else {
49857a
+		set check_prog(regex) $opts(warning)
49857a
+	    }
49857a
+	} else {
49857a
+	    set check_prog(source) "file"
49857a
+	    if { $opts(error_output) != "" } {
49857a
+		set check_prog(file) $opts(error_output)
49857a
+	    } else {
49857a
+		set check_prog(file) $opts(warning_output)
49857a
+	    }
49857a
+	}
49857a
+    }
49857a
+
49857a
     set progopts1 $opts($program)
49857a
     eval set progopts \$[string toupper $program]FLAGS
49857a
     eval set binary \$[string toupper $program]
49857a
 
49857a
     set exec_output [binutils_run $binary "$progopts $progopts1 $tempfile $destopt ${copyfile}.o"]
49857a
-    if ![string match "" $exec_output] {
49857a
-	send_log "$exec_output\n"
49857a
+    set cmdret 0
49857a
+    if [info exists binutils_run_status] {
49857a
+	set cmdret $binutils_run_status
49857a
+    }
49857a
+
49857a
+    regsub "\n$" $exec_output "" exec_output
49857a
+    if { $cmdret != 0 || $exec_output != "" || $check_prog(source) != "" } {
49857a
+	set exitstat "succeeded"
49857a
+	if { $cmdret != 0 } {
49857a
+	    set exitstat "failed"
49857a
+	}
49857a
+
49857a
+	if { $check_prog(source) == "regex" } {
49857a
+	    verbose -log "$exitstat with: <$exec_output>,\
49857a
+			  expected: <$check_prog(regex)>"
49857a
+	} elseif { $check_prog(source) == "file" } {
49857a
+	    verbose -log "$exitstat with: <$exec_output>,\
49857a
+			  expected in file $check_prog(file)"
49857a
+	    set_file_contents "tmpdir/prog.messages" "$exec_output"
49857a
+	} else {
49857a
+	    verbose -log "$exitstat with: <$exec_output>, no expected output"
49857a
+	}
49857a
+	send_log -- "$exec_output\n"
49857a
 	verbose "$exec_output"
49857a
-	fail $testname
49857a
-	return
49857a
+
49857a
+	if { (($check_prog(source) == "") == ($exec_output == "")) \
49857a
+	     && (($cmdret == 0) == ($check_prog(terminal) == 0)) \
49857a
+	     && ((($check_prog(source) == "regex") \
49857a
+		  && ($check_prog(regex) == "") == ($exec_output == "") \
49857a
+		  && [regexp -- $check_prog(regex) $exec_output]) \
49857a
+		 || (($check_prog(source) == "file") \
49857a
+		     && (![regexp_diff "tmpdir/prog.messages" \
49857a
+			   "$srcdir/$subdir/$check_prog(file)"]))) } {
49857a
+	    # We have the expected output from prog.
49857a
+	    if { $check_prog(terminal) || $program == "" } {
49857a
+		pass $testname
49857a
+		return
49857a
+	    }
49857a
+	} else {
49857a
+	    fail $testname
49857a
+	    return
49857a
+	}
49857a
     }
49857a
 
49857a
     set progopts1 $opts($dumpprogram)
49857a
@@ -534,7 +650,7 @@ proc run_dump_test { name {extra_options
49857a
     }
49857a
 
49857a
     verbose_eval {[file_contents "tmpdir/dump.out"]} 3
49857a
-    if { [regexp_diff "tmpdir/dump.out" "${file}.d"] } then {
49857a
+    if { [regexp_diff "tmpdir/dump.out" "${dumpfile}"] } then {
49857a
 	fail $testname
49857a
 	verbose "output is [file_contents "tmpdir/dump.out"]" 2
49857a
 	return
49857a
--- /dev/null	2018-04-11 08:10:00.466225454 +0100
49857a
+++ binutils-2.27/binutils/testsuite/binutils-all/strip-13.d	2018-04-11 12:55:42.481306111 +0100
49857a
@@ -0,0 +1,10 @@
49857a
+#PROG: strip
49857a
+#strip: -g
49857a
+#error: \A[^\n]*: invalid relocation type 143\n
49857a
+#error:   [^\n]*: Bad value\Z
49857a
+#not-target: h8300-* ip2k-* m6811-* m68hc11-* rx-*
49857a
+# The H8300-*, IP2K and 68HC11 targets use 16-bit addressing, so `.dc.a'
49857a
+#  does not work for manual relocation data construction.
49857a
+# The RX targets do not complain about unrecognised relocs, unless they
49857a
+#  are actually used
49857a
+#  (which is what should really happen with the other targets...)
49857a
--- /dev/null	2018-04-11 08:10:00.466225454 +0100
49857a
+++ binutils-2.27/binutils/testsuite/binutils-all/strip-13mips64.s	2018-04-11 12:37:17.195412074 +0100
49857a
@@ -0,0 +1,14 @@
49857a
+	.text
49857a
+foo:
49857a
+	.dc.l    0x12345678
49857a
+
49857a
+	.section .rela.text
49857a
+	.dc.a	 0
49857a
+	.dc.l    0
49857a
+	.dc.b    0, 0, 0, 0x8f
49857a
+	.dc.a	 0x0000008f
49857a
+
49857a
+	.dc.a	 0
49857a
+	.dc.l    0
49857a
+	.dc.b    0, 0, 0, 0
49857a
+	.dc.a	 0
49857a
--- /dev/null	2018-04-11 08:10:00.466225454 +0100
49857a
+++ binutils-2.27/binutils/testsuite/binutils-all/strip-13rela.s	2018-04-11 12:37:17.195412074 +0100
49857a
@@ -0,0 +1,12 @@
49857a
+	.text
49857a
+foo:
49857a
+	.dc.l    0x12345678
49857a
+
49857a
+	.section .rela.text
49857a
+	.dc.a	 0
49857a
+	.dc.a    0x0000008f
49857a
+	.dc.a	 0x0000008f
49857a
+
49857a
+	.dc.a	 0
49857a
+	.dc.a    0
49857a
+	.dc.a	 0
49857a
--- /dev/null	2018-04-11 08:10:00.466225454 +0100
49857a
+++ binutils-2.27/binutils/testsuite/binutils-all/strip-13rel.s	2018-04-11 12:37:17.195412074 +0100
49857a
@@ -0,0 +1,10 @@
49857a
+	.text
49857a
+foo:
49857a
+	.dc.l    0x12345678
49857a
+
49857a
+	.section .rel.text
49857a
+	.dc.a	 0
49857a
+	.dc.a    0x0000008f
49857a
+
49857a
+	.dc.a	 0
49857a
+	.dc.a    0
49857a
--- binutils.orig/bfd/elfnn-aarch64.c	2018-04-11 12:34:04.649683557 +0100
49857a
+++ binutils-2.27/bfd/elfnn-aarch64.c	2018-04-11 13:33:08.539305994 +0100
49857a
@@ -1977,6 +1977,8 @@ elfNN_aarch64_info_to_howto (bfd *abfd A
49857a
 
49857a
   r_type = ELFNN_R_TYPE (elf_reloc->r_info);
49857a
   bfd_reloc->howto = elfNN_aarch64_howto_from_type (r_type);
49857a
+  if (bfd_reloc->howto == NULL)
49857a
+    _bfd_error_handler (_("%B: invalid relocation type %d"), abfd, r_type);
49857a
 }
49857a
 
49857a
 static reloc_howto_type *