aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/sys_openbsd_386.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_386.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_386.s')
-rw-r--r--src/runtime/sys_openbsd_386.s15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/runtime/sys_openbsd_386.s b/src/runtime/sys_openbsd_386.s
index 997c07fe17..76d22b0131 100644
--- a/src/runtime/sys_openbsd_386.s
+++ b/src/runtime/sys_openbsd_386.s
@@ -213,7 +213,15 @@ TEXT runtime·sigfwd(SB),NOSPLIT,$12-16
MOVL AX, SP
RET
-TEXT runtime·sigtramp(SB),NOSPLIT,$12
+TEXT runtime·sigtramp(SB),NOSPLIT,$28
+ // Save callee-saved C registers, since the caller may be a C signal handler.
+ MOVL BX, bx-4(SP)
+ MOVL BP, bp-8(SP)
+ MOVL SI, si-12(SP)
+ MOVL DI, di-16(SP)
+ // We don't save mxcsr or the x87 control word because sigtrampgo doesn't
+ // modify them.
+
MOVL signo+0(FP), BX
MOVL BX, 0(SP)
MOVL info+4(FP), BX
@@ -221,6 +229,11 @@ TEXT runtime·sigtramp(SB),NOSPLIT,$12
MOVL context+8(FP), BX
MOVL BX, 8(SP)
CALL runtime·sigtrampgo(SB)
+
+ MOVL di-16(SP), DI
+ MOVL si-12(SP), SI
+ MOVL bp-8(SP), BP
+ MOVL bx-4(SP), BX
RET
// int32 tfork(void *param, uintptr psize, M *mp, G *gp, void (*fn)(void));