diff options
author | Austin Clements <austin@google.com> | 2021-04-16 00:00:32 -0400 |
---|---|---|
committer | Austin Clements <austin@google.com> | 2021-04-16 16:09:59 +0000 |
commit | 639cb1b629e575487af78bb3f60af24a7df7a3f7 (patch) | |
tree | 9a6eceb80bb9abe069c730f876785e49ed4dd28d /src/runtime/os_windows.go | |
parent | 0613c748e8919536c360cfc9be4e63a0b55d4286 (diff) | |
download | go-639cb1b629e575487af78bb3f60af24a7df7a3f7.tar.gz go-639cb1b629e575487af78bb3f60af24a7df7a3f7.zip |
runtime: mark stdcallN functions cgo_unsafe_args
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>
Diffstat (limited to 'src/runtime/os_windows.go')
-rw-r--r-- | src/runtime/os_windows.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/runtime/os_windows.go b/src/runtime/os_windows.go index bc1240f8bb..36182f4e9a 100644 --- a/src/runtime/os_windows.go +++ b/src/runtime/os_windows.go @@ -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 |