]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: fix windows signal handlers
authorRuss Cox <rsc@golang.org>
Wed, 27 Aug 2014 18:43:07 +0000 (14:43 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 27 Aug 2014 18:43:07 +0000 (14:43 -0400)
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
src/pkg/runtime/sys_windows_amd64.s

index 2a1f4f929cea0f58f0253f8a50c24512ce5a7718..f9a456a2ca95a0faf8f70384ac0720ea2e1a1c21 100644 (file)
@@ -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
index 60302622cb440c697ccfd337c7098d51c2dbe61b..7e59dfc50c9ff694e37630d59fa0ba9d65dcf92f 100644 (file)
@@ -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