+2009-08-05 Chao-ying Fu <fu@mips.com>
+
+ * elf32-mips.c (mips_reloc_map): Add BFD_RELOC_MIPS_JALR.
+ * elfxx-mips.c (JAL_TO_BAL_P): New define to transform JAL to BAL
+ for CPUs. It is true for RM9000.
+ (JALR_TO_BAL_P): New define to transform JALR to BAL. It is true
+ for all CPUs.
+ (mips_elf_perform_relocation): Use JAL_TO_BAL_P and JALR_TO_BAL_P
+ to guard the transformation.
+
2009-08-05 Trevor Smigiel <Trevor_Smigiel@playstation.sony.com>
* elf32-spu.h (spu_elf_params): Add member emit_fixups.
{ BFD_RELOC_MIPS_GOT_PAGE, R_MIPS_GOT_PAGE },
{ BFD_RELOC_MIPS_GOT_OFST, R_MIPS_GOT_OFST },
{ BFD_RELOC_MIPS_GOT_DISP, R_MIPS_GOT_DISP },
+ { BFD_RELOC_MIPS_JALR, R_MIPS_JALR },
{ BFD_RELOC_MIPS_TLS_DTPMOD32, R_MIPS_TLS_DTPMOD32 },
{ BFD_RELOC_MIPS_TLS_DTPREL32, R_MIPS_TLS_DTPREL32 },
{ BFD_RELOC_MIPS_TLS_DTPMOD64, R_MIPS_TLS_DTPMOD64 },
( ((elf_elfheader (abfd)->e_flags & EF_MIPS_ARCH) != E_MIPS_ARCH_1) \
|| ((elf_elfheader (abfd)->e_flags & EF_MIPS_MACH) == E_MIPS_MACH_3900))
+/* True if ABFD is for CPUs that are faster if JAL is converted to BAL.
+ This should be safe for all architectures. We enable this predicate
+ for RM9000 for now. */
+#define JAL_TO_BAL_P(abfd) \
+ ((elf_elfheader (abfd)->e_flags & EF_MIPS_MACH) == E_MIPS_MACH_9000)
+
+/* True if ABFD is for CPUs that are faster if JALR is converted to BAL.
+ This should be safe for all architectures. We enable this predicate for
+ all CPUs. */
+#define JALR_TO_BAL_P(abfd) 1
+
/* True if ABFD is a PIC object. */
#define PIC_OBJECT_P(abfd) \
((elf_elfheader (abfd)->e_flags & EF_MIPS_PIC) != 0)
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
+ /* Try converting JAL and JALR to BAL, if the target is in range. */
+ if (!info->relocatable
&& !require_jalx
- && ((r_type == R_MIPS_26 && (x >> 26) == 0x3) /* jal addr */
- || (r_type == R_MIPS_JALR && x == 0x0320f809))) /* jalr t9 */
+ && ((JAL_TO_BAL_P (input_bfd)
+ && r_type == R_MIPS_26
+ && (x >> 26) == 0x3) /* jal addr */
+ || (JALR_TO_BAL_P (input_bfd)
+ && r_type == R_MIPS_JALR
+ && x == 0x0320f809))) /* jalr t9 */
{
bfd_vma addr;
bfd_vma dest;