aboutsummaryrefslogtreecommitdiff
path: root/bfd/elfxx-mips.c
diff options
context:
space:
mode:
authorChao-ying Fu <fu@mips.com>2009-08-05 21:17:51 +0000
committerChao-ying Fu <fu@mips.com>2009-08-05 21:17:51 +0000
commitcd8d5a82a25684b60494b5ac21e7807b985e1ca4 (patch)
tree810d7a3958d1e0c1b9173e6a09d4bac60d14e143 /bfd/elfxx-mips.c
parentef15dade898122c47e0f7dc0f48c1399c444afdd (diff)
downloadgdb-cd8d5a82a25684b60494b5ac21e7807b985e1ca4.zip
gdb-cd8d5a82a25684b60494b5ac21e7807b985e1ca4.tar.gz
gdb-cd8d5a82a25684b60494b5ac21e7807b985e1ca4.tar.bz2
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.
Diffstat (limited to 'bfd/elfxx-mips.c')
-rw-r--r--bfd/elfxx-mips.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index 814ba90..ec712fa 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -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;