This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: MIPS JAL/JALR to BAL transformation for Linux (o32 ABI)
- From: Richard Sandiford <rdsandiford at googlemail dot com>
- To: "Fu\, Chao-Ying" <fu at mips dot com>
- Cc: "Adam Nemet" <anemet at caviumnetworks dot com>, <binutils at sourceware dot org>, "Lau\, David" <davidlau at mips dot com>, "Garbacea\, Ilie" <ilie at mips dot com>
- Date: Wed, 05 Aug 2009 20:34:31 +0100
- Subject: Re: MIPS JAL/JALR to BAL transformation for Linux (o32 ABI)
- References: <87y6q4dj6l.fsf@firetop.home> <94BD67F8AF3ED34FA362C662BA1F12C502BB5CFF@MTVEXCHANGE.mips.com>
"Fu, Chao-Ying" <fu@mips.com> writes:
> @@ -5590,11 +5601,12 @@ mips_elf_perform_relocation (struct bfd_
> 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. */
You need to update this comment too. With the new macros, it can
be a lot simpler, such as:
/* Try converting JAL and JALR to BAL, if the target is in range. */
> - if (bfd_get_mach (input_bfd) == bfd_mach_mips9000
> - && !info->relocatable
> + 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 */
Odd formatting. I think it should be:
if (!info->relocatable
&& !require_jalx
&& ((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 */
More importantly, I think we should be checking the output_bfd
rather than the input bfd. E.g. if you were linking legacy MIPS 3
n32 objects with MIPS64 objects, you'd want the MIPS64-related
optimisations to be applied to both.
Looks good to me with those changes.
Richard