diff options
| author | Cherry Mui <cherryyz@google.com> | 2026-02-25 12:26:54 -0500 |
|---|---|---|
| committer | Cherry Mui <cherryyz@google.com> | 2026-04-02 13:12:00 -0700 |
| commit | caa169ee4804ba0dbe1c430e8e9a4d2940f5145b (patch) | |
| tree | 24486172c5b6a6ac45e864233d692bf2f26dae2e /src/runtime | |
| parent | 3a0f18376fb974b6f5d30613f1a20d826a2564aa (diff) | |
| download | go-caa169ee4804ba0dbe1c430e8e9a4d2940f5145b.tar.xz | |
all: add export linknames for assembly symbols accessed from other package
For Go symbols accessed from other package via linkname or
assembly, we have an export linkname from the definition side. We
currently don't always have the linkname directive for assembly
functions, for which external accesses are allowed. We may want
to tighten up the restriction. So add export linknames for the ones
that are needed.
Change-Id: If664634c81580edd49086d916024f23f86871092
Reviewed-on: https://go-review.googlesource.com/c/go/+/749981
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'src/runtime')
| -rw-r--r-- | src/runtime/alg.go | 4 | ||||
| -rw-r--r-- | src/runtime/stubs.go | 9 | ||||
| -rw-r--r-- | src/runtime/stubs_amd64.go | 4 | ||||
| -rw-r--r-- | src/runtime/stubs_arm.go | 6 | ||||
| -rw-r--r-- | src/runtime/stubs_arm64.go | 8 | ||||
| -rw-r--r-- | src/runtime/stubs_loong64.go | 8 | ||||
| -rw-r--r-- | src/runtime/stubs_mips64x.go | 4 | ||||
| -rw-r--r-- | src/runtime/stubs_mipsx.go | 6 | ||||
| -rw-r--r-- | src/runtime/stubs_ppc64x.go | 10 | ||||
| -rw-r--r-- | src/runtime/stubs_riscv64.go | 8 | ||||
| -rw-r--r-- | src/runtime/stubs_s390x.go | 8 |
11 files changed, 73 insertions, 2 deletions
diff --git a/src/runtime/alg.go b/src/runtime/alg.go index 9b726b2180..e99acf8242 100644 --- a/src/runtime/alg.go +++ b/src/runtime/alg.go @@ -80,8 +80,12 @@ var useAeshash bool //go:linkname memhash func memhash(p unsafe.Pointer, h, s uintptr) uintptr +// Accessed in internal/runtime/maps. +// +//go:linknamestd memhash32 func memhash32(p unsafe.Pointer, h uintptr) uintptr +//go:linknamestd memhash64 func memhash64(p unsafe.Pointer, h uintptr) uintptr // strhash should be an internal detail, diff --git a/src/runtime/stubs.go b/src/runtime/stubs.go index 31e35c74f5..d4c79d288c 100644 --- a/src/runtime/stubs.go +++ b/src/runtime/stubs.go @@ -203,12 +203,14 @@ func noEscapePtr[T any](p *T) *T { // Not all cgocallback frames are actually cgocallback, // so not all have these arguments. Mark them uintptr so that the GC // does not misinterpret memory when the arguments are not present. -// cgocallback is not called from Go, only from crosscall2. +// cgocallback is not called from Go, only from crosscall2 in runtime/cgo. // This in turn calls cgocallbackg, which is where we'll find // pointer-declared arguments. // // When fn is nil (frame is saved g), call dropm instead, // this is used when the C thread is exiting. +// +//go:linknamestd cgocallback func cgocallback(fn, frame, ctxt uintptr) func gogo(buf *gobuf) @@ -260,6 +262,7 @@ func breakpoint() // only in a very limited callee of reflectcall, the stackArgs are copied, and // regArgs is only used in the reflectcall frame. // +//go:linknamestd reflectcall //go:noescape func reflectcall(stackArgsType *_type, fn, stackArgs unsafe.Pointer, stackArgsSize, stackRetOffset, frameSize uint32, regArgs *abi.RegArgs) @@ -409,6 +412,10 @@ func bool2int(x bool) int { // (e.g., an INT3 on x86). A crash in abort is recognized by the // signal handler, which will attempt to tear down the runtime // immediately. +// +// Also called from runtime test. +// +//go:linkname abort func abort() // Called from compiled code; declared for vet; do NOT call from Go. diff --git a/src/runtime/stubs_amd64.go b/src/runtime/stubs_amd64.go index 6d0b113740..9517d03283 100644 --- a/src/runtime/stubs_amd64.go +++ b/src/runtime/stubs_amd64.go @@ -48,7 +48,11 @@ func asmcgocall_landingpad() // // Spills/loads arguments in registers to/from an internal/abi.RegArgs // respectively. Does not follow the Go ABI. +// +//go:linknamestd spillArgs func spillArgs() + +//go:linknamestd unspillArgs func unspillArgs() // getfp returns the frame pointer register of its caller or 0 if not implemented. diff --git a/src/runtime/stubs_arm.go b/src/runtime/stubs_arm.go index 49bfd9ef04..786d90174b 100644 --- a/src/runtime/stubs_arm.go +++ b/src/runtime/stubs_arm.go @@ -14,12 +14,16 @@ func _mod() func _modu() // Called from assembly only; declared for go vet. -func usplitR0() +// +// load_g is also called from runtime/cgo. +// +//go:linknamestd load_g func load_g() func save_g() func emptyfunc() func _initcgo() func read_tls_fallback() +func usplitR0() //go:noescape func asmcgocall_no_g(fn, arg unsafe.Pointer) diff --git a/src/runtime/stubs_arm64.go b/src/runtime/stubs_arm64.go index df04e64291..f6cba6c2fa 100644 --- a/src/runtime/stubs_arm64.go +++ b/src/runtime/stubs_arm64.go @@ -7,6 +7,10 @@ package runtime import "unsafe" // Called from assembly only; declared for go vet. +// +// load_g is also called from runtime/cgo. +// +//go:linknamestd load_g func load_g() func save_g() @@ -19,7 +23,11 @@ func emptyfunc() // // Spills/loads arguments in registers to/from an internal/abi.RegArgs // respectively. Does not follow the Go ABI. +// +//go:linknamestd spillArgs func spillArgs() + +//go:linknamestd unspillArgs func unspillArgs() // getfp returns the frame pointer register of its caller or 0 if not implemented. diff --git a/src/runtime/stubs_loong64.go b/src/runtime/stubs_loong64.go index dfcfff2d16..9b73e8d963 100644 --- a/src/runtime/stubs_loong64.go +++ b/src/runtime/stubs_loong64.go @@ -9,6 +9,10 @@ package runtime import "unsafe" // Called from assembly only; declared for go vet. +// +// load_g is also called from runtime/cgo. +// +//go:linknamestd load_g func load_g() func save_g() @@ -19,7 +23,11 @@ func asmcgocall_no_g(fn, arg unsafe.Pointer) // // Spills/loads arguments in registers to/from an internal/abi.RegArgs // respectively. Does not follow the Go ABI. +// +//go:linknamestd spillArgs func spillArgs() + +//go:linknamestd unspillArgs func unspillArgs() // getfp returns the frame pointer register of its caller or 0 if not implemented. diff --git a/src/runtime/stubs_mips64x.go b/src/runtime/stubs_mips64x.go index fb5220b0de..f73fbefad7 100644 --- a/src/runtime/stubs_mips64x.go +++ b/src/runtime/stubs_mips64x.go @@ -9,6 +9,10 @@ package runtime import "unsafe" // Called from assembly only; declared for go vet. +// +// load_g is also called from runtime/cgo. +// +//go:linknamestd load_g func load_g() func save_g() diff --git a/src/runtime/stubs_mipsx.go b/src/runtime/stubs_mipsx.go index 175d4f9741..242a7e4554 100644 --- a/src/runtime/stubs_mipsx.go +++ b/src/runtime/stubs_mipsx.go @@ -6,7 +6,13 @@ package runtime +import _ "unsafe" // for linkname + // Called from assembly only; declared for go vet. +// +// load_g is also called from runtime/cgo. +// +//go:linknamestd load_g func load_g() func save_g() diff --git a/src/runtime/stubs_ppc64x.go b/src/runtime/stubs_ppc64x.go index dbc82c8453..7a0d8cec36 100644 --- a/src/runtime/stubs_ppc64x.go +++ b/src/runtime/stubs_ppc64x.go @@ -9,6 +9,10 @@ package runtime import "unsafe" // Called from assembly only; declared for go vet. +// +// load_g is also called from runtime/cgo. +// +//go:linknamestd load_g func load_g() func save_g() func reginit() @@ -16,9 +20,15 @@ func reginit() //go:noescape func asmcgocall_no_g(fn, arg unsafe.Pointer) +// Used by reflectcall and the reflect package. +// // Spills/loads arguments in registers to/from an internal/abi.RegArgs // respectively. Does not follow the Go ABI. +// +//go:linknamestd spillArgs func spillArgs() + +//go:linknamestd unspillArgs func unspillArgs() // getfp returns the frame pointer register of its caller or 0 if not implemented. diff --git a/src/runtime/stubs_riscv64.go b/src/runtime/stubs_riscv64.go index 2306ba878b..302a0f41e8 100644 --- a/src/runtime/stubs_riscv64.go +++ b/src/runtime/stubs_riscv64.go @@ -7,6 +7,10 @@ package runtime import "unsafe" // Called from assembly only; declared for go vet. +// +// load_g is also called from runtime/cgo. +// +//go:linknamestd load_g func load_g() func save_g() @@ -17,7 +21,11 @@ func asmcgocall_no_g(fn, arg unsafe.Pointer) // // Spills/loads arguments in registers to/from an internal/abi.RegArgs // respectively. Does not follow the Go ABI. +// +//go:linknamestd spillArgs func spillArgs() + +//go:linknamestd unspillArgs func unspillArgs() // getfp returns the frame pointer register of its caller or 0 if not implemented. diff --git a/src/runtime/stubs_s390x.go b/src/runtime/stubs_s390x.go index c872799a56..ee62dcf3b5 100644 --- a/src/runtime/stubs_s390x.go +++ b/src/runtime/stubs_s390x.go @@ -7,6 +7,10 @@ package runtime import "unsafe" // Called from assembly only; declared for go vet. +// +// load_g is also called from runtime/cgo. +// +//go:linknamestd load_g func load_g() func save_g() @@ -17,7 +21,11 @@ func asmcgocall_no_g(fn, arg unsafe.Pointer) // // Spills/loads arguments in registers to/from an internal/abi.RegArgs // respectively. Does not follow the Go ABI. +// +//go:linknamestd spillArgs func spillArgs() + +//go:linknamestd unspillArgs func unspillArgs() // getfp returns the frame pointer register of its caller or 0 if not implemented. |
