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: Adam Nemet <anemet at caviumnetworks dot com>
- To: "Fu\, Chao-Ying" <fu at mips dot com>
- Cc: "Richard Sandiford" <rdsandiford at googlemail dot com>, <binutils at sourceware dot org>, "Lau\, David" <davidlau at mips dot com>, "Garbacea\, Ilie" <ilie at mips dot com>, "Hakewill\, James" <jamesh at mips dot com>
- Date: Thu, 27 Aug 2009 09:29:28 -0700
- Subject: Re: MIPS JAL/JALR to BAL transformation for Linux (o32 ABI)
- References: <94BD67F8AF3ED34FA362C662BA1F12C502BB5D33@MTVEXCHANGE.mips.com>
> Fu, Chao-Ying wrote:
>> .globl __start
>> .space 8
>> .ent __start
>> __start:
>> .Lstart:
>> .space 16
>> jal __start <------------ NOT relaxed
>> .space 32
>> jal __start <------------ NOT relaxed
>> .space 64
>> jal .Lstart <------------ relaxed
>> .end __start
>>
>> # make objdump print ...
>> .space 8
>>
>> The first two JALRs aren't relaxed in
>> "_bfd_mips_relax_section" due to the check.
>> as follows.
>> /* If a symbol is undefined, or if it may be overridden,
>> skip it. */
>> if (! ((h->root.root.type == bfd_link_hash_defined
>> || h->root.root.type == bfd_link_hash_defweak)
>> && h->root.root.u.def.section)
>> || (link_info->shared && ! link_info->symbolic
>> && ! (h->root.elf_link_hash_flags & ELF_LINK_FORCED_LOCAL)))
>> continue;
>>
>> But later, these two JALRs are transformed to BAL in
>> "mips_elf_perform_relocation".
>> Is it safe to use BAL for the first two JALRs?
No it's not safe in a shared library unless -Bsymbolic is used. This is
actually causing a regression with my GCC testing of the R_MIPS_JALR
patch. It seems that my patch:
http://sourceware.org/ml/binutils/2009-08/msg00404.html
needs to exclude global symbols in shared libs just like it's done under
relaxation. I'll update that patch.
Also did you test your binutils R_MIPS_JALR patch with a GCC bootstrap?
If not then next time you probably should. The binutils testsuite is
not very good in this area and I don't think the problems I have found
since your patch are "-mexplicit-relocs"-specific.
>> And, the relaxation code seems redundant, after we can do the
>> same thing in
>> "mips_elf_perform_relocation".
Yes, it does seem redundant.
Adam