This extends CL 402190 from Linux to the rest of the Unix OSes.
Marking sigtramp as TOPFRAME allows gentraceback to stop tracebacks at
the end of a signal handler, since there is not much beyond sigtramp.
Change-Id: I8b7f5d55d41889f59c0a79c65351b9b0b2d77717
Reviewed-on: https://go-review.googlesource.com/c/go/+/402934
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Pratt <mpratt@google.com>
// This function must not have any frame as we want to control how
// every registers are used.
// TODO(aix): Implement SetCgoTraceback handler.
-TEXT sigtramp<>(SB),NOSPLIT|NOFRAME,$0
+TEXT sigtramp<>(SB),NOSPLIT|NOFRAME|TOPFRAME,$0
MOVD LR, R0
MOVD R0, 16(R1)
// initialize essential registers (just in case)
// This is the function registered during sigaction and is invoked when
// a signal is received. It just redirects to the Go function sigtrampgo.
// Called using C ABI.
-TEXT runtime·sigtramp(SB),NOSPLIT,$0
+TEXT runtime·sigtramp(SB),NOSPLIT|TOPFRAME,$0
// Transition from C ABI to Go ABI.
PUSH_REGS_HOST_TO_ABI0()
BL (R11)
RET
-TEXT runtime·sigtramp(SB),NOSPLIT,$176
+TEXT runtime·sigtramp(SB),NOSPLIT|TOPFRAME,$176
// Save callee-save registers in the case of signal forwarding.
// Please refer to https://golang.org/issue/31827 .
SAVE_R19_TO_R28(8*4)
RET
// Called using C ABI.
-TEXT runtime·sigtramp(SB),NOSPLIT,$0
+TEXT runtime·sigtramp(SB),NOSPLIT|TOPFRAME,$0
// Transition from C ABI to Go ABI.
PUSH_REGS_HOST_TO_ABI0()
RET
// Called by OS using C ABI.
-TEXT runtime·sigtramp(SB),NOSPLIT,$12
+TEXT runtime·sigtramp(SB),NOSPLIT|TOPFRAME,$12
NOP SP // tell vet SP changed - stop checking offsets
MOVL 16(SP), BX // signo
MOVL BX, 0(SP)
RET
// Called using C ABI.
-TEXT runtime·sigtramp(SB),NOSPLIT,$0
+TEXT runtime·sigtramp(SB),NOSPLIT|TOPFRAME,$0
// Transition from C ABI to Go ABI.
PUSH_REGS_HOST_TO_ABI0()
MOVW R0, ret+12(FP)
RET
-TEXT runtime·sigtramp(SB),NOSPLIT,$0
+TEXT runtime·sigtramp(SB),NOSPLIT|TOPFRAME,$0
// Reserve space for callee-save registers and arguments.
MOVM.DB.W [R4-R11], (R13)
SUB $16, R13
RET
// func sigtramp()
-TEXT runtime·sigtramp(SB),NOSPLIT,$176
+TEXT runtime·sigtramp(SB),NOSPLIT|TOPFRAME,$176
// Save callee-save registers in the case of signal forwarding.
// Please refer to https://golang.org/issue/31827 .
SAVE_R19_TO_R28(8*4)
RET
// Called by OS using C ABI.
-TEXT runtime·sigtramp(SB),NOSPLIT,$28
+TEXT runtime·sigtramp(SB),NOSPLIT|TOPFRAME,$28
NOP SP // tell vet SP changed - stop checking offsets
// Save callee-saved C registers, since the caller may be a C signal handler.
MOVL BX, bx-4(SP)
RET
// Called using C ABI.
-TEXT runtime·sigtramp(SB),NOSPLIT,$0
+TEXT runtime·sigtramp(SB),NOSPLIT|TOPFRAME,$0
// Transition from C ABI to Go ABI.
PUSH_REGS_HOST_TO_ABI0()
MOVW R4, R13
RET
-TEXT runtime·sigtramp(SB),NOSPLIT,$0
+TEXT runtime·sigtramp(SB),NOSPLIT|TOPFRAME,$0
// Reserve space for callee-save registers and arguments.
MOVM.DB.W [R4-R11], (R13)
SUB $16, R13
BL (R11)
RET
-TEXT runtime·sigtramp(SB),NOSPLIT,$176
+TEXT runtime·sigtramp(SB),NOSPLIT|TOPFRAME,$176
// Save callee-save registers in the case of signal forwarding.
// Please refer to https://golang.org/issue/31827 .
SAVE_R19_TO_R28(8*4)
RET
// Called by OS using C ABI.
-TEXT runtime·sigtramp(SB),NOSPLIT,$28
+TEXT runtime·sigtramp(SB),NOSPLIT|TOPFRAME,$28
NOP SP // tell vet SP changed - stop checking offsets
// Save callee-saved C registers, since the caller may be a C signal handler.
MOVL BX, bx-4(SP)
RET
// Called using C ABI.
-TEXT runtime·sigtramp(SB),NOSPLIT,$0
+TEXT runtime·sigtramp(SB),NOSPLIT|TOPFRAME,$0
// Transition from C ABI to Go ABI.
PUSH_REGS_HOST_TO_ABI0()
MOVW R9, R13
RET
-TEXT runtime·sigtramp(SB),NOSPLIT,$0
+TEXT runtime·sigtramp(SB),NOSPLIT|TOPFRAME,$0
// Reserve space for callee-save registers and arguments.
MOVM.DB.W [R4-R11], (R13)
SUB $16, R13
BL (R11) // Alignment for ELF ABI?
RET
-TEXT runtime·sigtramp(SB),NOSPLIT,$192
+TEXT runtime·sigtramp(SB),NOSPLIT|TOPFRAME,$192
// Save callee-save registers in the case of signal forwarding.
// Please refer to https://golang.org/issue/31827 .
SAVE_R19_TO_R28(8*4)
CALL (R25)
RET
-TEXT runtime·sigtramp(SB),NOSPLIT,$192
+TEXT runtime·sigtramp(SB),NOSPLIT|TOPFRAME,$192
// initialize REGSB = PC&0xffffffff00000000
BGEZAL R0, 1(PC)
SRLV $32, R31, RSB
// Careful, this is called by __sighndlr, a libc function. We must preserve
// registers as per AMD 64 ABI.
-TEXT runtime·sigtramp(SB),NOSPLIT,$0
+TEXT runtime·sigtramp(SB),NOSPLIT|TOPFRAME,$0
// Note that we are executing on altsigstack here, so we have
// more stack available than NOSPLIT would have us believe.
// To defeat the linker, we make our own stack frame with