+2018-04-04 Maciej W. Rozycki <macro@mips.com>
+
+ * elf32-i860.c (lookup_howto): Add `abfd' parameter. Set the
+ `bfd_error_bad_value' error and call `_bfd_error_handler' on a
+ howto lookup failure.
+ (elf32_i860_reloc_type_lookup): Adjust `lookup_howto' call
+ accordingly.
+ (elf32_i860_info_to_howto_rela): Likewise.
+ (elf32_i860_relocate_splitn): Likewise.
+ (elf32_i860_relocate_pc16): Likewise.
+ (elf32_i860_relocate_pc26): Likewise.
+ (elf32_i860_relocate_section): Likewise.
+
2018-04-04 Maciej W. Rozycki <macro@mips.com>
* elf32-visium.c (visium_info_to_howto_rela): Correct the range
static unsigned char elf_code_to_howto_index[R_860_max + 1];
static reloc_howto_type *
-lookup_howto (unsigned int rtype)
+lookup_howto (bfd *abfd, unsigned int rtype)
{
static int initialized = 0;
int i;
int howto_tbl_size = (int) (sizeof (elf32_i860_howto_table)
/ sizeof (elf32_i860_howto_table[0]));
+ reloc_howto_type *howto = NULL;
if (! initialized)
{
elf_code_to_howto_index[elf32_i860_howto_table[i].type] = i;
}
- if (rtype > R_860_max)
- return NULL;
- i = elf_code_to_howto_index[rtype];
- if (i >= howto_tbl_size)
- return NULL;
- return elf32_i860_howto_table + i;
+ if (rtype < R_860_max)
+ {
+ i = elf_code_to_howto_index[rtype];
+ if (i < howto_tbl_size)
+ howto = elf32_i860_howto_table + i;
+ }
+ if (howto == NULL)
+ {
+ _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+ abfd, rtype);
+ bfd_set_error (bfd_error_bad_value);
+ }
+ return howto;
}
/* Given a BFD reloc, return the matching HOWTO structure. */
static reloc_howto_type *
-elf32_i860_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
- bfd_reloc_code_real_type code)
+elf32_i860_reloc_type_lookup (bfd *abfd, bfd_reloc_code_real_type code)
{
unsigned int rtype;
default:
return NULL;
}
- return lookup_howto (rtype);
+ return lookup_howto (abfd, rtype);
}
static reloc_howto_type *
/* Given a ELF reloc, return the matching HOWTO structure. */
static bfd_boolean
-elf32_i860_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED,
+elf32_i860_info_to_howto_rela (bfd *abfd,
arelent *bfd_reloc,
Elf_Internal_Rela *elf_reloc)
{
bfd_reloc->howto
- = lookup_howto ((unsigned) ELF32_R_TYPE (elf_reloc->r_info));
+ = lookup_howto (abfd, (unsigned) ELF32_R_TYPE (elf_reloc->r_info));
return bfd_reloc->howto != NULL;
}
\f
{
bfd_vma insn;
reloc_howto_type *howto;
- howto = lookup_howto ((unsigned) ELF32_R_TYPE (rello->r_info));
+ howto = lookup_howto (input_bfd, (unsigned) ELF32_R_TYPE (rello->r_info));
insn = bfd_get_32 (input_bfd, contents + rello->r_offset);
/* Relocate. */
{
bfd_vma insn;
reloc_howto_type *howto;
- howto = lookup_howto ((unsigned) ELF32_R_TYPE (rello->r_info));
+ howto = lookup_howto (input_bfd, (unsigned) ELF32_R_TYPE (rello->r_info));
insn = bfd_get_32 (input_bfd, contents + rello->r_offset);
/* Adjust for PC-relative relocation. */
{
bfd_vma insn;
reloc_howto_type *howto;
- howto = lookup_howto ((unsigned) ELF32_R_TYPE (rello->r_info));
+ howto = lookup_howto (input_bfd, (unsigned) ELF32_R_TYPE (rello->r_info));
insn = bfd_get_32 (input_bfd, contents + rello->r_offset);
/* Adjust for PC-relative relocation. */
r_type = ELF32_R_TYPE (rel->r_info);
r_symndx = ELF32_R_SYM (rel->r_info);
- howto = lookup_howto ((unsigned) ELF32_R_TYPE (rel->r_info));
+ howto = lookup_howto (input_bfd, (unsigned) ELF32_R_TYPE (rel->r_info));
h = NULL;
sym = NULL;
sec = NULL;