From c548cc2ec8c5c83ba16ab92c1cf8bcc3320ba624 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 27 Aug 2014 14:43:07 -0400 Subject: [PATCH] runtime: fix windows signal handlers Windows needs the return result in AX, but runtime.sighandler no longer stores it in AX. Load it back during the assembly trampoline. TBR=brainman CC=golang-codereviews https://golang.org/cl/133980043 --- src/pkg/runtime/sys_windows_386.s | 9 +++++---- src/pkg/runtime/sys_windows_amd64.s | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/pkg/runtime/sys_windows_386.s b/src/pkg/runtime/sys_windows_386.s index 2a1f4f929c..f9a456a2ca 100644 --- a/src/pkg/runtime/sys_windows_386.s +++ b/src/pkg/runtime/sys_windows_386.s @@ -76,10 +76,10 @@ TEXT runtime·setlasterror(SB),NOSPLIT,$0 // Return 0 for 'not handled', -1 for handled. TEXT runtime·sigtramp(SB),NOSPLIT,$0-0 MOVL ptrs+0(FP), CX - SUBL $28, SP + SUBL $32, SP // save callee-saved registers - MOVL BX, 12(SP) + MOVL BX, 28(SP) MOVL BP, 16(SP) MOVL SI, 20(SP) MOVL DI, 24(SP) @@ -103,15 +103,16 @@ TEXT runtime·sigtramp(SB),NOSPLIT,$0-0 MOVL DX, 8(SP) CALL runtime·sighandler(SB) // AX is set to report result back to Windows + MOVL 12(SP), AX done: // restore callee-saved registers MOVL 24(SP), DI MOVL 20(SP), SI MOVL 16(SP), BP - MOVL 12(SP), BX + MOVL 28(SP), BX - ADDL $28, SP + ADDL $32, SP // RET 4 (return and pop 4 bytes parameters) BYTE $0xC2; WORD $4 RET // unreached; make assembler happy diff --git a/src/pkg/runtime/sys_windows_amd64.s b/src/pkg/runtime/sys_windows_amd64.s index 60302622cb..7e59dfc50c 100644 --- a/src/pkg/runtime/sys_windows_amd64.s +++ b/src/pkg/runtime/sys_windows_amd64.s @@ -106,7 +106,7 @@ TEXT runtime·sigtramp(SB),NOSPLIT,$0-0 // DI SI BP BX R12 R13 R14 R15 registers and DF flag are preserved // as required by windows callback convention. PUSHFQ - SUBQ $88, SP + SUBQ $96, SP MOVQ DI, 80(SP) MOVQ SI, 72(SP) MOVQ BP, 64(SP) @@ -114,7 +114,7 @@ TEXT runtime·sigtramp(SB),NOSPLIT,$0-0 MOVQ R12, 48(SP) MOVQ R13, 40(SP) MOVQ R14, 32(SP) - MOVQ R15, 24(SP) + MOVQ R15, 88(SP) MOVQ 0(CX), BX // ExceptionRecord* MOVQ 8(CX), CX // Context* @@ -135,10 +135,11 @@ TEXT runtime·sigtramp(SB),NOSPLIT,$0-0 MOVQ DX, 16(SP) CALL runtime·sighandler(SB) // AX is set to report result back to Windows + MOVL 24(SP), AX done: // restore registers as required for windows callback - MOVQ 24(SP), R15 + MOVQ 88(SP), R15 MOVQ 32(SP), R14 MOVQ 40(SP), R13 MOVQ 48(SP), R12 @@ -146,7 +147,7 @@ done: MOVQ 64(SP), BP MOVQ 72(SP), SI MOVQ 80(SP), DI - ADDQ $88, SP + ADDQ $96, SP POPFQ RET -- 2.48.1