aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/sys_darwin_arm64.s
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2020-09-12 12:33:24 -0400
committerCherry Zhang <cherryyz@google.com>2020-10-06 21:25:42 +0000
commit28e549dec3954b36d0c83442be913d8709d7e5ae (patch)
tree2c147b877df8c32fd1715cf9443937f8dc80a72f /src/runtime/sys_darwin_arm64.s
parent04c7e32517faf6257986e7c4cdd3f5f03eeae37b (diff)
downloadgo-28e549dec3954b36d0c83442be913d8709d7e5ae.tar.gz
go-28e549dec3954b36d0c83442be913d8709d7e5ae.zip
runtime: use sigaltstack on macOS/ARM64
Currently we don't use sigaltstack on darwin/arm64, as is not supported on iOS. However, it is supported on macOS. Use it. (iOS remains unchanged.) Change-Id: Icc154c5e2edf2dbdc8ca68741ad9157fc15a72ee Reviewed-on: https://go-review.googlesource.com/c/go/+/256917 Trust: Cherry Zhang <cherryyz@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/runtime/sys_darwin_arm64.s')
-rw-r--r--src/runtime/sys_darwin_arm64.s22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/runtime/sys_darwin_arm64.s b/src/runtime/sys_darwin_arm64.s
index 585d4f2c64..427cb17781 100644
--- a/src/runtime/sys_darwin_arm64.s
+++ b/src/runtime/sys_darwin_arm64.s
@@ -202,6 +202,7 @@ TEXT runtime·sigtramp(SB),NOSPLIT,$192
BEQ 2(PC)
BL runtime·load_g(SB)
+#ifdef GOOS_ios
MOVD RSP, R6
CMP $0, g
BEQ nog
@@ -226,16 +227,21 @@ nog:
// Switch to gsignal stack.
MOVD R6, RSP
- // Call sigtrampgo.
+ // Save arguments.
MOVW R0, (8*1)(RSP)
MOVD R1, (8*2)(RSP)
MOVD R2, (8*3)(RSP)
+#endif
+
+ // Call sigtrampgo.
MOVD $runtime·sigtrampgo(SB), R11
BL (R11)
+#ifdef GOOS_ios
// Switch to old stack.
MOVD (8*4)(RSP), R5
MOVD R5, RSP
+#endif
// Restore callee-save registers.
MOVD (8*4)(RSP), R19
@@ -329,12 +335,20 @@ TEXT runtime·fcntl_trampoline(SB),NOSPLIT,$0
ADD $16, RSP
RET
-// sigaltstack on iOS is not supported and will always
-// run the signal handler on the main stack, so our sigtramp has
-// to do the stack switch ourselves.
TEXT runtime·sigaltstack_trampoline(SB),NOSPLIT,$0
+#ifdef GOOS_ios
+ // sigaltstack on iOS is not supported and will always
+ // run the signal handler on the main stack, so our sigtramp has
+ // to do the stack switch ourselves.
MOVW $43, R0
BL libc_exit(SB)
+#else
+ MOVD 8(R0), R1 // arg 2 old
+ MOVD 0(R0), R0 // arg 1 new
+ CALL libc_sigaltstack(SB)
+ CBZ R0, 2(PC)
+ BL notok<>(SB)
+#endif
RET
// Thread related functions