aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/sys_openbsd_amd64.s
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2016-12-15 14:21:13 -0800
committerIan Lance Taylor <iant@golang.org>2016-12-15 23:41:06 +0000
commit29cb72154d3bb3530d8092cc89d35b3ed4f7e9c5 (patch)
tree709d55025d6e18c828487a53a58070d2656ebc42 /src/runtime/sys_openbsd_amd64.s
parentc1d449c42c6ea3c61f4636d1e9412b660be6f6bd (diff)
downloadgo-29cb72154d3bb3530d8092cc89d35b3ed4f7e9c5.tar.gz
go-29cb72154d3bb3530d8092cc89d35b3ed4f7e9c5.zip
runtime: preserve callee-saved C registers in sigtramp
This fixes Linux and the *BSD platforms on 386/amd64. A few OS/arch combinations were already saving registers and/or doing something that doesn't clearly resemble the SysV C ABI; those have been left alone. Fixes #18328. Change-Id: I6398f6c71020de108fc8b26ca5946f0ba0258667 Reviewed-on: https://go-review.googlesource.com/34501 TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/runtime/sys_openbsd_amd64.s')
-rw-r--r--src/runtime/sys_openbsd_amd64.s25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/runtime/sys_openbsd_amd64.s b/src/runtime/sys_openbsd_amd64.s
index 6ca5a81d2a..cf7a3fb7a9 100644
--- a/src/runtime/sys_openbsd_amd64.s
+++ b/src/runtime/sys_openbsd_amd64.s
@@ -242,11 +242,28 @@ TEXT runtime·sigfwd(SB),NOSPLIT,$0-32
POPQ BP
RET
-TEXT runtime·sigtramp(SB),NOSPLIT,$24
- MOVQ DI, 0(SP)
- MOVQ SI, 8(SP)
- MOVQ DX, 16(SP)
+TEXT runtime·sigtramp(SB),NOSPLIT,$72
+ // Save callee-saved C registers, since the caller may be a C signal handler.
+ MOVQ BX, bx-8(SP)
+ MOVQ BP, bp-16(SP) // save in case GOEXPERIMENT=noframepointer is set
+ MOVQ R12, r12-24(SP)
+ MOVQ R13, r13-32(SP)
+ MOVQ R14, r14-40(SP)
+ MOVQ R15, r15-48(SP)
+ // We don't save mxcsr or the x87 control word because sigtrampgo doesn't
+ // modify them.
+
+ MOVQ DX, ctx-56(SP)
+ MOVQ SI, info-64(SP)
+ MOVQ DI, signum-72(SP)
CALL runtime·sigtrampgo(SB)
+
+ MOVQ r15-48(SP), R15
+ MOVQ r14-40(SP), R14
+ MOVQ r13-32(SP), R13
+ MOVQ r12-24(SP), R12
+ MOVQ bp-16(SP), BP
+ MOVQ bx-8(SP), BX
RET
TEXT runtime·mmap(SB),NOSPLIT,$0