This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: relax jalr $t9 [R_MIPS_JALR symbol] to bal symbol


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~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]