]> Cypherpunks repositories - gostls13.git/commit
cmd/internal/obj/arm64: make function epilogue async-signal safe
authorCherry Zhang <cherryyz@google.com>
Fri, 8 Nov 2019 03:40:50 +0000 (22:40 -0500)
committerCherry Zhang <cherryyz@google.com>
Fri, 8 Nov 2019 16:46:24 +0000 (16:46 +0000)
commit47232f0d929bd7ca44aeea23ad3f1806dfa55c5e
tree891fe47834242f0686f834586c49d45b7501c68c
parent374c2847f9c03da7365bfb78e5ef96a0cb837656
cmd/internal/obj/arm64: make function epilogue async-signal safe

When the frame size is large, we generate

MOVD.P 0xf0(SP), LR
ADD $(framesize-0xf0), SP

This is problematic: after the first instruction, we have a
partial frame of size (framesize-0xf0). If we try to unwind the
stack at this point, we'll try to read the LR from the stack at
0(SP) (the new SP) as the frame size is not 0. But this slot does
not contain a valid LR.

Fix this by not changing SP in two instructions. Instead,
generate

MOVD (SP), LR
ADD $framesize, SP

This affects not only async preemption but also profiling. So we
change the generated instructions, instead of marking unsafe
point.

Change-Id: I4e78c62d50ffc4acff70ccfbfec16a5ccae17f24
Reviewed-on: https://go-review.googlesource.com/c/go/+/206057
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/cmd/internal/obj/arm64/obj7.go