]> Cypherpunks repositories - gostls13.git/commit
runtime: avoid cgo_unsafe_args for syscall.syscall functions on darwin/arm64
authorCherry Mui <cherryyz@google.com>
Fri, 18 Feb 2022 18:09:54 +0000 (13:09 -0500)
committerCherry Mui <cherryyz@google.com>
Mon, 28 Feb 2022 17:51:12 +0000 (17:51 +0000)
commit57e3809884dd695d484acaefba8ded720c5a02c1
tree226379324482a96fcb0b1e5126032ae78cc600fa
parent06a43e4ab62bc5f8353e1c6ed5267d51ce2b483c
runtime: avoid cgo_unsafe_args for syscall.syscall functions on darwin/arm64

Currently, syscall.syscall-like functions are defined as
cgo_unsafe_args, which makes them ABI0, as it takes the address of
the argument area based on ABI0 layout. Those functions are
linkname'd to the syscall package. When compiling the syscall
package, the compiler doesn't know they are ABI0 therefore
generate an ABIInternal call, which will use the wrapper. As some
of the functions (e.g. syscall6) has many arguments, the wrapper
would take a good amount of stack space. And those functions must
be nosplit. This causes nosplit overflow when building with -N -l
and -race.

Avoid that by rewriting the functions to not use cgo_unsafe_args.
Instead, make a struct locally and pass the address of that
struct. This way the functions are ABIInternal and the call will
not use the wrapper.

Fixes #51247.

Change-Id: I76c1ab86b9d28664fa7d5b9c7928fbb2fd8d1417
Reviewed-on: https://go-review.googlesource.com/c/go/+/386719
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
src/runtime/sys_darwin.go