This is the mail archive of the binutils-cvs@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Have info_to_howto functions return a success/fail status. Check this result. Stop strip from comp


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f3185997ac0951edac802e29df03dfc0844fda34

commit f3185997ac0951edac802e29df03dfc0844fda34
Author: Nick Clifton <nickc@redhat.com>
Date:   Tue Feb 27 10:15:13 2018 +0000

    Have info_to_howto functions return a success/fail status.  Check this result.  Stop strip from completeing if one of these functions fails.
    
    bfd	PR 22875
    	* elf-bfd.h (struct elf_backend_data): Change the return type of
    	the elf_info_to_howto and elf_info_to_howto_rel function pointers
    	to bfd_boolean.
    	* elfcode.h (elf_slurp_reloc_table_from_section): Check the return value from the info_to_howto function and fail if that function failed.
    	* elf32-h8300.c (elf32_h8_relocate_section): Check return value from the info_to_howto function.
    	(elf32_h8_relax_section): Likewise.
    	* elf32-lm32.c (lm32_elf_relocate_section): Likewise.
    	* elf32-m68hc1x.c (elf32_m68hc11_relocate_section): Likewise.
    	* elf32-score.c (s3_bfd_score_elf_relocate_section): Likewise.
    	* elf32-score7.c (s7_bfd_score_elf_relocate_section): Likewise.
    	* elf32-tic6x.c (elf32_tic6x_relocate_section): Likewise.
    	* elf64-ia64-vms.c (elf64_ia64_relocate_section): Likewise.
    	* elf64-sparc.c (elf64_sparc_slurp_one_reloc_table): Likewise.
    	* elf64-x86-64.c (elf_x86_64_tls_transition): Likewise.
    	* elfnn-ia64.c (elfNN_ia64_relocate_section): Likewise.
    	* elfnn-riscv.c (riscv_elf_check_relocs): Likewise.
    	(riscv_elf_relocate_section): Likewise.
    	* elf-hppa.h (elf_hppa_info_to_howto): Change return type to
    	bfd_boolean.  Issue an error message, set an error value and
    	return FALSE if the reloc is not recognized.
    	(elf_hppa_info_to_howto_rel): Likewise.
    	* elf-m10200.c (mn10200_info_to_howto): Likewise.
    	* elf-m10300.c (mn10300_info_to_howto): Likewise.
    	* elf.c (_bfd_elf_no_info_to_howto): Likewise.
    	* elf32-arc.c (arc_info_to_howto_rel): Likewise.
    	* elf32-arm.c (elf32_arm_info_to_howto): Likewise.
    	* elf32-avr.c (avr_info_to_howto_rela): Likewise.
    	* elf32-bfin.c (bfin_info_to_howto): Likewise.
    	* elf32-cr16.c (elf_cr16_info_to_howto): Likewise.
    	* elf32-cr16c.c (elf_cr16c_info_to_howto): Likewise.
    	* elf32-cris.c (elf_cr16c_info_to_howto_rel, cris_info_to_howto_rela): Likewise.
    	* elf32-crx.c (elf_crx_info_to_howto): Likewise.
    	* elf32-d10v.c (d10v_info_to_howto_rel): Likewise.
    	* elf32-d30v.c (d30v_info_to_howto_rel, d30v_info_to_howto_rela): Likewise.
    	* elf32-dlx.c (dlx_rtype_to_howto, elf32_dlx_info_to_howto, elf32_dlx_info_to_howto_rel): Likewise.
    	* elf32-epiphany.c (epiphany_info_to_howto_rela): Likewise.
    	* elf32-fr30.c (fr30_info_to_howto_rela): Likewise.
    	* elf32-frv.c (frv_info_to_howto_rela, 	frvfdpic_info_to_howto_rel): Likewise.
    	* elf32-ft32.c (ft32_info_to_howto_rela): Likewise.
    	* elf32-gen.c (elf_generic_info_to_howto, elf_generic_info_to_howto_rel): Likewise.
    	* elf32-h8300.c (elf32_h8_info_to_howto, elf32_h8_info_to_howto_rel): Likewise.
    	* elf32-i370.c (i370_elf_info_to_howto): Likewise.
    	* elf32-i386.c (elf_i386_reloc_type_lookup, elf_i386_rtype_to_howto, elf_i386_info_to_howto_rel): Likewise.
    	* elf32-i860.c (lookup_howto, elf32_i860_info_to_howto_rela): Likewise.
    	* elf32-i960.c (elf32_i960_info_to_howto_rel): Likewise.
    	* elf32-ip2k.c (ip2k_info_to_howto_rela): Likewise.
    	* elf32-iq2000.c (iq2000_info_to_howto_rela): Likewise.
    	* elf32-lm32.c (lm32_info_to_howto_rela): Likewise.
    	* elf32-m32c.c (m32c_info_to_howto_rela): Likewise.
    	* elf32-m32r.c (m32r_info_to_howto_rel, m32r_info_to_howto): Likewise.
    	* elf32-m68hc11.c (m68hc11_info_to_howto_rel): Likewise.
    	* elf32-m68hc12.c (m68hc11_info_to_howto_rel): Likewise.
    	* elf32-m68k.c (rtype_to_howto): Likewise.
    	* elf32-mcore.c (mcore_elf_info_to_howto): Likewise.
    	* elf32-mep.c (mep_info_to_howto_rela): Likewise.
    	* elf32-metag.c (metag_info_to_howto_rela): Likewise.
    	* elf32-microblaze.c (microblaze_elf_info_to_howto): Likewise.
    	* elf32-mips.c (mips_info_to_howto_rel, mips_info_to_howto_rela): Likewise.
    	* elf32-moxie.c (moxie_info_to_howto_rela): Likewise.
    	* elf32-msp430.c (msp430_info_to_howto_rela): Likewise.
    	* elf32-mt.c (mt_info_to_howto_rela): Likewise.
    	* elf32-nds32.c (nds32_info_to_howto_rel, nds32_info_to_howto): Likewise.
    	* elf32-nios2.c (nios2_elf32_info_to_howto): Likewise.
    	* elf32-or1k.c (or1k_info_to_howto_rela): Likewise.
    	* elf32-pj.c (pj_elf_info_to_howto): Likewise.
    	* elf32-ppc.c (ppc_elf_info_to_howto): Likewise.
    	* elf32-pru.c (pru_elf32_info_to_howto): Likewise.
    	* elf32-rl78.c (rl78_info_to_howto_rela): Likewise.
    	* elf32-rx.c (rx_info_to_howto_rela): Likewise.
    	* elf32-s390.c (elf_s390_info_to_howto): Likewise.
    	* elf32-score.c (s3_bfd_score_info_to_howto, _bfd_score_info_to_howto): Likewise.
    	* elf32-score7.c (s7_bfd_score_info_to_howto): Likewise.
    	* elf32-sh.c (sh_elf_info_to_howto): Likewise.
    	* elf32-spu.c (spu_elf_info_to_howto): Likewise.
    	* elf32-tic6x.c (elf32_tic6x_info_to_howto, elf32_tic6x_info_to_howto_rel): Likewise.
    	* elf32-tilepro.c (tilepro_info_to_howto_rela): Likewise.
    	* elf32-v850.c (v850_elf_info_to_howto_rel, v850_elf_info_to_howto_rela, v800_elf_info_to_howto): Likewise.
    	* elf32-vax.c (rtype_to_howto): Likewise.
    	* elf32-visium.c (visium_info_to_howto_rela): Likewise.
    	* elf32-wasm32.c (elf32_wasm32_rtype_to_howto, elf32_wasm32_info_to_howto_rela): Likewise.
    	* elf32-xc16x.c (elf32_xc16x_info_to_howto): Likewise.
    	* elf32-xgate.c (xgate_info_to_howto_rel): Likewise.
    	* elf32-xstormy16.c (xstormy16_info_to_howto_rela): Likewise.
    	* elf32-xtensa.c (elf_xtensa_info_to_howto_rela): Likewise.
    	* elf64-alpha.c (elf64_alpha_info_to_howto): Likewise.
    	* elf64-gen.c (elf_generic_info_to_howto, elf_generic_info_to_howto_rel): Likewise.
    	* elf64-ia64-vms.c (elf64_ia64_info_to_howto): Likewise.
    	* elf64-mips.c (mips_elf64_info_to_howto_rela): Likewise.
    	* elf64-mmix.c (mmix_info_to_howto_rela): Likewise.
    	* elf64-ppc.c (ppc64_elf_info_to_howto): Likewise.
    	* elf64-s390.c (elf_s390_reloc_type_lookup): Likewise.
    	* elf64-sh64.c (elf_s390_info_to_howto, sh_elf64_info_to_howto): Likewise.
    	* elf64-x86-64.c (elf_x86_64_info_to_howto): Likewise.
    	* elfn32-mips.c (mips_info_to_howto_rel, mips_info_to_howto_rela): Likewise.
    	* elfnn-aarch64.c (elfNN_aarch64_info_to_howto): Likewise.
    	* elfnn-ia64.c (elfNN_ia64_info_to_howto): Likewise.
    	* elfnn-riscv.c (riscv_info_to_howto_rela): Likewise.
    	* elfxx-ia64.c (ia64_elf_reloc_type_lookup): Likewise.
    	* elfxx-sparc.c (_bfd_sparc_elf_info_to_howto): Likewise.
    	* elfxx-tilegx.c (tilegx_info_to_howto_rela): Likewise.
    	* elf32-score.h (s7_bfd_score_info_to_howto): Update prototype.
    	* elfxx-sparc.h (_bfd_sparc_elf_info_to_howto): Update prototype.
    	* elfxx-tilegx.h (tilegx_info_to_howto_rela): Update prototype.
    	* elfxx-target.h (elf_info_to_howto, elf_info_to_howto_rel): Default to NULL.
    
    binutils PR 22875
    	* objcopy.c (copy_object): Check the error status after marking symbols used in relocations.
    	* testsuite/binutils-all/strip-13.s: New test source file.
    	* testsuite/binutils-all/strip-13.s: New test driver file.
    	* testsuite/binutils-all/objcopy.exp: Run the new test.

Diff:
---
 bfd/ChangeLog                               | 130 ++++++++++++++++++++++++++++
 bfd/elf-bfd.h                               |  10 +--
 bfd/elf-hppa.h                              |  36 ++++++--
 bfd/elf-m10200.c                            |  17 +++-
 bfd/elf-m10300.c                            |   7 +-
 bfd/elf.c                                   |   3 +-
 bfd/elf32-arc.c                             |  15 +++-
 bfd/elf32-arm.c                             |  20 +++--
 bfd/elf32-avr.c                             |   6 +-
 bfd/elf32-bfin.c                            |  16 +++-
 bfd/elf32-cr16.c                            |   7 +-
 bfd/elf32-cr16c.c                           |  10 ++-
 bfd/elf32-cris.c                            |   6 +-
 bfd/elf32-crx.c                             |   9 +-
 bfd/elf32-d10v.c                            |   8 +-
 bfd/elf32-d30v.c                            |  12 ++-
 bfd/elf32-dlx.c                             |  11 +--
 bfd/elf32-epiphany.c                        |   6 +-
 bfd/elf32-fr30.c                            |   6 +-
 bfd/elf32-frv.c                             |  12 ++-
 bfd/elf32-ft32.c                            |  15 +++-
 bfd/elf32-gen.c                             |   6 +-
 bfd/elf32-h8300.c                           |  36 ++++----
 bfd/elf32-i370.c                            |   5 +-
 bfd/elf32-i386.c                            |  37 ++++----
 bfd/elf32-i860.c                            |  12 +--
 bfd/elf32-i960.c                            |  16 ++--
 bfd/elf32-ip2k.c                            |   6 +-
 bfd/elf32-iq2000.c                          |   6 +-
 bfd/elf32-lm32.c                            |  11 ++-
 bfd/elf32-m32c.c                            |  14 +--
 bfd/elf32-m32r.c                            |  26 ++++--
 bfd/elf32-m68hc11.c                         |  10 ++-
 bfd/elf32-m68hc12.c                         |  10 ++-
 bfd/elf32-m68hc1x.c                         |   3 +-
 bfd/elf32-m68k.c                            |   6 +-
 bfd/elf32-mcore.c                           |   5 +-
 bfd/elf32-mep.c                             |  12 +--
 bfd/elf32-metag.c                           |   6 +-
 bfd/elf32-microblaze.c                      |   5 +-
 bfd/elf32-mips.c                            |  21 +++--
 bfd/elf32-moxie.c                           |   6 +-
 bfd/elf32-msp430.c                          |  17 ++--
 bfd/elf32-mt.c                              |  14 +--
 bfd/elf32-nds32.c                           |  28 ++++--
 bfd/elf32-nios2.c                           |  44 ++++++----
 bfd/elf32-or1k.c                            |   6 +-
 bfd/elf32-pj.c                              |   5 +-
 bfd/elf32-ppc.c                             |  11 ++-
 bfd/elf32-pru.c                             |  48 ++++++----
 bfd/elf32-rl78.c                            |   8 +-
 bfd/elf32-rx.c                              |  20 +++--
 bfd/elf32-s390.c                            |  10 ++-
 bfd/elf32-score.c                           |  16 ++--
 bfd/elf32-score.h                           |   2 +-
 bfd/elf32-score7.c                          |  12 +--
 bfd/elf32-sh.c                              |   5 +-
 bfd/elf32-spu.c                             |   5 +-
 bfd/elf32-tic6x.c                           |  58 ++++++++++---
 bfd/elf32-tilepro.c                         |  14 ++-
 bfd/elf32-v850.c                            |  37 +++++---
 bfd/elf32-vax.c                             |   7 +-
 bfd/elf32-visium.c                          |   6 +-
 bfd/elf32-wasm32.c                          |   9 +-
 bfd/elf32-xc16x.c                           |  15 ++--
 bfd/elf32-xgate.c                           |  14 +--
 bfd/elf32-xstormy16.c                       |  16 +++-
 bfd/elf32-xtensa.c                          |   9 +-
 bfd/elf64-alpha.c                           |   5 +-
 bfd/elf64-gen.c                             |   6 +-
 bfd/elf64-ia64-vms.c                        |  22 ++++-
 bfd/elf64-mips.c                            |  27 +++---
 bfd/elf64-mmix.c                            |   6 +-
 bfd/elf64-ppc.c                             |  24 ++++-
 bfd/elf64-s390.c                            |  15 +++-
 bfd/elf64-sh64.c                            |  12 ++-
 bfd/elf64-sparc.c                           |   6 +-
 bfd/elf64-x86-64.c                          |  14 ++-
 bfd/elfcode.h                               |  10 ++-
 bfd/elfn32-mips.c                           |  16 ++--
 bfd/elfnn-aarch64.c                         |  10 ++-
 bfd/elfnn-ia64.c                            |  23 ++++-
 bfd/elfnn-riscv.c                           |  32 ++++---
 bfd/elfxx-ia64.c                            |  19 ++--
 bfd/elfxx-sparc.c                           |  30 ++++---
 bfd/elfxx-sparc.h                           |   2 +-
 bfd/elfxx-target.h                          |   4 +-
 bfd/elfxx-tilegx.c                          |  20 ++++-
 bfd/elfxx-tilegx.h                          |   2 +-
 binutils/ChangeLog                          |   9 ++
 binutils/objcopy.c                          |  15 +++-
 binutils/testsuite/binutils-all/objcopy.exp |   2 +
 binutils/testsuite/binutils-all/readelf.exp |   2 +
 binutils/testsuite/binutils-all/strip-13.d  |   9 ++
 binutils/testsuite/binutils-all/strip-13.s  |  12 +++
 95 files changed, 996 insertions(+), 415 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 3df1591..42dfaed 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,133 @@
+2018-02-27  Nick Clifton  <nickc@redhat.com>
+
+	PR 22875
+	* elf-bfd.h (struct elf_backend_data): Change the return type of
+	the elf_info_to_howto and elf_info_to_howto_rel function pointers
+	to bfd_boolean.
+	* elfcode.h (elf_slurp_reloc_table_from_section): Check the return
+	value from the info_to_howto function and fail if that function
+	failed.
+	* elf32-h8300.c (elf32_h8_relocate_section): Check return value
+	from the info_to_howto function.
+	(elf32_h8_relax_section): Likewise.
+	* elf32-lm32.c (lm32_elf_relocate_section): Likewise.
+	* elf32-m68hc1x.c (elf32_m68hc11_relocate_section): Likewise.
+	* elf32-score.c (s3_bfd_score_elf_relocate_section): Likewise.
+	* elf32-score7.c (s7_bfd_score_elf_relocate_section): Likewise.
+	* elf32-tic6x.c (elf32_tic6x_relocate_section): Likewise.
+	* elf64-ia64-vms.c (elf64_ia64_relocate_section): Likewise.
+	* elf64-sparc.c (elf64_sparc_slurp_one_reloc_table): Likewise.
+	* elf64-x86-64.c (elf_x86_64_tls_transition): Likewise.
+	* elfnn-ia64.c (elfNN_ia64_relocate_section): Likewise.
+	* elfnn-riscv.c (riscv_elf_check_relocs): Likewise.
+	(riscv_elf_relocate_section): Likewise.
+	* elf-hppa.h (elf_hppa_info_to_howto): Change return type to
+	bfd_boolean.  Issue an error message, set an error value and
+	return FALSE if the reloc is not recognized.
+	(elf_hppa_info_to_howto_rel): Likewise.
+	* elf-m10200.c (mn10200_info_to_howto): Likewise.
+	* elf-m10300.c (mn10300_info_to_howto): Likewise.
+	* elf.c (_bfd_elf_no_info_to_howto): Likewise.
+	* elf32-arc.c (arc_info_to_howto_rel): Likewise.
+	* elf32-arm.c (elf32_arm_info_to_howto): Likewise.
+	* elf32-avr.c (avr_info_to_howto_rela): Likewise.
+	* elf32-bfin.c (bfin_info_to_howto): Likewise.
+	* elf32-cr16.c (elf_cr16_info_to_howto): Likewise.
+	* elf32-cr16c.c (elf_cr16c_info_to_howto): Likewise.
+	* elf32-cris.c (elf_cr16c_info_to_howto_rel)
+	(cris_info_to_howto_rela): Likewise.
+	* elf32-crx.c (elf_crx_info_to_howto): Likewise.
+	* elf32-d10v.c (d10v_info_to_howto_rel): Likewise.
+	* elf32-d30v.c (d30v_info_to_howto_rel, d30v_info_to_howto_rela):
+	Likewise.
+	* elf32-dlx.c (dlx_rtype_to_howto, elf32_dlx_info_to_howto)
+	(elf32_dlx_info_to_howto_rel): Likewise.
+	* elf32-epiphany.c (epiphany_info_to_howto_rela): Likewise.
+	* elf32-fr30.c (fr30_info_to_howto_rela): Likewise.
+	* elf32-frv.c (frv_info_to_howto_rela)
+	(frvfdpic_info_to_howto_rel): Likewise.
+	* elf32-ft32.c (ft32_info_to_howto_rela): Likewise.
+	* elf32-gen.c (elf_generic_info_to_howto)
+	(elf_generic_info_to_howto_rel): Likewise.
+	* elf32-h8300.c (elf32_h8_info_to_howto)
+	(elf32_h8_info_to_howto_rel): Likewise.
+	* elf32-i370.c (i370_elf_info_to_howto): Likewise.
+	* elf32-i386.c (elf_i386_reloc_type_lookup)
+	(elf_i386_rtype_to_howto, elf_i386_info_to_howto_rel): Likewise.
+	* elf32-i860.c (lookup_howto, elf32_i860_info_to_howto_rela):
+	Likewise.
+	* elf32-i960.c (elf32_i960_info_to_howto_rel): Likewise.
+	* elf32-ip2k.c (ip2k_info_to_howto_rela): Likewise.
+	* elf32-iq2000.c (iq2000_info_to_howto_rela): Likewise.
+	* elf32-lm32.c (lm32_info_to_howto_rela): Likewise.
+	* elf32-m32c.c (m32c_info_to_howto_rela): Likewise.
+	* elf32-m32r.c (m32r_info_to_howto_rel, m32r_info_to_howto):
+	Likewise.
+	* elf32-m68hc11.c (m68hc11_info_to_howto_rel): Likewise.
+	* elf32-m68hc12.c (m68hc11_info_to_howto_rel): Likewise.
+	* elf32-m68k.c (rtype_to_howto): Likewise.
+	* elf32-mcore.c (mcore_elf_info_to_howto): Likewise.
+	* elf32-mep.c (mep_info_to_howto_rela): Likewise.
+	* elf32-metag.c (metag_info_to_howto_rela): Likewise.
+	* elf32-microblaze.c (microblaze_elf_info_to_howto): Likewise.
+	* elf32-mips.c (mips_info_to_howto_rel, mips_info_to_howto_rela):
+	Likewise.
+	* elf32-moxie.c (moxie_info_to_howto_rela): Likewise.
+	* elf32-msp430.c (msp430_info_to_howto_rela): Likewise.
+	* elf32-mt.c (mt_info_to_howto_rela): Likewise.
+	* elf32-nds32.c (nds32_info_to_howto_rel, nds32_info_to_howto):
+	Likewise.
+	* elf32-nios2.c (nios2_elf32_info_to_howto): Likewise.
+	* elf32-or1k.c (or1k_info_to_howto_rela): Likewise.
+	* elf32-pj.c (pj_elf_info_to_howto): Likewise.
+	* elf32-ppc.c (ppc_elf_info_to_howto): Likewise.
+	* elf32-pru.c (pru_elf32_info_to_howto): Likewise.
+	* elf32-rl78.c (rl78_info_to_howto_rela): Likewise.
+	* elf32-rx.c (rx_info_to_howto_rela): Likewise.
+	* elf32-s390.c (elf_s390_info_to_howto): Likewise.
+	* elf32-score.c (s3_bfd_score_info_to_howto)
+	(_bfd_score_info_to_howto): Likewise.
+	* elf32-score7.c (s7_bfd_score_info_to_howto): Likewise.
+	* elf32-sh.c (sh_elf_info_to_howto): Likewise.
+	* elf32-spu.c (spu_elf_info_to_howto): Likewise.
+	* elf32-tic6x.c (elf32_tic6x_info_to_howto)
+	(elf32_tic6x_info_to_howto_rel): Likewise.
+	* elf32-tilepro.c (tilepro_info_to_howto_rela): Likewise.
+	* elf32-v850.c (v850_elf_info_to_howto_rel)
+	(v850_elf_info_to_howto_rela, v800_elf_info_to_howto): Likewise.
+	* elf32-vax.c (rtype_to_howto): Likewise.
+	* elf32-visium.c (visium_info_to_howto_rela): Likewise.
+	* elf32-wasm32.c (elf32_wasm32_rtype_to_howto)
+	(elf32_wasm32_info_to_howto_rela): Likewise.
+	* elf32-xc16x.c (elf32_xc16x_info_to_howto): Likewise.
+	* elf32-xgate.c (xgate_info_to_howto_rel): Likewise.
+	* elf32-xstormy16.c (xstormy16_info_to_howto_rela): Likewise.
+	* elf32-xtensa.c (elf_xtensa_info_to_howto_rela): Likewise.
+	* elf64-alpha.c (elf64_alpha_info_to_howto): Likewise.
+	* elf64-gen.c (elf_generic_info_to_howto)
+	(elf_generic_info_to_howto_rel): Likewise.
+	* elf64-ia64-vms.c (elf64_ia64_info_to_howto): Likewise.
+	* elf64-mips.c (mips_elf64_info_to_howto_rela): Likewise.
+	* elf64-mmix.c (mmix_info_to_howto_rela): Likewise.
+	* elf64-ppc.c (ppc64_elf_info_to_howto): Likewise.
+	* elf64-s390.c (elf_s390_reloc_type_lookup): Likewise.
+	* elf64-sh64.c (elf_s390_info_to_howto, sh_elf64_info_to_howto):
+	Likewise.
+	* elf64-x86-64.c (elf_x86_64_info_to_howto): Likewise.
+	* elfn32-mips.c (mips_info_to_howto_rel, mips_info_to_howto_rela):
+	Likewise.
+	* elfnn-aarch64.c (elfNN_aarch64_info_to_howto): Likewise.
+	* elfnn-ia64.c (elfNN_ia64_info_to_howto): Likewise.
+	* elfnn-riscv.c (riscv_info_to_howto_rela): Likewise.
+	* elfxx-ia64.c (ia64_elf_reloc_type_lookup): Likewise.
+	* elfxx-sparc.c (_bfd_sparc_elf_info_to_howto): Likewise.
+	* elfxx-tilegx.c (tilegx_info_to_howto_rela): Likewise.
+	* elf32-score.h (s7_bfd_score_info_to_howto): Update prototype.
+	* elfxx-sparc.h (_bfd_sparc_elf_info_to_howto): Update prototype.
+	* elfxx-tilegx.h (tilegx_info_to_howto_rela): Update prototype.
+	* elfxx-target.h (elf_info_to_howto, elf_info_to_howto_rel):
+	Default to NULL.
+
 2018-02-26  Jim Wilson  <jimw@sifive.com>
 	    Stephan Schreiber <info@fs-driver.org>
 
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 1edb31e..afd6982 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -872,13 +872,13 @@ struct elf_backend_data
   const void *arch_data;
 
   /* A function to translate an ELF RELA relocation to a BFD arelent
-     structure.  */
-  void (*elf_info_to_howto)
+     structure.  Returns TRUE upon success, FALSE otherwise.  */
+  bfd_boolean (*elf_info_to_howto)
     (bfd *, arelent *, Elf_Internal_Rela *);
 
   /* A function to translate an ELF REL relocation to a BFD arelent
-     structure.  */
-  void (*elf_info_to_howto_rel)
+     structure.  Returns TRUE upon success, FALSE otherwise.  */
+  bfd_boolean (*elf_info_to_howto_rel)
     (bfd *, arelent *, Elf_Internal_Rela *);
 
   /* A function to determine whether a symbol is global when
@@ -2181,7 +2181,7 @@ extern const struct bfd_elf_special_section *_bfd_elf_get_sec_type_attr
   (bfd *, asection *);
 
 /* If the target doesn't have reloc handling written yet:  */
-extern void _bfd_elf_no_info_to_howto
+extern bfd_boolean _bfd_elf_no_info_to_howto
   (bfd *, arelent *, Elf_Internal_Rela *);
 
 extern bfd_boolean bfd_section_from_shdr
diff --git a/bfd/elf-hppa.h b/bfd/elf-hppa.h
index b87ee83..75b4e26 100644
--- a/bfd/elf-hppa.h
+++ b/bfd/elf-hppa.h
@@ -1020,26 +1020,44 @@ _bfd_elf_hppa_gen_reloc_type (bfd *abfd,
 
 /* Translate from an elf into field into a howto relocation pointer.  */
 
-static void
+static bfd_boolean
 elf_hppa_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
 			arelent *bfd_reloc,
 			Elf_Internal_Rela *elf_reloc)
 {
-  BFD_ASSERT (ELF_R_TYPE (elf_reloc->r_info)
-	      < (unsigned int) R_PARISC_UNIMPLEMENTED);
-  bfd_reloc->howto = &elf_hppa_howto_table[ELF_R_TYPE (elf_reloc->r_info)];
+  unsigned int r_type = ELF32_R_TYPE (elf_reloc->r_info);
+
+  if (r_type >= (unsigned int) R_PARISC_UNIMPLEMENTED)
+    {
+      /* xgettext:c-format */
+      _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+			  abfd, r_type);
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
+    }
+  bfd_reloc->howto = &elf_hppa_howto_table[r_type];
+  return TRUE;
 }
 
 /* Translate from an elf into field into a howto relocation pointer.  */
 
-static void
-elf_hppa_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED,
+static bfd_boolean
+elf_hppa_info_to_howto_rel (bfd *abfd,
 			    arelent *bfd_reloc,
 			    Elf_Internal_Rela *elf_reloc)
 {
-  BFD_ASSERT (ELF_R_TYPE (elf_reloc->r_info)
-	      < (unsigned int) R_PARISC_UNIMPLEMENTED);
-  bfd_reloc->howto = &elf_hppa_howto_table[ELF_R_TYPE (elf_reloc->r_info)];
+  unsigned int r_type = ELF_R_TYPE (elf_reloc->r_info);
+
+  if (r_type >= (unsigned int) R_PARISC_UNIMPLEMENTED)
+    {
+      /* xgettext:c-format */
+      _bfd_error_handler (_("%pB: invalid relocation type %d"), abfd, r_type);
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
+    }
+
+  bfd_reloc->howto = &elf_hppa_howto_table[r_type];
+  return TRUE;
 }
 
 /* Return the address of the howto table entry to perform the CODE
diff --git a/bfd/elf-m10200.c b/bfd/elf-m10200.c
index 82c4ee7..cc71c1e 100644
--- a/bfd/elf-m10200.c
+++ b/bfd/elf-m10200.c
@@ -212,16 +212,25 @@ bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 
 /* Set the howto pointer for an MN10200 ELF reloc.  */
 
-static void
-mn10200_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
+static bfd_boolean
+mn10200_info_to_howto (bfd *abfd,
 		       arelent *cache_ptr,
 		       Elf_Internal_Rela *dst)
 {
   unsigned int r_type;
 
   r_type = ELF32_R_TYPE (dst->r_info);
-  BFD_ASSERT (r_type < (unsigned int) R_MN10200_MAX);
+  if (r_type >= (unsigned int) R_MN10200_MAX)
+    {
+      /* xgettext:c-format */
+      _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+			  abfd, r_type);
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
+    }
+  
   cache_ptr->howto = &elf_mn10200_howto_table[r_type];
+  return cache_ptr->howto != NULL;
 }
 
 /* Perform a relocation as part of a final link.  */
@@ -1378,7 +1387,7 @@ mn10200_elf_get_relocated_section_contents (bfd *output_bfd,
 
 #define elf_backend_rela_normal 1
 #define elf_info_to_howto	mn10200_info_to_howto
-#define elf_info_to_howto_rel	0
+#define elf_info_to_howto_rel	NULL
 #define elf_backend_relocate_section mn10200_elf_relocate_section
 #define bfd_elf32_bfd_relax_section	mn10200_elf_relax_section
 #define bfd_elf32_bfd_get_relocated_section_contents \
diff --git a/bfd/elf-m10300.c b/bfd/elf-m10300.c
index d578416..f86346e 100644
--- a/bfd/elf-m10300.c
+++ b/bfd/elf-m10300.c
@@ -798,7 +798,7 @@ bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 
 /* Set the howto pointer for an MN10300 ELF reloc.  */
 
-static void
+static bfd_boolean
 mn10300_info_to_howto (bfd *abfd,
 		       arelent *cache_ptr,
 		       Elf_Internal_Rela *dst)
@@ -812,9 +812,10 @@ mn10300_info_to_howto (bfd *abfd,
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, r_type);
       bfd_set_error (bfd_error_bad_value);
-      r_type = R_MN10300_NONE;
+      return FALSE;
     }
   cache_ptr->howto = elf_mn10300_howto_table + r_type;
+  return TRUE;
 }
 
 static int
@@ -5544,7 +5545,7 @@ mn10300_elf_mkobject (bfd *abfd)
 #endif
 
 #define elf_info_to_howto		mn10300_info_to_howto
-#define elf_info_to_howto_rel		0
+#define elf_info_to_howto_rel		NULL
 #define elf_backend_can_gc_sections	1
 #define elf_backend_rela_normal		1
 #define elf_backend_check_relocs	mn10300_elf_check_relocs
diff --git a/bfd/elf.c b/bfd/elf.c
index 5d39a98..8ea5a81 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -8870,12 +8870,13 @@ _bfd_elf_set_section_contents (bfd *abfd,
   return TRUE;
 }
 
-void
+bfd_boolean
 _bfd_elf_no_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
 			   arelent *cache_ptr ATTRIBUTE_UNUSED,
 			   Elf_Internal_Rela *dst ATTRIBUTE_UNUSED)
 {
   abort ();
+  return FALSE;
 }
 
 /* Try to convert a non-ELF reloc into an ELF one.  */
diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c
index 3bee87d..33fff58 100644
--- a/bfd/elf32-arc.c
+++ b/bfd/elf32-arc.c
@@ -505,16 +505,25 @@ bfd_elf32_bfd_reloc_name_lookup (bfd * abfd ATTRIBUTE_UNUSED,
 
 /* Set the howto pointer for an ARC ELF reloc.  */
 
-static void
-arc_info_to_howto_rel (bfd * abfd ATTRIBUTE_UNUSED,
+static bfd_boolean
+arc_info_to_howto_rel (bfd * abfd,
 		       arelent * cache_ptr,
 		       Elf_Internal_Rela * dst)
 {
   unsigned int r_type;
 
   r_type = ELF32_R_TYPE (dst->r_info);
-  BFD_ASSERT (r_type < (unsigned int) R_ARC_max);
+  if (r_type >= (unsigned int) R_ARC_max)
+    {
+      /* xgettext:c-format */
+      _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+			  abfd, r_type);
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
+    }
+
   cache_ptr->howto = arc_elf_howto (r_type);
+  return TRUE;
 }
 
 /* Extract CPU features from an NTBS.  */
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index 881f2cf..ce9c2f2 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -56,7 +56,7 @@
    ? bfd_elf32_swap_reloc_out \
    : bfd_elf32_swap_reloca_out)
 
-#define elf_info_to_howto		0
+#define elf_info_to_howto		NULL
 #define elf_info_to_howto_rel		elf32_arm_info_to_howto
 
 #define ARM_ELF_ABI_VERSION		0
@@ -1839,14 +1839,22 @@ elf32_arm_howto_from_type (unsigned int r_type)
   return NULL;
 }
 
-static void
-elf32_arm_info_to_howto (bfd * abfd ATTRIBUTE_UNUSED, arelent * bfd_reloc,
+static bfd_boolean
+elf32_arm_info_to_howto (bfd * abfd, arelent * bfd_reloc,
 			 Elf_Internal_Rela * elf_reloc)
 {
   unsigned int r_type;
 
   r_type = ELF32_R_TYPE (elf_reloc->r_info);
-  bfd_reloc->howto = elf32_arm_howto_from_type (r_type);
+  if ((bfd_reloc->howto = elf32_arm_howto_from_type (r_type)) == NULL)
+    {
+      /* xgettext:c-format */
+      _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+			  abfd, r_type);
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
+    }
+  return TRUE;
 }
 
 struct elf32_arm_reloc_map
@@ -3142,7 +3150,7 @@ struct elf32_arm_link_hash_table
   int nacl_p;
 
   /* True if the target uses REL relocations.  */
-  int use_rel;
+  bfd_boolean use_rel;
 
   /* Nonzero if import library must be a secure gateway import library
      as per ARMv8-M Security Extensions.  */
@@ -3796,7 +3804,7 @@ elf32_arm_link_hash_table_create (bfd *abfd)
   ret->plt_header_size = 20;
   ret->plt_entry_size = elf32_arm_use_long_plt_entry ? 16 : 12;
 #endif
-  ret->use_rel = 1;
+  ret->use_rel = TRUE;
   ret->obfd = abfd;
 
   if (!bfd_hash_table_init (&ret->stub_hash_table, stub_hash_newfunc,
diff --git a/bfd/elf32-avr.c b/bfd/elf32-avr.c
index 74934de..7087606 100644
--- a/bfd/elf32-avr.c
+++ b/bfd/elf32-avr.c
@@ -945,7 +945,7 @@ bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 
 /* Set the howto pointer for an AVR ELF reloc.  */
 
-static void
+static bfd_boolean
 avr_info_to_howto_rela (bfd *abfd,
 			arelent *cache_ptr,
 			Elf_Internal_Rela *dst)
@@ -958,9 +958,11 @@ avr_info_to_howto_rela (bfd *abfd,
       /* xgettext:c-format */
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, r_type);
-      r_type = 0;
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
     }
   cache_ptr->howto = &elf_avr_howto_table[r_type];
+  return TRUE;
 }
 
 static bfd_boolean
diff --git a/bfd/elf32-bfin.c b/bfd/elf32-bfin.c
index 8f15f9a..ae83771 100644
--- a/bfd/elf32-bfin.c
+++ b/bfd/elf32-bfin.c
@@ -1040,8 +1040,8 @@ static const struct bfin_reloc_map bfin_reloc_map [] =
 };
 
 
-static void
-bfin_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
+static bfd_boolean
+bfin_info_to_howto (bfd *abfd,
 		    arelent *cache_ptr,
 		    Elf_Internal_Rela *dst)
 {
@@ -1056,7 +1056,15 @@ bfin_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
     cache_ptr->howto = &bfin_gnuext_howto_table [r_type - BFIN_GNUEXT_RELOC_MIN];
 
   else
-    cache_ptr->howto = (reloc_howto_type *) NULL;
+    {
+      /* xgettext:c-format */
+      _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+			  abfd, r_type);
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
+    }
+
+  return TRUE;
 }
 
 /* Given a BFD reloc type, return the howto.  */
@@ -5424,7 +5432,7 @@ struct bfd_elf_special_section const elf32_bfin_special_sections[] =
 #define bfd_elf32_bfd_reloc_name_lookup \
 					bfin_bfd_reloc_name_lookup
 #define elf_info_to_howto		bfin_info_to_howto
-#define elf_info_to_howto_rel		0
+#define elf_info_to_howto_rel		NULL
 #define elf_backend_object_p		elf32_bfin_object_p
 
 #define bfd_elf32_bfd_is_local_label_name \
diff --git a/bfd/elf32-cr16.c b/bfd/elf32-cr16.c
index 46d9fe2..7756ef5 100644
--- a/bfd/elf32-cr16.c
+++ b/bfd/elf32-cr16.c
@@ -671,7 +671,7 @@ elf_cr16_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 
 /* Retrieve a howto ptr using an internal relocation entry.  */
 
-static void
+static bfd_boolean
 elf_cr16_info_to_howto (bfd *abfd, arelent *cache_ptr,
 			Elf_Internal_Rela *dst)
 {
@@ -683,9 +683,10 @@ elf_cr16_info_to_howto (bfd *abfd, arelent *cache_ptr,
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, r_type);
       bfd_set_error (bfd_error_bad_value);
-      r_type = R_CR16_NONE;
+      return FALSE;
     }
   cache_ptr->howto = cr16_elf_howto_table + r_type;
+  return TRUE;
 }
 
 /* Look through the relocs for a section during the first phase.
@@ -2895,7 +2896,7 @@ _bfd_cr16_elf_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSE
 #define bfd_elf32_bfd_reloc_type_lookup	  elf_cr16_reloc_type_lookup
 #define bfd_elf32_bfd_reloc_name_lookup	  elf_cr16_reloc_name_lookup
 #define elf_info_to_howto		  elf_cr16_info_to_howto
-#define elf_info_to_howto_rel		  0
+#define elf_info_to_howto_rel		  NULL
 #define elf_backend_relocate_section	  elf32_cr16_relocate_section
 #define bfd_elf32_bfd_relax_section	  elf32_cr16_relax_section
 #define bfd_elf32_bfd_get_relocated_section_contents \
diff --git a/bfd/elf32-cr16c.c b/bfd/elf32-cr16c.c
index f2793a9..40ec759 100644
--- a/bfd/elf32-cr16c.c
+++ b/bfd/elf32-cr16c.c
@@ -165,15 +165,15 @@ elf_cr16c_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
   return NULL;
 }
 
-static void
+static bfd_boolean
 elf_cr16c_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
 			 arelent *cache_ptr ATTRIBUTE_UNUSED,
 			 Elf_Internal_Rela *dst ATTRIBUTE_UNUSED)
 {
-  abort ();
+  return FALSE;
 }
 
-static void
+static bfd_boolean
 elf_cr16c_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED,
 			     arelent *cache_ptr,
 			     Elf_Internal_Rela *dst)
@@ -185,9 +185,11 @@ elf_cr16c_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED,
       /* xgettext:c-format */
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, r_type);
-      r_type = 0;
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
     }
   cache_ptr->howto = &elf_howto_table[r_type];
+  return TRUE;
 }
 
 /* Perform a relocation as part of a final link.  */
diff --git a/bfd/elf32-cris.c b/bfd/elf32-cris.c
index f47deb0..1c367c4 100644
--- a/bfd/elf32-cris.c
+++ b/bfd/elf32-cris.c
@@ -453,7 +453,7 @@ cris_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, const char *r_name)
 
 /* Set the howto pointer for an CRIS ELF reloc.  */
 
-static void
+static bfd_boolean
 cris_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED,
 			 arelent * cache_ptr,
 			 Elf_Internal_Rela * dst)
@@ -466,9 +466,11 @@ cris_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED,
       /* xgettext:c-format */
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, r_type);
-      r_type = 0;
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
     }
   cache_ptr->howto = & cris_elf_howto_table [r_type];
+  return TRUE;
 }
 
 bfd_reloc_status_type
diff --git a/bfd/elf32-crx.c b/bfd/elf32-crx.c
index 90857c8..fde3a58 100644
--- a/bfd/elf32-crx.c
+++ b/bfd/elf32-crx.c
@@ -28,7 +28,7 @@
 
 static reloc_howto_type *elf_crx_reloc_type_lookup
   (bfd *, bfd_reloc_code_real_type);
-static void elf_crx_info_to_howto
+static bfd_boolean elf_crx_info_to_howto
   (bfd *, arelent *, Elf_Internal_Rela *);
 static bfd_boolean elf32_crx_relax_delete_bytes
   (struct bfd_link_info *, bfd *, asection *, bfd_vma, int);
@@ -418,7 +418,7 @@ elf_crx_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 
 /* Retrieve a howto ptr using an internal relocation entry.  */
 
-static void
+static bfd_boolean
 elf_crx_info_to_howto (bfd *abfd, arelent *cache_ptr,
 		       Elf_Internal_Rela *dst)
 {
@@ -429,9 +429,10 @@ elf_crx_info_to_howto (bfd *abfd, arelent *cache_ptr,
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, r_type);
       bfd_set_error (bfd_error_bad_value);
-      r_type = R_CRX_NONE;
+      return FALSE;
     }
   cache_ptr->howto = &crx_elf_howto_table[r_type];
+  return TRUE;
 }
 
 /* Perform a relocation as part of a final link.  */
@@ -1320,7 +1321,7 @@ elf32_crx_relax_section (bfd *abfd, asection *sec,
 #define bfd_elf32_bfd_reloc_name_lookup \
 					elf_crx_reloc_name_lookup
 #define elf_info_to_howto		elf_crx_info_to_howto
-#define elf_info_to_howto_rel		0
+#define elf_info_to_howto_rel		NULL
 #define elf_backend_relocate_section	elf32_crx_relocate_section
 #define bfd_elf32_bfd_relax_section	elf32_crx_relax_section
 #define bfd_elf32_bfd_get_relocated_section_contents \
diff --git a/bfd/elf32-d10v.c b/bfd/elf32-d10v.c
index 8dac777..c901595 100644
--- a/bfd/elf32-d10v.c
+++ b/bfd/elf32-d10v.c
@@ -220,7 +220,7 @@ bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 
 /* Set the howto pointer for an D10V ELF reloc.  */
 
-static void
+static bfd_boolean
 d10v_info_to_howto_rel (bfd *abfd,
 			arelent *cache_ptr,
 			Elf_Internal_Rela *dst)
@@ -233,9 +233,11 @@ d10v_info_to_howto_rel (bfd *abfd,
       /* xgettext:c-format */
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, r_type);
-      r_type = 0;
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
     }
   cache_ptr->howto = &elf_d10v_howto_table[r_type];
+  return TRUE;
 }
 
 static asection *
@@ -540,7 +542,7 @@ elf32_d10v_relocate_section (bfd *output_bfd,
 #define TARGET_BIG_SYM		d10v_elf32_vec
 #define TARGET_BIG_NAME		"elf32-d10v"
 
-#define elf_info_to_howto		     0
+#define elf_info_to_howto		     NULL
 #define elf_info_to_howto_rel		     d10v_info_to_howto_rel
 #define elf_backend_object_p		     0
 #define elf_backend_final_write_processing   0
diff --git a/bfd/elf32-d30v.c b/bfd/elf32-d30v.c
index 984b4c4..7620a73 100644
--- a/bfd/elf32-d30v.c
+++ b/bfd/elf32-d30v.c
@@ -508,7 +508,7 @@ bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 
 /* Set the howto pointer for an D30V ELF reloc (type REL).  */
 
-static void
+static bfd_boolean
 d30v_info_to_howto_rel (bfd *abfd,
 			arelent *cache_ptr,
 			Elf_Internal_Rela *dst)
@@ -521,14 +521,16 @@ d30v_info_to_howto_rel (bfd *abfd,
       /* xgettext:c-format */
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, r_type);
-      r_type = 0;
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
     }
   cache_ptr->howto = &elf_d30v_howto_table[r_type];
+  return TRUE;
 }
 
 /* Set the howto pointer for an D30V ELF reloc (type RELA).  */
 
-static void
+static bfd_boolean
 d30v_info_to_howto_rela (bfd *abfd,
 			 arelent *cache_ptr,
 			 Elf_Internal_Rela *dst)
@@ -541,9 +543,11 @@ d30v_info_to_howto_rela (bfd *abfd,
       /* xgettext:c-format */
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, r_type);
-      r_type = 0;
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
     }
   cache_ptr->howto = &elf_d30v_howto_table[r_type];
+  return TRUE;
 }
 
 #define ELF_ARCH		bfd_arch_d30v
diff --git a/bfd/elf32-dlx.c b/bfd/elf32-dlx.c
index 907eddd..d82d3ea 100644
--- a/bfd/elf32-dlx.c
+++ b/bfd/elf32-dlx.c
@@ -547,21 +547,22 @@ dlx_rtype_to_howto (bfd *abfd, unsigned int r_type)
 	{
 	  _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			      abfd, r_type);
-	  r_type = 0;
+	  bfd_set_error (bfd_error_bad_value);
+	  return NULL;
 	}
       return & dlx_elf_howto_table[r_type];
     }
 }
 
-static void
+static bfd_boolean
 elf32_dlx_info_to_howto (bfd * abfd ATTRIBUTE_UNUSED,
 			 arelent * cache_ptr ATTRIBUTE_UNUSED,
 			 Elf_Internal_Rela * dst ATTRIBUTE_UNUSED)
 {
-  abort ();
+  return FALSE;
 }
 
-static void
+static bfd_boolean
 elf32_dlx_info_to_howto_rel (bfd *abfd,
 			     arelent *cache_ptr,
 			     Elf_Internal_Rela *dst)
@@ -570,7 +571,7 @@ elf32_dlx_info_to_howto_rel (bfd *abfd,
 
   r_type = ELF32_R_TYPE (dst->r_info);
   cache_ptr->howto = dlx_rtype_to_howto (abfd, r_type);
-  return;
+  return cache_ptr->howto != NULL;
 }
 
 #define TARGET_BIG_SYM		dlx_elf32_be_vec
diff --git a/bfd/elf32-epiphany.c b/bfd/elf32-epiphany.c
index 8c24541..efbd67b 100644
--- a/bfd/elf32-epiphany.c
+++ b/bfd/elf32-epiphany.c
@@ -362,7 +362,7 @@ epiphany_elf_relax_section (bfd *abfd, asection *sec,
 
 /* Set the howto pointer for a EPIPHANY ELF reloc.  */
 
-static void
+static bfd_boolean
 epiphany_info_to_howto_rela (bfd * abfd,
 			     arelent * cache_ptr,
 			     Elf_Internal_Rela * dst)
@@ -375,9 +375,11 @@ epiphany_info_to_howto_rela (bfd * abfd,
       /* xgettext:c-format */
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, r_type);
-      r_type = 0;
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
     }
   cache_ptr->howto = & epiphany_elf_howto_table [r_type];
+  return TRUE;
 }
 
 /* Perform a single relocation.
diff --git a/bfd/elf32-fr30.c b/bfd/elf32-fr30.c
index 6d8a040..7b0fc88 100644
--- a/bfd/elf32-fr30.c
+++ b/bfd/elf32-fr30.c
@@ -367,7 +367,7 @@ fr30_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, const char *r_name)
 
 /* Set the howto pointer for an FR30 ELF reloc.  */
 
-static void
+static bfd_boolean
 fr30_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED,
 			 arelent *cache_ptr,
 			 Elf_Internal_Rela *dst)
@@ -380,9 +380,11 @@ fr30_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED,
       /* xgettext:c-format */
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, r_type);
-      r_type = 0;
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
     }
   cache_ptr->howto = & fr30_elf_howto_table [r_type];
+  return TRUE;
 }
 
 /* Perform a single relocation.  By default we use the standard BFD
diff --git a/bfd/elf32-frv.c b/bfd/elf32-frv.c
index 91815df..7831aff 100644
--- a/bfd/elf32-frv.c
+++ b/bfd/elf32-frv.c
@@ -2532,7 +2532,7 @@ frv_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, const char *r_name)
 
 /* Set the howto pointer for an FRV ELF reloc.  */
 
-static void
+static bfd_boolean
 frv_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED,
 			arelent *cache_ptr,
 			Elf_Internal_Rela *dst)
@@ -2556,15 +2556,18 @@ frv_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED,
 	  /* xgettext:c-format */
 	  _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			      abfd, r_type);
-	  r_type = 0;
+	  bfd_set_error (bfd_error_bad_value);
+	  return FALSE;
 	}
       cache_ptr->howto = & elf32_frv_howto_table [r_type];
       break;
     }
+  return TRUE;
 }
 
 /* Set the howto pointer for an FRV ELF REL reloc.  */
-static void
+
+static bfd_boolean
 frvfdpic_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED,
 			    arelent *cache_ptr, Elf_Internal_Rela *dst)
 {
@@ -2595,8 +2598,9 @@ frvfdpic_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED,
 
     default:
       cache_ptr->howto = NULL;
-      break;
+      return FALSE;
     }
+  return TRUE;
 }
 
 /* Perform a single relocation.  By default we use the standard BFD
diff --git a/bfd/elf32-ft32.c b/bfd/elf32-ft32.c
index 86157d8..b981a34 100644
--- a/bfd/elf32-ft32.c
+++ b/bfd/elf32-ft32.c
@@ -292,16 +292,25 @@ ft32_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, const char *r_name)
 
 /* Set the howto pointer for an FT32 ELF reloc.  */
 
-static void
-ft32_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED,
+static bfd_boolean
+ft32_info_to_howto_rela (bfd *abfd,
 			  arelent *cache_ptr,
 			  Elf_Internal_Rela *dst)
 {
   unsigned int r_type;
 
   r_type = ELF32_R_TYPE (dst->r_info);
-  BFD_ASSERT (r_type < (unsigned int) R_FT32_max);
+  if (r_type < (unsigned int) R_FT32_max)
+    {
+      /* xgettext:c-format */
+      _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+			  abfd, r_type);
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
+    }
+
   cache_ptr->howto = & ft32_elf_howto_table [r_type];
+  return cache_ptr->howto != NULL;
 }
 
 /* Relocate an FT32 ELF section.
diff --git a/bfd/elf32-gen.c b/bfd/elf32-gen.c
index 8f9e338..1d907a0 100644
--- a/bfd/elf32-gen.c
+++ b/bfd/elf32-gen.c
@@ -41,20 +41,22 @@ static reloc_howto_type dummy =
 	 0,			/* dst_mask */
 	 FALSE);		/* pcrel_offset */
 
-static void
+static bfd_boolean
 elf_generic_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
 			   arelent *bfd_reloc,
 			   Elf_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED)
 {
   bfd_reloc->howto = &dummy;
+  return TRUE;
 }
 
-static void
+static bfd_boolean
 elf_generic_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED,
 			       arelent *bfd_reloc,
 			       Elf_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED)
 {
   bfd_reloc->howto = &dummy;
+  return TRUE;
 }
 
 static void
diff --git a/bfd/elf32-h8300.c b/bfd/elf32-h8300.c
index 0412424..a41ae63 100644
--- a/bfd/elf32-h8300.c
+++ b/bfd/elf32-h8300.c
@@ -26,9 +26,9 @@
 
 static reloc_howto_type *elf32_h8_reloc_type_lookup
   (bfd *abfd, bfd_reloc_code_real_type code);
-static void elf32_h8_info_to_howto
+static bfd_boolean elf32_h8_info_to_howto
   (bfd *, arelent *, Elf_Internal_Rela *);
-static void elf32_h8_info_to_howto_rel
+static bfd_boolean elf32_h8_info_to_howto_rel
   (bfd *, arelent *, Elf_Internal_Rela *);
 static unsigned long elf32_h8_mach (flagword);
 static void elf32_h8_final_write_processing (bfd *, bfd_boolean);
@@ -284,7 +284,7 @@ elf32_h8_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
   return NULL;
 }
 
-static void
+static bfd_boolean
 elf32_h8_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *bfd_reloc,
 			Elf_Internal_Rela *elf_reloc)
 {
@@ -296,20 +296,20 @@ elf32_h8_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *bfd_reloc,
     if (h8_elf_howto_table[i].type == r)
       {
 	bfd_reloc->howto = &h8_elf_howto_table[i];
-	return;
+	return TRUE;
       }
-  abort ();
+  /* xgettext:c-format */
+  _bfd_error_handler (_("%pB: unsupported relocation type %#x"), abfd, r);
+  bfd_set_error (bfd_error_bad_value);
+  return FALSE;
 }
 
-static void
-elf32_h8_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, arelent *bfd_reloc,
+static bfd_boolean
+elf32_h8_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED,
+			    arelent *bfd_reloc ATTRIBUTE_UNUSED,
 			    Elf_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED)
 {
-  unsigned int r;
-
-  abort ();
-  r = ELF32_R_TYPE (elf_reloc->r_info);
-  bfd_reloc->howto = &h8_elf_howto_table[r];
+  return FALSE;
 }
 
 /* Special handling for H8/300 relocs.
@@ -453,7 +453,8 @@ elf32_h8_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
       arelent bfd_reloc;
       reloc_howto_type *howto;
 
-      elf32_h8_info_to_howto (input_bfd, &bfd_reloc, rel);
+      if (! elf32_h8_info_to_howto (input_bfd, &bfd_reloc, rel))
+	continue;
       howto = bfd_reloc.howto;
 
       r_symndx = ELF32_R_SYM (rel->r_info);
@@ -733,7 +734,8 @@ elf32_h8_relax_section (bfd *abfd, asection *sec,
       {
 	arelent bfd_reloc;
 
-	elf32_h8_info_to_howto (abfd, &bfd_reloc, irel);
+	if (! elf32_h8_info_to_howto (abfd, &bfd_reloc, irel))
+	  continue;
       }
       /* Keep track of the previous reloc so that we can delete
 	 some long jumps created by the compiler.  */
@@ -1249,7 +1251,8 @@ elf32_h8_relax_section (bfd *abfd, asection *sec,
 			reloc_howto_type *h;
 			bfd_vma last_reloc_size;
 
-			elf32_h8_info_to_howto (abfd, &bfd_reloc, last_reloc);
+			if (! elf32_h8_info_to_howto (abfd, &bfd_reloc, last_reloc))
+			  break;
 			h = bfd_reloc.howto;
 			last_reloc_size = 1 << h->size;
 			if (last_reloc->r_offset + last_reloc_size
@@ -1267,7 +1270,8 @@ elf32_h8_relax_section (bfd *abfd, asection *sec,
 			reloc_howto_type *h;
 			bfd_vma next_reloc_size;
 
-			elf32_h8_info_to_howto (abfd, &bfd_reloc, next_reloc);
+			if (! elf32_h8_info_to_howto (abfd, &bfd_reloc, next_reloc))
+			  break;
 			h = bfd_reloc.howto;
 			next_reloc_size = 1 << h->size;
 			if (next_reloc->r_offset + next_reloc_size
diff --git a/bfd/elf32-i370.c b/bfd/elf32-i370.c
index 79ec159..2c6a30d 100644
--- a/bfd/elf32-i370.c
+++ b/bfd/elf32-i370.c
@@ -289,7 +289,7 @@ i370_elf_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 
 /* Set the howto pointer for an i370 ELF reloc.  */
 
-static void
+static bfd_boolean
 i370_elf_info_to_howto (bfd *abfd,
 			arelent *cache_ptr,
 			Elf_Internal_Rela *dst)
@@ -307,9 +307,10 @@ i370_elf_info_to_howto (bfd *abfd,
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, r_type);
       bfd_set_error (bfd_error_bad_value);
-      r_type = R_I370_NONE;
+      return FALSE;
     }
   cache_ptr->howto = i370_elf_howto_table[r_type];
+  return TRUE;
 }
 
 /* Hack alert --  the following several routines look generic to me ...
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index 32b84e6..5163e24 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -194,7 +194,7 @@ static reloc_howto_type elf_howto_table[]=
 #endif
 
 static reloc_howto_type *
-elf_i386_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+elf_i386_reloc_type_lookup (bfd *abfd,
 			    bfd_reloc_code_real_type code)
 {
   switch (code)
@@ -346,11 +346,13 @@ elf_i386_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
       return &elf_howto_table[R_386_GNU_VTENTRY - R_386_vt_offset];
 
     default:
-      break;
+      TRACE ("Unknown");
+      /* xgettext:c-format */
+      _bfd_error_handler (_("%pB: invalid Alpha reloc number: %d"),
+			  abfd, (int) code);
+      bfd_set_error (bfd_error_bad_value);
+      return NULL;
     }
-
-  TRACE ("Unknown");
-  return 0;
 }
 
 static reloc_howto_type *
@@ -368,7 +370,7 @@ elf_i386_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 }
 
 static reloc_howto_type *
-elf_i386_rtype_to_howto (bfd *abfd, unsigned r_type)
+elf_i386_rtype_to_howto (bfd *abfd ATTRIBUTE_UNUSED, unsigned r_type)
 {
   unsigned int indx;
 
@@ -379,25 +381,30 @@ elf_i386_rtype_to_howto (bfd *abfd, unsigned r_type)
 	  >= R_386_ext2 - R_386_ext)
       && ((indx = r_type - R_386_vt_offset) - R_386_ext2
 	  >= R_386_vt - R_386_ext2))
-    {
-      /* xgettext:c-format */
-      _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
-			  abfd, r_type);
-      indx = R_386_NONE;
-    }
+      return NULL;
   /* PR 17512: file: 0f67f69d.  */
   if (elf_howto_table [indx].type != r_type)
     return NULL;
   return &elf_howto_table[indx];
 }
 
-static void
-elf_i386_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED,
+static bfd_boolean
+elf_i386_info_to_howto_rel (bfd *abfd,
 			    arelent *cache_ptr,
 			    Elf_Internal_Rela *dst)
 {
   unsigned int r_type = ELF32_R_TYPE (dst->r_info);
-  cache_ptr->howto = elf_i386_rtype_to_howto (abfd, r_type);
+
+  if ((cache_ptr->howto = elf_i386_rtype_to_howto (abfd, r_type)) == NULL)
+    {
+      /* xgettext:c-format */
+      _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+			  abfd, r_type);
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
+    }
+
+  return TRUE;
 }
 
 /* Return whether a symbol name implies a local label.  The UnixWare
diff --git a/bfd/elf32-i860.c b/bfd/elf32-i860.c
index e34965c..737e7f5 100644
--- a/bfd/elf32-i860.c
+++ b/bfd/elf32-i860.c
@@ -761,10 +761,11 @@ lookup_howto (unsigned int rtype)
 	elf_code_to_howto_index[elf32_i860_howto_table[i].type] = i;
     }
 
-  BFD_ASSERT (rtype <= R_860_max);
+  if (rtype > R_860_max)
+    return NULL;
   i = elf_code_to_howto_index[rtype];
   if (i >= howto_tbl_size)
-    return 0;
+    return NULL;
   return elf32_i860_howto_table + i;
 }
 
@@ -880,8 +881,7 @@ elf32_i860_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
       rtype = R_860_HIGOTOFF;
       break;
     default:
-      rtype = 0;
-      break;
+      return NULL;
     }
   return lookup_howto (rtype);
 }
@@ -904,13 +904,15 @@ elf32_i860_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 }
 
 /* Given a ELF reloc, return the matching HOWTO structure.  */
-static void
+
+static bfd_boolean
 elf32_i860_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED,
 			       arelent *bfd_reloc,
 			       Elf_Internal_Rela *elf_reloc)
 {
   bfd_reloc->howto
     = lookup_howto ((unsigned) ELF32_R_TYPE (elf_reloc->r_info));
+  return bfd_reloc->howto != NULL;
 }
 
 /* Specialized relocation handler for R_860_SPLITn.  These relocations
diff --git a/bfd/elf32-i960.c b/bfd/elf32-i960.c
index dbfb1bb..244e4ea 100644
--- a/bfd/elf32-i960.c
+++ b/bfd/elf32-i960.c
@@ -29,7 +29,7 @@
 #define bfd_elf32_bfd_reloc_type_lookup	elf32_i960_reloc_type_lookup
 #define bfd_elf32_bfd_reloc_name_lookup \
   elf32_i960_reloc_name_lookup
-#define elf_info_to_howto		elf32_i960_info_to_howto
+#define elf_info_to_howto		NULL
 #define elf_info_to_howto_rel		elf32_i960_info_to_howto_rel
 
 /* ELF relocs are against symbols.  If we are producing relocatable
@@ -116,15 +116,7 @@ elf32_i960_bfd_to_reloc_type (bfd_reloc_code_real_type code)
     }
 }
 
-static void
-elf32_i960_info_to_howto (bfd *		      abfd ATTRIBUTE_UNUSED,
-			  arelent *	      cache_ptr ATTRIBUTE_UNUSED,
-			  Elf_Internal_Rela * dst ATTRIBUTE_UNUSED)
-{
-  abort ();
-}
-
-static void
+static bfd_boolean
 elf32_i960_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED,
 			      arelent *cache_ptr,
 			      Elf_Internal_Rela *dst)
@@ -139,10 +131,12 @@ elf32_i960_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED,
       /* xgettext:c-format */
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, type);
-      type = 0;
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
     }
 
   cache_ptr->howto = &elf_howto_table[(int) type];
+  return TRUE;
 }
 
 static reloc_howto_type *
diff --git a/bfd/elf32-ip2k.c b/bfd/elf32-ip2k.c
index aa93524..1432f18 100644
--- a/bfd/elf32-ip2k.c
+++ b/bfd/elf32-ip2k.c
@@ -1231,7 +1231,7 @@ ip2k_elf_relax_section (bfd *abfd,
 
 /* Set the howto pointer for a IP2K ELF reloc.  */
 
-static void
+static bfd_boolean
 ip2k_info_to_howto_rela (bfd * abfd,
 			 arelent * cache_ptr,
 			 Elf_Internal_Rela * dst)
@@ -1244,9 +1244,11 @@ ip2k_info_to_howto_rela (bfd * abfd,
       /* xgettext:c-format */
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, r_type);
-      r_type = 0;
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
     }
   cache_ptr->howto = & ip2k_elf_howto_table [r_type];
+  return TRUE;
 }
 
 /* Perform a single relocation.
diff --git a/bfd/elf32-iq2000.c b/bfd/elf32-iq2000.c
index 14cd167..d1ce3c8 100644
--- a/bfd/elf32-iq2000.c
+++ b/bfd/elf32-iq2000.c
@@ -416,7 +416,7 @@ iq2000_final_link_relocate (reloc_howto_type *	howto,
 
 /* Set the howto pointer for a IQ2000 ELF reloc.  */
 
-static void
+static bfd_boolean
 iq2000_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED,
 			   arelent * cache_ptr,
 			   Elf_Internal_Rela * dst)
@@ -440,11 +440,13 @@ iq2000_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED,
 	  /* xgettext:c-format */
 	  _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			      abfd, r_type);
-	  r_type = 0;
+	  bfd_set_error (bfd_error_bad_value);
+	  return FALSE;
 	}
       cache_ptr->howto = & iq2000_elf_howto_table [r_type];
       break;
     }
+  return TRUE;
 }
 
 /* Look through the relocs for a section during the first phase.
diff --git a/bfd/elf32-lm32.c b/bfd/elf32-lm32.c
index 0cd67b4..027830b 100644
--- a/bfd/elf32-lm32.c
+++ b/bfd/elf32-lm32.c
@@ -525,7 +525,7 @@ lm32_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 
 /* Set the howto pointer for an Lattice Mico32 ELF reloc.  */
 
-static void
+static bfd_boolean
 lm32_info_to_howto_rela (bfd *abfd,
 			 arelent *cache_ptr,
 			 Elf_Internal_Rela *dst)
@@ -538,9 +538,11 @@ lm32_info_to_howto_rela (bfd *abfd,
       /* xgettext:c-format */
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, r_type);
-      r_type = 0;
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
     }
   cache_ptr->howto = &lm32_elf_howto_table[r_type];
+  return TRUE;
 }
 
 /* Set the right machine number for an Lattice Mico32 ELF file. */
@@ -1076,7 +1078,8 @@ lm32_elf_relocate_section (bfd *output_bfd,
 	  const char *msg = NULL;
 	  arelent bfd_reloc;
 
-	  lm32_info_to_howto_rela (input_bfd, &bfd_reloc, rel);
+	  if (! lm32_info_to_howto_rela (input_bfd, &bfd_reloc, rel))
+	    continue;
 	  howto = bfd_reloc.howto;
 
 	  if (h != NULL)
@@ -2568,7 +2571,7 @@ lm32_elf_fdpic_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
 #define bfd_elf32_bfd_reloc_type_lookup		lm32_reloc_type_lookup
 #define bfd_elf32_bfd_reloc_name_lookup		lm32_reloc_name_lookup
 #define elf_info_to_howto			lm32_info_to_howto_rela
-#define elf_info_to_howto_rel			0
+#define elf_info_to_howto_rel			NULL
 #define elf_backend_rela_normal			1
 #define elf_backend_object_p			lm32_elf_object_p
 #define elf_backend_final_write_processing	lm32_elf_final_write_processing
diff --git a/bfd/elf32-m32c.c b/bfd/elf32-m32c.c
index 6e7e71c..613844a 100644
--- a/bfd/elf32-m32c.c
+++ b/bfd/elf32-m32c.c
@@ -28,7 +28,7 @@
 /* Forward declarations.  */
 static reloc_howto_type * m32c_reloc_type_lookup
   (bfd *, bfd_reloc_code_real_type);
-static void m32c_info_to_howto_rela
+static bfd_boolean m32c_info_to_howto_rela
   (bfd *, arelent *, Elf_Internal_Rela *);
 static bfd_boolean m32c_elf_relocate_section
   (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, Elf_Internal_Rela *, Elf_Internal_Sym *, asection **);
@@ -291,10 +291,10 @@ m32c_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, const char *r_name)
 
 /* Set the howto pointer for an M32C ELF reloc.  */
 
-static void
-m32c_info_to_howto_rela (bfd *abfd,
-			 arelent *cache_ptr,
-			 Elf_Internal_Rela *dst)
+static bfd_boolean
+m32c_info_to_howto_rela (bfd *               abfd,
+			 arelent *           cache_ptr,
+			 Elf_Internal_Rela * dst)
 {
   unsigned int r_type;
 
@@ -304,9 +304,11 @@ m32c_info_to_howto_rela (bfd *abfd,
       /* xgettext:c-format */
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, r_type);
-      r_type = 0;
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
     }
   cache_ptr->howto = & m32c_elf_howto_table [r_type];
+  return TRUE;
 }
 
 
diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c
index 0129c29..94a4bc9 100644
--- a/bfd/elf32-m32r.c
+++ b/bfd/elf32-m32r.c
@@ -1272,7 +1272,7 @@ bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 
 /* Set the howto pointer for an M32R ELF reloc.  */
 
-static void
+static bfd_boolean
 m32r_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED,
 			arelent *cache_ptr,
 			Elf_Internal_Rela *dst)
@@ -1285,20 +1285,32 @@ m32r_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED,
       /* xgettext:c-format */
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, r_type);
-      r_type = 0;
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
     }
   cache_ptr->howto = &m32r_elf_howto_table[r_type];
+  return TRUE;
 }
 
-static void
+static bfd_boolean
 m32r_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
 		    arelent *cache_ptr,
 		    Elf_Internal_Rela *dst)
 {
-  BFD_ASSERT ((ELF32_R_TYPE(dst->r_info) == (unsigned int) R_M32R_NONE)
-	      || ((ELF32_R_TYPE(dst->r_info) > (unsigned int) R_M32R_GNU_VTENTRY)
-		  && (ELF32_R_TYPE(dst->r_info) < (unsigned int) R_M32R_max)));
-  cache_ptr->howto = &m32r_elf_howto_table[ELF32_R_TYPE(dst->r_info)];
+  unsigned int r_type = ELF32_R_TYPE (dst->r_info);
+
+  if (r_type == (unsigned int) R_M32R_NONE
+      || ((r_type > (unsigned int) R_M32R_GNU_VTENTRY)
+	  && (r_type < (unsigned int) R_M32R_max)))
+    {
+      cache_ptr->howto = &m32r_elf_howto_table[r_type];
+      return TRUE;
+    }
+
+  /* xgettext:c-format */
+  _bfd_error_handler (_("%pB: unsupported relocation type %#x"), abfd, r_type);
+  bfd_set_error (bfd_error_bad_value);
+  return FALSE;  
 }
 
 
diff --git a/bfd/elf32-m68hc11.c b/bfd/elf32-m68hc11.c
index 4c57fe8..95d271f 100644
--- a/bfd/elf32-m68hc11.c
+++ b/bfd/elf32-m68hc11.c
@@ -32,7 +32,7 @@
 /* Relocation functions.  */
 static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
   (bfd *, bfd_reloc_code_real_type);
-static void m68hc11_info_to_howto_rel
+static bfd_boolean m68hc11_info_to_howto_rel
   (bfd *, arelent *, Elf_Internal_Rela *);
 
 /* Trampoline generation.  */
@@ -377,7 +377,7 @@ bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 
 /* Set the howto pointer for an M68HC11 ELF reloc.  */
 
-static void
+static bfd_boolean
 m68hc11_info_to_howto_rel (bfd *abfd,
 			   arelent *cache_ptr, Elf_Internal_Rela *dst)
 {
@@ -389,9 +389,11 @@ m68hc11_info_to_howto_rel (bfd *abfd,
       /* xgettext:c-format */
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, r_type);
-      r_type = 0;
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
     }
   cache_ptr->howto = &elf_m68hc11_howto_table[r_type];
+  return TRUE;
 }
 
 
@@ -1297,7 +1299,7 @@ static const struct bfd_elf_special_section elf32_m68hc11_special_sections[] =
 #define TARGET_BIG_SYM		m68hc11_elf32_vec
 #define TARGET_BIG_NAME		"elf32-m68hc11"
 
-#define elf_info_to_howto	0
+#define elf_info_to_howto	NULL
 #define elf_info_to_howto_rel	m68hc11_info_to_howto_rel
 #define bfd_elf32_bfd_relax_section  m68hc11_elf_relax_section
 #define elf_backend_check_relocs     elf32_m68hc11_check_relocs
diff --git a/bfd/elf32-m68hc12.c b/bfd/elf32-m68hc12.c
index d2300c4..0b53674 100644
--- a/bfd/elf32-m68hc12.c
+++ b/bfd/elf32-m68hc12.c
@@ -32,7 +32,7 @@
 /* Relocation functions.  */
 static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
   (bfd *, bfd_reloc_code_real_type);
-static void m68hc11_info_to_howto_rel
+static bfd_boolean m68hc11_info_to_howto_rel
   (bfd *, arelent *, Elf_Internal_Rela *);
 
 /* Trampoline generation.  */
@@ -497,7 +497,7 @@ bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 
 /* Set the howto pointer for an M68HC11 ELF reloc.  */
 
-static void
+static bfd_boolean
 m68hc11_info_to_howto_rel (bfd *abfd,
 			   arelent *cache_ptr, Elf_Internal_Rela *dst)
 {
@@ -509,9 +509,11 @@ m68hc11_info_to_howto_rel (bfd *abfd,
       /* xgettext:c-format */
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, r_type);
-      r_type = 0;
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
     }
   cache_ptr->howto = &elf_m68hc11_howto_table[r_type];
+  return TRUE;
 }
 
 
@@ -647,7 +649,7 @@ static const struct bfd_elf_special_section elf32_m68hc12_special_sections[] =
 #define TARGET_BIG_SYM		m68hc12_elf32_vec
 #define TARGET_BIG_NAME		"elf32-m68hc12"
 
-#define elf_info_to_howto	0
+#define elf_info_to_howto	NULL
 #define elf_info_to_howto_rel	m68hc11_info_to_howto_rel
 #define elf_backend_check_relocs     elf32_m68hc11_check_relocs
 #define elf_backend_relocate_section elf32_m68hc11_relocate_section
diff --git a/bfd/elf32-m68hc1x.c b/bfd/elf32-m68hc1x.c
index 794663a..35152ee 100644
--- a/bfd/elf32-m68hc1x.c
+++ b/bfd/elf32-m68hc1x.c
@@ -963,7 +963,8 @@ elf32_m68hc11_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
 	  || r_type == R_M68HC11_GNU_VTINHERIT)
 	continue;
 
-      (*ebd->elf_info_to_howto_rel) (input_bfd, &arel, rel);
+      if (! (*ebd->elf_info_to_howto_rel) (input_bfd, &arel, rel))
+	continue;
       howto = arel.howto;
 
       h = NULL;
diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c
index 2718564..8680504 100644
--- a/bfd/elf32-m68k.c
+++ b/bfd/elf32-m68k.c
@@ -341,7 +341,7 @@ static reloc_howto_type howto_table[] =
 	 FALSE),		/* pcrel_offset */
 };
 
-static void
+static bfd_boolean
 rtype_to_howto (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst)
 {
   unsigned int indx = ELF32_R_TYPE (dst->r_info);
@@ -351,9 +351,11 @@ rtype_to_howto (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst)
       /* xgettext:c-format */
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, indx);
-      indx = R_68K_NONE;
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
     }
   cache_ptr->howto = &howto_table[indx];
+  return TRUE;
 }
 
 #define elf_info_to_howto rtype_to_howto
diff --git a/bfd/elf32-mcore.c b/bfd/elf32-mcore.c
index 2e4d5c2..a88acae 100644
--- a/bfd/elf32-mcore.c
+++ b/bfd/elf32-mcore.c
@@ -336,7 +336,7 @@ mcore_elf_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 
 /* Set the howto pointer for a RCE ELF reloc.  */
 
-static void
+static bfd_boolean
 mcore_elf_info_to_howto (bfd * abfd,
 			 arelent * cache_ptr,
 			 Elf_Internal_Rela * dst)
@@ -354,10 +354,11 @@ mcore_elf_info_to_howto (bfd * abfd,
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, r_type);
       bfd_set_error (bfd_error_bad_value);
-      r_type = R_MCORE_NONE;
+      return FALSE;
     }
 
   cache_ptr->howto = mcore_elf_howto_table [r_type];
+  return TRUE;
 }
 
 /* The RELOCATE_SECTION function is called by the ELF backend linker
diff --git a/bfd/elf32-mep.c b/bfd/elf32-mep.c
index e03fe50..5224d9a 100644
--- a/bfd/elf32-mep.c
+++ b/bfd/elf32-mep.c
@@ -375,10 +375,10 @@ mep_final_link_relocate
 
 /* Set the howto pointer for a MEP ELF reloc.  */
 
-static void
-mep_info_to_howto_rela (bfd *abfd,
-			arelent *cache_ptr,
-			Elf_Internal_Rela *dst)
+static bfd_boolean
+mep_info_to_howto_rela (bfd *		    abfd,
+			arelent *	    cache_ptr,
+			Elf_Internal_Rela * dst)
 {
   unsigned int r_type;
 
@@ -388,9 +388,11 @@ mep_info_to_howto_rela (bfd *abfd,
       /* xgettext:c-format */
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, r_type);
-      r_type = 0;
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
     }
   cache_ptr->howto = & mep_elf_howto_table [r_type];
+  return TRUE;
 }
 
 /* Relocate a MEP ELF section.
diff --git a/bfd/elf32-metag.c b/bfd/elf32-metag.c
index c4b2c48..efe95bd 100644
--- a/bfd/elf32-metag.c
+++ b/bfd/elf32-metag.c
@@ -864,7 +864,7 @@ tpoff (struct bfd_link_info *info, bfd_vma address)
 			 elf_hash_table (info)->tls_sec->alignment_power));
 }
 
-static void
+static bfd_boolean
 metag_info_to_howto_rela (bfd *abfd,
 			  arelent *cache_ptr,
 			  Elf_Internal_Rela *dst)
@@ -877,9 +877,11 @@ metag_info_to_howto_rela (bfd *abfd,
       /* xgettext:c-format */
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, r_type);
-      r_type = 0;
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
     }
   cache_ptr->howto = & elf_metag_howto_table [r_type];
+  return TRUE;
 }
 
 static reloc_howto_type *
diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
index 29fffb4..3acf93a 100644
--- a/bfd/elf32-microblaze.c
+++ b/bfd/elf32-microblaze.c
@@ -638,7 +638,7 @@ microblaze_elf_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 
 /* Set the howto pointer for a RCE ELF reloc.  */
 
-static void
+static bfd_boolean
 microblaze_elf_info_to_howto (bfd * abfd,
 			      arelent * cache_ptr,
 			      Elf_Internal_Rela * dst)
@@ -656,10 +656,11 @@ microblaze_elf_info_to_howto (bfd * abfd,
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, r_type);
       bfd_set_error (bfd_error_bad_value);
-      r_type = R_MICROBLAZE_NONE;
+      return FALSE;
     }
 
   cache_ptr->howto = microblaze_elf_howto_table [r_type];
+  return TRUE;
 }
 
 /* Microblaze ELF local labels start with 'L.' or '$L', not '.L'.  */
diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c
index be462a1..d6005ff 100644
--- a/bfd/elf32-mips.c
+++ b/bfd/elf32-mips.c
@@ -57,9 +57,9 @@ static bfd_reloc_status_type mips32_64bit_reloc
   (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
 static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
   (bfd *, bfd_reloc_code_real_type);
-static void mips_info_to_howto_rel
+static bfd_boolean mips_info_to_howto_rel
   (bfd *, arelent *, Elf_Internal_Rela *);
-static void mips_info_to_howto_rela
+static bfd_boolean mips_info_to_howto_rela
   (bfd *, arelent *, Elf_Internal_Rela *);
 static bfd_boolean mips_elf_sym_is_global
   (bfd *, asymbol *);
@@ -2224,7 +2224,7 @@ mips_elf32_rtype_to_howto (bfd *abfd,
 	  _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			      abfd, r_type);
 	  bfd_set_error (bfd_error_bad_value);
-	  r_type = R_MIPS_NONE;
+	  return NULL;
 	}
       return &elf_mips_howto_table_rel[r_type];
     }
@@ -2232,7 +2232,7 @@ mips_elf32_rtype_to_howto (bfd *abfd,
 
 /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure.  */
 
-static void
+static bfd_boolean
 mips_info_to_howto_rel (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst)
 {
   const struct elf_backend_data *bed;
@@ -2241,6 +2241,13 @@ mips_info_to_howto_rel (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst)
   r_type = ELF32_R_TYPE (dst->r_info);
   bed = get_elf_backend_data (abfd);
   cache_ptr->howto = bed->elf_backend_mips_rtype_to_howto (abfd, r_type, FALSE);
+  if (cache_ptr->howto == NULL)
+    {
+      /* xgettext:c-format */
+      _bfd_error_handler (_("%pB: unsupported relocation type %#x"), abfd, r_type);
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
+    }
 
   /* The addend for a GPREL16 or LITERAL relocation comes from the GP
      value for the object file.  We get the addend now, rather than
@@ -2249,14 +2256,16 @@ mips_info_to_howto_rel (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst)
   if (((*cache_ptr->sym_ptr_ptr)->flags & BSF_SECTION_SYM) != 0
       && (gprel16_reloc_p (r_type) || literal_reloc_p (r_type)))
     cache_ptr->addend = elf_gp (abfd);
+
+  return TRUE;
 }
 
 /* Given a MIPS Elf_Internal_Rela, fill in an arelent structure.  */
 
-static void
+static bfd_boolean
 mips_info_to_howto_rela (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst)
 {
-  mips_info_to_howto_rel (abfd, cache_ptr, dst);
+  return mips_info_to_howto_rel (abfd, cache_ptr, dst);
 
   /* If we ever need to do any extra processing with dst->r_addend
      (the field omitted in an Elf_Internal_Rel) we can do it here.  */
diff --git a/bfd/elf32-moxie.c b/bfd/elf32-moxie.c
index 7a617a8..d8b549d 100644
--- a/bfd/elf32-moxie.c
+++ b/bfd/elf32-moxie.c
@@ -123,7 +123,7 @@ moxie_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, const char *r_name)
 
 /* Set the howto pointer for an MOXIE ELF reloc.  */
 
-static void
+static bfd_boolean
 moxie_info_to_howto_rela (bfd *abfd,
 			  arelent *cache_ptr,
 			  Elf_Internal_Rela *dst)
@@ -136,9 +136,11 @@ moxie_info_to_howto_rela (bfd *abfd,
       /* xgettext:c-format */
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, r_type);
-      r_type = 0;
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
     }
   cache_ptr->howto = & moxie_elf_howto_table [r_type];
+  return TRUE;
 }
 
 /* Perform a single relocation.  By default we use the standard BFD
diff --git a/bfd/elf32-msp430.c b/bfd/elf32-msp430.c
index 9f2a3d0..2d351d3 100644
--- a/bfd/elf32-msp430.c
+++ b/bfd/elf32-msp430.c
@@ -631,7 +631,7 @@ bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 
 /* Set the howto pointer for an MSP430 ELF reloc.  */
 
-static void
+static bfd_boolean
 msp430_info_to_howto_rela (bfd * abfd,
 			   arelent * cache_ptr,
 			   Elf_Internal_Rela * dst)
@@ -647,20 +647,23 @@ msp430_info_to_howto_rela (bfd * abfd,
 	  /* xgettext:c-format */
 	  _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			      abfd, r_type);
-	  r_type = 0;
+	  bfd_set_error (bfd_error_bad_value);
+	  return FALSE;
 	}
       cache_ptr->howto = elf_msp430x_howto_table + r_type;
-      return;
     }
-
-  if (r_type >= (unsigned int) R_MSP430_max)
+  else if (r_type >= (unsigned int) R_MSP430_max)
     {
       /* xgettext:c-format */
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, r_type);
-      r_type = 0;
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
     }
-  cache_ptr->howto = &elf_msp430_howto_table[r_type];
+  else
+    cache_ptr->howto = &elf_msp430_howto_table[r_type];
+
+  return TRUE;
 }
 
 /* Look through the relocs for a section during the first phase.
diff --git a/bfd/elf32-mt.c b/bfd/elf32-mt.c
index efaaf68..94c2fac 100644
--- a/bfd/elf32-mt.c
+++ b/bfd/elf32-mt.c
@@ -28,7 +28,7 @@
 static reloc_howto_type * mt_reloc_type_lookup
   (bfd *, bfd_reloc_code_real_type);
 
-static void mt_info_to_howto_rela
+static bfd_boolean mt_info_to_howto_rela
   (bfd *, arelent *, Elf_Internal_Rela *);
 
 static bfd_reloc_status_type mt_elf_relocate_hi16
@@ -227,10 +227,10 @@ mt_elf_relocate_hi16
 
 /* Set the howto pointer for a MT ELF reloc.  */
 
-static void
-mt_info_to_howto_rela (bfd *abfd,
-		       arelent *cache_ptr,
-		       Elf_Internal_Rela *dst)
+static bfd_boolean
+mt_info_to_howto_rela (bfd *		    abfd,
+		       arelent *	    cache_ptr,
+		       Elf_Internal_Rela *  dst)
 {
   unsigned int r_type;
 
@@ -240,9 +240,11 @@ mt_info_to_howto_rela (bfd *abfd,
       /* xgettext:c-format */
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, r_type);
-      r_type = 0;
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
     }
   cache_ptr->howto = & mt_elf_howto_table [r_type];
+  return TRUE;
 }
 
 /* Perform a single relocation.  By default we use the standard BFD
diff --git a/bfd/elf32-nds32.c b/bfd/elf32-nds32.c
index 62e8572..e240d31 100644
--- a/bfd/elf32-nds32.c
+++ b/bfd/elf32-nds32.c
@@ -2884,8 +2884,8 @@ bfd_elf32_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 
 /* Set the howto pointer for an NDS32 ELF reloc.  */
 
-static void
-nds32_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, arelent *cache_ptr,
+static bfd_boolean
+nds32_info_to_howto_rel (bfd *abfd, arelent *cache_ptr,
 			 Elf_Internal_Rela *dst)
 {
   enum elf_nds32_reloc_type r_type;
@@ -2896,19 +2896,31 @@ nds32_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, arelent *cache_ptr,
       /* xgettext:c-format */
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, r_type);
-      r_type = 0;
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
     }
   cache_ptr->howto = bfd_elf32_bfd_reloc_type_table_lookup (r_type);
+  return TRUE;
 }
 
-static void
+static bfd_boolean
 nds32_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *cache_ptr,
 		     Elf_Internal_Rela *dst)
 {
-  BFD_ASSERT ((ELF32_R_TYPE (dst->r_info) == R_NDS32_NONE)
-	      || ((ELF32_R_TYPE (dst->r_info) > R_NDS32_GNU_VTENTRY)
-		  && (ELF32_R_TYPE (dst->r_info) < R_NDS32_max)));
-  cache_ptr->howto = bfd_elf32_bfd_reloc_type_table_lookup (ELF32_R_TYPE (dst->r_info));
+  unsigned int r_type = ELF32_R_TYPE (dst->r_info);
+
+  if ((r_type == R_NDS32_NONE)
+      || ((r_type > R_NDS32_GNU_VTENTRY)
+	  && (r_type < R_NDS32_max)))
+    {
+      cache_ptr->howto = bfd_elf32_bfd_reloc_type_table_lookup (r_type);
+      return TRUE;
+    }
+
+  /* xgettext:c-format */
+  _bfd_error_handler (_("%pB: unsupported relocation type %#x"), abfd, r_type);
+  bfd_set_error (bfd_error_bad_value);
+  return FALSE;  
 }
 
 /* Support for core dump NOTE sections.
diff --git a/bfd/elf32-nios2.c b/bfd/elf32-nios2.c
index 29e1e5a..e160054 100644
--- a/bfd/elf32-nios2.c
+++ b/bfd/elf32-nios2.c
@@ -31,6 +31,7 @@
 #include "elf/nios2.h"
 #include "opcode/nios2.h"
 #include "elf32-nios2.h"
+#include "libiberty.h"
 
 /* Use RELA relocations.  */
 #ifndef USE_RELA
@@ -1578,10 +1579,8 @@ lookup_howto (unsigned int rtype, bfd *abfd)
   int i;
   /* R2 relocations are a superset of R1, so use that for the lookup
      table.  */
-  int r1_howto_tbl_size = (int) (sizeof (elf_nios2_r1_howto_table_rel)
-				 / sizeof (elf_nios2_r1_howto_table_rel[0]));
-  int r2_howto_tbl_size = (int) (sizeof (elf_nios2_r2_howto_table_rel)
-				 / sizeof (elf_nios2_r2_howto_table_rel[0]));
+  int r1_howto_tbl_size = (int) ARRAY_SIZE (elf_nios2_r1_howto_table_rel);
+  int r2_howto_tbl_size = (int) ARRAY_SIZE (elf_nios2_r2_howto_table_rel);
 
   if (!initialized)
     {
@@ -1597,18 +1596,19 @@ lookup_howto (unsigned int rtype, bfd *abfd)
 	}
     }
 
-  BFD_ASSERT (rtype <= R_NIOS2_ILLEGAL);
+  if (rtype > R_NIOS2_ILLEGAL)
+    return NULL;
   i = elf_code_to_howto_index[rtype];
   if (BFD_IS_R2 (abfd))
     {
       if (i >= r2_howto_tbl_size)
-	return 0;
+	return NULL;
       return elf_nios2_r2_howto_table_rel + i;
     }
   else
     {
       if (i >= r1_howto_tbl_size)
-	return 0;
+	return NULL;
       return elf_nios2_r1_howto_table_rel + i;
     }
 }
@@ -1620,7 +1620,8 @@ struct elf_reloc_map
   enum elf_nios2_reloc_type elf_val;
 };
 
-static const struct elf_reloc_map nios2_reloc_map[] = {
+static const struct elf_reloc_map nios2_reloc_map[] =
+{
   {BFD_RELOC_NONE, R_NIOS2_NONE},
   {BFD_RELOC_NIOS2_S16, R_NIOS2_S16},
   {BFD_RELOC_NIOS2_U16, R_NIOS2_U16},
@@ -2954,18 +2955,16 @@ nios2_elf32_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
   return TRUE;
 }
 
-
 /* Implement bfd_elf32_bfd_reloc_type_lookup:
    Given a BFD reloc type, return a howto structure.  */
+
 static reloc_howto_type *
 nios2_elf32_bfd_reloc_type_lookup (bfd *abfd,
 				   bfd_reloc_code_real_type code)
 {
   int i;
 
-  for (i = 0;
-       i < (int) (sizeof (nios2_reloc_map) / sizeof (struct elf_reloc_map));
-       ++i)
+  for (i = 0; i < (int) ARRAY_SIZE (nios2_reloc_map); ++i)
     if (nios2_reloc_map[i].bfd_val == code)
       return lookup_howto (nios2_reloc_map[i].elf_val, abfd);
   return NULL;
@@ -2973,6 +2972,7 @@ nios2_elf32_bfd_reloc_type_lookup (bfd *abfd,
 
 /* Implement bfd_elf32_bfd_reloc_name_lookup:
    Given a reloc name, return a howto structure.  */
+
 static reloc_howto_type *
 nios2_elf32_bfd_reloc_name_lookup (bfd *abfd,
 				   const char *r_name)
@@ -2984,32 +2984,40 @@ nios2_elf32_bfd_reloc_name_lookup (bfd *abfd,
   if (BFD_IS_R2 (abfd))
     {
       howto_tbl = elf_nios2_r2_howto_table_rel;
-      howto_tbl_size = (int) (sizeof (elf_nios2_r2_howto_table_rel)
-			      / sizeof (elf_nios2_r2_howto_table_rel[0]));
+      howto_tbl_size = (int) ARRAY_SIZE (elf_nios2_r2_howto_table_rel);
     }
   else
     {
       howto_tbl = elf_nios2_r1_howto_table_rel;
-      howto_tbl_size = (int) (sizeof (elf_nios2_r1_howto_table_rel)
-			      / sizeof (elf_nios2_r1_howto_table_rel[0]));
+      howto_tbl_size = (int) ARRAY_SIZE (elf_nios2_r1_howto_table_rel);
     }
 
   for (i = 0; i < howto_tbl_size; i++)
     if (howto_tbl[i].name && strcasecmp (howto_tbl[i].name, r_name) == 0)
       return howto_tbl + i;
+
   return NULL;
 }
 
 /* Implement elf_info_to_howto:
    Given a ELF32 relocation, fill in a arelent structure.  */
-static void
+
+static bfd_boolean
 nios2_elf32_info_to_howto (bfd *abfd, arelent *cache_ptr,
 			   Elf_Internal_Rela *dst)
 {
   unsigned int r_type;
 
   r_type = ELF32_R_TYPE (dst->r_info);
-  cache_ptr->howto = lookup_howto (r_type, abfd);
+  if ((cache_ptr->howto = lookup_howto (r_type, abfd)) == NULL)
+    {
+      /* xgettext:c-format */
+      _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+			  abfd, r_type);
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
+    }
+  return TRUE;
 }
 
 /* Return the base VMA address which should be subtracted from real addresses
diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c
index 3818df9..91b780f 100644
--- a/bfd/elf32-or1k.c
+++ b/bfd/elf32-or1k.c
@@ -701,7 +701,7 @@ or1k_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 
 /* Set the howto pointer for an Or1k ELF reloc.  */
 
-static void
+static bfd_boolean
 or1k_info_to_howto_rela (bfd * abfd,
 			 arelent * cache_ptr,
 			 Elf_Internal_Rela * dst)
@@ -714,9 +714,11 @@ or1k_info_to_howto_rela (bfd * abfd,
       /* xgettext:c-format */
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, r_type);
-      r_type = 0;
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
     }
   cache_ptr->howto = & or1k_elf_howto_table[r_type];
+  return TRUE;
 }
 
 
diff --git a/bfd/elf32-pj.c b/bfd/elf32-pj.c
index 1c75523..470d20a 100644
--- a/bfd/elf32-pj.c
+++ b/bfd/elf32-pj.c
@@ -310,7 +310,7 @@ pj_elf_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 
 /* Given an ELF reloc, fill in the howto field of a relent.  */
 
-static void
+static bfd_boolean
 pj_elf_info_to_howto (bfd *abfd,
 		      arelent *cache_ptr,
 		      Elf_Internal_Rela *dst)
@@ -325,10 +325,11 @@ pj_elf_info_to_howto (bfd *abfd,
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, r);
       bfd_set_error (bfd_error_bad_value);
-      r = R_PJ_NONE;
+      return FALSE;
     }
 
   cache_ptr->howto = &pj_elf_howto_table[r];
+  return TRUE;
 }
 
 /* Take this moment to fill in the special picoJava bits in the
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index be95498..66bbf0d 100644
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -2014,7 +2014,7 @@ ppc_elf_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 
 /* Set the howto pointer for a PowerPC ELF reloc.  */
 
-static void
+static bfd_boolean
 ppc_elf_info_to_howto (bfd *abfd,
 		       arelent *cache_ptr,
 		       Elf_Internal_Rela *dst)
@@ -2032,21 +2032,24 @@ ppc_elf_info_to_howto (bfd *abfd,
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, r_type);
       bfd_set_error (bfd_error_bad_value);
-      r_type = R_PPC_NONE;
+      return FALSE;
     }
+
   cache_ptr->howto = ppc_elf_howto_table[r_type];
 
   /* Just because the above assert didn't trigger doesn't mean that
      ELF32_R_TYPE (dst->r_info) is necessarily a valid relocation.  */
-  if (!cache_ptr->howto)
+  if (cache_ptr->howto == NULL)
     {
       /* xgettext:c-format */
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, r_type);
       bfd_set_error (bfd_error_bad_value);
 
-      cache_ptr->howto = ppc_elf_howto_table[R_PPC_NONE];
+      return FALSE;
     }
+
+  return TRUE;
 }
 
 /* Handle the R_PPC_ADDR16_HA and R_PPC_REL16_HA relocs.  */
diff --git a/bfd/elf32-pru.c b/bfd/elf32-pru.c
index 71bb0a0..a3c431b 100644
--- a/bfd/elf32-pru.c
+++ b/bfd/elf32-pru.c
@@ -30,6 +30,7 @@
 #include "elf-bfd.h"
 #include "elf/pru.h"
 #include "opcode/pru.h"
+#include "libiberty.h"
 
 #define SWAP_VALS(A,B)		      \
   do {				      \
@@ -291,38 +292,42 @@ static reloc_howto_type elf_pru_howto_table_rel[] = {
 static unsigned char elf_code_to_howto_index[R_PRU_ILLEGAL + 1];
 
 /* Return the howto for relocation RTYPE.  */
+
 static reloc_howto_type *
 lookup_howto (unsigned int rtype)
 {
-  static int initialized = 0;
+  static bfd_boolean initialized = FALSE;
   int i;
   int howto_tbl_size = (int) (sizeof (elf_pru_howto_table_rel)
 			      / sizeof (elf_pru_howto_table_rel[0]));
 
-  if (!initialized)
+  if (! initialized)
     {
-      initialized = 1;
+      initialized = TRUE;
       memset (elf_code_to_howto_index, 0xff,
 	      sizeof (elf_code_to_howto_index));
       for (i = 0; i < howto_tbl_size; i++)
 	elf_code_to_howto_index[elf_pru_howto_table_rel[i].type] = i;
     }
 
-  BFD_ASSERT (rtype <= R_PRU_ILLEGAL);
+  if (rtype > R_PRU_ILLEGAL)
+    return NULL;
   i = elf_code_to_howto_index[rtype];
   if (i >= howto_tbl_size)
-    return 0;
+    return NULL;
   return elf_pru_howto_table_rel + i;
 }
 
 /* Map for converting BFD reloc types to PRU reloc types.  */
+
 struct elf_reloc_map
 {
   bfd_reloc_code_real_type bfd_val;
   enum elf_pru_reloc_type elf_val;
 };
 
-static const struct elf_reloc_map pru_reloc_map[] = {
+static const struct elf_reloc_map pru_reloc_map[] =
+{
   {BFD_RELOC_NONE, R_PRU_NONE},
   {BFD_RELOC_PRU_16_PMEM, R_PRU_16_PMEM},
   {BFD_RELOC_PRU_U16_PMEMIMM, R_PRU_U16_PMEMIMM},
@@ -346,6 +351,7 @@ static const struct elf_reloc_map pru_reloc_map[] = {
 /* Assorted hash table functions.  */
 
 /* Create an entry in a PRU ELF linker hash table.  */
+
 static struct bfd_hash_entry *
 link_hash_newfunc (struct bfd_hash_entry *entry,
 		   struct bfd_hash_table *table, const char *string)
@@ -368,14 +374,14 @@ link_hash_newfunc (struct bfd_hash_entry *entry,
 
 /* Implement bfd_elf32_bfd_reloc_type_lookup:
    Given a BFD reloc type, return a howto structure.  */
+
 static reloc_howto_type *
 pru_elf32_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 				   bfd_reloc_code_real_type code)
 {
-  int i;
-  for (i = 0;
-       i < (int) (sizeof (pru_reloc_map) / sizeof (struct elf_reloc_map));
-       ++i)
+  unsigned int i;
+
+  for (i = 0; i < ARRAY_SIZE (pru_reloc_map); ++i)
     if (pru_reloc_map[i].bfd_val == code)
       return lookup_howto ((unsigned int) pru_reloc_map[i].elf_val);
   return NULL;
@@ -383,15 +389,14 @@ pru_elf32_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 
 /* Implement bfd_elf32_bfd_reloc_name_lookup:
    Given a reloc name, return a howto structure.  */
+
 static reloc_howto_type *
 pru_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 				   const char *r_name)
 {
   unsigned int i;
-  for (i = 0;
-       i < (sizeof (elf_pru_howto_table_rel)
-	    / sizeof (elf_pru_howto_table_rel[0]));
-       i++)
+
+  for (i = 0; i < ARRAY_SIZE (elf_pru_howto_table_rel); i++)
     if (elf_pru_howto_table_rel[i].name
 	&& strcasecmp (elf_pru_howto_table_rel[i].name, r_name) == 0)
       return &elf_pru_howto_table_rel[i];
@@ -401,15 +406,24 @@ pru_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 
 /* Implement elf_info_to_howto:
    Given a ELF32 relocation, fill in a arelent structure.  */
-static void
-pru_elf32_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *cache_ptr,
+
+static bfd_boolean
+pru_elf32_info_to_howto (bfd *abfd, arelent *cache_ptr,
 			 Elf_Internal_Rela *dst)
 {
   unsigned int r_type;
 
   r_type = ELF32_R_TYPE (dst->r_info);
-  BFD_ASSERT (r_type < R_PRU_ILLEGAL);
+  if (r_type >= R_PRU_ILLEGAL)
+    {
+      /* xgettext:c-format */
+      _bfd_error_handler (_("%pB: unsupported relocation type %#x"), abfd, r_type);
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
+    }
+    
   cache_ptr->howto = lookup_howto (r_type);
+  return cache_ptr->howto != NULL;
 }
 
 /* Do the relocations that require special handling.  */
diff --git a/bfd/elf32-rl78.c b/bfd/elf32-rl78.c
index 7cfe312..e072b1a 100644
--- a/bfd/elf32-rl78.c
+++ b/bfd/elf32-rl78.c
@@ -278,8 +278,8 @@ rl78_reloc_name_lookup (bfd * abfd ATTRIBUTE_UNUSED, const char * r_name)
 
 /* Set the howto pointer for an RL78 ELF reloc.  */
 
-static void
-rl78_info_to_howto_rela (bfd *		     abfd ATTRIBUTE_UNUSED,
+static bfd_boolean
+rl78_info_to_howto_rela (bfd *		     abfd,
 			 arelent *	     cache_ptr,
 			 Elf_Internal_Rela * dst)
 {
@@ -291,9 +291,11 @@ rl78_info_to_howto_rela (bfd *		     abfd ATTRIBUTE_UNUSED,
       /* xgettext:c-format */
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, r_type);
-      r_type = 0;
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
     }
   cache_ptr->howto = rl78_elf_howto_table + r_type;
+  return TRUE;
 }
 
 static bfd_vma
diff --git a/bfd/elf32-rx.c b/bfd/elf32-rx.c
index 42f5fc2..1f70b97 100644
--- a/bfd/elf32-rx.c
+++ b/bfd/elf32-rx.c
@@ -300,10 +300,10 @@ rx_reloc_name_lookup (bfd * abfd ATTRIBUTE_UNUSED, const char * r_name)
 
 /* Set the howto pointer for an RX ELF reloc.  */
 
-static void
-rx_info_to_howto_rela (bfd *abfd,
-		       arelent *cache_ptr,
-		       Elf_Internal_Rela *dst)
+static bfd_boolean
+rx_info_to_howto_rela (bfd *		   abfd,
+		       arelent *	   cache_ptr,
+		       Elf_Internal_Rela * dst)
 {
   unsigned int r_type;
 
@@ -313,9 +313,19 @@ rx_info_to_howto_rela (bfd *abfd,
       /* xgettext:c-format */
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, r_type);
-      r_type = 0;
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
     }
   cache_ptr->howto = rx_elf_howto_table + r_type;
+  if (cache_ptr->howto->name == NULL)
+    {
+      /* xgettext:c-format */
+      _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+			  abfd, r_type);
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
+    }
+  return TRUE;
 }
 
 static bfd_vma
diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c
index ce9c25f..d077104 100644
--- a/bfd/elf32-s390.c
+++ b/bfd/elf32-s390.c
@@ -323,12 +323,13 @@ elf_s390_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 /* We need to use ELF32_R_TYPE so we have our own copy of this function,
    and elf32-s390.c has its own copy.  */
 
-static void
-elf_s390_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
+static bfd_boolean
+elf_s390_info_to_howto (bfd *abfd,
 			arelent *cache_ptr,
 			Elf_Internal_Rela *dst)
 {
   unsigned int r_type = ELF32_R_TYPE(dst->r_info);
+
   switch (r_type)
     {
     case R_390_GNU_VTINHERIT:
@@ -345,10 +346,13 @@ elf_s390_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
 	  /* xgettext:c-format */
 	  _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			      abfd, r_type);
-	  r_type = R_390_NONE;
+	  bfd_set_error (bfd_error_bad_value);
+	  return FALSE;
 	}
       cache_ptr->howto = &elf_howto_table[r_type];
     }
+
+  return TRUE;
 }
 
 /* A relocation function which doesn't do anything.  */
diff --git a/bfd/elf32-score.c b/bfd/elf32-score.c
index 91d92cc..42ef221 100644
--- a/bfd/elf32-score.c
+++ b/bfd/elf32-score.c
@@ -2375,7 +2375,7 @@ score_elf_final_link_relocate (reloc_howto_type *howto,
 }
 
 /* Score backend functions.  */
-static void
+static bfd_boolean
 s3_bfd_score_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
 			    arelent *bfd_reloc,
 			    Elf_Internal_Rela *elf_reloc)
@@ -2384,9 +2384,10 @@ s3_bfd_score_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
 
   r_type = ELF32_R_TYPE (elf_reloc->r_info);
   if (r_type >= ARRAY_SIZE (elf32_score_howto_table))
-    bfd_reloc->howto = NULL;
-  else
-    bfd_reloc->howto = &elf32_score_howto_table[r_type];
+    return FALSE;
+
+  bfd_reloc->howto = &elf32_score_howto_table[r_type];
+  return TRUE;
 }
 
 /* Relocate an score ELF section.  */
@@ -2448,7 +2449,8 @@ s3_bfd_score_elf_relocate_section (bfd *output_bfd,
       r_symndx = ELF32_R_SYM (rel->r_info);
       r_type = ELF32_R_TYPE (rel->r_info);
 
-      s3_bfd_score_info_to_howto (input_bfd, &bfd_reloc, (Elf_Internal_Rela *) rel);
+      if (! s3_bfd_score_info_to_howto (input_bfd, &bfd_reloc, (Elf_Internal_Rela *) rel))
+	continue;
       howto = bfd_reloc.howto;
 
       h = NULL;
@@ -4069,7 +4071,7 @@ s3_elf32_score_new_section_hook (bfd *abfd, asection *sec)
 /*****************************************************************************/
 
 /* s3_s7: backend hooks.  */
-static void
+static bfd_boolean
 _bfd_score_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
 			  arelent *bfd_reloc,
 			  Elf_Internal_Rela *elf_reloc)
@@ -4450,7 +4452,7 @@ _bfd_score_elf_common_definition (Elf_Internal_Sym *sym)
 #define ELF_MACHINE_ALT1		EM_SCORE_OLD
 #define ELF_MAXPAGESIZE			0x8000
 
-#define elf_info_to_howto		0
+#define elf_info_to_howto		NULL
 #define elf_info_to_howto_rel		_bfd_score_info_to_howto
 #define elf_backend_relocate_section	_bfd_score_elf_relocate_section
 #define elf_backend_check_relocs	_bfd_score_elf_check_relocs
diff --git a/bfd/elf32-score.h b/bfd/elf32-score.h
index dc9fd1e..ed5c9fc 100644
--- a/bfd/elf32-score.h
+++ b/bfd/elf32-score.h
@@ -30,7 +30,7 @@ s7_bfd_score_elf_hide_symbol (struct bfd_link_info *,
 			      struct elf_link_hash_entry *,
 			      bfd_boolean);
 
-extern void
+extern bfd_boolean
 s7_bfd_score_info_to_howto (bfd *, arelent *, Elf_Internal_Rela *);
 
 extern bfd_boolean
diff --git a/bfd/elf32-score7.c b/bfd/elf32-score7.c
index b36c95e..3c022e6 100644
--- a/bfd/elf32-score7.c
+++ b/bfd/elf32-score7.c
@@ -2214,7 +2214,7 @@ score_elf_final_link_relocate (reloc_howto_type *howto,
 
 /* Score backend functions.  */
 
-void
+bfd_boolean
 s7_bfd_score_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
 			    arelent *bfd_reloc,
 			    Elf_Internal_Rela *elf_reloc)
@@ -2223,9 +2223,10 @@ s7_bfd_score_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
 
   r_type = ELF32_R_TYPE (elf_reloc->r_info);
   if (r_type >= ARRAY_SIZE (elf32_score_howto_table))
-    bfd_reloc->howto = NULL;
-  else
-    bfd_reloc->howto = &elf32_score_howto_table[r_type];
+    return FALSE;
+
+  bfd_reloc->howto = &elf32_score_howto_table[r_type];
+  return TRUE;
 }
 
 /* Relocate an score ELF section.  */
@@ -2288,7 +2289,8 @@ s7_bfd_score_elf_relocate_section (bfd *output_bfd,
       r_symndx = ELF32_R_SYM (rel->r_info);
       r_type = ELF32_R_TYPE (rel->r_info);
 
-      s7_bfd_score_info_to_howto (input_bfd, &bfd_reloc, (Elf_Internal_Rela *) rel);
+      if (! s7_bfd_score_info_to_howto (input_bfd, &bfd_reloc, (Elf_Internal_Rela *) rel))
+	continue;
       howto = bfd_reloc.howto;
 
       h = NULL;
diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c
index a13d60b..d0f5ac8 100644
--- a/bfd/elf32-sh.c
+++ b/bfd/elf32-sh.c
@@ -472,7 +472,7 @@ sh_elf_reloc_name_lookup (bfd *abfd, const char *r_name)
 
 /* Given an ELF reloc, fill in the howto field of a relent.  */
 
-static void
+static bfd_boolean
 sh_elf_info_to_howto (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst)
 {
   unsigned int r;
@@ -491,10 +491,11 @@ sh_elf_info_to_howto (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst)
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, r);
       bfd_set_error (bfd_error_bad_value);
-      r = R_SH_NONE;
+      return FALSE;
     }
 
   cache_ptr->howto = get_howto_table (abfd) + r;
+  return TRUE;
 }
 
 /* This function handles relaxing for SH ELF.  See the corresponding
diff --git a/bfd/elf32-spu.c b/bfd/elf32-spu.c
index d682de2..c3bfbbd 100644
--- a/bfd/elf32-spu.c
+++ b/bfd/elf32-spu.c
@@ -145,7 +145,7 @@ spu_elf_bfd_to_reloc_type (bfd_reloc_code_real_type code)
     }
 }
 
-static void
+static bfd_boolean
 spu_elf_info_to_howto (bfd *abfd,
 		       arelent *cache_ptr,
 		       Elf_Internal_Rela *dst)
@@ -160,9 +160,10 @@ spu_elf_info_to_howto (bfd *abfd,
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, r_type);
       bfd_set_error (bfd_error_bad_value);
-      r_type = R_SPU_NONE;
+      return FALSE;
     }
   cache_ptr->howto = &elf_howto_table[(int) r_type];
+  return TRUE;
 }
 
 static reloc_howto_type *
diff --git a/bfd/elf32-tic6x.c b/bfd/elf32-tic6x.c
index 0199c2c..96965b3 100644
--- a/bfd/elf32-tic6x.c
+++ b/bfd/elf32-tic6x.c
@@ -1495,7 +1495,7 @@ elf32_tic6x_reloc_name_lookup (bfd *abfd, const char *r_name)
   return NULL;
 }
 
-static void
+static bfd_boolean
 elf32_tic6x_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *bfd_reloc,
 			   Elf_Internal_Rela *elf_reloc)
 {
@@ -1503,12 +1503,28 @@ elf32_tic6x_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *bfd_reloc,
 
   r_type = ELF32_R_TYPE (elf_reloc->r_info);
   if (r_type >= ARRAY_SIZE (elf32_tic6x_howto_table))
-    bfd_reloc->howto = NULL;
-  else
-    bfd_reloc->howto = &elf32_tic6x_howto_table[r_type];
+    {
+      /* xgettext:c-format */
+      _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+			  abfd, r_type);
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
+    }
+
+  bfd_reloc->howto = &elf32_tic6x_howto_table[r_type];
+  if (bfd_reloc->howto == NULL || bfd_reloc->howto->name == NULL)
+    {
+      /* xgettext:c-format */
+      _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+			  abfd, r_type);
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
+    }
+
+  return TRUE;
 }
 
-static void
+static bfd_boolean
 elf32_tic6x_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, arelent *bfd_reloc,
 			       Elf_Internal_Rela *elf_reloc)
 {
@@ -1516,9 +1532,25 @@ elf32_tic6x_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, arelent *bfd_reloc,
 
   r_type = ELF32_R_TYPE (elf_reloc->r_info);
   if (r_type >= ARRAY_SIZE (elf32_tic6x_howto_table_rel))
-    bfd_reloc->howto = NULL;
-  else
-    bfd_reloc->howto = &elf32_tic6x_howto_table_rel[r_type];
+    {
+      /* xgettext:c-format */
+      _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+			  abfd, r_type);
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
+    }
+
+  bfd_reloc->howto = &elf32_tic6x_howto_table_rel[r_type];
+  if (bfd_reloc->howto == NULL || bfd_reloc->howto->name == NULL)
+    {
+      /* xgettext:c-format */
+      _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+			  abfd, r_type);
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
+    }
+
+  return TRUE;
 }
 
 void
@@ -2213,6 +2245,7 @@ elf32_tic6x_relocate_section (bfd *output_bfd,
       bfd_reloc_status_type r;
       struct bfd_link_hash_entry *sbh;
       bfd_boolean is_rel;
+      bfd_boolean res;
 
       r_type = ELF32_R_TYPE (rel->r_info);
       r_symndx = ELF32_R_SYM (rel->r_info);
@@ -2221,11 +2254,11 @@ elf32_tic6x_relocate_section (bfd *output_bfd,
 					     relocs, rel);
 
       if (is_rel)
-	elf32_tic6x_info_to_howto_rel (input_bfd, &bfd_reloc, rel);
+	res = elf32_tic6x_info_to_howto_rel (input_bfd, &bfd_reloc, rel);
       else
-	elf32_tic6x_info_to_howto (input_bfd, &bfd_reloc, rel);
-      howto = bfd_reloc.howto;
-      if (howto == NULL)
+	res = elf32_tic6x_info_to_howto (input_bfd, &bfd_reloc, rel);
+
+      if (!res || (howto = bfd_reloc.howto) == NULL)
 	{
 	  bfd_set_error (bfd_error_bad_value);
 	  return FALSE;
@@ -2608,6 +2641,7 @@ elf32_tic6x_relocate_section (bfd *output_bfd,
 	  /* xgettext:c-format */
 	  _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			      input_bfd, r_type);
+	  bfd_set_error (bfd_error_bad_value);
 	  ok = FALSE;
 	  continue;
 	}
diff --git a/bfd/elf32-tilepro.c b/bfd/elf32-tilepro.c
index 24fc64e..55b19f8 100644
--- a/bfd/elf32-tilepro.c
+++ b/bfd/elf32-tilepro.c
@@ -783,7 +783,7 @@ tilepro_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 
 /* Set the howto pointer for an TILEPro ELF reloc.  */
 
-static void
+static bfd_boolean
 tilepro_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED,
 			    arelent * cache_ptr,
 			    Elf_Internal_Rela * dst)
@@ -793,11 +793,19 @@ tilepro_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED,
   if (r_type <= (unsigned int) R_TILEPRO_IMM16_X1_TLS_LE_HA)
     cache_ptr->howto = &tilepro_elf_howto_table [r_type];
   else if (r_type - R_TILEPRO_GNU_VTINHERIT
-	   <= (unsigned int) R_TILEPRO_GNU_VTENTRY)
+	   <= ((unsigned int) R_TILEPRO_GNU_VTENTRY
+	       - (unsigned int) R_TILEPRO_GNU_VTINHERIT))
     cache_ptr->howto
       = &tilepro_elf_howto_table2 [r_type - R_TILEPRO_GNU_VTINHERIT];
   else
-    abort ();
+    {
+      /* xgettext:c-format */
+      _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+			  abfd, r_type);
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
+    }
+  return TRUE;
 }
 
 typedef tilepro_bundle_bits (*tilepro_create_func)(int);
diff --git a/bfd/elf32-v850.c b/bfd/elf32-v850.c
index fa041e9..430153a 100644
--- a/bfd/elf32-v850.c
+++ b/bfd/elf32-v850.c
@@ -1885,7 +1885,7 @@ v850_elf_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 
 /* Set the howto pointer for an V850 ELF reloc.  */
 
-static void
+static bfd_boolean
 v850_elf_info_to_howto_rel (bfd *abfd,
 			    arelent *cache_ptr,
 			    Elf_Internal_Rela *dst)
@@ -1898,16 +1898,18 @@ v850_elf_info_to_howto_rel (bfd *abfd,
       /* xgettext:c-format */
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, r_type);
-      r_type = 0;
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
     }
   cache_ptr->howto = &v850_elf_howto_table[r_type];
+  return TRUE;
 }
 
 /* Set the howto pointer for a V850 ELF reloc (type RELA).  */
 
-static void
+static bfd_boolean
 v850_elf_info_to_howto_rela (bfd *abfd,
-			     arelent *cache_ptr,
+			     arelent * cache_ptr,
 			     Elf_Internal_Rela *dst)
 {
   unsigned int r_type;
@@ -1918,9 +1920,11 @@ v850_elf_info_to_howto_rela (bfd *abfd,
       /* xgettext:c-format */
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, r_type);
-      r_type = 0;
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
     }
   cache_ptr->howto = &v850_elf_howto_table[r_type];
+  return TRUE;
 }
 
 static bfd_boolean
@@ -4247,25 +4251,30 @@ v800_elf_reloc_name_lookup (bfd * abfd, const char * r_name)
 
 /* Set the howto pointer in CACHE_PTR for a V800 ELF reloc.  */
 
-static void
+static bfd_boolean
 v800_elf_info_to_howto (bfd *		    abfd,
 			arelent *	    cache_ptr,
 			Elf_Internal_Rela * dst)
 {
   unsigned int r_type = ELF32_R_TYPE (dst->r_info);
 
-  BFD_ASSERT (bfd_get_arch (abfd) == bfd_arch_v850_rh850);
-
-  BFD_ASSERT (r_type < (unsigned int) R_V800_max);
-
   if (r_type == R_V800_NONE)
     r_type = R_V810_NONE;
 
-  BFD_ASSERT (r_type >= (unsigned int) R_V810_NONE);
-  r_type -= R_V810_NONE;
-  BFD_ASSERT (r_type < ARRAY_SIZE (v800_elf_howto_table));
+  if (bfd_get_arch (abfd) != bfd_arch_v850_rh850
+      || r_type >= (unsigned int) R_V800_max
+      || r_type < (unsigned int) R_V810_NONE
+      || (r_type - R_V810_NONE) >= ARRAY_SIZE (v800_elf_howto_table))
+    {
+      /* xgettext:c-format */
+      _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+			  abfd, r_type);
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
+    }
 
-  cache_ptr->howto = v800_elf_howto_table + r_type;
+  cache_ptr->howto = v800_elf_howto_table + (r_type - R_V810_NONE);
+  return TRUE;
 }
 
 #undef  TARGET_LITTLE_SYM
diff --git a/bfd/elf32-vax.c b/bfd/elf32-vax.c
index 61310b6..0236180 100644
--- a/bfd/elf32-vax.c
+++ b/bfd/elf32-vax.c
@@ -27,7 +27,7 @@
 #include "elf/vax.h"
 
 static reloc_howto_type *reloc_type_lookup (bfd *, bfd_reloc_code_real_type);
-static void rtype_to_howto (bfd *, arelent *, Elf_Internal_Rela *);
+static bfd_boolean rtype_to_howto (bfd *, arelent *, Elf_Internal_Rela *);
 static struct bfd_hash_entry *elf_vax_link_hash_newfunc (struct bfd_hash_entry *,
 							 struct bfd_hash_table *,
 							 const char *);
@@ -278,7 +278,7 @@ static reloc_howto_type howto_table[] = {
 	 FALSE),		/* pcrel_offset */
 };
 
-static void
+static bfd_boolean
 rtype_to_howto (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst)
 {
   unsigned int r_type;
@@ -290,9 +290,10 @@ rtype_to_howto (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst)
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, r_type);
       bfd_set_error (bfd_error_bad_value);
-      r_type = R_VAX_NONE;
+      return FALSE;
     }
   cache_ptr->howto = &howto_table[r_type];
+  return TRUE;
 }
 
 #define elf_info_to_howto rtype_to_howto
diff --git a/bfd/elf32-visium.c b/bfd/elf32-visium.c
index 9310d42..3f8d16a 100644
--- a/bfd/elf32-visium.c
+++ b/bfd/elf32-visium.c
@@ -458,7 +458,7 @@ visium_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, const char *r_name)
 
 /* Set the howto pointer for a VISIUM ELF reloc.  */
 
-static void
+static bfd_boolean
 visium_info_to_howto_rela (bfd *abfd, arelent *cache_ptr,
 			   Elf_Internal_Rela *dst)
 {
@@ -480,11 +480,13 @@ visium_info_to_howto_rela (bfd *abfd, arelent *cache_ptr,
 	  /* xgettext:c-format */
 	  _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			      abfd, r_type);
-	  r_type = 0;
+	  bfd_set_error (bfd_error_bad_value);
+	  return FALSE;
 	}
       cache_ptr->howto = &visium_elf_howto_table[r_type];
       break;
     }
+  return TRUE;
 }
 
 /* Look through the relocs for a section during the first phase.
diff --git a/bfd/elf32-wasm32.c b/bfd/elf32-wasm32.c
index b9f3cb2..9fc48de 100644
--- a/bfd/elf32-wasm32.c
+++ b/bfd/elf32-wasm32.c
@@ -105,24 +105,27 @@ elf32_wasm32_rtype_to_howto (bfd *abfd, unsigned r_type)
       /* xgettext:c-format */
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, r_type);
-      i = R_WASM32_NONE;
+      bfd_set_error (bfd_error_bad_value);
+      return NULL;
     }
 
   if (elf32_wasm32_howto_table[i].type != r_type)
     return NULL;
 
-  return &elf32_wasm32_howto_table[i];
+  return elf32_wasm32_howto_table + i;
 }
 
 /* Translate the ELF-internal relocation RELA into CACHE_PTR.  */
 
-static void
+static bfd_boolean
 elf32_wasm32_info_to_howto_rela (bfd *abfd,
 				arelent *cache_ptr,
 				Elf_Internal_Rela *dst)
 {
   unsigned int r_type = ELF32_R_TYPE (dst->r_info);
+
   cache_ptr->howto = elf32_wasm32_rtype_to_howto (abfd, r_type);
+  return cache_ptr->howto != NULL;
 }
 
 #define ELF_ARCH		bfd_arch_wasm32
diff --git a/bfd/elf32-xc16x.c b/bfd/elf32-xc16x.c
index 42a3dca..66fe33d 100644
--- a/bfd/elf32-xc16x.c
+++ b/bfd/elf32-xc16x.c
@@ -212,9 +212,7 @@ xc16x_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 {
   unsigned int i;
 
-  for (i = 0;
-       i < sizeof (xc16x_elf_howto_table) / sizeof (xc16x_elf_howto_table[0]);
-       i++)
+  for (i = 0; i < ARRAY_SIZE (xc16x_elf_howto_table); i++)
     if (xc16x_elf_howto_table[i].name != NULL
 	&& strcasecmp (xc16x_elf_howto_table[i].name, r_name) == 0)
       return &xc16x_elf_howto_table[i];
@@ -225,8 +223,8 @@ xc16x_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 /* For a particular operand this function is
    called to finalise the type of relocation.  */
 
-static void
-elf32_xc16x_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *bfd_reloc,
+static bfd_boolean
+elf32_xc16x_info_to_howto (bfd *abfd, arelent *bfd_reloc,
 			   Elf_Internal_Rela *elf_reloc)
 {
   unsigned int r;
@@ -237,9 +235,12 @@ elf32_xc16x_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *bfd_reloc,
     if (xc16x_elf_howto_table[i].type == r)
       {
 	bfd_reloc->howto = &xc16x_elf_howto_table[i];
-	return;
+	return TRUE;
       }
-  abort ();
+  /* xgettext:c-format */
+  _bfd_error_handler (_("%pB: unsupported relocation type %#x"), abfd, r);
+  bfd_set_error (bfd_error_bad_value);
+  return FALSE;
 }
 
 static bfd_reloc_status_type
diff --git a/bfd/elf32-xgate.c b/bfd/elf32-xgate.c
index 3e2669c..a367526 100644
--- a/bfd/elf32-xgate.c
+++ b/bfd/elf32-xgate.c
@@ -34,7 +34,7 @@ static reloc_howto_type *
 bfd_elf32_bfd_reloc_type_lookup (bfd *, bfd_reloc_code_real_type);
 static reloc_howto_type *
 bfd_elf32_bfd_reloc_name_lookup (bfd *, const char *);
-static void
+static bfd_boolean
 xgate_info_to_howto_rel (bfd *, arelent *, Elf_Internal_Rela *);
 static bfd_boolean
 xgate_elf_set_mach_from_flags (bfd *);
@@ -395,7 +395,7 @@ bfd_elf32_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
   for (i = 0; i < ARRAY_SIZE (xgate_reloc_map); i++)
     if (xgate_reloc_map[i].bfd_reloc_val == code)
       return &elf_xgate_howto_table[xgate_reloc_map[i].elf_reloc_val];
-
+  
   return NULL;
 }
 
@@ -414,7 +414,7 @@ bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, const char *r_name)
 
 /* Set the howto pointer for an XGATE ELF reloc.  */
 
-static void
+static bfd_boolean
 xgate_info_to_howto_rel (bfd *abfd,
 			 arelent *cache_ptr,
 			 Elf_Internal_Rela *dst)
@@ -427,9 +427,11 @@ xgate_info_to_howto_rel (bfd *abfd,
       /* xgettext:c-format */
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
 			  abfd, r_type);
-      r_type = 0;
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
     }
   cache_ptr->howto = &elf_xgate_howto_table[r_type];
+  return TRUE;
 }
 
 /* Destroy an XGATE ELF linker hash table.  */
@@ -702,12 +704,12 @@ elf32_xgate_post_process_headers (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_link_in
 #define TARGET_BIG_SYM			     xgate_elf32_vec
 #define TARGET_BIG_NAME			     "elf32-xgate"
 
-#define elf_info_to_howto		     0
+#define elf_info_to_howto		     NULL
 #define elf_info_to_howto_rel		     xgate_info_to_howto_rel
 #define elf_backend_check_relocs	     elf32_xgate_check_relocs
 #define elf_backend_relocate_section	     elf32_xgate_relocate_section
 #define elf_backend_object_p		     xgate_elf_set_mach_from_flags
-#define elf_backend_final_write_processing   0
+#define elf_backend_final_write_processing   NULL
 #define elf_backend_can_gc_sections	     1
 #define elf_backend_special_sections	     elf32_xgate_special_sections
 #define elf_backend_post_process_headers     elf32_xgate_post_process_headers
diff --git a/bfd/elf32-xstormy16.c b/bfd/elf32-xstormy16.c
index 6e38219..4cd7e62 100644
--- a/bfd/elf32-xstormy16.c
+++ b/bfd/elf32-xstormy16.c
@@ -375,8 +375,8 @@ xstormy16_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 
 /* Set the howto pointer for an XSTORMY16 ELF reloc.  */
 
-static void
-xstormy16_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED,
+static bfd_boolean
+xstormy16_info_to_howto_rela (bfd * abfd,
 			      arelent * cache_ptr,
 			      Elf_Internal_Rela * dst)
 {
@@ -385,11 +385,19 @@ xstormy16_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED,
   if (r_type <= (unsigned int) R_XSTORMY16_12)
     cache_ptr->howto = &xstormy16_elf_howto_table [r_type];
   else if (r_type - R_XSTORMY16_GNU_VTINHERIT
-	   <= (unsigned int) R_XSTORMY16_GNU_VTENTRY)
+	   <= ((unsigned int) R_XSTORMY16_GNU_VTENTRY
+	       - (unsigned int) R_XSTORMY16_GNU_VTINHERIT))
     cache_ptr->howto
       = &xstormy16_elf_howto_table2 [r_type - R_XSTORMY16_GNU_VTINHERIT];
   else
-    abort ();
+    {
+      /* xgettext:c-format */
+      _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+			  abfd, r_type);
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
+    }
+  return TRUE;
 }
 
 /* We support 16-bit pointers to code above 64k by generating a thunk
diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c
index 1d[...]

[diff truncated at 100000 bytes]


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]