]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: follow Windows calling convention for _cgo_sys_thread_create
authorJingnan Si <jingnan.si@gmail.com>
Mon, 8 Apr 2019 19:02:40 +0000 (19:02 +0000)
committerIan Lance Taylor <iant@golang.org>
Mon, 8 Apr 2019 19:05:25 +0000 (19:05 +0000)
Windows requires space for four pointers on the stack.

Change-Id: I9f7ba3e09b6c660f86d15139bb51954fffc8ccb1
GitHub-Last-Rev: 76d21bcc2b07edfde6daa45000093d070e2337bc
GitHub-Pull-Request: golang/go#30944
Reviewed-on: https://go-review.googlesource.com/c/go/+/168351
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/runtime/rt0_windows_amd64.s

index 1604711cdb89085038b43b0384db11ddfe6be1e8..345e1418023221ce49d2b5c0b1359cd632b8542a 100644 (file)
@@ -14,12 +14,14 @@ TEXT _rt0_amd64_windows(SB),NOSPLIT,$-8
 // library is loaded. For static libraries it is called when the
 // final executable starts, during the C runtime initialization
 // phase.
-TEXT _rt0_amd64_windows_lib(SB),NOSPLIT,$0x28
-       MOVQ    BP, 0x00(SP)
-       MOVQ    BX, 0x08(SP)
-       MOVQ    AX, 0x10(SP)
-       MOVQ  CX, 0x18(SP)
-       MOVQ  DX, 0x20(SP)
+// Leave space for four pointers on the stack as required
+// by the Windows amd64 calling convention.
+TEXT _rt0_amd64_windows_lib(SB),NOSPLIT,$0x48
+       MOVQ    BP, 0x20(SP)
+       MOVQ    BX, 0x28(SP)
+       MOVQ    AX, 0x30(SP)
+       MOVQ  CX, 0x38(SP)
+       MOVQ  DX, 0x40(SP)
 
        // Create a new thread to do the runtime initialization and return.
        MOVQ    _cgo_sys_thread_create(SB), AX
@@ -27,11 +29,11 @@ TEXT _rt0_amd64_windows_lib(SB),NOSPLIT,$0x28
        MOVQ    $0, DX
        CALL    AX
 
-       MOVQ    0x00(SP), BP
-       MOVQ    0x08(SP), BX
-       MOVQ    0x10(SP), AX
-       MOVQ    0x18(SP), CX
-       MOVQ    0x20(SP), DX
+       MOVQ    0x20(SP), BP
+       MOVQ    0x28(SP), BX
+       MOVQ    0x30(SP), AX
+       MOVQ    0x38(SP), CX
+       MOVQ    0x40(SP), DX
        RET
 
 TEXT _rt0_amd64_windows_lib_go(SB),NOSPLIT,$0