gas generating bad code for i386

Alan Modra alan@SPRI.Levels.UniSA.Edu.Au
Wed Mar 8 16:32:00 GMT 2000


On 7 Mar 2000, Andrew Haley wrote:
> > This has changed.  With the current sources `call 4' generates a
> > relocation for a PC relative call to the absolute address 4.
> 
> That's good news.  There are hacks in gcc to work around this
> misfeature.

Hey, the misfeature was in gcc.  It generated bad x86 code.  There is no
x86 direct call to an absolute address, at least not without specifying
the full segment:offset form.  The "hacks" in gcc are simply bug fixes :)
Don't take them out, as assemblers other than gas will give a fatal error
on `call 4'.

gas did have a rather useless and probably unintentional "feature" in that
it accepted `jmp constant' (and `call constant', `jc ...' etc.) and
generated a `jmp' opcode with `constant' as the operand.  ie. you got a
jmp, with offset `constant' relative to the *next* instruction.  All quite
confusing really.

Incidentally Tom, `call *4' isn't an absolute call to address 4.  Instead,
with `call *4', memory location 4 holds the address of the call
destination.  ie. it's an indirect call.



More information about the Binutils mailing list