You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Upon closer inspection, I noticed that the offset in the call instruction is wrong. In particular, it's an absolute value instead of being relative to PC. Here's the generated code for main.jump:
bradfitz
changed the title
Incorrect offset generated for indirect calls on amd64
cmd/link: incorrect offset generated for indirect calls on amd64
May 9, 2016
This was broken in 1.5 and 1.6, which use the new assembler. I don't know how to write this instruction with the old assembler, so I don't know whether it was broken then.
There is a reasonably easy workaround:
MOVL ·pointer(SB),AX
CALL AX
I think 1.8 is the right target. We could consider a clearly correct fix for 1.7 but I don't see the CL that was sent out as clearly correct.
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?What operating system and processor architecture are you using (
go env
)?What did you do?
I compiled a program that included an indirect call. Repro steps are below:
What did you expect to see?
I expected the program above to run.
What did you see instead?
It crashed.
Upon closer inspection, I noticed that the offset in the call instruction is wrong. In particular, it's an absolute value instead of being relative to PC. Here's the generated code for main.jump:
Note that
0x488a60
is actually the address of main.pointer:So instead of reading from
0x488a60
we're trying to read from0x889ae6
instead, which is0x488a60 + 0x401086
(offset + rip).The text was updated successfully, but these errors were encountered: