Have info_to_howto functions return a success/fail status. Check this result. Stop...
authorNick Clifton <nickc@redhat.com>
Tue, 27 Feb 2018 10:15:13 +0000 (10:15 +0000)
committerNick Clifton <nickc@redhat.com>
Tue, 27 Feb 2018 10:15:13 +0000 (10:15 +0000)
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.

95 files changed:
bfd/ChangeLog
bfd/elf-bfd.h
bfd/elf-hppa.h
bfd/elf-m10200.c
bfd/elf-m10300.c
bfd/elf.c
bfd/elf32-arc.c
bfd/elf32-arm.c
bfd/elf32-avr.c
bfd/elf32-bfin.c
bfd/elf32-cr16.c
bfd/elf32-cr16c.c
bfd/elf32-cris.c
bfd/elf32-crx.c
bfd/elf32-d10v.c
bfd/elf32-d30v.c
bfd/elf32-dlx.c
bfd/elf32-epiphany.c
bfd/elf32-fr30.c
bfd/elf32-frv.c
bfd/elf32-ft32.c
bfd/elf32-gen.c
bfd/elf32-h8300.c
bfd/elf32-i370.c
bfd/elf32-i386.c
bfd/elf32-i860.c
bfd/elf32-i960.c
bfd/elf32-ip2k.c
bfd/elf32-iq2000.c
bfd/elf32-lm32.c
bfd/elf32-m32c.c
bfd/elf32-m32r.c
bfd/elf32-m68hc11.c
bfd/elf32-m68hc12.c
bfd/elf32-m68hc1x.c
bfd/elf32-m68k.c
bfd/elf32-mcore.c
bfd/elf32-mep.c
bfd/elf32-metag.c
bfd/elf32-microblaze.c
bfd/elf32-mips.c
bfd/elf32-moxie.c
bfd/elf32-msp430.c
bfd/elf32-mt.c
bfd/elf32-nds32.c
bfd/elf32-nios2.c
bfd/elf32-or1k.c
bfd/elf32-pj.c
bfd/elf32-ppc.c
bfd/elf32-pru.c
bfd/elf32-rl78.c
bfd/elf32-rx.c
bfd/elf32-s390.c
bfd/elf32-score.c
bfd/elf32-score.h
bfd/elf32-score7.c
bfd/elf32-sh.c
bfd/elf32-spu.c
bfd/elf32-tic6x.c
bfd/elf32-tilepro.c
bfd/elf32-v850.c
bfd/elf32-vax.c
bfd/elf32-visium.c
bfd/elf32-wasm32.c
bfd/elf32-xc16x.c
bfd/elf32-xgate.c
bfd/elf32-xstormy16.c
bfd/elf32-xtensa.c
bfd/elf64-alpha.c
bfd/elf64-gen.c
bfd/elf64-ia64-vms.c
bfd/elf64-mips.c
bfd/elf64-mmix.c
bfd/elf64-ppc.c
bfd/elf64-s390.c
bfd/elf64-sh64.c
bfd/elf64-sparc.c
bfd/elf64-x86-64.c
bfd/elfcode.h
bfd/elfn32-mips.c
bfd/elfnn-aarch64.c
bfd/elfnn-ia64.c
bfd/elfnn-riscv.c
bfd/elfxx-ia64.c
bfd/elfxx-sparc.c
bfd/elfxx-sparc.h
bfd/elfxx-target.h
bfd/elfxx-tilegx.c
bfd/elfxx-tilegx.h
binutils/ChangeLog
binutils/objcopy.c
binutils/testsuite/binutils-all/objcopy.exp
binutils/testsuite/binutils-all/readelf.exp
binutils/testsuite/binutils-all/strip-13.d [new file with mode: 0644]
binutils/testsuite/binutils-all/strip-13.s [new file with mode: 0644]

index 3df1591fb528411c17789df2fbf3680145424abc..42dfaed13552e0dc05bbb177f83187c842d2ead1 100644 (file)
@@ -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>
 
index 1edb31e62ce0159c441622dac1dee81c1f3c4dc8..afd6982a92b07e8895b83e53c64b845669faab93 100644 (file)
@@ -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
index b87ee836ea19336d6687b92bc5ddf739b4f6e0a3..75b4e2694497b4db13f4f7ce36f3fd0229da75ed 100644 (file)
@@ -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
index 82c4ee7338483da4ac3616b8850da8f0fc3204df..cc71c1e3b9f2e158bc17f472ab1fae7c00914f3b 100644 (file)
@@ -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 \
index d5784167038c27eaf6777761dc22efca16cd62a9..f86346e7f1d397cbaef9917e2ff3a9bd86753244 100644 (file)
@@ -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
index 5d39a9881d59d433875c6fc46d8a26a8c6c9998b..8ea5a81cbe36020d4bc2fc8b880ca83282c5349f 100644 (file)
--- 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.  */
index 3bee87d77f0d5a445d78f8bcd2a277a473891074..33fff585e404b6e47178201195782a4516125443 100644 (file)
@@ -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.  */
index 881f2cf783ef50f79d566c4ea5dc68b845e4f44d..ce9c2f29bf82b680fea7281ffb723a1c04bd5d0c 100644 (file)
@@ -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,
index 74934de4af105862323b1d8f3d4c9fc28b488095..7087606c935041836bda6aea226166372e22a717 100644 (file)
@@ -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
index 8f15f9a8b525de9fc94219ef854ff64774e0a0c2..ae8377118028b2e379cc38254c24d17777d66cb7 100644 (file)
@@ -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 \
index 46d9fe2c18e3503bb8c51f484d27502e13f9472d..7756ef5c8aee81f3ebb4c1b27ff4d61e3051db40 100644 (file)
@@ -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 \
index f2793a986833607444324d68bdc5a3896e3cfe90..40ec7599c69a934a56e34319130eea170831e9de 100644 (file)
@@ -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.  */
index f47deb0e7b716fedd6993d1b064132410ccb131e..1c367c44cf9b6c8f50f100033da51286c8f72370 100644 (file)
@@ -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
index 90857c8d056a3a06acd2b21189257e9b2b936f0e..fde3a588f7314e864729568409138be373802ac2 100644 (file)
@@ -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 \
index 8dac777c56227cb423fe077b8d2c54afe8bf9a08..c901595817fa83e4a078e0e0c574b05000fc346b 100644 (file)
@@ -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
index 984b4c4fb582ef4e2b489ee07a68fbac426eece7..7620a737ff0404965b3f22c79ac162b5dc01f629 100644 (file)
@@ -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
index 907eddd7ce78f3b8aa3979370f6e7ab7b76b1776..d82d3eafe77fd1c3ea565e7c52d56bc4ba33e9af 100644 (file)
@@ -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
index 8c24541ef96e3fc4d84d274f98b1456e773c403b..efbd67ba1573adf7039c50e9a5fc32fdd6bb1a01 100644 (file)
@@ -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.
index 6d8a0409a795f68f78283c62c79df1f3097a4bd9..7b0fc88ce7093d529ee7674e3910fea7ba9753e2 100644 (file)
@@ -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;
 }
 \f
 /* Perform a single relocation.  By default we use the standard BFD
index 91815dff275cbe345709a002ff212611840a0b9c..7831aff806bf3b424072052378e01922bb97f646 100644 (file)
@@ -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;
 }
 \f
 /* Perform a single relocation.  By default we use the standard BFD
index 86157d86b9f0dd5ababaf9268d98fa377ffac64f..b981a3431bd836baa57934b97814674c6d93a973 100644 (file)
@@ -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.
index 8f9e33830f9d0819efafa4d402e9df2bcc7ea1cb..1d907a045670fe591c989f9b28978800e9d9b38a 100644 (file)
@@ -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
index 041242499c0ceee628e3a6b04ba66f3ea483465e..a41ae631a8f6492b1cf3bedc921ea9ddd931a922 100644 (file)
@@ -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
index 79ec1592c1f99410942b1310d08fd69a6a1adb31..2c6a30d2abf81e38892e0f4a8e01525fa8a5292b 100644 (file)
@@ -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 ...
index 32b84e6323c043448c8853f8236552f1ac11ef3d..5163e2468f0d047ee5d926d63a41b4a91207ad4e 100644 (file)
@@ -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
index e34965c040d6f34413829449546e4b499aae1996..737e7f5990c9df544dd3f0077d8889372bc9fb0c 100644 (file)
@@ -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;
 }
 \f
 /* Specialized relocation handler for R_860_SPLITn.  These relocations
index dbfb1bb0f8b463499a8079463ff6f5e3f0dfc495..244e4eaf2505c1d7d7c7998132a00749de769855 100644 (file)
@@ -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 *
index aa935243d9ca69db4616352d3a13922489a6da4f..1432f18aaf82185c9eff63de3bb2d58c3c9e3e5a 100644 (file)
@@ -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.
index 14cd1677a31db902e29cbfa348cd7d71ca53168f..d1ce3c8b4cc74c3047edaa800370e58c26b37f1f 100644 (file)
@@ -416,7 +416,7 @@ iq2000_final_link_relocate (reloc_howto_type *      howto,
 \f
 /* 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.
index 0cd67b4947c73fb36056492155675097a72440fc..027830b7b72b6613874da23932c3346409989a2e 100644 (file)
@@ -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
index 6e7e71ccc8a3a5dcb7e0486da15306eede529e67..613844aba8c6e3fb6e6666b6114bdad06693d7eb 100644 (file)
@@ -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;
 }
 
 \f
index 0129c298478f908b0ea1f96b657140707c247514..94a4bc9dffbedefe4ea4d5a16b5737326a8c03fa 100644 (file)
@@ -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;  
 }
 
 \f
index 4c57fe8235477f6a9b6df1023472c7d0b3de738c..95d271f65aa0fce3a0362933971e7414829b3418 100644 (file)
@@ -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;
 }
 
 \f
@@ -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
index d2300c437a6ac333bb46e0435014bfc9a29eb352..0b53674b788212198b97eae6b9a81a5c4a7bd34e 100644 (file)
@@ -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;
 }
 
 \f
@@ -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
index 794663a9e194a1434c1cec75b67d9e586769dda4..35152ee1c7be3f8594769209de9b89526d760995 100644 (file)
@@ -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;
index 2718564ea264f6f09e132bafe6a1bb06eb90ec2c..8680504cee6b2ccaa7ad6e034fba078296643c0b 100644 (file)
@@ -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
index 2e4d5c245fb4d4ac2df967274038f5f46ab658c8..a88acae5c5095afa42e7310a5527d4ea45ac7109 100644 (file)
@@ -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;
 }
 \f
 /* The RELOCATE_SECTION function is called by the ELF backend linker
index e03fe5045e7e29d9289f8eb05b2d2f5403d2e505..5224d9abfa0050393a9db1ed6abf740baa142edf 100644 (file)
@@ -375,10 +375,10 @@ mep_final_link_relocate
 \f
 /* 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;
 }
 \f
 /* Relocate a MEP ELF section.
index c4b2c4848534303606d6a1ef917e472606eb968a..efe95bddff574395427df046b1b61d2c0662f538 100644 (file)
@@ -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 *
index 29fffb4e2c10bac879f66efd030bde5c02fbed0e..3acf93a44fc329cae8a82550d63173fda8aefa47 100644 (file)
@@ -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'.  */
index be462a1a69839335ea65153dda0140e65b8ef410..d6005ff53f751130a8c18339529bb95ac840a095 100644 (file)
@@ -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.  */
index 7a617a81b2b8b3adacab69d115ddbb285d256459..d8b549de248310fe59ddcf9aa7a614550c008d36 100644 (file)
@@ -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;
 }
 \f
 /* Perform a single relocation.  By default we use the standard BFD
index 9f2a3d07b8ec8e4b93381f008eba01d448ea281b..2d351d3906cc5f985d43d9b6766ae2b2ab100b90 100644 (file)
@@ -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.
index efaaf6880b003052c6b812980350b5cf4c3f6d07..94c2fac6963b24c52dbd1c6f072b7394b8d589ed 100644 (file)
@@ -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
index 62e85724383aea9d883e6cd7eba1f0149a43622f..e240d31032272f4457ace3c3a8262d908c28dc6a 100644 (file)
@@ -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.
index 29e1e5aca79f33c148534726ebc2bf4b5715f5b3..e160054fa8943ef75bbc222c81bf9139b6c0282e 100644 (file)
@@ -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
index 3818df9b2ac0a4153cfa32eef73e402e730bc18f..91b780fedf9d94adea9c2db4cafd9d11bc083b7d 100644 (file)
@@ -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;
 }
 
 
index 1c7552375e8c47adfe497c1a7407ed6b020ebb1c..470d20a8b9758836afd227ea0da451610a54a4fe 100644 (file)
@@ -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
index be9549893a0b2faa390d9f83ae372eeb735c799e..66bbf0d869125d07ff3a7ad7a2fece0d9e6689a9 100644 (file)
@@ -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.  */
index 71bb0a006f64d977d2cb2b2f46d8da0d271a51b2..a3c431ba7e8a08882fbce641b6bd39a77d36f438 100644 (file)
@@ -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.  */
index 7cfe31273bd10b447b1d56380098b8915f094e64..e072b1a96efe7c1881b1866ecf277c5b3b21d369 100644 (file)
@@ -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;
 }
 \f
 static bfd_vma
index 42f5fc21fb4ca4233b658d77e084e77951f193a3..1f70b97a34501b6c4864a6221296e835d695ae90 100644 (file)
@@ -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;
 }
 \f
 static bfd_vma
index ce9c25f4dafeb328ecbf8c8b06bcc9e890c92128..d0771042f48ba9c0080f6ca9b71219c87c1320ed 100644 (file)
@@ -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.  */
index 91d92cc6decef4a2665107a1bad062ca8a22de92..42ef221d9c5b44daa33f2611af4f34b8cd23f3e7 100644 (file)
@@ -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
index dc9fd1ea9c9910cc9252e549f68bb4e347fd349b..ed5c9fc1ef7ba785d04ffb4084b4fb95e64acdc3 100644 (file)
@@ -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
index b36c95e57637aa2bd96b0f3953478aef2057301a..3c022e6ebf7ae2c076be92f86a2ba6a0f5ba1b3f 100644 (file)
@@ -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;
index a13d60bded922e22f8ee8d23a0eae3897c65cc85..d0f5ac8f29d2fe9b40dab0363467eeb14c119f47 100644 (file)
@@ -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;
 }
 \f
 /* This function handles relaxing for SH ELF.  See the corresponding
index d682de29c56ca309264d48b95ae9daeb438c2649..c3bfbbdd031f00e0d75f15951560d0dbd4c30957 100644 (file)
@@ -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 *
index 0199c2cbb617d3b474b13124055b916ef7748c3b..96965b3992728a3e8284cbaa250388f778f74481 100644 (file)
@@ -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;
        }
index 24fc64e0f113bb7a42f8308fdb327d1456527cfb..55b19f859a22cf939a4c22d5718e36340cd9a955 100644 (file)
@@ -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);
index fa041e9556b4f97d60f7a2bd2775f296513074a6..430153abc5e5f7f1dcd523692c3c19d2f88e9b67 100644 (file)
@@ -1885,7 +1885,7 @@ v850_elf_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 \f
 /* 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;
 }
 \f
 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;
 }
 \f
 #undef  TARGET_LITTLE_SYM
index 61310b60838efa72e89837655b17ebf8888695b2..023618082b59d18e78d75a2f31d4597cf2311095 100644 (file)
@@ -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
index 9310d421207042177462719333784398a8bf107c..3f8d16aa97c6719ba49d0e235ade1d49e57dd5d0 100644 (file)
@@ -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.
index b9f3cb2c45e14ee8088c5bf221e56c204331d8a3..9fc48de6d6540290807916d7dda0eb390a8642f1 100644 (file)
@@ -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
index 42a3dcaaf125283dd09576376022cd0332f8eea7..66fe33dcb5138b91993d86461235f17bf3151e0a 100644 (file)
@@ -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
index 3e2669c2ce465d4b1112b02edf53e2282422cdfe..a3675260f5059b5a5f67362d4744466bcd1f9d3c 100644 (file)
@@ -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
index 6e38219a091ce883daf970486fcaaabe27b24aa5..4cd7e6273b88f5331dce9846b41331eab7ac1c41 100644 (file)
@@ -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;
 }
 \f
 /* We support 16-bit pointers to code above 64k by generating a thunk
index 1d7a1d81294c050218cff525e67fc83e95b4012f..02effe71adb805643e809f89b28934cab172c5cb 100644 (file)
@@ -450,6 +450,9 @@ elf_xtensa_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
       break;
     }
 
+  /* xgettext:c-format */
+  _bfd_error_handler (_("%pB: invalid relocation type %d"), abfd, (int) code);
+  bfd_set_error (bfd_error_bad_value);
   TRACE ("Unknown");
   return NULL;
 }
@@ -472,7 +475,7 @@ elf_xtensa_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 /* Given an ELF "rela" relocation, find the corresponding howto and record
    it in the BFD internal arelent representation of the relocation.  */
 
-static void
+static bfd_boolean
 elf_xtensa_info_to_howto_rela (bfd *abfd,
                               arelent *cache_ptr,
                               Elf_Internal_Rela *dst)
@@ -484,9 +487,11 @@ elf_xtensa_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_howto_table[r_type];
+  return TRUE;
 }
 
 \f
index e302605bb87846574a051a5282afa4f155a3491c..d59c596adc77c67fb3fb56e30649e484f70ca04f 100644 (file)
@@ -1100,7 +1100,7 @@ elf64_alpha_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 
 /* Given an Alpha ELF reloc type, fill in an arelent structure.  */
 
-static void
+static bfd_boolean
 elf64_alpha_info_to_howto (bfd *abfd, arelent *cache_ptr,
                           Elf_Internal_Rela *dst)
 {
@@ -1112,9 +1112,10 @@ elf64_alpha_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_ALPHA_NONE;
+      return FALSE;
     }
   cache_ptr->howto = &elf64_alpha_howto_table[r_type];
+  return TRUE;
 }
 
 /* These two relocations create a two-word entry in the got.  */
index 2dbc1dd1138be53463bc274e8f6a0b6d09883ec5..fef6277a3a1ad07dc66155e41cb9e794865343b8 100644 (file)
@@ -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
index 07597ba97b53ee3d07acea68e9055a4270a613ef..bc66b17bf639316dcaccf161b6684825b841709f 100644 (file)
@@ -240,13 +240,24 @@ static asection *get_got
 
 /* Given a ELF reloc, return the matching HOWTO structure.  */
 
-static void
+static bfd_boolean
 elf64_ia64_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
                          arelent *bfd_reloc,
                          Elf_Internal_Rela *elf_reloc)
 {
-  bfd_reloc->howto
-    = ia64_elf_lookup_howto ((unsigned int) ELF64_R_TYPE (elf_reloc->r_info));
+  unsigned int r_type = ELF32_R_TYPE (elf_reloc->r_info);
+
+  bfd_reloc->howto = ia64_elf_lookup_howto (r_type);
+  if (bfd_reloc->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;
+    }
+
+  return TRUE;
 }
 
 
@@ -3434,6 +3445,11 @@ elf64_ia64_relocate_section (bfd *output_bfd,
        }
 
       howto = ia64_elf_lookup_howto (r_type);
+      if (howto == NULL)
+       {
+         ret_val = FALSE;
+         continue;
+       }
       r_symndx = ELF64_R_SYM (rel->r_info);
       h = NULL;
       sym = NULL;
index 4e798ad9f79224575a4d7c06d4992b036f6dca47..ea2e921474fd146ea011ebb4a1a8d6013fdce450 100644 (file)
@@ -80,9 +80,7 @@ static void mips_elf64_be_swap_reloca_out
   (bfd *, const Elf_Internal_Rela *, bfd_byte *);
 static reloc_howto_type *bfd_elf64_bfd_reloc_type_lookup
   (bfd *, bfd_reloc_code_real_type);
-static void mips_elf64_info_to_howto_rel
-  (bfd *, arelent *, Elf_Internal_Rela *);
-static void mips_elf64_info_to_howto_rela
+static bfd_boolean mips_elf64_info_to_howto_rela
   (bfd *, arelent *, Elf_Internal_Rela *);
 static long mips_elf64_get_dynamic_reloc_upper_bound
   (bfd *);
@@ -3625,20 +3623,17 @@ mips_elf64_rtype_to_howto (bfd *abfd, unsigned int r_type, bfd_boolean rela_p)
 
 /* Prevent relocation handling by bfd for MIPS ELF64.  */
 
-static void
-mips_elf64_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED,
-                             arelent *cache_ptr ATTRIBUTE_UNUSED,
-                             Elf_Internal_Rela *dst ATTRIBUTE_UNUSED)
-{
-  BFD_ASSERT (0);
-}
-
-static void
-mips_elf64_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED,
+static bfd_boolean
+mips_elf64_info_to_howto_rela (bfd *abfd,
                               arelent *cache_ptr ATTRIBUTE_UNUSED,
-                              Elf_Internal_Rela *dst ATTRIBUTE_UNUSED)
+                              Elf_Internal_Rela *dst)
 {
-  BFD_ASSERT (0);
+  unsigned int r_type = ELF32_R_TYPE (dst->r_info);
+  /* xgettext:c-format */
+  _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+                     abfd, r_type);
+  bfd_set_error (bfd_error_bad_value);
+  return FALSE;
 }
 
 /* Since each entry in an SHT_REL or SHT_RELA section can represent up
@@ -4378,7 +4373,7 @@ const struct elf_size_info mips_elf64_size_info =
 #define elf_backend_gc_mark_extra_sections \
                                        _bfd_mips_elf_gc_mark_extra_sections
 #define elf_info_to_howto              mips_elf64_info_to_howto_rela
-#define elf_info_to_howto_rel          mips_elf64_info_to_howto_rel
+#define elf_info_to_howto_rel          mips_elf64_info_to_howto_rela
 #define elf_backend_object_p           mips_elf64_object_p
 #define elf_backend_symbol_processing  _bfd_mips_elf_symbol_processing
 #define elf_backend_section_processing _bfd_mips_elf_section_processing
index ecef6c9c319f0688e88cae05c20196c68cc3545d..6f56b31e3196f1f6466587196161ca12de9c03e4 100644 (file)
@@ -1250,7 +1250,7 @@ mmix_elf_perform_relocation (asection *isec, reloc_howto_type *howto,
 
 /* Set the howto pointer for an MMIX ELF reloc (type RELA).  */
 
-static void
+static bfd_boolean
 mmix_info_to_howto_rela (bfd *abfd,
                         arelent *cache_ptr,
                         Elf_Internal_Rela *dst)
@@ -1263,9 +1263,11 @@ mmix_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_mmix_howto_table[r_type];
+  return TRUE;
 }
 
 /* Any MMIX-specific relocation gets here at assembly time or when linking
index 0c10a7e93934a62ff89be899c5f3e92274147196..a79a6b637d0369c0205229f29564971aec93552f 100644 (file)
@@ -270,7 +270,8 @@ set_abiversion (bfd *abfd, int ver)
 /* Relocation HOWTO's.  */
 static reloc_howto_type *ppc64_elf_howto_table[(int) R_PPC64_max];
 
-static reloc_howto_type ppc64_elf_howto_raw[] = {
+static reloc_howto_type ppc64_elf_howto_raw[] =
+{
   /* This reloc does nothing.  */
   HOWTO (R_PPC64_NONE,         /* type */
         0,                     /* rightshift */
@@ -2231,7 +2232,7 @@ ppc_howto_init (void)
 }
 
 static reloc_howto_type *
-ppc64_elf_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+ppc64_elf_reloc_type_lookup (bfd *abfd,
                             bfd_reloc_code_real_type code)
 {
   enum elf_ppc64_reloc_type r = R_PPC64_NONE;
@@ -2243,6 +2244,9 @@ ppc64_elf_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
   switch (code)
     {
     default:
+      /* xgettext:c-format */
+      _bfd_error_handler (_("%pB: invalid relocation type %d"), abfd, (int) code);
+      bfd_set_error (bfd_error_bad_value);
       return NULL;
 
     case BFD_RELOC_NONE:                       r = R_PPC64_NONE;
@@ -2495,12 +2499,13 @@ ppc64_elf_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
        && strcasecmp (ppc64_elf_howto_raw[i].name, r_name) == 0)
       return &ppc64_elf_howto_raw[i];
 
+  
   return NULL;
 }
 
 /* Set the howto pointer for a PowerPC ELF reloc.  */
 
-static void
+static bfd_boolean
 ppc64_elf_info_to_howto (bfd *abfd, arelent *cache_ptr,
                         Elf_Internal_Rela *dst)
 {
@@ -2516,9 +2521,20 @@ ppc64_elf_info_to_howto (bfd *abfd, arelent *cache_ptr,
       /* xgettext:c-format */
       _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
                          abfd, type);
-      type = R_PPC64_NONE;
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
     }
   cache_ptr->howto = ppc64_elf_howto_table[type];
+  if (cache_ptr->howto == NULL || cache_ptr->howto->name == NULL)
+    {
+      /* xgettext:c-format */
+      _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+                         abfd, type);
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
+    }
+  
+  return TRUE;
 }
 
 /* Handle the R_PPC64_ADDR16_HA and similar relocs.  */
index aeb1cedf63e76942c0b531782482bdc856dc81b0..5c320a52d6419e5ae7a4cd9505b615d599968f2a 100644 (file)
@@ -189,7 +189,7 @@ static reloc_howto_type elf64_s390_vtentry_howto =
   HOWTO (R_390_GNU_VTENTRY, 0,4,0,FALSE,0,complain_overflow_dont, _bfd_elf_rel_vtable_reloc_fn,"R_390_GNU_VTENTRY", FALSE,0,0, FALSE);
 
 static reloc_howto_type *
-elf_s390_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+elf_s390_reloc_type_lookup (bfd *abfd,
                            bfd_reloc_code_real_type code)
 {
   switch (code)
@@ -323,7 +323,11 @@ elf_s390_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
     default:
       break;
     }
-  return 0;
+
+  /* xgettext:c-format */
+  _bfd_error_handler (_("%pB: invalid relocation type %d"), abfd, (int) code);
+  bfd_set_error (bfd_error_bad_value);
+  return NULL;
 }
 
 static reloc_howto_type *
@@ -350,12 +354,13 @@ elf_s390_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 /* We need to use ELF64_R_TYPE so we have our own copy of this function,
    and elf64-s390.c has its own copy.  */
 
-static void
+static bfd_boolean
 elf_s390_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
                        arelent *cache_ptr,
                        Elf_Internal_Rela *dst)
 {
   unsigned int r_type = ELF64_R_TYPE(dst->r_info);
+
   switch (r_type)
     {
     case R_390_GNU_VTINHERIT:
@@ -372,10 +377,12 @@ 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.  */
index cb0e0fffe6e7e77fba27385daa21321d59427486..d8dca7f2c263b28618f79c9759312c7e6536e5ca 100644 (file)
@@ -1400,7 +1400,7 @@ sh_elf64_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 
    See sh_elf_info_to_howto in elf32-sh.c for the original.  */
 
-static void
+static bfd_boolean
 sh_elf64_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *cache_ptr,
                        Elf_Internal_Rela *dst)
 {
@@ -1408,13 +1408,21 @@ sh_elf64_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *cache_ptr,
 
   r = ELF64_R_TYPE (dst->r_info);
 
-  BFD_ASSERT (r <= (unsigned int) R_SH_64_PCREL);
+  if (r > (unsigned int) R_SH_64_PCREL)
+    {
+      /* xgettext:c-format */
+      _bfd_error_handler (_("%pB: invalid relocation type %d"), abfd, r);
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
+    }
+    
   BFD_ASSERT (r < R_SH_FIRST_INVALID_RELOC || r > R_SH_LAST_INVALID_RELOC);
   BFD_ASSERT (r < R_SH_DIR8WPN || r > R_SH_LAST_INVALID_RELOC_2);
   BFD_ASSERT (r < R_SH_FIRST_INVALID_RELOC_3 || r > R_SH_GOTPLT32);
   BFD_ASSERT (r < R_SH_FIRST_INVALID_RELOC_4 || r > R_SH_LAST_INVALID_RELOC_4);
 
   cache_ptr->howto = &sh_elf64_howto_table[r];
+  return cache_ptr->howto != NULL;
 }
 
 /* Relocate an SH ELF section.
index 8018f6a4ea2ad333c483184ec1c860e451d438ee..b4c04755ce325b3e14bf55aea55a4f5cd80b955e 100644 (file)
@@ -130,7 +130,11 @@ elf64_sparc_slurp_one_reloc_table (bfd *abfd, asection *asect,
          relent->howto = _bfd_sparc_elf_info_to_howto_ptr (abfd, R_SPARC_13);
        }
       else
-       relent->howto = _bfd_sparc_elf_info_to_howto_ptr (abfd, r_type);
+       {
+         relent->howto = _bfd_sparc_elf_info_to_howto_ptr (abfd, r_type);
+         if (relent->howto == NULL)
+           goto error_return;
+       }
     }
 
   canon_reloc_count (asect) += relent - relents;
index c66d286f434b5b1b99bc2e25e0390d5d797d1d95..02a3d37e43c0b9df6bff9973fba3de391d6d42d7 100644 (file)
@@ -284,7 +284,8 @@ elf_x86_64_rtype_to_howto (bfd *abfd, unsigned r_type)
          /* xgettext:c-format */
          _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
                              abfd, r_type);
-         r_type = R_X86_64_NONE;
+         bfd_set_error (bfd_error_bad_value);
+         return NULL;
        }
       i = r_type;
     }
@@ -336,8 +337,8 @@ elf_x86_64_reloc_name_lookup (bfd *abfd,
 
 /* Given an x86_64 ELF reloc type, fill in an arelent structure.  */
 
-static void
-elf_x86_64_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *cache_ptr,
+static bfd_boolean
+elf_x86_64_info_to_howto (bfd *abfd, arelent *cache_ptr,
                          Elf_Internal_Rela *dst)
 {
   unsigned r_type;
@@ -347,8 +348,10 @@ elf_x86_64_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *cache_ptr,
       && r_type != (unsigned int) R_X86_64_GNU_VTENTRY)
     r_type &= ~R_X86_64_converted_reloc_bit;
   cache_ptr->howto = elf_x86_64_rtype_to_howto (abfd, r_type);
-
+  if (cache_ptr->howto == NULL)
+    return FALSE;
   BFD_ASSERT (r_type == cache_ptr->howto->type || cache_ptr->howto->type == R_X86_64_NONE);
+  return TRUE;
 }
 \f
 /* Support for core dump NOTE sections.  */
@@ -1311,6 +1314,9 @@ elf_x86_64_tls_transition (struct bfd_link_info *info, bfd *abfd,
       from = elf_x86_64_rtype_to_howto (abfd, from_type);
       to = elf_x86_64_rtype_to_howto (abfd, to_type);
 
+      if (from == NULL || to == NULL)
+       return FALSE;
+
       if (h)
        name = h->root.root.string;
       else
index 14c8187e3f669655190d9642ed1721caf4312ce4..fb02e255fdec73887101d6541a4c0ea56c59fcdd 100644 (file)
@@ -1430,6 +1430,7 @@ elf_slurp_reloc_table_from_section (bfd *abfd,
        i < reloc_count;
        i++, relent++, native_relocs += entsize)
     {
+      bfd_boolean res;
       Elf_Internal_Rela rela;
 
       if (entsize == sizeof (Elf_External_Rela))
@@ -1456,6 +1457,7 @@ elf_slurp_reloc_table_from_section (bfd *abfd,
            /* xgettext:c-format */
            (_("%pB(%pA): relocation %d has invalid symbol index %ld"),
             abfd, asect, i, (long) ELF_R_SYM (rela.r_info));
+         bfd_set_error (bfd_error_bad_value);
          relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
        }
       else
@@ -1472,14 +1474,16 @@ elf_slurp_reloc_table_from_section (bfd *abfd,
       if ((entsize == sizeof (Elf_External_Rela)
           && ebd->elf_info_to_howto != NULL)
          || ebd->elf_info_to_howto_rel == NULL)
-       (*ebd->elf_info_to_howto) (abfd, relent, &rela);
+       res = ebd->elf_info_to_howto (abfd, relent, &rela);
       else
-       (*ebd->elf_info_to_howto_rel) (abfd, relent, &rela);
+       res = ebd->elf_info_to_howto_rel (abfd, relent, &rela);
+
+      if (! res || relent->howto == NULL)
+       goto error_return;
     }
 
   if (allocated != NULL)
     free (allocated);
-
   return TRUE;
 
  error_return:
index 64246fc24875109f5afea1b64a11bdbd4964e6d7..076bec165d733d0cd4f42ffda3f0f25e84031cb0 100644 (file)
@@ -66,9 +66,9 @@ static bfd_reloc_status_type mips16_gprel_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 *);
@@ -3441,7 +3441,7 @@ mips_elf_n32_rtype_to_howto (bfd *abfd, unsigned int r_type, bfd_boolean rela_p)
          _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;
        }
       if (rela_p)
        return &elf_mips_howto_table_rela[r_type];
@@ -3453,7 +3453,7 @@ mips_elf_n32_rtype_to_howto (bfd *abfd, unsigned int r_type, bfd_boolean rela_p)
 
 /* 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)
 {
   unsigned int r_type;
@@ -3461,6 +3461,9 @@ mips_info_to_howto_rel (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst)
   r_type = ELF32_R_TYPE (dst->r_info);
   cache_ptr->howto = mips_elf_n32_rtype_to_howto (abfd, r_type, FALSE);
 
+  if (cache_ptr->howto == NULL)
+    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
      when we do the relocation, because the symbol manipulations done
@@ -3468,11 +3471,13 @@ 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) || r_type == (unsigned int) R_MIPS_LITERAL))
     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)
 {
@@ -3481,6 +3486,7 @@ mips_info_to_howto_rela (bfd *abfd,
   r_type = ELF32_R_TYPE (dst->r_info);
   cache_ptr->howto = mips_elf_n32_rtype_to_howto (abfd, r_type, TRUE);
   cache_ptr->addend = dst->r_addend;
+  return cache_ptr->howto != NULL;
 }
 \f
 /* Determine whether a symbol is global for the purposes of splitting
index a6d3cce88fcc9db1183a8c05a8168ea2736d60e4..59027ccaf979bb26070b629f3187627cbf8c0f2b 100644 (file)
@@ -2081,7 +2081,7 @@ elfNN_aarch64_howto_from_type (bfd *abfd, unsigned int r_type)
   return NULL;
 }
 
-static void
+static bfd_boolean
 elfNN_aarch64_info_to_howto (bfd *abfd, arelent *bfd_reloc,
                             Elf_Internal_Rela *elf_reloc)
 {
@@ -2089,6 +2089,14 @@ elfNN_aarch64_info_to_howto (bfd *abfd, arelent *bfd_reloc,
 
   r_type = ELFNN_R_TYPE (elf_reloc->r_info);
   bfd_reloc->howto = elfNN_aarch64_howto_from_type (abfd, r_type);
+
+  if (bfd_reloc->howto == NULL)
+    {
+      /* xgettext:c-format */
+      _bfd_error_handler (_("%pB: unsupported relocation type %#x"), abfd, r_type);
+      return FALSE;
+    }
+  return TRUE;
 }
 
 static reloc_howto_type *
index 84b1af1456edf7cd29bc7a33eddd4efad914358c..e6551df204627b4ac1fb8497148b3c1b8d912500 100644 (file)
@@ -197,13 +197,24 @@ static asection *get_pltoff
 
 /* Given a ELF reloc, return the matching HOWTO structure.  */
 
-static void
+static bfd_boolean
 elfNN_ia64_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
                          arelent *bfd_reloc,
                          Elf_Internal_Rela *elf_reloc)
 {
-  bfd_reloc->howto
-    = ia64_elf_lookup_howto ((unsigned int) ELFNN_R_TYPE (elf_reloc->r_info));
+  unsigned int r_type = ELF32_R_TYPE (elf_reloc->r_info);
+
+  bfd_reloc->howto = ia64_elf_lookup_howto (r_type);
+  if (bfd_reloc->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;
+    }
+
+  return TRUE;
 }
 \f
 #define PLT_HEADER_SIZE                (3 * 16)
@@ -3857,6 +3868,12 @@ elfNN_ia64_relocate_section (bfd *output_bfd,
        }
 
       howto = ia64_elf_lookup_howto (r_type);
+      if (howto == NULL)
+       {
+         ret_val = FALSE;
+         continue;
+       }
+      
       r_symndx = ELFNN_R_SYM (rel->r_info);
       h = NULL;
       sym = NULL;
index 6403af91f2f252510614e29f424ae118d7a0ae38..6b2d80c379879a3fc55712c4f8531a81bf7f2d6e 100644 (file)
@@ -121,12 +121,13 @@ struct riscv_elf_link_hash_table
   (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
   == RISCV_ELF_DATA ? ((struct riscv_elf_link_hash_table *) ((p)->hash)) : NULL)
 
-static void
+static bfd_boolean
 riscv_info_to_howto_rela (bfd *abfd,
                          arelent *cache_ptr,
                          Elf_Internal_Rela *dst)
 {
   cache_ptr->howto = riscv_elf_rtype_to_howto (abfd, ELFNN_R_TYPE (dst->r_info));
+  return cache_ptr->howto != NULL;
 }
 
 static void
@@ -467,11 +468,13 @@ riscv_elf_record_got_reference (bfd *abfd, struct bfd_link_info *info,
 static bfd_boolean
 bad_static_reloc (bfd *abfd, unsigned r_type, struct elf_link_hash_entry *h)
 {
+  reloc_howto_type * r = riscv_elf_rtype_to_howto (abfd, r_type);
+
   (*_bfd_error_handler)
     (_("%pB: relocation %s against `%s' can not be used when making a shared "
        "object; recompile with -fPIC"),
-      abfd, riscv_elf_rtype_to_howto (abfd, r_type)->name,
-      h != NULL ? h->root.root.string : "a local symbol");
+     abfd, r ? r->name : _("<unknown>"),
+     h != NULL ? h->root.root.string : "a local symbol");
   bfd_set_error (bfd_error_bad_value);
   return FALSE;
 }
@@ -624,9 +627,11 @@ riscv_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
             may need to keep relocations for symbols satisfied by a
             dynamic library if we manage to avoid copy relocs for the
             symbol.  */
+         reloc_howto_type * r = riscv_elf_rtype_to_howto (abfd, r_type);
+
          if ((bfd_link_pic (info)
               && (sec->flags & SEC_ALLOC) != 0
-              && (! riscv_elf_rtype_to_howto (abfd, r_type)->pc_relative
+              && ((r != NULL && ! r->pc_relative)
                   || (h != NULL
                       && (! info->symbolic
                           || h->root.type == bfd_link_hash_defweak
@@ -696,7 +701,7 @@ riscv_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
                }
 
              p->count += 1;
-             p->pc_count += riscv_elf_rtype_to_howto (abfd, r_type)->pc_relative;
+             p->pc_count += r == NULL ? 0 : r->pc_relative;
            }
 
          break;
@@ -1727,7 +1732,8 @@ riscv_elf_relocate_section (bfd *output_bfd,
       reloc_howto_type *howto = riscv_elf_rtype_to_howto (input_bfd, r_type);
       const char *msg = NULL;
 
-      if (r_type == R_RISCV_GNU_VTINHERIT || r_type == R_RISCV_GNU_VTENTRY)
+      if (howto == NULL
+         || r_type == R_RISCV_GNU_VTINHERIT || r_type == R_RISCV_GNU_VTENTRY)
        continue;
 
       /* This is a final link.  */
@@ -1889,8 +1895,10 @@ riscv_elf_relocate_section (bfd *output_bfd,
                                                input_bfd);
          r_type = ELFNN_R_TYPE (rel->r_info);
          howto = riscv_elf_rtype_to_howto (input_bfd, r_type);
-         if (!riscv_record_pcrel_hi_reloc (&pcrel_relocs, pc,
-                                           relocation, absolute))
+         if (howto == NULL)
+           r = bfd_reloc_notsupported;
+         else if (!riscv_record_pcrel_hi_reloc (&pcrel_relocs, pc,
+                                                relocation, absolute))
            r = bfd_reloc_overflow;
          break;
 
@@ -1985,9 +1993,11 @@ riscv_elf_relocate_section (bfd *output_bfd,
                                                input_bfd);
          r_type = ELFNN_R_TYPE (rel->r_info);
          howto = riscv_elf_rtype_to_howto (input_bfd, r_type);
-         if (!riscv_record_pcrel_hi_reloc (&pcrel_relocs, pc,
-                                           relocation + rel->r_addend,
-                                           absolute))
+         if (howto == NULL)
+           r = bfd_reloc_notsupported;
+         else if (!riscv_record_pcrel_hi_reloc (&pcrel_relocs, pc,
+                                                relocation + rel->r_addend,
+                                                absolute))
            r = bfd_reloc_overflow;
          break;
 
index 97b67e693120b951c3e0fb38977d16e0101a6e4a..8f532722da24cab2eb48b884d7641688d2118e37 100644 (file)
@@ -196,12 +196,12 @@ static unsigned char elf_code_to_howto_index[R_IA64_MAX_RELOC_CODE + 1];
 reloc_howto_type *
 ia64_elf_lookup_howto (unsigned int rtype)
 {
-  static int inited = 0;
+  static bfd_boolean inited = FALSE;
   int i;
 
   if (!inited)
     {
-      inited = 1;
+      inited = TRUE;
 
       memset (elf_code_to_howto_index, 0xff, sizeof (elf_code_to_howto_index));
       for (i = 0; i < NELEMS (ia64_howto_table); ++i)
@@ -209,15 +209,15 @@ ia64_elf_lookup_howto (unsigned int rtype)
     }
 
   if (rtype > R_IA64_MAX_RELOC_CODE)
-    return 0;
+    return NULL;
   i = elf_code_to_howto_index[rtype];
   if (i >= NELEMS (ia64_howto_table))
-    return 0;
+    return NULL;
   return ia64_howto_table + i;
 }
 
-reloc_howto_type*
-ia64_elf_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+reloc_howto_type *
+ia64_elf_reloc_type_lookup (bfd *abfd,
                            bfd_reloc_code_real_type bfd_code)
 {
   unsigned int rtype;
@@ -320,7 +320,12 @@ ia64_elf_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
     case BFD_RELOC_IA64_DTPREL64LSB:   rtype = R_IA64_DTPREL64LSB; break;
     case BFD_RELOC_IA64_LTOFF_DTPREL22:        rtype = R_IA64_LTOFF_DTPREL22; break;
 
-    default: return 0;
+    default:
+      /* xgettext:c-format */
+      _bfd_error_handler (_("%pB: invalid BFD relocation type %d"),
+                         abfd, (int) bfd_code);
+      bfd_set_error (bfd_error_bad_value);
+      return NULL;
     }
   return ia64_elf_lookup_howto (rtype);
 }
index c75d053dbf7721a9e94fc0395b410fdcc8de45b4..4108aa619a80d6a5b4ba09e69642fa71ee9ee215 100644 (file)
@@ -311,7 +311,7 @@ static reloc_howto_type sparc_rev32_howto =
   HOWTO(R_SPARC_REV32, 0,2,32,FALSE,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_REV32", FALSE,0,0xffffffff,TRUE);
 
 reloc_howto_type *
-_bfd_sparc_elf_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+_bfd_sparc_elf_reloc_type_lookup (bfd *abfd,
                                  bfd_reloc_code_real_type code)
 {
   /* We explicitly handle each relocation type in the switch
@@ -585,8 +585,10 @@ _bfd_sparc_elf_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
     default:
       break;
     }
-    bfd_set_error (bfd_error_bad_value);
-    return NULL;
+  /* xgettext:c-format */
+  _bfd_error_handler (_("%pB: invalid BFD relocation type %d"), abfd, (int) code);
+  bfd_set_error (bfd_error_bad_value);
+  return NULL;
 }
 
 reloc_howto_type *
@@ -595,10 +597,7 @@ _bfd_sparc_elf_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 {
   unsigned int i;
 
-  for (i = 0;
-       i < (sizeof (_bfd_sparc_elf_howto_table)
-           / sizeof (_bfd_sparc_elf_howto_table[0]));
-       i++)
+  for (i = 0; i < ARRAY_SIZE (_bfd_sparc_elf_howto_table); i++)
     if (_bfd_sparc_elf_howto_table[i].name != NULL
        && strcasecmp (_bfd_sparc_elf_howto_table[i].name, r_name) == 0)
       return &_bfd_sparc_elf_howto_table[i];
@@ -614,7 +613,8 @@ _bfd_sparc_elf_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 }
 
 reloc_howto_type *
-_bfd_sparc_elf_info_to_howto_ptr (bfd *abfd, unsigned int r_type)
+_bfd_sparc_elf_info_to_howto_ptr (bfd *abfd ATTRIBUTE_UNUSED,
+                                 unsigned int r_type)
 {
   switch (r_type)
     {
@@ -638,7 +638,8 @@ _bfd_sparc_elf_info_to_howto_ptr (bfd *abfd, unsigned int r_type)
        {
          _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
                              abfd, r_type);
-         r_type = R_SPARC_NONE;
+         bfd_set_error (bfd_error_bad_value);
+         return NULL;
        }
       return &_bfd_sparc_elf_howto_table[r_type];
     }
@@ -649,13 +650,20 @@ _bfd_sparc_elf_info_to_howto_ptr (bfd *abfd, unsigned int r_type)
 #define SPARC_ELF_R_TYPE(r_info)       \
        ((r_info) & 0xff)
 
-void
+bfd_boolean
 _bfd_sparc_elf_info_to_howto (bfd *abfd, arelent *cache_ptr,
                              Elf_Internal_Rela *dst)
 {
   unsigned int r_type = SPARC_ELF_R_TYPE (dst->r_info);
 
-  cache_ptr->howto = _bfd_sparc_elf_info_to_howto_ptr (abfd, r_type);
+  if ((cache_ptr->howto = _bfd_sparc_elf_info_to_howto_ptr (abfd, r_type)) == NULL)
+    {
+      _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+                         abfd, r_type);
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
+    }
+  return TRUE;
 }
 \f
 
index f465ca7e646863ea05deb2ba1d68e3d8d36553df..524b39eeb1a2e2cd851ca2c40f900217f867db63 100644 (file)
@@ -97,7 +97,7 @@ extern reloc_howto_type *_bfd_sparc_elf_reloc_type_lookup
   (bfd *, bfd_reloc_code_real_type);
 extern reloc_howto_type *_bfd_sparc_elf_reloc_name_lookup
   (bfd *, const char *);
-extern void _bfd_sparc_elf_info_to_howto
+extern bfd_boolean _bfd_sparc_elf_info_to_howto
   (bfd *, arelent *, Elf_Internal_Rela *);
 extern reloc_howto_type *_bfd_sparc_elf_info_to_howto_ptr
   (bfd*, unsigned int);
index 9593e3478a326a41aa6a9036998f4316105f05f4..ccab02d39d7ea6a23600d33ee205ee79c0779dde 100644 (file)
 #endif
 
 #ifndef elf_info_to_howto
-#define elf_info_to_howto 0
+#define elf_info_to_howto NULL
 #endif
 
 #ifndef elf_info_to_howto_rel
-#define elf_info_to_howto_rel 0
+#define elf_info_to_howto_rel NULL
 #endif
 
 #ifndef elf_backend_arch_data
index 43d8121de98c21dbcd376a76761fa281716fd447..2b7bf58b6bad8e62be1822d067e163cd212dbc6a 100644 (file)
@@ -892,7 +892,7 @@ tilegx_put_word_32 (bfd *abfd, bfd_vma val, void *ptr)
 }
 
 reloc_howto_type *
-tilegx_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
+tilegx_reloc_type_lookup (bfd * abfd,
                          bfd_reloc_code_real_type code)
 {
   unsigned int i;
@@ -908,6 +908,10 @@ tilegx_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
                               - entry->table[0].type);
     }
 
+  /* xgettext:c-format */
+  _bfd_error_handler (_("%pB: invalid BFD relocation type %d"),
+                     abfd, (int) code);
+  bfd_set_error (bfd_error_bad_value);
   return NULL;
 }
 
@@ -928,7 +932,7 @@ tilegx_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
   return NULL;
 }
 
-void
+bfd_boolean
 tilegx_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED,
                           arelent *cache_ptr,
                           Elf_Internal_Rela *dst)
@@ -938,11 +942,19 @@ tilegx_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED,
   if (r_type <= (unsigned int) R_TILEGX_IMM8_Y1_TLS_ADD)
     cache_ptr->howto = &tilegx_elf_howto_table [r_type];
   else if (r_type - R_TILEGX_GNU_VTINHERIT
-          <= (unsigned int) R_TILEGX_GNU_VTENTRY)
+          <= ((unsigned int) R_TILEGX_GNU_VTENTRY
+              - (unsigned int) R_TILEGX_GNU_VTINHERIT))
     cache_ptr->howto
       = &tilegx_elf_howto_table2 [r_type - R_TILEGX_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 tilegx_bundle_bits (*tilegx_create_func)(int);
index 2233116bf55f7d68ca787849497c2aad64840c15..a5afc549d8e83bfe275746e79c784e5e70db10e6 100644 (file)
@@ -76,7 +76,7 @@ tilegx_elf_gc_mark_hook (asection *,
 extern bfd_vma
 tilegx_elf_plt_sym_val (bfd_vma, const asection *, const arelent *);
 
-extern void
+extern bfd_boolean
 tilegx_info_to_howto_rela (bfd *, arelent *, Elf_Internal_Rela *);
 
 extern int
index a1a5e7c67350879f6c65f9f9b4b53f304221312d..b7800e16cca1fd4432f154865b6c2679fa226c00 100644 (file)
@@ -1,3 +1,12 @@
+2018-02-27  Nick Clifton  <nickc@redhat.com>
+
+       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.
+
 2018-02-26  Alan Modra  <amodra@gmail.com>
 
        * testsuite/binutils-all/mips/mips-reginfo-n32.d,
index 8cdf27a87ee37642d38b11dc17a0082232bc4649..d0a152c0f6173f2c442c8e9454a3edd5e30816cf 100644 (file)
@@ -3023,9 +3023,18 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch)
         ignore input sections which have no corresponding output
         section.  */
       if (strip_symbols != STRIP_ALL)
-       bfd_map_over_sections (ibfd,
-                              mark_symbols_used_in_relocations,
-                              isympp);
+       {
+         bfd_set_error (bfd_error_no_error);
+         bfd_map_over_sections (ibfd,
+                                mark_symbols_used_in_relocations,
+                                isympp);
+         if (bfd_get_error () != bfd_error_no_error)
+           {
+             status = 1;
+             return FALSE;
+           }
+       }
+
       osympp = (asymbol **) xmalloc ((symcount + add_symbols + 1) * sizeof (asymbol *));
       symcount = filter_symbols (ibfd, obfd, osympp, isympp, symcount);
     }
index f4a7692cdf36bafc1f52e961f71add1eb5c94a61..f7b811c9c037725471ba55a4151df8ea42d74e3a 100644 (file)
@@ -1084,6 +1084,8 @@ if [is_elf_format] {
     run_dump_test "strip-8"
     run_dump_test "strip-9"
     run_dump_test "strip-12"
+    run_dump_test "strip-13"
+
     # This requires STB_GNU_UNIQUE support with OSABI set to GNU.
     if { [supports_gnu_unique] } {
        run_dump_test "strip-10"
index 6fc5070c70b2f913183029ba91c8f15580d3e0ff..45a022a8b674550c078b97e7749828a53591bd44 100644 (file)
@@ -324,6 +324,8 @@ if {![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o]} then {
     unresolved "readelf -S bintest (failed to assemble)"
     unresolved "readelf -s bintest (failed to assemble)"
     unresolved "readelf -r bintest (failed to assemble)"
+    global readelf_size
+    set readelf_size ""
 } else {
 
     if ![is_remote host] {
diff --git a/binutils/testsuite/binutils-all/strip-13.d b/binutils/testsuite/binutils-all/strip-13.d
new file mode 100644 (file)
index 0000000..a34e1eb
--- /dev/null
@@ -0,0 +1,9 @@
+#PROG: strip
+#strip: -g
+#error: .* bad value
+#not-target: arm-* d10v-* dlx-* h8300-* hppa*-* ip2k-* rx-* xgate-*
+# The D10V, DLX and XGATE targets only support REL relocations but this test uses RELA relocations.
+# The ARM target does support both types, but defaults to REL.
+# The HPPA targets use reloc 241, which is the value this test uses as its "unknown" reloc.
+# The H8300-*, IP2K and RX targets do not complain about unrecognised relocs, unless they are actually used
+#  (which is what should really happen with the other targets...)
diff --git a/binutils/testsuite/binutils-all/strip-13.s b/binutils/testsuite/binutils-all/strip-13.s
new file mode 100644 (file)
index 0000000..5da2426
--- /dev/null
@@ -0,0 +1,12 @@
+       .text
+foo:
+       .dc.l    0x12345678
+
+       .section .rela.text
+       .dc.a    0
+       .dc.a    0x000000f1
+       .dc.a    0x000000f1
+
+       .dc.a    0
+       .dc.a    0
+       .dc.a    0
This page took 0.109001 seconds and 4 git commands to generate.