mn10300 linker relaxations broken (patch)

Alexandre Oliva aoliva@redhat.com
Sun May 13 20:09:00 GMT 2001


There are very serious bugs with mn10300 linker relaxations.  The most
simple of them is that we sometimes relax negative values into
zero-extended 16-bit operands.  This seldom shows up in practice,
since it's quite rare to have addresses in the range -0x8000..0, but
it's possible, and it will do bad things then.  I thought of creating
a separate chunk of code that would work on values in the range
0..0xffff, but I was too lazy, so I just arranged for us to skip the
relaxation opportunity if we find the value is negative but the opcode
sign-extends its operand.  While I was at it, I fixed some comments
that were wrong.  Oh, BTW, does anybody know why the linker tests for
values < 0x7fff, instead of <= 0x7fff?  This seems wrong to me.  Not
that it would hit that much, but...

The other, more serious problem, is that we don't adjust
section+offset relocations, and all references to local labels are
adjusted to section+offset by the assembler.  (This is also a problem
because references to labels become ambiguous, especially if the
addends of the relocations are non-zero, but this is probably rare in
comparison with direct references to labels).

One idea I had was to fix the linker so that it searches for
section+offset relocations and transform them in temporary symbols
before doing any relaxations (so they can be adjusted when bytes are
deleted from the section containing them), but implementing this was
beyond my linker-hacking abilities.  Meanwhile, I fixed the assembler
so that it doesn't ambiguate references to labels, letting them make
it to the linker unchanged, so linker relaxations immediately work.

Tested on i686-pc-linux-gnu-x-mn10300-elf.  Ok to install?



More information about the Binutils mailing list