MIPS assembler branch relaxations

Alexandre Oliva aoliva@redhat.com
Sun Sep 15 01:00:00 GMT 2002


On Sep 14, 2002, Alexandre Oliva <aoliva@redhat.com> wrote:

> +      val = S_GET_VALUE (fragp->fr_symbol) + fragp->fr_offset;
> +
> +      addr = fragp->fr_address + fragp->fr_fix;
> +
> +      val -= addr;
> +
> +      toofar = val < - (0x8000 << 2) || val >= (0x8000 << 2);

I just realized this test is off by 4.  The base address added to the
branch offset is the address of the instruction in the delay slot, not
that of the branch instruction.  I'm amending the patch as follows:

         addr = fragp->fr_address + fragp->fr_fix + 4;

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                 aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist                Professional serial bug killer



More information about the Binutils mailing list