runtime: fix inline assembly trampoline for arm64

Use the program counter to compute the address of the first instruction
of the ret sled. The ret sled is located after 5 instructions from the
MOVD instruction saving the value of the program counter.

Change-Id: Ie7ae7a0807785d6fea035cf7a770dba7f37de0ec
GitHub-Last-Rev: 2719208c6a
GitHub-Pull-Request: golang/go#53039
Reviewed-on: https://go-review.googlesource.com/c/go/+/407895
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
Khaled Yakdan 2022-05-23 23:20:00 +00:00 committed by Cherry Mui
parent 38607c5538
commit 77d9252ddf
1 changed files with 4 additions and 3 deletions

View File

@ -43,8 +43,8 @@ TEXT runtime·libfuzzerCallTraceIntCmp(SB), NOSPLIT, $8-32
MOVD R12, RSP MOVD R12, RSP
call: call:
// Load address of the ret sled into the default register for the return // Load address of the ret sled into the default register for the return
// address (offset of four instructions, which means 16 bytes). // address.
ADR $16, R30 ADR ret_sled, R30
// Clear the lowest 2 bits of fakePC. All ARM64 instructions are four // Clear the lowest 2 bits of fakePC. All ARM64 instructions are four
// bytes long, so we cannot get better return address granularity than // bytes long, so we cannot get better return address granularity than
// multiples of 4. // multiples of 4.
@ -62,6 +62,7 @@ call:
#define RET_SLED \ #define RET_SLED \
JMP end_of_function; JMP end_of_function;
ret_sled:
REPEAT_128(RET_SLED); REPEAT_128(RET_SLED);
end_of_function: end_of_function: