+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>
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
(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
/* 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
/* 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. */
#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 \
/* 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)
_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
#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
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. */
/* 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. */
? 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
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
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. */
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,
/* 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)
/* 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
};
-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)
{
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. */
#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 \
/* 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)
{
_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.
#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 \
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)
/* 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. */
/* 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)
/* 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
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);
/* 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)
{
_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. */
#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 \
/* 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)
/* 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 *
#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
/* 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)
/* 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)
/* 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
{
_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)
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
/* 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)
/* 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.
/* 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)
/* 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
/* 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)
/* 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)
{
default:
cache_ptr->howto = NULL;
- break;
+ return FALSE;
}
+ return TRUE;
}
\f
/* Perform a single relocation. By default we use the standard BFD
/* 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.
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
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);
return NULL;
}
-static void
+static bfd_boolean
elf32_h8_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *bfd_reloc,
Elf_Internal_Rela *elf_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.
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);
{
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. */
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
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
/* 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)
_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 ...
#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)
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 *
}
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;
>= 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
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;
}
rtype = R_860_HIGOTOFF;
break;
default:
- rtype = 0;
- break;
+ return NULL;
}
return lookup_howto (rtype);
}
}
/* 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
#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
}
}
-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)
/* 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 *
/* 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)
/* 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.
\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)
/* 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.
/* 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)
/* 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. */
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)
#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
/* 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 **);
/* 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;
/* 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
/* 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)
/* 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
/* 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. */
/* 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)
{
/* 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
#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
/* 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. */
/* 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)
{
/* 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
#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
|| 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;
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);
/* 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
/* 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)
_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
\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;
/* 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.
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)
/* 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 *
/* 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)
_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'. */
(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 *);
_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];
}
/* 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;
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
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. */
/* 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)
/* 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
/* 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)
/* 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.
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
/* 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;
/* 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
/* 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;
/* 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.
#include "elf/nios2.h"
#include "opcode/nios2.h"
#include "elf32-nios2.h"
+#include "libiberty.h"
/* Use RELA relocations. */
#ifndef USE_RELA
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)
{
}
}
- 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;
}
}
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},
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;
/* 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)
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
/* 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)
/* 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;
}
/* 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)
_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
/* 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)
_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. */
#include "elf-bfd.h"
#include "elf/pru.h"
#include "opcode/pru.h"
+#include "libiberty.h"
#define SWAP_VALS(A,B) \
do { \
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},
/* 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)
/* 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;
/* 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];
/* 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. */
/* 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)
{
/* 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
/* 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;
/* 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
/* 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:
/* 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. */
}
/* 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)
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. */
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;
/*****************************************************************************/
/* 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)
#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
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
/* Score backend functions. */
-void
+bfd_boolean
s7_bfd_score_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
arelent *bfd_reloc,
Elf_Internal_Rela *elf_reloc)
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. */
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;
/* 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;
_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
}
}
-static void
+static bfd_boolean
spu_elf_info_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_SPU_NONE;
+ return FALSE;
}
cache_ptr->howto = &elf_howto_table[(int) r_type];
+ return TRUE;
}
static reloc_howto_type *
return NULL;
}
-static void
+static bfd_boolean
elf32_tic6x_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *bfd_reloc,
Elf_Internal_Rela *elf_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)
{
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
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);
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;
/* 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;
}
/* 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)
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);
\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)
/* 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;
/* 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
/* 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
#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 *);
FALSE), /* pcrel_offset */
};
-static void
+static bfd_boolean
rtype_to_howto (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst)
{
unsigned int r_type;
_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
/* 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)
{
/* 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.
/* 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
{
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];
/* 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;
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
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 *);
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;
}
/* 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)
/* 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. */
#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
/* 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)
{
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
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;
}
/* 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)
/* 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
/* 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)
{
_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. */
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
/* 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;
}
}
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;
(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 *);
/* 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
#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
/* 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)
/* 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
/* 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 */
}
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;
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;
&& 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)
{
/* 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. */
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)
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 *
/* 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:
/* 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. */
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)
{
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.
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;
/* 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;
}
/* 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;
&& 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. */
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
i < reloc_count;
i++, relent++, native_relocs += entsize)
{
+ bfd_boolean res;
Elf_Internal_Rela rela;
if (entsize == sizeof (Elf_External_Rela))
/* 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
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:
(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 *);
_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];
/* 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;
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
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)
{
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
return NULL;
}
-static void
+static bfd_boolean
elfNN_aarch64_info_to_howto (bfd *abfd, arelent *bfd_reloc,
Elf_Internal_Rela *elf_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 *
/* 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)
}
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;
(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
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;
}
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
}
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;
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. */
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;
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;
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)
}
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;
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);
}
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
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 *
{
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];
}
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)
{
{
_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];
}
#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
(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);
#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
}
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;
- 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;
}
return NULL;
}
-void
+bfd_boolean
tilegx_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED,
arelent *cache_ptr,
Elf_Internal_Rela *dst)
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);
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
+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,
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);
}
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"
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] {
--- /dev/null
+#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...)
--- /dev/null
+ .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