This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: ARC port broken reloc processing
- From: Alan Modra <amodra at gmail dot com>
- To: Cupertino Miranda <Cupertino dot Miranda at synopsys dot com>
- Cc: Andrew Burgess <andrew dot burgess at embecosm dot com>, "binutils at sourceware dot org" <binutils at sourceware dot org>, Claudiu Zissulescu <Claudiu dot Zissulescu at synopsys dot com>
- Date: Tue, 1 Dec 2015 13:41:31 +1030
- Subject: Re: ARC port broken reloc processing
- Authentication-results: sourceware.org; auth=none
- References: <1448580380-2724-1-git-send-email-andrew dot burgess at embecosm dot com> <20151127024411 dot GA8901 at bubble dot grove dot modra dot org> <20151127033938 dot GB8901 at bubble dot grove dot modra dot org> <20151128211826 dot GA4625 at embecosm dot com> <20151130021307 dot GE8901 at bubble dot grove dot modra dot org> <EB86EB452ADE4B44B294F7149B8A2777021853F2 at DE02WEMBXB dot internal dot synopsys dot com> <20151201010445 dot GI8901 at bubble dot grove dot modra dot org>
On Tue, Dec 01, 2015 at 11:34:45AM +1030, Alan Modra wrote:
> On Mon, Nov 30, 2015 at 11:57:32AM +0000, Cupertino Miranda wrote:
> > I believe in this way we set the mask to a correct value for all the relocation types, without possibly introducing inconsistencies (repetitions) in the reloc definition.
> > Nevertheless, the generic relocation patching cannot be used to fix relocations, as FORMULA would not be applied.
>
> Applied. Your patch will fix the relocs used in debug sections, but
Except it didn't fix the testcase, due to nothing calling
arc_elf_howto_init. Next time, please test patches before posting.
* 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.
diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c
index c02db9d..bc63991 100644
--- a/bfd/elf32-arc.c
+++ b/bfd/elf32-arc.c
@@ -246,8 +246,13 @@ const int howto_table_lookup[] =
};
#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. */
@@ -275,18 +280,11 @@ bfd_elf32_bfd_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
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;
@@ -300,7 +298,7 @@ bfd_elf32_bfd_reloc_name_lookup (bfd * abfd ATTRIBUTE_UNUSED, const char *r_name
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;
}
@@ -316,7 +314,7 @@ arc_info_to_howto_rel (bfd * abfd ATTRIBUTE_UNUSED,
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. */
@@ -743,7 +741,7 @@ elf_arc_relocate_section (bfd * output_bfd,
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;
@@ -960,7 +958,7 @@ elf_arc_check_relocs (bfd * abfd,
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);
--
Alan Modra
Australia Development Lab, IBM