func testSigaltstack(t *testing.T) {
switch {
- case runtime.GOOS == "solaris", runtime.GOOS == "illumos", (runtime.GOOS == "darwin" || runtime.GOOS == "ios") && runtime.GOARCH == "arm64":
+ case runtime.GOOS == "solaris", runtime.GOOS == "illumos", runtime.GOOS == "ios" && runtime.GOARCH == "arm64":
t.Skipf("switching signal stack not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
}
q1.To.Reg = REGSP
q1.Spadj = c.autosize
- if c.ctxt.Headtype == objabi.Hdarwin {
+ if objabi.GOOS == "ios" {
// iOS does not support SA_ONSTACK. We will run the signal handler
// on the G stack. If we write below SP, it may be clobbered by
// the signal handler. So we save LR after decrementing SP.
p("MOVD R29, -8(RSP)") // save frame pointer (only used on Linux)
p("SUB $8, RSP, R29") // set up new frame pointer
p("#endif")
- // On darwin, save the LR again after decrementing SP. We run the
- // signal handler on the G stack (as it doesn't support SA_ONSTACK),
+ // On iOS, save the LR again after decrementing SP. We run the
+ // signal handler on the G stack (as it doesn't support sigaltstack),
// so any writes below SP may be clobbered.
- p("#ifdef GOOS_darwin")
- p("MOVD R30, (RSP)")
- p("#endif")
p("#ifdef GOOS_ios")
p("MOVD R30, (RSP)")
p("#endif")
// Called to initialize a new m (including the bootstrap m).
// Called on the new thread, cannot allocate memory.
func minit() {
- // The alternate signal stack is buggy on arm64.
+ // iOS does not support alternate signal stack.
// The signal handler handles it directly.
- if GOARCH != "arm64" {
+ if !(GOOS == "ios" && GOARCH == "arm64") {
minitSignalStack()
}
minitSignalMask()
// Called from dropm to undo the effect of an minit.
//go:nosplit
func unminit() {
- // The alternate signal stack is buggy on arm64.
+ // iOS does not support alternate signal stack.
// See minit.
- if GOARCH != "arm64" {
+ if !(GOOS == "ios" && GOARCH == "arm64") {
unminitSignals()
}
}
MOVD R29, -8(RSP)
SUB $8, RSP, R29
#endif
- #ifdef GOOS_darwin
- MOVD R30, (RSP)
- #endif
#ifdef GOOS_ios
MOVD R30, (RSP)
#endif
// to each stack below the usual guard area for OS-specific
// purposes like signal handling. Used on Windows, Plan 9,
// and iOS because they do not use a separate stack.
- _StackSystem = sys.GoosWindows*512*sys.PtrSize + sys.GoosPlan9*512 + (sys.GoosDarwin+sys.GoosIos)*sys.GoarchArm64*1024
+ _StackSystem = sys.GoosWindows*512*sys.PtrSize + sys.GoosPlan9*512 + sys.GoosIos*sys.GoarchArm64*1024
// The minimum size of stack used by Go code
_StackMin = 2048
BEQ 2(PC)
BL runtime·load_g(SB)
+#ifdef GOOS_ios
MOVD RSP, R6
CMP $0, g
BEQ 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
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