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>
This commit is contained in:
Russ Cox 2024-05-22 15:46:02 -04:00 committed by Gopher Robot
parent 05cbbf985f
commit 4cac885741
30 changed files with 342 additions and 12 deletions

View file

@ -12,7 +12,6 @@ import _ "unsafe"
// This may change in the future. Please do not depend on them // This may change in the future. Please do not depend on them
// in new code. // in new code.
//go:linkname aeadAESGCMTLS13
//go:linkname cipherSuiteTLS13ByID //go:linkname cipherSuiteTLS13ByID
//go:linkname errShutdown //go:linkname errShutdown

View file

@ -533,6 +533,15 @@ func aeadAESGCM(key, noncePrefix []byte) aead {
return ret return ret
} }
// aeadAESGCMTLS13 should be an internal detail,
// but widely used packages access it using linkname.
// Notable members of the hall of shame include:
// - github.com/xtls/xray-core
//
// Do not remove or change the type signature.
// See go.dev/issue/67401.
//
//go:linkname aeadAESGCMTLS13
func aeadAESGCMTLS13(key, nonceMask []byte) aead { func aeadAESGCMTLS13(key, nonceMask []byte) aead {
if len(nonceMask) != aeadNonceLength { if len(nonceMask) != aeadNonceLength {
panic("tls: internal error: wrong nonce length") panic("tls: internal error: wrong nonce length")

View file

@ -25,6 +25,7 @@ import (
"strings" "strings"
"sync" "sync"
"time" "time"
_ "unsafe" // for linkname
) )
const ( const (
@ -1129,6 +1130,15 @@ func (c *Config) mutualVersion(isClient bool, peerVersions []uint16) (uint16, bo
return 0, false return 0, false
} }
// errNoCertificates should be an internal detail,
// but widely used packages access it using linkname.
// Notable members of the hall of shame include:
// - github.com/xtls/xray-core
//
// Do not remove or change the type signature.
// See go.dev/issue/67401.
//
//go:linkname errNoCertificates
var errNoCertificates = errors.New("tls: no certificates configured") var errNoCertificates = errors.New("tls: no certificates configured")
// getCertificate returns the best certificate for the given ClientHelloInfo, // getCertificate returns the best certificate for the given ClientHelloInfo,

View file

@ -12,12 +12,6 @@ import _ "unsafe"
// This may change in the future. Please do not depend on them // This may change in the future. Please do not depend on them
// in new code. // in new code.
//go:linkname cloneMultipartFileHeader
//go:linkname cloneMultipartForm
//go:linkname cloneOrMakeHeader
//go:linkname cloneTLSConfig
//go:linkname cloneURL
//go:linkname cloneURLValues
//go:linkname newBufioReader //go:linkname newBufioReader
//go:linkname newBufioWriterSize //go:linkname newBufioWriterSize
//go:linkname putBufioReader //go:linkname putBufioReader

View file

@ -8,8 +8,18 @@ import (
"mime/multipart" "mime/multipart"
"net/textproto" "net/textproto"
"net/url" "net/url"
_ "unsafe" // for linkname
) )
// cloneURLValues should be an internal detail,
// but widely used packages access it using linkname.
// Notable members of the hall of shame include:
// - github.com/searKing/golang
//
// Do not remove or change the type signature.
// See go.dev/issue/67401.
//
//go:linkname cloneURLValues
func cloneURLValues(v url.Values) url.Values { func cloneURLValues(v url.Values) url.Values {
if v == nil { if v == nil {
return nil return nil
@ -19,6 +29,15 @@ func cloneURLValues(v url.Values) url.Values {
return url.Values(Header(v).Clone()) return url.Values(Header(v).Clone())
} }
// cloneURL should be an internal detail,
// but widely used packages access it using linkname.
// Notable members of the hall of shame include:
// - github.com/searKing/golang
//
// Do not remove or change the type signature.
// See go.dev/issue/67401.
//
//go:linkname cloneURL
func cloneURL(u *url.URL) *url.URL { func cloneURL(u *url.URL) *url.URL {
if u == nil { if u == nil {
return nil return nil
@ -32,6 +51,15 @@ func cloneURL(u *url.URL) *url.URL {
return u2 return u2
} }
// cloneMultipartForm should be an internal detail,
// but widely used packages access it using linkname.
// Notable members of the hall of shame include:
// - github.com/searKing/golang
//
// Do not remove or change the type signature.
// See go.dev/issue/67401.
//
//go:linkname cloneMultipartForm
func cloneMultipartForm(f *multipart.Form) *multipart.Form { func cloneMultipartForm(f *multipart.Form) *multipart.Form {
if f == nil { if f == nil {
return nil return nil
@ -53,6 +81,15 @@ func cloneMultipartForm(f *multipart.Form) *multipart.Form {
return f2 return f2
} }
// cloneMultipartFileHeader should be an internal detail,
// but widely used packages access it using linkname.
// Notable members of the hall of shame include:
// - github.com/searKing/golang
//
// Do not remove or change the type signature.
// See go.dev/issue/67401.
//
//go:linkname cloneMultipartFileHeader
func cloneMultipartFileHeader(fh *multipart.FileHeader) *multipart.FileHeader { func cloneMultipartFileHeader(fh *multipart.FileHeader) *multipart.FileHeader {
if fh == nil { if fh == nil {
return nil return nil
@ -65,6 +102,16 @@ func cloneMultipartFileHeader(fh *multipart.FileHeader) *multipart.FileHeader {
// cloneOrMakeHeader invokes Header.Clone but if the // cloneOrMakeHeader invokes Header.Clone but if the
// result is nil, it'll instead make and return a non-nil Header. // result is nil, it'll instead make and return a non-nil Header.
//
// cloneOrMakeHeader should be an internal detail,
// but widely used packages access it using linkname.
// Notable members of the hall of shame include:
// - github.com/searKing/golang
//
// Do not remove or change the type signature.
// See go.dev/issue/67401.
//
//go:linkname cloneOrMakeHeader
func cloneOrMakeHeader(hdr Header) Header { func cloneOrMakeHeader(hdr Header) Header {
clone := hdr.Clone() clone := hdr.Clone()
if clone == nil { if clone == nil {

View file

@ -30,6 +30,7 @@ import (
"sync" "sync"
"sync/atomic" "sync/atomic"
"time" "time"
_ "unsafe"
"golang.org/x/net/http/httpguts" "golang.org/x/net/http/httpguts"
"golang.org/x/net/http/httpproxy" "golang.org/x/net/http/httpproxy"
@ -2983,6 +2984,16 @@ func (fakeLocker) Unlock() {}
// cloneTLSConfig returns a shallow clone of cfg, or a new zero tls.Config if // cloneTLSConfig returns a shallow clone of cfg, or a new zero tls.Config if
// cfg is nil. This is safe to call even if cfg is in active use by a TLS // cfg is nil. This is safe to call even if cfg is in active use by a TLS
// client or server. // client or server.
//
// cloneTLSConfig should be an internal detail,
// but widely used packages access it using linkname.
// Notable members of the hall of shame include:
// - github.com/searKing/golang
//
// Do not remove or change the type signature.
// See go.dev/issue/67401.
//
//go:linkname cloneTLSConfig
func cloneTLSConfig(cfg *tls.Config) *tls.Config { func cloneTLSConfig(cfg *tls.Config) *tls.Config {
if cfg == nil { if cfg == nil {
return &tls.Config{} return &tls.Config{}

View file

@ -49,8 +49,12 @@ var useAeshash bool
// memhash should be an internal detail, // memhash should be an internal detail,
// but widely used packages access it using linkname. // but widely used packages access it using linkname.
// Notable members of the hall of shame include: // Notable members of the hall of shame include:
// - github.com/aacfactory/fns
// - github.com/dgraph-io/ristretto // - github.com/dgraph-io/ristretto
// - github.com/nbd-wtf/go-nostr
// - github.com/outcaste-io/ristretto // - github.com/outcaste-io/ristretto
// - github.com/puzpuzpuz/xsync/v2
// - github.com/puzpuzpuz/xsync/v3
// //
// Do not remove or change the type signature. // Do not remove or change the type signature.
// See go.dev/issue/67401. // See go.dev/issue/67401.
@ -67,6 +71,7 @@ func memhash64(p unsafe.Pointer, h uintptr) uintptr
// - github.com/aristanetworks/goarista // - github.com/aristanetworks/goarista
// - github.com/bytedance/sonic // - github.com/bytedance/sonic
// - github.com/bytedance/go-tagexpr/v2 // - github.com/bytedance/go-tagexpr/v2
// - github.com/cloudwego/frugal
// //
// Do not remove or change the type signature. // Do not remove or change the type signature.
// See go.dev/issue/67401. // See go.dev/issue/67401.
@ -176,6 +181,17 @@ func nilinterhash(p unsafe.Pointer, h uintptr) uintptr {
// maps generated by reflect.MapOf (reflect_typehash, below). // maps generated by reflect.MapOf (reflect_typehash, below).
// Note: this function must match the compiler generated // Note: this function must match the compiler generated
// functions exactly. See issue 37716. // functions exactly. See issue 37716.
//
// typehash should be an internal detail,
// but widely used packages access it using linkname.
// Notable members of the hall of shame include:
// - github.com/puzpuzpuz/xsync/v2
// - github.com/puzpuzpuz/xsync/v3
//
// Do not remove or change the type signature.
// See go.dev/issue/67401.
//
//go:linkname typehash
func typehash(t *_type, p unsafe.Pointer, h uintptr) uintptr { func typehash(t *_type, p unsafe.Pointer, h uintptr) uintptr {
if t.TFlag&abi.TFlagRegularMemory != 0 { if t.TFlag&abi.TFlagRegularMemory != 0 {
// Handle ptr sizes specially, see issue 37086. // Handle ptr sizes specially, see issue 37086.

View file

@ -25,7 +25,6 @@ import _ "unsafe"
//go:linkname startTheWorld //go:linkname startTheWorld
//go:linkname stopTheWorld //go:linkname stopTheWorld
//go:linkname stringHash //go:linkname stringHash
//go:linkname typehash
// Notable members of the hall of shame include: // Notable members of the hall of shame include:
// - github.com/dgraph-io/ristretto // - github.com/dgraph-io/ristretto

View file

@ -663,6 +663,7 @@ var emptyInterfaceSwitchCache = abi.InterfaceSwitchCache{Mask: 0}
// reflect_ifaceE2I is for package reflect, // reflect_ifaceE2I is for package reflect,
// but widely used packages access it using linkname. // but widely used packages access it using linkname.
// Notable members of the hall of shame include: // Notable members of the hall of shame include:
// - gitee.com/quant1x/gox
// - github.com/modern-go/reflect2 // - github.com/modern-go/reflect2
// //
// Do not remove or change the type signature. // Do not remove or change the type signature.

View file

@ -971,6 +971,7 @@ func (c *mcache) nextFree(spc spanClass) (v gclinkptr, s *mspan, shouldhelpgc bo
// Notable members of the hall of shame include: // Notable members of the hall of shame include:
// - github.com/bytedance/gopkg // - github.com/bytedance/gopkg
// - github.com/bytedance/sonic // - github.com/bytedance/sonic
// - github.com/cloudwego/frugal
// - github.com/cockroachdb/cockroach // - github.com/cockroachdb/cockroach
// - github.com/cockroachdb/pebble // - github.com/cockroachdb/pebble
// - github.com/ugorji/go/codec // - github.com/ugorji/go/codec
@ -1388,6 +1389,7 @@ func newobject(typ *_type) unsafe.Pointer {
// reflect_unsafe_New is meant for package reflect, // reflect_unsafe_New is meant for package reflect,
// but widely used packages access it using linkname. // but widely used packages access it using linkname.
// Notable members of the hall of shame include: // Notable members of the hall of shame include:
// - gitee.com/quant1x/gox
// - github.com/goccy/json // - github.com/goccy/json
// - github.com/modern-go/reflect2 // - github.com/modern-go/reflect2
// //
@ -1430,6 +1432,7 @@ func newarray(typ *_type, n int) unsafe.Pointer {
// reflect_unsafe_NewArray is meant for package reflect, // reflect_unsafe_NewArray is meant for package reflect,
// but widely used packages access it using linkname. // but widely used packages access it using linkname.
// Notable members of the hall of shame include: // Notable members of the hall of shame include:
// - gitee.com/quant1x/gox
// - github.com/bytedance/sonic // - github.com/bytedance/sonic
// - github.com/goccy/json // - github.com/goccy/json
// - github.com/modern-go/reflect2 // - github.com/modern-go/reflect2

View file

@ -308,6 +308,7 @@ func makemap_small() *hmap {
// makemap should be an internal detail, // makemap should be an internal detail,
// but widely used packages access it using linkname. // but widely used packages access it using linkname.
// Notable members of the hall of shame include: // Notable members of the hall of shame include:
// - github.com/cloudwego/frugal
// - github.com/ugorji/go/codec // - github.com/ugorji/go/codec
// //
// Do not remove or change the type signature. // Do not remove or change the type signature.
@ -602,6 +603,7 @@ func mapaccess2_fat(t *maptype, h *hmap, key, zero unsafe.Pointer) (unsafe.Point
// but widely used packages access it using linkname. // but widely used packages access it using linkname.
// Notable members of the hall of shame include: // Notable members of the hall of shame include:
// - github.com/bytedance/sonic // - github.com/bytedance/sonic
// - github.com/cloudwego/frugal
// - github.com/segmentio/encoding // - github.com/segmentio/encoding
// - github.com/ugorji/go/codec // - github.com/ugorji/go/codec
// //
@ -860,6 +862,7 @@ search:
// but widely used packages access it using linkname. // but widely used packages access it using linkname.
// Notable members of the hall of shame include: // Notable members of the hall of shame include:
// - github.com/bytedance/sonic // - github.com/bytedance/sonic
// - github.com/cloudwego/frugal
// - github.com/goccy/go-json // - github.com/goccy/go-json
// - github.com/segmentio/encoding // - github.com/segmentio/encoding
// - github.com/ugorji/go/codec // - github.com/ugorji/go/codec
@ -918,8 +921,9 @@ func mapiterinit(t *maptype, h *hmap, it *hiter) {
// but widely used packages access it using linkname. // but widely used packages access it using linkname.
// Notable members of the hall of shame include: // Notable members of the hall of shame include:
// - github.com/bytedance/sonic // - github.com/bytedance/sonic
// - github.com/ugorji/go/codec // - github.com/cloudwego/frugal
// - github.com/segmentio/encoding // - github.com/segmentio/encoding
// - github.com/ugorji/go/codec
// - gonum.org/v1/gonum // - gonum.org/v1/gonum
// //
// Do not remove or change the type signature. // Do not remove or change the type signature.
@ -1053,6 +1057,17 @@ next:
} }
// mapclear deletes all keys from a map. // mapclear deletes all keys from a map.
// It is called by the compiler.
//
// mapclear 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 mapclear
func mapclear(t *maptype, h *hmap) { func mapclear(t *maptype, h *hmap) {
if raceenabled && h != nil { if raceenabled && h != nil {
callerpc := getcallerpc() callerpc := getcallerpc()
@ -1371,6 +1386,7 @@ func advanceEvacuationMark(h *hmap, t *maptype, newbit uintptr) {
// reflect_makemap is for package reflect, // reflect_makemap is for package reflect,
// but widely used packages access it using linkname. // but widely used packages access it using linkname.
// Notable members of the hall of shame include: // Notable members of the hall of shame include:
// - gitee.com/quant1x/gox
// - github.com/modern-go/reflect2 // - github.com/modern-go/reflect2
// - github.com/goccy/go-json // - github.com/goccy/go-json
// - github.com/segmentio/encoding // - github.com/segmentio/encoding
@ -1420,6 +1436,7 @@ func reflect_makemap(t *maptype, cap int) *hmap {
// reflect_mapaccess is for package reflect, // reflect_mapaccess is for package reflect,
// but widely used packages access it using linkname. // but widely used packages access it using linkname.
// Notable members of the hall of shame include: // Notable members of the hall of shame include:
// - gitee.com/quant1x/gox
// - github.com/modern-go/reflect2 // - github.com/modern-go/reflect2
// //
// Do not remove or change the type signature. // Do not remove or change the type signature.
@ -1445,6 +1462,13 @@ func reflect_mapaccess_faststr(t *maptype, h *hmap, key string) unsafe.Pointer {
return elem return elem
} }
// reflect_mapassign is for package reflect,
// but widely used packages access it using linkname.
// Notable members of the hall of shame include:
// - gitee.com/quant1x/gox
//
// Do not remove or change the type signature.
//
//go:linkname reflect_mapassign reflect.mapassign0 //go:linkname reflect_mapassign reflect.mapassign0
func reflect_mapassign(t *maptype, h *hmap, key unsafe.Pointer, elem unsafe.Pointer) { func reflect_mapassign(t *maptype, h *hmap, key unsafe.Pointer, elem unsafe.Pointer) {
p := mapassign(t, h, key) p := mapassign(t, h, key)
@ -1471,6 +1495,7 @@ func reflect_mapdelete_faststr(t *maptype, h *hmap, key string) {
// but widely used packages access it using linkname. // but widely used packages access it using linkname.
// Notable members of the hall of shame include: // Notable members of the hall of shame include:
// - github.com/modern-go/reflect2 // - github.com/modern-go/reflect2
// - gitee.com/quant1x/gox
// //
// Do not remove or change the type signature. // Do not remove or change the type signature.
// See go.dev/issue/67401. // See go.dev/issue/67401.
@ -1483,6 +1508,7 @@ func reflect_mapiterinit(t *maptype, h *hmap, it *hiter) {
// reflect_mapiternext is for package reflect, // reflect_mapiternext is for package reflect,
// but widely used packages access it using linkname. // but widely used packages access it using linkname.
// Notable members of the hall of shame include: // Notable members of the hall of shame include:
// - gitee.com/quant1x/gox
// - github.com/modern-go/reflect2 // - github.com/modern-go/reflect2
// - github.com/goccy/go-json // - github.com/goccy/go-json
// //

View file

@ -103,6 +103,7 @@ func mapaccess2_fast32(t *maptype, h *hmap, key uint32) (unsafe.Pointer, bool) {
// but widely used packages access it using linkname. // but widely used packages access it using linkname.
// Notable members of the hall of shame include: // Notable members of the hall of shame include:
// - github.com/bytedance/sonic // - github.com/bytedance/sonic
// - github.com/cloudwego/frugal
// - github.com/ugorji/go/codec // - github.com/ugorji/go/codec
// //
// Do not remove or change the type signature. // Do not remove or change the type signature.

View file

@ -103,6 +103,7 @@ func mapaccess2_fast64(t *maptype, h *hmap, key uint64) (unsafe.Pointer, bool) {
// but widely used packages access it using linkname. // but widely used packages access it using linkname.
// Notable members of the hall of shame include: // Notable members of the hall of shame include:
// - github.com/bytedance/sonic // - github.com/bytedance/sonic
// - github.com/cloudwego/frugal
// - github.com/ugorji/go/codec // - github.com/ugorji/go/codec
// //
// Do not remove or change the type signature. // Do not remove or change the type signature.
@ -203,6 +204,7 @@ done:
// but widely used packages access it using linkname. // but widely used packages access it using linkname.
// Notable members of the hall of shame include: // Notable members of the hall of shame include:
// - github.com/bytedance/sonic // - github.com/bytedance/sonic
// - github.com/cloudwego/frugal
// - github.com/ugorji/go/codec // - github.com/ugorji/go/codec
// //
// Do not remove or change the type signature. // Do not remove or change the type signature.

View file

@ -213,6 +213,7 @@ dohash:
// but widely used packages access it using linkname. // but widely used packages access it using linkname.
// Notable members of the hall of shame include: // Notable members of the hall of shame include:
// - github.com/bytedance/sonic // - github.com/bytedance/sonic
// - github.com/cloudwego/frugal
// - github.com/ugorji/go/codec // - github.com/ugorji/go/codec
// //
// Do not remove or change the type signature. // Do not remove or change the type signature.

View file

@ -211,6 +211,7 @@ func wbMove(typ *_type, dst, src unsafe.Pointer) {
// reflect_typedmemmove is meant for package reflect, // reflect_typedmemmove is meant for package reflect,
// but widely used packages access it using linkname. // but widely used packages access it using linkname.
// Notable members of the hall of shame include: // Notable members of the hall of shame include:
// - gitee.com/quant1x/gox
// - github.com/goccy/json // - github.com/goccy/json
// - github.com/modern-go/reflect2 // - github.com/modern-go/reflect2
// - github.com/ugorji/go/codec // - github.com/ugorji/go/codec
@ -334,6 +335,7 @@ func typedslicecopy(typ *_type, dstPtr unsafe.Pointer, dstLen int, srcPtr unsafe
// reflect_typedslicecopy is meant for package reflect, // reflect_typedslicecopy is meant for package reflect,
// but widely used packages access it using linkname. // but widely used packages access it using linkname.
// Notable members of the hall of shame include: // Notable members of the hall of shame include:
// - gitee.com/quant1x/gox
// - github.com/modern-go/reflect2 // - github.com/modern-go/reflect2
// - github.com/segmentio/encoding // - github.com/segmentio/encoding
// //

View file

@ -220,6 +220,7 @@ var gcphase uint32
// but widely used packages access it using linkname. // but widely used packages access it using linkname.
// Notable members of the hall of shame include: // Notable members of the hall of shame include:
// - github.com/bytedance/sonic // - github.com/bytedance/sonic
// - github.com/cloudwego/frugal
// //
// Do not remove or change the type signature. // Do not remove or change the type signature.
// See go.dev/issue/67401. // See go.dev/issue/67401.

View file

@ -7039,6 +7039,7 @@ func setMaxThreads(in int) (out int) {
// but widely used packages access it using linkname. // but widely used packages access it using linkname.
// Notable members of the hall of shame include: // Notable members of the hall of shame include:
// - github.com/bytedance/gopkg // - github.com/bytedance/gopkg
// - github.com/choleraehyq/pid
// //
// Do not remove or change the type signature. // Do not remove or change the type signature.
// See go.dev/issue/67401. // See go.dev/issue/67401.
@ -7057,6 +7058,7 @@ func procPin() int {
// but widely used packages access it using linkname. // but widely used packages access it using linkname.
// Notable members of the hall of shame include: // Notable members of the hall of shame include:
// - github.com/bytedance/gopkg // - github.com/bytedance/gopkg
// - github.com/choleraehyq/pid
// //
// Do not remove or change the type signature. // Do not remove or change the type signature.
// See go.dev/issue/67401. // See go.dev/issue/67401.
@ -7097,6 +7099,7 @@ func sync_atomic_runtime_procUnpin() {
// sync_runtime_canSpin should be an internal detail, // sync_runtime_canSpin should be an internal detail,
// but widely used packages access it using linkname. // but widely used packages access it using linkname.
// Notable members of the hall of shame include: // Notable members of the hall of shame include:
// - github.com/livekit/protocol
// - gvisor.dev/gvisor // - gvisor.dev/gvisor
// //
// Do not remove or change the type signature. // Do not remove or change the type signature.
@ -7122,6 +7125,7 @@ func sync_runtime_canSpin(i int) bool {
// sync_runtime_doSpin should be an internal detail, // sync_runtime_doSpin should be an internal detail,
// but widely used packages access it using linkname. // but widely used packages access it using linkname.
// Notable members of the hall of shame include: // Notable members of the hall of shame include:
// - github.com/livekit/protocol
// - gvisor.dev/gvisor // - gvisor.dev/gvisor
// //
// Do not remove or change the type signature. // Do not remove or change the type signature.

View file

@ -8,6 +8,14 @@ import "unsafe"
var labelSync uintptr var labelSync uintptr
// runtime_setProfLabel should be an internal detail,
// but widely used packages access it using linkname.
// Notable members of the hall of shame include:
// - github.com/DataDog/datadog-agent
//
// Do not remove or change the type signature.
// See go.dev/issue/67401.
//
//go:linkname runtime_setProfLabel runtime/pprof.runtime_setProfLabel //go:linkname runtime_setProfLabel runtime/pprof.runtime_setProfLabel
func runtime_setProfLabel(labels unsafe.Pointer) { func runtime_setProfLabel(labels unsafe.Pointer) {
// Introduce race edge for read-back via profile. // Introduce race edge for read-back via profile.
@ -34,6 +42,14 @@ func runtime_setProfLabel(labels unsafe.Pointer) {
getg().labels = labels getg().labels = labels
} }
// runtime_getProfLabel should be an internal detail,
// but widely used packages access it using linkname.
// Notable members of the hall of shame include:
// - github.com/DataDog/datadog-agent
//
// Do not remove or change the type signature.
// See go.dev/issue/67401.
//
//go:linkname runtime_getProfLabel runtime/pprof.runtime_getProfLabel //go:linkname runtime_getProfLabel runtime/pprof.runtime_getProfLabel
func runtime_getProfLabel() unsafe.Pointer { func runtime_getProfLabel() unsafe.Pointer {
return getg().labels return getg().labels

View file

@ -617,6 +617,7 @@ func releasem(mp *m) {
// reflect_typelinks is meant for package reflect, // reflect_typelinks is meant for package reflect,
// but widely used packages access it using linkname. // but widely used packages access it using linkname.
// Notable members of the hall of shame include: // Notable members of the hall of shame include:
// - gitee.com/quant1x/gox
// - github.com/goccy/json // - github.com/goccy/json
// - github.com/modern-go/reflect2 // - github.com/modern-go/reflect2
// - github.com/vmware/govmomi // - github.com/vmware/govmomi
@ -638,6 +639,14 @@ func reflect_typelinks() ([]unsafe.Pointer, [][]int32) {
// reflect_resolveNameOff resolves a name offset from a base pointer. // reflect_resolveNameOff resolves a name offset from a base pointer.
// //
// reflect_resolveNameOff is for package reflect,
// but widely used packages access it using linkname.
// Notable members of the hall of shame include:
// - github.com/agiledragon/gomonkey/v2
//
// Do not remove or change the type signature.
// See go.dev/issue/67401.
//
//go:linkname reflect_resolveNameOff reflect.resolveNameOff //go:linkname reflect_resolveNameOff reflect.resolveNameOff
func reflect_resolveNameOff(ptrInModule unsafe.Pointer, off int32) unsafe.Pointer { func reflect_resolveNameOff(ptrInModule unsafe.Pointer, off int32) unsafe.Pointer {
return unsafe.Pointer(resolveNameOff(ptrInModule, nameOff(off)).Bytes) return unsafe.Pointer(resolveNameOff(ptrInModule, nameOff(off)).Bytes)
@ -648,6 +657,7 @@ func reflect_resolveNameOff(ptrInModule unsafe.Pointer, off int32) unsafe.Pointe
// reflect_resolveTypeOff is meant for package reflect, // reflect_resolveTypeOff is meant for package reflect,
// but widely used packages access it using linkname. // but widely used packages access it using linkname.
// Notable members of the hall of shame include: // Notable members of the hall of shame include:
// - gitee.com/quant1x/gox
// - github.com/modern-go/reflect2 // - github.com/modern-go/reflect2
// //
// Do not remove or change the type signature. // Do not remove or change the type signature.
@ -660,6 +670,15 @@ func reflect_resolveTypeOff(rtype unsafe.Pointer, off int32) unsafe.Pointer {
// reflect_resolveTextOff resolves a function pointer offset from a base type. // reflect_resolveTextOff resolves a function pointer offset from a base type.
// //
// reflect_resolveTextOff is for package reflect,
// but widely used packages access it using linkname.
// Notable members of the hall of shame include:
// - github.com/cloudwego/frugal
// - github.com/agiledragon/gomonkey/v2
//
// Do not remove or change the type signature.
// See go.dev/issue/67401.
//
//go:linkname reflect_resolveTextOff reflect.resolveTextOff //go:linkname reflect_resolveTextOff reflect.resolveTextOff
func reflect_resolveTextOff(rtype unsafe.Pointer, off int32) unsafe.Pointer { func reflect_resolveTextOff(rtype unsafe.Pointer, off int32) unsafe.Pointer {
return toRType((*_type)(rtype)).textOff(textOff(off)) return toRType((*_type)(rtype)).textOff(textOff(off))

View file

@ -166,6 +166,7 @@ func makeslice64(et *_type, len64, cap64 int64) unsafe.Pointer {
// but widely used packages access it using linkname. // but widely used packages access it using linkname.
// Notable members of the hall of shame include: // Notable members of the hall of shame include:
// - github.com/bytedance/sonic // - github.com/bytedance/sonic
// - github.com/chenzhuoyu/iasm
// - github.com/ugorji/go/codec // - github.com/ugorji/go/codec
// //
// Do not remove or change the type signature. // Do not remove or change the type signature.

View file

@ -78,6 +78,16 @@ func concatstring5(buf *tmpBuf, a0, a1, a2, a3, a4 string) string {
// n is the length of the slice. // n is the length of the slice.
// Buf is a fixed-size buffer for the result, // Buf is a fixed-size buffer for the result,
// it is not nil if the result does not escape. // it is not nil if the result does not escape.
//
// slicebytetostring 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 slicebytetostring
func slicebytetostring(buf *tmpBuf, ptr *byte, n int) string { func slicebytetostring(buf *tmpBuf, ptr *byte, n int) string {
if n == 0 { if n == 0 {
// Turns out to be a relatively common case. // Turns out to be a relatively common case.

View file

@ -87,6 +87,8 @@ func badsystemstack() {
// but widely used packages access it using linkname. // but widely used packages access it using linkname.
// Notable members of the hall of shame include: // Notable members of the hall of shame include:
// - github.com/bytedance/sonic // - github.com/bytedance/sonic
// - github.com/chenzhuoyu/iasm
// - github.com/cloudwego/frugal
// - github.com/dgraph-io/ristretto // - github.com/dgraph-io/ristretto
// - github.com/outcaste-io/ristretto // - github.com/outcaste-io/ristretto
// //
@ -120,6 +122,7 @@ func reflect_memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr) {
// but widely used packages access it using linkname. // but widely used packages access it using linkname.
// Notable members of the hall of shame include: // Notable members of the hall of shame include:
// - github.com/bytedance/sonic // - github.com/bytedance/sonic
// - github.com/cloudwego/frugal
// - github.com/ebitengine/purego // - github.com/ebitengine/purego
// - github.com/tetratelabs/wazero // - github.com/tetratelabs/wazero
// - github.com/ugorji/go/codec // - github.com/ugorji/go/codec
@ -165,6 +168,7 @@ func memequal(a, b unsafe.Pointer, size uintptr) bool
// Notable members of the hall of shame include: // Notable members of the hall of shame include:
// - github.com/bytedance/gopkg // - github.com/bytedance/gopkg
// - github.com/ebitengine/purego // - github.com/ebitengine/purego
// - github.com/puzpuzpuz/xsync/v3
// //
// Do not remove or change the type signature. // Do not remove or change the type signature.
// See go.dev/issue/67401. // See go.dev/issue/67401.
@ -345,7 +349,18 @@ func getclosureptr() uintptr
func asmcgocall(fn, arg unsafe.Pointer) int32 func asmcgocall(fn, arg unsafe.Pointer) int32
func morestack() func morestack()
// morestack_noctxt 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 morestack_noctxt
func morestack_noctxt() func morestack_noctxt()
func rt0_go() func rt0_go()
// return0 is a stub used to return 0 from deferproc. // return0 is a stub used to return 0 from deferproc.
@ -435,6 +450,7 @@ func gcWriteBarrier1()
// but widely used packages access it using linkname. // but widely used packages access it using linkname.
// Notable members of the hall of shame include: // Notable members of the hall of shame include:
// - github.com/bytedance/sonic // - github.com/bytedance/sonic
// - github.com/cloudwego/frugal
// //
// Do not remove or change the type signature. // Do not remove or change the type signature.
// See go.dev/issue/67401. // See go.dev/issue/67401.

View file

@ -437,8 +437,19 @@ type modulehash struct {
// To make sure the map isn't collected, we keep a second reference here. // To make sure the map isn't collected, we keep a second reference here.
var pinnedTypemaps []map[typeOff]*_type 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 lastmoduledatap *moduledata // linker symbol
var modulesSlice *[]*moduledata // see activeModules var modulesSlice *[]*moduledata // see activeModules
// activeModules returns a slice of active modules. // activeModules returns a slice of active modules.
@ -547,6 +558,15 @@ func moduledataverify() {
const debugPcln = false 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) { func moduledataverify1(datap *moduledata) {
// Check that the pclntab's format is valid. // Check that the pclntab's format is valid.
hdr := datap.pcHeader hdr := datap.pcHeader
@ -674,6 +694,16 @@ func (md *moduledata) funcName(nameOff int32) string {
// If pc represents multiple functions because of inlining, it returns // If pc represents multiple functions because of inlining, it returns
// the *Func describing the innermost function, but with an entry of // the *Func describing the innermost function, but with an entry of
// the outermost function. // 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 { func FuncForPC(pc uintptr) *Func {
f := findfunc(pc) f := findfunc(pc)
if !f.valid() { if !f.valid() {
@ -793,7 +823,16 @@ func (f funcInfo) entry() uintptr {
// It is nosplit because it's part of the isgoexception // It is nosplit because it's part of the isgoexception
// implementation. // 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:nosplit
//go:linkname findfunc
func findfunc(pc uintptr) funcInfo { func findfunc(pc uintptr) funcInfo {
datap := findmoduledatap(pc) datap := findmoduledatap(pc)
if datap == nil { 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. // 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) { func pcdatavalue2(f funcInfo, table uint32, targetpc uintptr) (int32, uintptr) {
if table >= f.npcdata { if table >= f.npcdata {
return -1, 0 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 returns a pointer to the ith funcdata for f.
// funcdata should be kept in sync with cmd/link:writeFuncs. // 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 { func funcdata(f funcInfo, i uint8) unsafe.Pointer {
if i < 0 || i >= f.nfuncdata { if i < 0 || i >= f.nfuncdata {
return nil 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 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) { func step(p []byte, pc *uintptr, val *int32, first bool) (newp []byte, ok bool) {
// For both uvdelta and pcdelta, the common case (~70%) // For both uvdelta and pcdelta, the common case (~70%)
// is that they are a single byte. If so, avoid calling readvarint. // 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 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 //go:nowritebarrier
func stackmapdata(stkmap *stackmap, n int32) bitvector { func stackmapdata(stkmap *stackmap, n int32) bitvector {
// Check this invariant only when stackDebug is on at all. // Check this invariant only when stackDebug is on at all.

View file

@ -380,6 +380,15 @@ func nanotime1() int64 {
} }
func nanotime_trampoline() func nanotime_trampoline()
// walltime should be an internal detail,
// but widely used packages access it 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 walltime
//go:nosplit //go:nosplit
//go:cgo_unsafe_args //go:cgo_unsafe_args
func walltime() (int64, int32) { func walltime() (int64, int32) {

View file

@ -36,6 +36,14 @@ func nanotime() int64 {
// overrideWrite allows write to be redirected externally, by // overrideWrite allows write to be redirected externally, by
// linkname'ing this and set it to a write function. // linkname'ing this and set it to a write function.
// //
// overrideWrite should be an internal detail,
// but widely used packages access it using linkname.
// Notable members of the hall of shame include:
// - golang.zx2c4.com/wireguard/windows
//
// Do not remove or change the type signature.
// See go.dev/issue/67401.
//
//go:linkname overrideWrite //go:linkname overrideWrite
var overrideWrite func(fd uintptr, p unsafe.Pointer, n int32) int32 var overrideWrite func(fd uintptr, p unsafe.Pointer, n int32) int32

View file

@ -11,6 +11,16 @@ package runtime
import _ "unsafe" // for go:linkname import _ "unsafe" // for go:linkname
// time_now should be an internal detail,
// but widely used packages access it using linkname.
// Notable members of the hall of shame include:
// - gitee.com/quant1x/gox
// - github.com/sethvargo/go-limiter
// - github.com/ulule/limiter/v3
//
// Do not remove or change the type signature.
// See go.dev/issue/67401.
//
//go:linkname time_now time.now //go:linkname time_now time.now
func time_now() (sec int64, nsec int32, mono int64) { func time_now() (sec int64, nsec int32, mono int64) {
sec, nsec = walltime() sec, nsec = walltime()

View file

@ -106,6 +106,15 @@ func reflectOffsUnlock() {
unlock(&reflectOffs.lock) unlock(&reflectOffs.lock)
} }
// resolveNameOff 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 resolveNameOff
func resolveNameOff(ptrInModule unsafe.Pointer, off nameOff) name { func resolveNameOff(ptrInModule unsafe.Pointer, off nameOff) name {
if off == 0 { if off == 0 {
return name{} return name{}
@ -140,6 +149,15 @@ func (t rtype) nameOff(off nameOff) name {
return resolveNameOff(unsafe.Pointer(t.Type), off) return resolveNameOff(unsafe.Pointer(t.Type), off)
} }
// resolveTypeOff 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 resolveTypeOff
func resolveTypeOff(ptrInModule unsafe.Pointer, off typeOff) *_type { func resolveTypeOff(ptrInModule unsafe.Pointer, off typeOff) *_type {
if off == 0 || off == -1 { if off == 0 || off == -1 {
// -1 is the sentinel value for unreachable code. // -1 is the sentinel value for unreachable code.

View file

@ -13,5 +13,3 @@ import _ "unsafe"
// in new code. // in new code.
//go:linkname absClock //go:linkname absClock
//go:linkname absDate
//go:linkname nextStdChunk

View file

@ -7,6 +7,7 @@ package time
import ( import (
"errors" "errors"
"internal/stringslite" "internal/stringslite"
_ "unsafe" // for linkname
) )
// These are predefined layouts for use in [Time.Format] and [time.Parse]. // These are predefined layouts for use in [Time.Format] and [time.Parse].
@ -184,6 +185,16 @@ func startsWithLowerCase(str string) bool {
// nextStdChunk finds the first occurrence of a std string in // nextStdChunk finds the first occurrence of a std string in
// layout and returns the text before, the std string, and the text after. // layout and returns the text before, the std string, and the text after.
//
// nextStdChunk should be an internal detail,
// but widely used packages access it using linkname.
// Notable members of the hall of shame include:
// - github.com/searKing/golang/go
//
// Do not remove or change the type signature.
// See go.dev/issue/67401.
//
//go:linkname nextStdChunk
func nextStdChunk(layout string) (prefix string, std int, suffix string) { func nextStdChunk(layout string) (prefix string, std int, suffix string) {
for i := 0; i < len(layout); i++ { for i := 0; i < len(layout); i++ {
switch c := int(layout[i]); c { switch c := int(layout[i]); c {

View file

@ -988,6 +988,16 @@ func (t Time) date(full bool) (year int, month Month, day int, yday int) {
} }
// absDate is like date but operates on an absolute time. // absDate is like date but operates on an absolute time.
//
// absDate should be an internal detail,
// but widely used packages access it 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 absDate
func absDate(abs uint64, full bool) (year int, month Month, day int, yday int) { func absDate(abs uint64, full bool) (year int, month Month, day int, yday int) {
// Split into time and day. // Split into time and day.
d := abs / secondsPerDay d := abs / secondsPerDay