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.
This commit is contained in:
Peter Zotov 2015-09-25 15:21:14 +01:00 committed by Nick Clifton
parent 6cd8405efd
commit 8a9e7a9121
7 changed files with 70 additions and 21 deletions

View File

@ -1,3 +1,10 @@
2015-08-11 Peter Zotov <whitequark@whitequark.org>
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 <nickc@redhat.com>
* bout.c (b_out_slurp_reloc_table): Cast constant to unsigned in

View File

@ -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. */

View File

@ -1,3 +1,10 @@
2015-08-11 Peter Zotov <whitequark@whitequark.org>
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 <ryo_on@yk.rim.or.jp>
PR 18994

View File

@ -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)
{
arelent * reloc;
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;
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;
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;
}
return gas_cgen_tc_gen_reloc (sec, fx);
reloc->howto = bfd_reloc_type_lookup (stdoutput, code);
if (reloc->howto == NULL)
{
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 reloc;
}
void

View File

@ -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);

View File

@ -1,3 +1,8 @@
2015-08-11 Peter Zotov <whitequark@whitequark.org>
PR ld/18759
* ld-elf/eh-frame-hdr: Expect to pass on the or1k-linux target.
2015-09-22 H.J. Lu <hongjiu.lu@intel.com>
* ld-mips-elf/pie-n32.d: Updated.

View File

@ -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] .*