aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/symtab.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2024-05-22 15:46:02 -0400
committerGopher Robot <gobot@golang.org>2024-05-23 01:17:26 +0000
commit4cac885741b845bd7f4aaad5bc9844b44eb23136 (patch)
treeed100e299cb58e1783aaf80f18b2375555d024d2 /src/runtime/symtab.go
parent05cbbf985fed823a174bf95cc78a7d44f948fdab (diff)
downloadgo-4cac885741b845bd7f4aaad5bc9844b44eb23136.tar.xz
all: document legacy //go:linkname for modules with ≥200 dependents
Ignored these linknames which have not worked for a while: github.com/xtls/xray-core: context.newCancelCtx removed in CL 463999 (Feb 2023) github.com/u-root/u-root: funcPC removed in CL 513837 (Jul 2023) tinygo.org/x/drivers: net.useNetdev never existed For #67401. Change-Id: I9293f4ef197bb5552b431de8939fa94988a060ce Reviewed-on: https://go-review.googlesource.com/c/go/+/587576 Auto-Submit: Russ Cox <rsc@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/runtime/symtab.go')
-rw-r--r--src/runtime/symtab.go80
1 files changed, 79 insertions, 1 deletions
diff --git a/src/runtime/symtab.go b/src/runtime/symtab.go
index a7ce9c3a7e..40f0be6542 100644
--- a/src/runtime/symtab.go
+++ b/src/runtime/symtab.go
@@ -437,8 +437,19 @@ type modulehash struct {
// To make sure the map isn't collected, we keep a second reference here.
var pinnedTypemaps []map[typeOff]*_type
-var firstmoduledata moduledata // linker symbol
+var firstmoduledata moduledata // linker symbol
+
+// lastmoduledatap should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+// - github.com/cloudwego/frugal
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname lastmoduledatap
var lastmoduledatap *moduledata // linker symbol
+
var modulesSlice *[]*moduledata // see activeModules
// activeModules returns a slice of active modules.
@@ -547,6 +558,15 @@ func moduledataverify() {
const debugPcln = false
+// moduledataverify1 should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+// - github.com/cloudwego/frugal
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname moduledataverify1
func moduledataverify1(datap *moduledata) {
// Check that the pclntab's format is valid.
hdr := datap.pcHeader
@@ -674,6 +694,16 @@ func (md *moduledata) funcName(nameOff int32) string {
// If pc represents multiple functions because of inlining, it returns
// the *Func describing the innermost function, but with an entry of
// the outermost function.
+//
+// For completely unclear reasons, even though they can import runtime,
+// some widely used packages access this using linkname.
+// Notable members of the hall of shame include:
+// - gitee.com/quant1x/gox
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname FuncForPC
func FuncForPC(pc uintptr) *Func {
f := findfunc(pc)
if !f.valid() {
@@ -793,7 +823,16 @@ func (f funcInfo) entry() uintptr {
// It is nosplit because it's part of the isgoexception
// implementation.
//
+// findfunc should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+// - github.com/cloudwego/frugal
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
//go:nosplit
+//go:linkname findfunc
func findfunc(pc uintptr) funcInfo {
datap := findmoduledatap(pc)
if datap == nil {
@@ -1101,6 +1140,16 @@ func pcdatavalue1(f funcInfo, table uint32, targetpc uintptr, strict bool) int32
}
// Like pcdatavalue, but also return the start PC of this PCData value.
+//
+// pcdatavalue2 should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+// - github.com/cloudwego/frugal
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname pcdatavalue2
func pcdatavalue2(f funcInfo, table uint32, targetpc uintptr) (int32, uintptr) {
if table >= f.npcdata {
return -1, 0
@@ -1110,6 +1159,16 @@ func pcdatavalue2(f funcInfo, table uint32, targetpc uintptr) (int32, uintptr) {
// funcdata returns a pointer to the ith funcdata for f.
// funcdata should be kept in sync with cmd/link:writeFuncs.
+//
+// funcdata should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+// - github.com/cloudwego/frugal
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname funcdata
func funcdata(f funcInfo, i uint8) unsafe.Pointer {
if i < 0 || i >= f.nfuncdata {
return nil
@@ -1129,6 +1188,16 @@ func funcdata(f funcInfo, i uint8) unsafe.Pointer {
}
// step advances to the next pc, value pair in the encoded table.
+//
+// step should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+// - github.com/cloudwego/frugal
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname step
func step(p []byte, pc *uintptr, val *int32, first bool) (newp []byte, ok bool) {
// For both uvdelta and pcdelta, the common case (~70%)
// is that they are a single byte. If so, avoid calling readvarint.
@@ -1174,6 +1243,15 @@ type stackmap struct {
bytedata [1]byte // bitmaps, each starting on a byte boundary
}
+// stackmapdata should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+// - github.com/cloudwego/frugal
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname stackmapdata
//go:nowritebarrier
func stackmapdata(stkmap *stackmap, n int32) bitvector {
// Check this invariant only when stackDebug is on at all.