From 29cb72154d3bb3530d8092cc89d35b3ed4f7e9c5 Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Thu, 15 Dec 2016 14:21:13 -0800 Subject: 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 Reviewed-by: Ian Lance Taylor --- src/runtime/sys_linux_386.s | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/runtime/sys_linux_386.s') diff --git a/src/runtime/sys_linux_386.s b/src/runtime/sys_linux_386.s index 1d798c741e..45320c068a 100644 --- a/src/runtime/sys_linux_386.s +++ b/src/runtime/sys_linux_386.s @@ -228,7 +228,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 sig+0(FP), BX MOVL BX, 0(SP) MOVL info+4(FP), BX @@ -236,6 +244,11 @@ TEXT runtime·sigtramp(SB),NOSPLIT,$12 MOVL ctx+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 TEXT runtime·cgoSigtramp(SB),NOSPLIT,$0 -- cgit v1.3-5-g9baa