diff options
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 12 | ||||
-rw-r--r-- | bfd/bfd-in2.h | 1 | ||||
-rw-r--r-- | bfd/elf32-arc.c | 93 | ||||
-rw-r--r-- | bfd/libbfd.h | 1 | ||||
-rw-r--r-- | bfd/reloc.c | 2 |
5 files changed, 90 insertions, 19 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 3d04690..eb702c2 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,17 @@ 2016-04-14 Andrew Burgess <andrew.burgess@embecosm.com> + * reloc.c: Add BFD_RELOC_ARC_NPS_CMEM16 entry. + * bfd-in2.h: Regenerate. + * libbfd.h: Regenerate. + * elf32-arc.c: Add 'opcode/arc.h' include. + (struct arc_relocation_data): Add symbol_name. + (arc_special_overflow_checks): New function. + (arc_do_relocation): Use arc_special_overflow_checks, reindent as + required, add an extra comment. + (elf_arc_relocate_section): Setup symbol_name in reloc_data. + +2016-04-14 Andrew Burgess <andrew.burgess@embecosm.com> + * elf32-arc.c (tls_got_entries): Add 'TLS_GOT_' prefix to all entries. (elf_arc_relocate_section): Update enum uses. diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index f02e2aa..6532f6e 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -3721,6 +3721,7 @@ pc-relative or some form of GOT-indirect relocation. */ BFD_RELOC_ARC_TLS_LE_32, BFD_RELOC_ARC_S25W_PCREL_PLT, BFD_RELOC_ARC_S21H_PCREL_PLT, + BFD_RELOC_ARC_NPS_CMEM16, /* ADI Blackfin 16 bit immediate absolute reloc. */ BFD_RELOC_BFIN_16_IMM, diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c index d67e88c..2df91b1 100644 --- a/bfd/elf32-arc.c +++ b/bfd/elf32-arc.c @@ -26,6 +26,7 @@ #include "elf/arc.h" #include "libiberty.h" #include "opcode/arc-func.h" +#include "opcode/arc.h" #include "arc-plt.h" #ifdef DEBUG @@ -722,6 +723,8 @@ struct arc_relocation_data bfd_signed_vma got_symbol_vma; bfd_boolean should_relocate; + + const char * symbol_name; }; static void @@ -788,6 +791,52 @@ middle_endian_convert (bfd_vma insn, bfd_boolean do_it) return insn; } +/* This function is called for relocations that are otherwise marked as NOT + requiring overflow checks. In here we perform non-standard checks of + the relocation value. */ + +static inline bfd_reloc_status_type +arc_special_overflow_checks (const struct arc_relocation_data reloc_data, + bfd_signed_vma relocation, + struct bfd_link_info *info ATTRIBUTE_UNUSED) +{ + switch (reloc_data.howto->type) + { + case R_ARC_NPS_CMEM16: + if (((relocation >> 16) & 0xffff) != NPS_CMEM_HIGH_VALUE) + { + if (reloc_data.reloc_addend == 0) + (*_bfd_error_handler) + (_("%B(%A+0x%lx): CMEM relocation to `%s' is invalid, " + "16 MSB should be 0x%04x (value is 0x%lx)"), + reloc_data.input_section->owner, + reloc_data.input_section, + reloc_data.reloc_offset, + reloc_data.symbol_name, + NPS_CMEM_HIGH_VALUE, + (relocation)); + else + (*_bfd_error_handler) + (_("%B(%A+0x%lx): CMEM relocation to `%s+0x%lx' is invalid, " + "16 MSB should be 0x%04x (value is 0x%lx)"), + reloc_data.input_section->owner, + reloc_data.input_section, + reloc_data.reloc_offset, + reloc_data.symbol_name, + reloc_data.reloc_addend, + NPS_CMEM_HIGH_VALUE, + (relocation)); + return bfd_reloc_overflow; + } + break; + + default: + break; + } + + return bfd_reloc_ok; +} + #define ME(reloc) (reloc) #define IS_ME(FORMULA,BFD) ((strstr (FORMULA, "ME") != NULL) \ @@ -896,6 +945,7 @@ arc_do_relocation (bfd_byte * contents, bfd_vma orig_insn ATTRIBUTE_UNUSED; bfd * abfd = reloc_data.input_section->owner; struct elf_link_hash_table *htab ATTRIBUTE_UNUSED = elf_hash_table (info); + bfd_reloc_status_type flag; if (reloc_data.should_relocate == FALSE) return bfd_reloc_ok; @@ -936,34 +986,34 @@ arc_do_relocation (bfd_byte * contents, /* Check for relocation overflow. */ if (reloc_data.howto->complain_on_overflow != complain_overflow_dont) - { - bfd_reloc_status_type flag; - flag = bfd_check_overflow (reloc_data.howto->complain_on_overflow, - reloc_data.howto->bitsize, - reloc_data.howto->rightshift, - bfd_arch_bits_per_address (abfd), - relocation); + flag = bfd_check_overflow (reloc_data.howto->complain_on_overflow, + reloc_data.howto->bitsize, + reloc_data.howto->rightshift, + bfd_arch_bits_per_address (abfd), + relocation); + else + flag = arc_special_overflow_checks (reloc_data, relocation, info); #undef DEBUG_ARC_RELOC #define DEBUG_ARC_RELOC(A) debug_arc_reloc (A) - if (flag != bfd_reloc_ok) - { - PR_DEBUG ( "Relocation overflows !!!!\n"); + if (flag != bfd_reloc_ok) + { + PR_DEBUG ( "Relocation overflows !!!!\n"); - DEBUG_ARC_RELOC (reloc_data); + DEBUG_ARC_RELOC (reloc_data); - PR_DEBUG ( - "Relocation value = signed -> %d, unsigned -> %u" - ", hex -> (0x%08x)\n", - (int) relocation, - (unsigned int) relocation, - (unsigned int) relocation); - return flag; - } + PR_DEBUG ( + "Relocation value = signed -> %d, unsigned -> %u" + ", hex -> (0x%08x)\n", + (int) relocation, + (unsigned int) relocation, + (unsigned int) relocation); + return flag; } #undef DEBUG_ARC_RELOC #define DEBUG_ARC_RELOC(A) + /* Write updated instruction back to memory. */ switch (reloc_data.howto->size) { case 2: @@ -1168,6 +1218,10 @@ elf_arc_relocate_section (bfd * output_bfd, reloc_data.sym_value = sym->st_value; reloc_data.sym_section = sec; + reloc_data.symbol_name = + bfd_elf_string_from_elf_section (input_bfd, + symtab_hdr->sh_link, + sym->st_name); /* Mergeable section handling. */ if ((sec->flags & SEC_MERGE) @@ -1284,6 +1338,7 @@ elf_arc_relocate_section (bfd * output_bfd, h = (struct elf_link_hash_entry *) h->root.u.i.link; BFD_ASSERT ((h->dynindx == -1) >= (h->forced_local != 0)); + reloc_data.symbol_name = h->root.root.string; /* If we have encountered a definition for this symbol. */ if (h->root.type == bfd_link_hash_defined || h->root.type == bfd_link_hash_defweak) diff --git a/bfd/libbfd.h b/bfd/libbfd.h index d7183d3..16c0aee 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -1738,6 +1738,7 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", "BFD_RELOC_ARC_TLS_LE_32", "BFD_RELOC_ARC_S25W_PCREL_PLT", "BFD_RELOC_ARC_S21H_PCREL_PLT", + "BFD_RELOC_ARC_NPS_CMEM16", "BFD_RELOC_BFIN_16_IMM", "BFD_RELOC_BFIN_16_HIGH", "BFD_RELOC_BFIN_4_PCREL", diff --git a/bfd/reloc.c b/bfd/reloc.c index 0135c04..c3b713b 100644 --- a/bfd/reloc.c +++ b/bfd/reloc.c @@ -3668,6 +3668,8 @@ ENUMX BFD_RELOC_ARC_S25W_PCREL_PLT ENUMX BFD_RELOC_ARC_S21H_PCREL_PLT +ENUMX + BFD_RELOC_ARC_NPS_CMEM16 ENUMDOC ARC relocs. |