* elfxx-mips.c (mips_elf_calculate_relocation): For R_MIPS_JALR,
return a real value, unless it is a PLT symbol. (mips_elf_perform_relocation): On the RM9000, turn a jal into a bal if possible.
This commit is contained in:
parent
74f79d8d75
commit
1367d393bb
2 changed files with 40 additions and 4 deletions
|
@ -1,5 +1,10 @@
|
||||||
2004-12-09 Ian Lance Taylor <ian@wasabisystems.com>
|
2004-12-09 Ian Lance Taylor <ian@wasabisystems.com>
|
||||||
|
|
||||||
|
* elfxx-mips.c (mips_elf_calculate_relocation): For R_MIPS_JALR,
|
||||||
|
return a real value, unless it is a PLT symbol.
|
||||||
|
(mips_elf_perform_relocation): On the RM9000, turn a jal into a
|
||||||
|
bal if possible.
|
||||||
|
|
||||||
* elfn32-mips.c (elf_mips_howto_table_rela): Change dst_mask of
|
* elfn32-mips.c (elf_mips_howto_table_rela): Change dst_mask of
|
||||||
R_MIPS_JALR entry to 0.
|
R_MIPS_JALR entry to 0.
|
||||||
|
|
||||||
|
|
|
@ -3523,12 +3523,16 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd,
|
||||||
value &= howto->dst_mask;
|
value &= howto->dst_mask;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case R_MIPS_PJUMP:
|
|
||||||
case R_MIPS_JALR:
|
case R_MIPS_JALR:
|
||||||
/* Both of these may be ignored. R_MIPS_JALR is an optimization
|
/* This relocation is only a hint. In some cases, we optimize
|
||||||
hint; we could improve performance by honoring that hint. */
|
it into a bal instruction. But we don't try to optimize
|
||||||
|
branches to the PLT; that will wind up wasting time. */
|
||||||
|
if (h != NULL && h->root.plt.offset != (bfd_vma) -1)
|
||||||
return bfd_reloc_continue;
|
return bfd_reloc_continue;
|
||||||
|
value = symbol + addend;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case R_MIPS_PJUMP:
|
||||||
case R_MIPS_GNU_VTINHERIT:
|
case R_MIPS_GNU_VTINHERIT:
|
||||||
case R_MIPS_GNU_VTENTRY:
|
case R_MIPS_GNU_VTENTRY:
|
||||||
/* We don't do anything with these at present. */
|
/* We don't do anything with these at present. */
|
||||||
|
@ -3730,6 +3734,33 @@ mips_elf_perform_relocation (struct bfd_link_info *info,
|
||||||
x = (x & ~(0x3f << 26)) | (jalx_opcode << 26);
|
x = (x & ~(0x3f << 26)) | (jalx_opcode << 26);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* On the RM9000, bal is faster than jal, because bal uses branch
|
||||||
|
prediction hardware. If we are linking for the RM9000, and we
|
||||||
|
see jal, and bal fits, use it instead. Note that this
|
||||||
|
transformation should be safe for all architectures. */
|
||||||
|
if (bfd_get_mach (input_bfd) == bfd_mach_mips9000
|
||||||
|
&& !info->relocatable
|
||||||
|
&& !require_jalx
|
||||||
|
&& ((r_type == R_MIPS_26 && (x >> 26) == 0x3) /* jal addr */
|
||||||
|
|| (r_type == R_MIPS_JALR && x == 0x0320f809))) /* jalr t9 */
|
||||||
|
{
|
||||||
|
bfd_vma addr;
|
||||||
|
bfd_vma dest;
|
||||||
|
bfd_signed_vma off;
|
||||||
|
|
||||||
|
addr = (input_section->output_section->vma
|
||||||
|
+ input_section->output_offset
|
||||||
|
+ relocation->r_offset
|
||||||
|
+ 4);
|
||||||
|
if (r_type == R_MIPS_26)
|
||||||
|
dest = (value << 2) | ((addr >> 28) << 28);
|
||||||
|
else
|
||||||
|
dest = value;
|
||||||
|
off = dest - addr;
|
||||||
|
if (off <= 0x1ffff && off >= -0x20000)
|
||||||
|
x = 0x04110000 | (((bfd_vma) off >> 2) & 0xffff); /* bal addr */
|
||||||
|
}
|
||||||
|
|
||||||
/* Swap the high- and low-order 16 bits on little-endian systems
|
/* Swap the high- and low-order 16 bits on little-endian systems
|
||||||
when doing a MIPS16 relocation. */
|
when doing a MIPS16 relocation. */
|
||||||
if ((r_type == R_MIPS16_GPREL || r_type == R_MIPS16_26)
|
if ((r_type == R_MIPS16_GPREL || r_type == R_MIPS16_26)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue