This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: relax jalr $t9 [R_MIPS_JALR symbol] to bal symbol
- From: Richard Henderson <rth at redhat dot com>
- To: Alexandre Oliva <aoliva at redhat dot com>
- Cc: binutils at sources dot redhat dot com
- Date: Sun, 23 Mar 2003 21:38:33 -0800
- Subject: Re: relax jalr $t9 [R_MIPS_JALR symbol] to bal symbol
- References: <orbs01tl13.fsf@free.redhat.lsd.ic.unicamp.br>
On Mon, Mar 24, 2003 at 02:02:00AM -0300, Alexandre Oliva wrote:
> + if (contents)
> + {
> + instruction = bfd_get_32 (abfd, contents + irel->r_offset);
> + /* if it's neither jalr nor jr, bail out. */
> + if ((instruction & 0xfc1fffff) != 0x0000f809
> + && (instruction & 0xfc1fffff) != 0x00000008)
> + continue;
I wouldn't bother doing this so early; you're optimizing
for the case that'll "never" happen.
> + /* If it was jalr <reg>, turn it into bgezal $0, <target>. */
> + if ((instruction & 0xfc1fffff) != 0x0000f809)
> + instruction = 0x10000000;
> + else if ((instruction & 0xfc1fffff) != 0x00000008)
> + instruction = 0x04110000;
Instead just continue here.
> + instruction |= (sym_offset & 0xffff);
In theory, what you're doing should be ok, but theory has a way
of not following practice, especially with binutils.
I know part of the problem with the oft restarted "branch to
external label" thread is that there isn't a proper R_MIPS_FOO
for this case, but there's nothing saying we can't invent an
internal relocation number in stead.
Secondly, as a follow-up patch I think that !link_info->shared
should make use of the j/jal absolute forms.
r~