+2015-12-01 Alan Modra <amodra@gmail.com>
+
+ * elf32-arc.c (ARC_ELF_HOWTO): Delete.
+ (arc_elf_howto): New function.
+ (bfd_elf32_bfd_reloc_type_lookup): Use it in place of existing
+ init code.
+ (bfd_elf32_bfd_reloc_name_lookup): Use arc_elf_howto.
+ (arc_info_to_howto_rel, elf_arc_relocate_section): Likwise.
+ (elf_arc_check_relocs): Likewise.
+
2015-12-01 Cupertino Miranda <cupertino.miranda@synopsys.com>
* elf32-arc.c (arc_elf_howto_init): Init dst_mask.
};
#undef ARC_RELOC_HOWTO
-#define ARC_ELF_HOWTO(r_type) \
- (&elf_arc_howto_table[r_type])
+static reloc_howto_type *
+arc_elf_howto (unsigned int r_type)
+{
+ if (elf_arc_howto_table[R_ARC_32].dst_mask == 0)
+ arc_elf_howto_init ();
+ return &elf_arc_howto_table[r_type];
+}
/* Map BFD reloc types to ARC ELF reloc types. */
bfd_reloc_code_real_type code)
{
unsigned int i;
- static int fully_initialized = FALSE;
-
- if (fully_initialized == FALSE)
- {
- arc_elf_howto_init ();
- fully_initialized = TRUE; /* TODO: CHECK THIS IF IT STOPS WORKING. */
- }
for (i = ARRAY_SIZE (arc_reloc_map); i--;)
{
if (arc_reloc_map[i].bfd_reloc_val == code)
- return elf_arc_howto_table + arc_reloc_map[i].elf_reloc_val;
+ return arc_elf_howto (arc_reloc_map[i].elf_reloc_val);
}
return NULL;
for (i = 0; i < ARRAY_SIZE (elf_arc_howto_table); i++)
if (elf_arc_howto_table[i].name != NULL
&& strcasecmp (elf_arc_howto_table[i].name, r_name) == 0)
- return elf_arc_howto_table + i;
+ return arc_elf_howto (i);
return NULL;
}
r_type = ELF32_R_TYPE (dst->r_info);
BFD_ASSERT (r_type < (unsigned int) R_ARC_max);
- cache_ptr->howto = &elf_arc_howto_table[r_type];
+ cache_ptr->howto = arc_elf_howto (r_type);
}
/* Set the right machine number for an ARC ELF file. */
bfd_set_error (bfd_error_bad_value);
return FALSE;
}
- howto = &elf_arc_howto_table[r_type];
+ howto = arc_elf_howto (r_type);
reloc_data.input_section = input_section;
reloc_data.howto = howto;
bfd_set_error (bfd_error_bad_value);
return FALSE;
}
- howto = &elf_arc_howto_table[r_type];
+ howto = arc_elf_howto (r_type);
/* Load symbol information. */
r_symndx = ELF32_R_SYM (rel->r_info);