From: Peter Zotov Date: Fri, 25 Sep 2015 14:21:14 +0000 (+0100) Subject: Correct the generation of OR1K pc-relative relocations. X-Git-Tag: users/ARM/embedded-binutils-2_26-branch-2016q1~589 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8a9e7a9121490a8c64d8c17f5be510e43104f6d9;p=external%2Fbinutils.git Correct the generation of OR1K pc-relative relocations. gas PR ld/18759 * config/tc-or1k.c (tc_gen_reloc): Correct computation of PC relative relocs. * config/tc-or1k.h (GAS_CGEN_PRCEL_R_TYPE): Delete. bfd * elf32-or1k.c (R_OR1K_32_PCREL): Set pcrel_offset to TRUE. (R_OR1K_16_PCREL): Likewise. (R_OR1K_8_PCREL): Likewise. ld/tests * ld-elf/eh-frame-hdr: Expect to pass on the or1k-linux target. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index c067211..d8068c4 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +2015-08-11 Peter Zotov + + PR ld/18759 + * elf32-or1k.c (R_OR1K_32_PCREL): Set pcrel_offset to TRUE. + (R_OR1K_16_PCREL): Likewise. + (R_OR1K_8_PCREL): Likewise. + 2015-09-23 Nick Clifton * bout.c (b_out_slurp_reloc_table): Cast constant to unsigned in diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c index a1eba09..556a9ac 100644 --- a/bfd/elf32-or1k.c +++ b/bfd/elf32-or1k.c @@ -199,7 +199,7 @@ static reloc_howto_type or1k_elf_howto_table[] = FALSE, /* partial_inplace */ 0, /* src_mask */ 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + TRUE), /* pcrel_offset */ HOWTO (R_OR1K_16_PCREL, 0, /* rightshift */ @@ -213,7 +213,7 @@ static reloc_howto_type or1k_elf_howto_table[] = FALSE, /* partial_inplace */ 0, /* src_mask */ 0xffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + TRUE), /* pcrel_offset */ HOWTO (R_OR1K_8_PCREL, 0, /* rightshift */ @@ -227,7 +227,7 @@ static reloc_howto_type or1k_elf_howto_table[] = FALSE, /* partial_inplace */ 0, /* src_mask */ 0xff, /* dst_mask */ - FALSE), /* pcrel_offset */ + TRUE), /* pcrel_offset */ HOWTO (R_OR1K_GOTPC_HI16, /* Type. */ 16, /* Rightshift. */ diff --git a/gas/ChangeLog b/gas/ChangeLog index a324f03..af99b96 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,10 @@ +2015-08-11 Peter Zotov + + PR ld/18759 + * config/tc-or1k.c (tc_gen_reloc): Correct computation of PC + relative relocs. + * config/tc-or1k.h (GAS_CGEN_PRCEL_R_TYPE): Delete. + 2015-09-25 Ryo ONODERA PR 18994 diff --git a/gas/config/tc-or1k.c b/gas/config/tc-or1k.c index e490ffc..dba2dde 100644 --- a/gas/config/tc-or1k.c +++ b/gas/config/tc-or1k.c @@ -298,27 +298,59 @@ or1k_fix_adjustable (fixS * fixP) #define GOT_NAME "_GLOBAL_OFFSET_TABLE_" arelent * -tc_gen_reloc (asection *sec, fixS *fx) +tc_gen_reloc (asection * section, fixS * fixp) { - bfd_reloc_code_real_type code = fx->fx_r_type; + arelent *reloc; + bfd_reloc_code_real_type code; - if (fx->fx_addsy != NULL - && strcmp (S_GET_NAME (fx->fx_addsy), GOT_NAME) == 0 - && (code == BFD_RELOC_OR1K_GOTPC_HI16 - || code == BFD_RELOC_OR1K_GOTPC_LO16)) + reloc = xmalloc (sizeof (arelent)); + + reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *)); + *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); + reloc->address = fixp->fx_frag->fr_address + fixp->fx_where; + + if (fixp->fx_pcrel) + { + if (section->use_rela_p) + fixp->fx_offset -= md_pcrel_from_section (fixp, section); + else + fixp->fx_offset = reloc->address; + } + reloc->addend = fixp->fx_offset; + + code = fixp->fx_r_type; + switch (code) + { + case BFD_RELOC_16: + if (fixp->fx_pcrel) + code = BFD_RELOC_16_PCREL; + break; + + case BFD_RELOC_32: + if (fixp->fx_pcrel) + code = BFD_RELOC_32_PCREL; + break; + + case BFD_RELOC_64: + if (fixp->fx_pcrel) + code = BFD_RELOC_64_PCREL; + break; + + default: + break; + } + + reloc->howto = bfd_reloc_type_lookup (stdoutput, code); + if (reloc->howto == NULL) { - arelent * reloc; - - reloc = xmalloc (sizeof (* reloc)); - reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *)); - *reloc->sym_ptr_ptr = symbol_get_bfdsym (fx->fx_addsy); - reloc->address = fx->fx_frag->fr_address + fx->fx_where; - reloc->howto = bfd_reloc_type_lookup (stdoutput, fx->fx_r_type); - reloc->addend = fx->fx_offset; - return reloc; + as_bad_where (fixp->fx_file, fixp->fx_line, + _ + ("cannot represent %s relocation in this object file format"), + bfd_get_reloc_code_name (code)); + return NULL; } - return gas_cgen_tc_gen_reloc (sec, fx); + return reloc; } void diff --git a/gas/config/tc-or1k.h b/gas/config/tc-or1k.h index cc04b3a..d052834 100644 --- a/gas/config/tc-or1k.h +++ b/gas/config/tc-or1k.h @@ -57,8 +57,6 @@ extern long md_pcrel_from_section (struct fix *, segT); extern const struct relax_type md_relax_table[]; #define TC_GENERIC_RELAX_TABLE md_relax_table -#define GAS_CGEN_PCREL_R_TYPE(r_type) gas_cgen_pcrel_r_type(r_type) - #define elf_tc_final_processing or1k_elf_final_processing void or1k_elf_final_processing (void); diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 8a1eef2..3a6a509 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-08-11 Peter Zotov + + PR ld/18759 + * ld-elf/eh-frame-hdr: Expect to pass on the or1k-linux target. + 2015-09-22 H.J. Lu * ld-mips-elf/pie-n32.d: Updated. diff --git a/ld/testsuite/ld-elf/eh-frame-hdr.d b/ld/testsuite/ld-elf/eh-frame-hdr.d index 4214ed5..e981dff 100644 --- a/ld/testsuite/ld-elf/eh-frame-hdr.d +++ b/ld/testsuite/ld-elf/eh-frame-hdr.d @@ -2,7 +2,7 @@ #ld: -e _start --eh-frame-hdr #objdump: -hw #target: cfi -#xfail: avr*-*-* or1k-*-* visium-*-* +#xfail: avr*-*-* or1k*-*-elf or1k*-*-rtems* visium-*-* # avr doesn't support shared libraries. #... [0-9] .eh_frame_hdr 0*[12][048c] .*