]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: mark stdcallN functions cgo_unsafe_args
authorAustin Clements <austin@google.com>
Fri, 16 Apr 2021 04:00:32 +0000 (00:00 -0400)
committerAustin Clements <austin@google.com>
Fri, 16 Apr 2021 16:09:59 +0000 (16:09 +0000)
These functions take the address of an argument and expect to be able
to reach later arguments from that pointer. This means they must be
laid out sequentially in memory (using ABI0) and all arguments must be
live even though they don't all appear to be referenced. This is
exactly what go:cgo_unsafe_args does.

Without this, GOEXPERIMENT=regabi,regabiargs on windows/amd64 crashes
on runtime startup because the stdcall functions are called with their
arguments in registers, so taking the address of one of them has no
bearing on the memory locations of the following arguments.

With this, GOEXPERIMENT=regabi,regabiargs on windows/amd64 passes
all.bash.

For #40724.

Change-Id: I4a4d6a913f85799b43f61c234d21ebb113a9b527
Reviewed-on: https://go-review.googlesource.com/c/go/+/310733
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/runtime/os_windows.go

index bc1240f8bb3b8385e5fff44457f2a375eb7d6b20..36182f4e9a11eea5ea30eab40bdfb6a60bff222f 100644 (file)
@@ -1084,6 +1084,7 @@ func stdcall0(fn stdFunction) uintptr {
 }
 
 //go:nosplit
+//go:cgo_unsafe_args
 func stdcall1(fn stdFunction, a0 uintptr) uintptr {
        mp := getg().m
        mp.libcall.n = 1
@@ -1092,6 +1093,7 @@ func stdcall1(fn stdFunction, a0 uintptr) uintptr {
 }
 
 //go:nosplit
+//go:cgo_unsafe_args
 func stdcall2(fn stdFunction, a0, a1 uintptr) uintptr {
        mp := getg().m
        mp.libcall.n = 2
@@ -1100,6 +1102,7 @@ func stdcall2(fn stdFunction, a0, a1 uintptr) uintptr {
 }
 
 //go:nosplit
+//go:cgo_unsafe_args
 func stdcall3(fn stdFunction, a0, a1, a2 uintptr) uintptr {
        mp := getg().m
        mp.libcall.n = 3
@@ -1108,6 +1111,7 @@ func stdcall3(fn stdFunction, a0, a1, a2 uintptr) uintptr {
 }
 
 //go:nosplit
+//go:cgo_unsafe_args
 func stdcall4(fn stdFunction, a0, a1, a2, a3 uintptr) uintptr {
        mp := getg().m
        mp.libcall.n = 4
@@ -1116,6 +1120,7 @@ func stdcall4(fn stdFunction, a0, a1, a2, a3 uintptr) uintptr {
 }
 
 //go:nosplit
+//go:cgo_unsafe_args
 func stdcall5(fn stdFunction, a0, a1, a2, a3, a4 uintptr) uintptr {
        mp := getg().m
        mp.libcall.n = 5
@@ -1124,6 +1129,7 @@ func stdcall5(fn stdFunction, a0, a1, a2, a3, a4 uintptr) uintptr {
 }
 
 //go:nosplit
+//go:cgo_unsafe_args
 func stdcall6(fn stdFunction, a0, a1, a2, a3, a4, a5 uintptr) uintptr {
        mp := getg().m
        mp.libcall.n = 6
@@ -1132,6 +1138,7 @@ func stdcall6(fn stdFunction, a0, a1, a2, a3, a4, a5 uintptr) uintptr {
 }
 
 //go:nosplit
+//go:cgo_unsafe_args
 func stdcall7(fn stdFunction, a0, a1, a2, a3, a4, a5, a6 uintptr) uintptr {
        mp := getg().m
        mp.libcall.n = 7