]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
2009-08-05 Chao-ying Fu <fu@mips.com>
authorChao-ying Fu <fu@mips.com>
Wed, 5 Aug 2009 21:17:51 +0000 (21:17 +0000)
committerChao-ying Fu <fu@mips.com>
Wed, 5 Aug 2009 21:17:51 +0000 (21:17 +0000)
* 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.

bfd/ChangeLog
bfd/elf32-mips.c
bfd/elfxx-mips.c

index a18c0dbf6429d0f810a2967cda8474d37b067a5b..95e033c15002df86004b0ba34673b2f9611dd569 100644 (file)
@@ -1,3 +1,13 @@
+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.
index c928586d1109fe9c88571e15c657fdf605b799f3..ba3ee916ea3da2a2f8c54739793a59df28ad47c1 100644 (file)
@@ -1261,6 +1261,7 @@ static const struct elf_reloc_map mips_reloc_map[] =
   { 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 },
index 814ba90cdb3c56da7235d4129734a7c8c267f970..ec712fac74d0873f1516592a226668d937b2781e 100644 (file)
@@ -668,6 +668,17 @@ static bfd *reldyn_sorting_bfd;
   (   ((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)
@@ -5586,15 +5597,15 @@ mips_elf_perform_relocation (struct bfd_link_info *info,
       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;