]> Cypherpunks repositories - gostls13.git/commitdiff
all: document legacy //go:linkname for final round of modules
authorRuss Cox <rsc@golang.org>
Thu, 23 May 2024 03:06:30 +0000 (23:06 -0400)
committerGopher Robot <gobot@golang.org>
Wed, 29 May 2024 17:58:53 +0000 (17:58 +0000)
Add linknames for most modules with ≥50 dependents.
Add linknames for a few other modules that we know
are important but are below 50.

Remove linknames from badlinkname.go that do not merit
inclusion (very small number of dependents).
We can add them back later if the need arises.

Fixes #67401. (For now.)

Change-Id: I1e49fec0292265256044d64b1841d366c4106002
Reviewed-on: https://go-review.googlesource.com/c/go/+/587756
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Bypass: Russ Cox <rsc@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
46 files changed:
src/bytes/bytes.go
src/crypto/tls/badlinkname.go [deleted file]
src/crypto/tls/cipher_suites.go
src/crypto/tls/defaults.go
src/crypto/x509/badlinkname.go [deleted file]
src/crypto/x509/root.go
src/database/sql/badlinkname.go [deleted file]
src/database/sql/convert.go
src/debug/buildinfo/buildinfo.go
src/go/build/badlinkname.go [deleted file]
src/internal/bytealg/compare_generic.go
src/internal/testlog/badlinkname.go [deleted file]
src/internal/testlog/exit.go
src/math/unsafe.go
src/mime/multipart/badlinkname.go [deleted file]
src/net/badlinkname.go [deleted file]
src/net/dnsconfig.go
src/net/http/badlinkname.go [deleted file]
src/net/http/request.go
src/net/http/roundtrip.go
src/net/http/server.go
src/net/ipsock.go
src/net/ipsock_posix.go
src/net/net.go
src/reflect/badlinkname.go
src/reflect/type.go
src/runtime/alg.go
src/runtime/badlinkname.go
src/runtime/cpuprof.go
src/runtime/iface.go
src/runtime/linkname.go
src/runtime/malloc.go
src/runtime/map.go
src/runtime/mbarrier.go
src/runtime/panic.go
src/runtime/proc.go
src/runtime/rand.go
src/runtime/runtime1.go
src/runtime/runtime2.go
src/runtime/sema.go
src/runtime/stubs.go
src/runtime/symtab.go
src/syscall/linkname_darwin.go
src/syscall/linkname_openbsd.go
src/syscall/linkname_unix.go [new file with mode: 0644]
src/time/time.go

index 23edd5a4be638a8c593830fdcd4335c687f5a8b1..2a07d2084e8efb0470005b5dc18542aa6cb7c89c 100644 (file)
@@ -10,6 +10,7 @@ import (
        "internal/bytealg"
        "unicode"
        "unicode/utf8"
+       _ "unsafe" // for linkname
 )
 
 // Equal reports whether a and b
@@ -568,6 +569,18 @@ func Map(mapping func(r rune) rune, s []byte) []byte {
        return b
 }
 
+// Despite being an exported symbol,
+// Repeat is linknamed by widely used packages.
+// Notable members of the hall of shame include:
+//   - gitee.com/quant1x/num
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+// Note that this comment is not part of the doc comment.
+//
+//go:linkname Repeat
+
 // Repeat returns a new byte slice consisting of count copies of b.
 //
 // It panics if count is negative or if the result of (len(b) * count)
diff --git a/src/crypto/tls/badlinkname.go b/src/crypto/tls/badlinkname.go
deleted file mode 100644 (file)
index 841030a..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright 2024 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package tls
-
-import _ "unsafe"
-
-// As of Go 1.22, the symbols below are found to be pulled via
-// linkname in the wild. We provide a push linkname here, to
-// keep them accessible with pull linknames.
-// This may change in the future. Please do not depend on them
-// in new code.
-
-//go:linkname cipherSuiteTLS13ByID
-//go:linkname errShutdown
-
-// The compiler doesn't allow linknames on methods, for good reasons.
-// We use this trick to push linknames of the methods.
-// Do not call them in this package.
-
-//go:linkname badlinkname_halfConn_incSeq crypto/tls.(*halfConn).incSeq
-func badlinkname_halfConn_incSeq(*halfConn)
index b2f330bc63ebe571b583b470fde80b6d61419279..eebc66880d631f841018634f944ec97ae57e9797 100644 (file)
@@ -202,6 +202,7 @@ type cipherSuiteTLS13 struct {
 // but widely used packages access it using linkname.
 // Notable members of the hall of shame include:
 //   - github.com/quic-go/quic-go
+//   - github.com/sagernet/quic-go
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
@@ -537,6 +538,7 @@ func aeadAESGCM(key, noncePrefix []byte) aead {
 // but widely used packages access it using linkname.
 // Notable members of the hall of shame include:
 //   - github.com/xtls/xray-core
+//   - github.com/v2fly/v2ray-core
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
index ef1a6137da32b1c4d9ff55582d42074c69a06924..9b28acdc2d866af5f38997c319626308dd5938a1 100644 (file)
@@ -62,6 +62,7 @@ func defaultCipherSuites() []uint16 {
 // but widely used packages access it using linkname.
 // Notable members of the hall of shame include:
 //   - github.com/quic-go/quic-go
+//   - github.com/sagernet/quic-go
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
@@ -77,6 +78,7 @@ var defaultCipherSuitesTLS13 = []uint16{
 // but widely used packages access it using linkname.
 // Notable members of the hall of shame include:
 //   - github.com/quic-go/quic-go
+//   - github.com/sagernet/quic-go
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
diff --git a/src/crypto/x509/badlinkname.go b/src/crypto/x509/badlinkname.go
deleted file mode 100644 (file)
index c119a5f..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2024 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package x509
-
-import _ "unsafe"
-
-// As of Go 1.22, the symbols below are found to be pulled via
-// linkname in the wild. We provide a push linkname here, to
-// keep them accessible with pull linknames.
-// This may change in the future. Please do not depend on them
-// in new code.
-
-//go:linkname systemRoots
index b454af2c4c19d2ca4832bb5b314dbd375b7e9eb8..fbd43430afa8f9b3063e75c58095ed815cd57f84 100644 (file)
@@ -7,8 +7,18 @@ package x509
 import (
        "internal/godebug"
        "sync"
+       _ "unsafe" // for linkname
 )
 
+// systemRoots should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - github.com/breml/rootcerts
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname systemRoots
 var (
        once           sync.Once
        systemRootsMu  sync.RWMutex
diff --git a/src/database/sql/badlinkname.go b/src/database/sql/badlinkname.go
deleted file mode 100644 (file)
index 95a2354..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2024 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package sql
-
-import _ "unsafe"
-
-// As of Go 1.22, the symbols below are found to be pulled via
-// linkname in the wild. We provide a push linkname here, to
-// keep them accessible with pull linknames.
-// This may change in the future. Please do not depend on them
-// in new code.
-
-//go:linkname convertAssign
index 8f71d5b8670c390c7fd2763bda0932c1ef74c970..c261046b187e5271861d75cedb2ff872f76dc721 100644 (file)
@@ -16,6 +16,7 @@ import (
        "time"
        "unicode"
        "unicode/utf8"
+       _ "unsafe" // for linkname
 )
 
 var errNilPtr = errors.New("destination pointer is nil") // embedded in descriptive error
@@ -207,6 +208,16 @@ func driverArgsConnLocked(ci driver.Conn, ds *driverStmt, args []any) ([]driver.
 
 // convertAssign is the same as convertAssignRows, but without the optional
 // rows argument.
+//
+// convertAssign should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - ariga.io/entcache
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname convertAssign
 func convertAssign(dest, src any) error {
        return convertAssignRows(dest, src, nil)
 }
index 1bfdd02a67932ef5add850cacba0b1a9e5fe5929..1dd70a9f33a41ce198813437905a6eb3eb64e110 100644 (file)
@@ -25,6 +25,7 @@ import (
        "io/fs"
        "os"
        "runtime/debug"
+       _ "unsafe" // for linkname
 )
 
 // Type alias for build info. We cannot move the types here, since
@@ -32,22 +33,30 @@ import (
 // a much larger dependency.
 type BuildInfo = debug.BuildInfo
 
-var (
-       // errUnrecognizedFormat is returned when a given executable file doesn't
-       // appear to be in a known format, or it breaks the rules of that format,
-       // or when there are I/O errors reading the file.
-       errUnrecognizedFormat = errors.New("unrecognized file format")
-
-       // errNotGoExe is returned when a given executable file is valid but does
-       // not contain Go build information.
-       errNotGoExe = errors.New("not a Go executable")
-
-       // The build info blob left by the linker is identified by
-       // a 16-byte header, consisting of buildInfoMagic (14 bytes),
-       // the binary's pointer size (1 byte),
-       // and whether the binary is big endian (1 byte).
-       buildInfoMagic = []byte("\xff Go buildinf:")
-)
+// errUnrecognizedFormat is returned when a given executable file doesn't
+// appear to be in a known format, or it breaks the rules of that format,
+// or when there are I/O errors reading the file.
+var errUnrecognizedFormat = errors.New("unrecognized file format")
+
+// errNotGoExe is returned when a given executable file is valid but does
+// not contain Go build information.
+//
+// errNotGoExe should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - github.com/quay/claircore
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname errNotGoExe
+var errNotGoExe = errors.New("not a Go executable")
+
+// The build info blob left by the linker is identified by
+// a 16-byte header, consisting of buildInfoMagic (14 bytes),
+// the binary's pointer size (1 byte),
+// and whether the binary is big endian (1 byte).
+var buildInfoMagic = []byte("\xff Go buildinf:")
 
 // ReadFile returns build information embedded in a Go binary
 // file at the given path. Most information is only available for binaries built
diff --git a/src/go/build/badlinkname.go b/src/go/build/badlinkname.go
deleted file mode 100644 (file)
index ad2ed2b..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2024 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package build
-
-import _ "unsafe"
-
-// As of Go 1.22, the symbols below are found to be pulled via
-// linkname in the wild. We provide a push linkname here, to
-// keep them accessible with pull linknames.
-// This may change in the future. Please do not depend on them
-// in new code.
-
-// The compiler doesn't allow linknames on methods, for good reasons.
-// We use this trick to push linknames of the methods.
-// Do not call them in this package.
-
-//go:linkname badlinkname_Context_goodOSArchFile go/build.(*Context).goodOSArchFile
-func badlinkname_Context_goodOSArchFile(*Context, string, map[string]bool) bool
index 204b9a9b1a38c8bafd997cb092dad62c58e7207c..614ae8b8cf229302c8512d4b07232450558da7fd 100644 (file)
@@ -44,6 +44,7 @@ func CompareString(a, b string) int {
 // runtime.cmpstring should be an internal detail,
 // but widely used packages access it using linkname.
 // Notable members of the hall of shame include:
+//   - gitee.com/zhaochuninhefei/gmgo
 //   - github.com/bytedance/gopkg
 //   - github.com/songzhibin97/gkit
 //
diff --git a/src/internal/testlog/badlinkname.go b/src/internal/testlog/badlinkname.go
deleted file mode 100644 (file)
index 4c53586..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2024 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package testlog
-
-import _ "unsafe"
-
-// As of Go 1.22, the symbols below are found to be pulled via
-// linkname in the wild. We provide a push linkname here, to
-// keep them accessible with pull linknames.
-// This may change in the future. Please do not depend on them
-// in new code.
-
-//go:linkname SetPanicOnExit0
index e15defdb5b0b72db65d61dece21c15864b843270..b985c6b3f79b128aeba95d086d7a9e6d56be2cfd 100644 (file)
@@ -4,7 +4,10 @@
 
 package testlog
 
-import "sync"
+import (
+       "sync"
+       _ "unsafe" // for linkname
+)
 
 // PanicOnExit0 reports whether to panic on a call to os.Exit(0).
 // This is in the testlog package because, like other definitions in
@@ -26,6 +29,15 @@ var panicOnExit0 struct {
 }
 
 // SetPanicOnExit0 sets panicOnExit0 to v.
+//
+// SetPanicOnExit0 should be an internal detail,
+// but alternate implementations of go test in other
+// build systems may need to access it using linkname.
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname SetPanicOnExit0
 func SetPanicOnExit0(v bool) {
        panicOnExit0.mu.Lock()
        defer panicOnExit0.mu.Unlock()
index e59f50ca62e5cc4ecdcc334b319093c5ef6a905d..e251f62a2a138508484a76e6dd66f3d8675efe3f 100644 (file)
@@ -6,6 +6,18 @@ package math
 
 import "unsafe"
 
+// Despite being an exported symbol,
+// Float32bits is linknamed by widely used packages.
+// Notable members of the hall of shame include:
+//   - gitee.com/quant1x/num
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+// Note that this comment is not part of the doc comment.
+//
+//go:linkname Float32bits
+
 // Float32bits returns the IEEE 754 binary representation of f,
 // with the sign bit of f and the result in the same bit position.
 // Float32bits(Float32frombits(x)) == x.
diff --git a/src/mime/multipart/badlinkname.go b/src/mime/multipart/badlinkname.go
deleted file mode 100644 (file)
index 7e3b0cc..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2024 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package multipart
-
-import _ "unsafe"
-
-// As of Go 1.22, the symbols below are found to be pulled via
-// linkname in the wild. We provide a push linkname here, to
-// keep them accessible with pull linknames.
-// This may change in the future. Please do not depend on them
-// in new code.
-
-//go:linkname escapeQuotes
diff --git a/src/net/badlinkname.go b/src/net/badlinkname.go
deleted file mode 100644 (file)
index 57d6f61..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2024 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package net
-
-import _ "unsafe"
-
-// As of Go 1.22, the symbols below are found to be pulled via
-// linkname in the wild. We provide a push linkname here, to
-// keep them accessible with pull linknames.
-// This may change in the future. Please do not depend on them
-// in new code.
-
-//go:linkname defaultNS
index c86a70be5afd57aaab851f7b2c354460a350bd84..7919c3c3b5519c949aedd4ccd3a5a864d969145e 100644 (file)
@@ -8,12 +8,25 @@ import (
        "os"
        "sync/atomic"
        "time"
+       _ "unsafe"
 )
 
-var (
-       defaultNS   = []string{"127.0.0.1:53", "[::1]:53"}
-       getHostname = os.Hostname // variable for testing
-)
+// defaultNS is the default name servers to use in the absence of DNS configuration.
+//
+// defaultNS should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - github.com/pojntfx/hydrapp/hydrapp
+//   - github.com/mtibben/androiddnsfix
+//   - github.com/metacubex/mihomo
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname defaultNS
+var defaultNS = []string{"127.0.0.1:53", "[::1]:53"}
+
+var getHostname = os.Hostname // variable for testing
 
 type dnsConfig struct {
        servers       []string      // server addresses (in host:port form) to use
diff --git a/src/net/http/badlinkname.go b/src/net/http/badlinkname.go
deleted file mode 100644 (file)
index c714edf..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 2024 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package http
-
-import _ "unsafe"
-
-// As of Go 1.22, the symbols below are found to be pulled via
-// linkname in the wild. We provide a push linkname here, to
-// keep them accessible with pull linknames.
-// This may change in the future. Please do not depend on them
-// in new code.
-
-//go:linkname newBufioReader
-//go:linkname newBufioWriterSize
-//go:linkname putBufioReader
-//go:linkname putBufioWriter
-
-// The compiler doesn't allow linknames on methods, for good reasons.
-// We use this trick to push linknames of the methods.
-// Do not call them in this package.
-
-//go:linkname badlinkname_serverHandler_ServeHTTP net/http.serverHandler.ServeHTTP
-func badlinkname_serverHandler_ServeHTTP(serverHandler, ResponseWriter, *Request)
-
-//go:linkname badlinkname_Transport_Roundtrip net/http.(*Transport).RoundTrip
-func badlinkname_Transport_Roundtrip(*Transport, *Request) (*Response, error)
index ecb48a4364226ec4a2d6e7045199653e25db71a0..456615a79ad59b7e95eff0d69d2c7f03ac850a25 100644 (file)
@@ -1076,6 +1076,8 @@ func ReadRequest(b *bufio.Reader) (*Request, error) {
 // but widely used packages access it using linkname.
 // Notable members of the hall of shame include:
 //   - github.com/sagernet/sing
+//   - github.com/v2fly/v2ray-core/v4
+//   - github.com/v2fly/v2ray-core/v5
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
index 08c270179afb7095ca08f1650bef9c07e9d924c9..6674b8419f3d32327e7e09fffad953481a1bda06 100644 (file)
@@ -6,6 +6,19 @@
 
 package http
 
+import _ "unsafe" // for linkname
+
+// RoundTrip should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - github.com/erda-project/erda-infra
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname badRoundTrip net/http.(*Transport).RoundTrip
+func badRoundTrip(*Transport, *Request) (*Response, error)
+
 // RoundTrip implements the [RoundTripper] interface.
 //
 // For higher-level HTTP client support (such as handling of cookies
index 9786a68129246bc915c312e881aa5083163634e5..e28b107e9931ebba539f9f101910d96c3c27d0f5 100644 (file)
@@ -29,6 +29,7 @@ import (
        "sync"
        "sync/atomic"
        "time"
+       _ "unsafe" // for linkname
 
        "golang.org/x/net/http/httpguts"
 )
@@ -837,6 +838,15 @@ func bufioWriterPool(size int) *sync.Pool {
        return nil
 }
 
+// newBufioReader should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - github.com/gobwas/ws
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname newBufioReader
 func newBufioReader(r io.Reader) *bufio.Reader {
        if v := bufioReaderPool.Get(); v != nil {
                br := v.(*bufio.Reader)
@@ -848,11 +858,29 @@ func newBufioReader(r io.Reader) *bufio.Reader {
        return bufio.NewReader(r)
 }
 
+// putBufioReader should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - github.com/gobwas/ws
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname putBufioReader
 func putBufioReader(br *bufio.Reader) {
        br.Reset(nil)
        bufioReaderPool.Put(br)
 }
 
+// newBufioWriterSize should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - github.com/gobwas/ws
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname newBufioWriterSize
 func newBufioWriterSize(w io.Writer, size int) *bufio.Writer {
        pool := bufioWriterPool(size)
        if pool != nil {
@@ -865,6 +893,15 @@ func newBufioWriterSize(w io.Writer, size int) *bufio.Writer {
        return bufio.NewWriterSize(w, size)
 }
 
+// putBufioWriter should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - github.com/gobwas/ws
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname putBufioWriter
 func putBufioWriter(bw *bufio.Writer) {
        bw.Reset(nil)
        if pool := bufioWriterPool(bw.Available()); pool != nil {
@@ -3150,6 +3187,15 @@ type serverHandler struct {
        srv *Server
 }
 
+// ServeHTTP should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - github.com/erda-project/erda-infra
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname badServeHTTP net/http.serverHandler.ServeHTTP
 func (sh serverHandler) ServeHTTP(rw ResponseWriter, req *Request) {
        handler := sh.srv.Handler
        if handler == nil {
@@ -3162,6 +3208,8 @@ func (sh serverHandler) ServeHTTP(rw ResponseWriter, req *Request) {
        handler.ServeHTTP(rw, req)
 }
 
+func badServeHTTP(serverHandler, ResponseWriter, *Request)
+
 // AllowQuerySemicolons returns a handler that serves requests by converting any
 // unescaped semicolons in the URL query to ampersands, and invoking the handler h.
 //
index 176dbc748e66c83cc311261400cc5496b34da2d4..496faf346ec1e0e33ba5c3779d4455d5d94bd154 100644 (file)
@@ -9,6 +9,7 @@ import (
        "internal/bytealg"
        "runtime"
        "sync"
+       _ "unsafe" // for linkname
 )
 
 // BUG(rsc,mikio): On DragonFly BSD and OpenBSD, listening on the
@@ -307,6 +308,17 @@ func (r *Resolver) internetAddrList(ctx context.Context, net, addr string) (addr
        return filterAddrList(filter, ips, inetaddr, host)
 }
 
+// loopbackIP should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - github.com/database64128/tfo-go/v2
+//   - github.com/metacubex/tfo-go
+//   - github.com/sagernet/tfo-go
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname loopbackIP
 func loopbackIP(net string) IP {
        if net != "" && net[len(net)-1] == '6' {
                return IPv6loopback
index 67ce1479c647cd578464ddd7c2038c3295132707..2aeabd44873f223f49aadb73ead56b6ef9b4dc6b 100644 (file)
@@ -12,6 +12,7 @@ import (
        "net/netip"
        "runtime"
        "syscall"
+       _ "unsafe" // for linkname
 )
 
 // probe probes IPv4, IPv6 and IPv4-mapped IPv6 communication
@@ -118,6 +119,18 @@ func (p *ipStackCapabilities) probe() {
 // Note that the latest DragonFly BSD and OpenBSD kernels allow
 // neither "net.inet6.ip6.v6only=1" change nor IPPROTO_IPV6 level
 // IPV6_V6ONLY socket option setting.
+//
+// favoriteAddrFamily should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - github.com/database64128/tfo-go/v2
+//   - github.com/metacubex/tfo-go
+//   - github.com/sagernet/tfo-go
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname favoriteAddrFamily
 func favoriteAddrFamily(network string, laddr, raddr sockaddr, mode string) (family int, ipv6only bool) {
        switch network[len(network)-1] {
        case '4':
@@ -192,6 +205,17 @@ func ipToSockaddrInet6(ip IP, port int, zone string) (syscall.SockaddrInet6, err
        return sa, nil
 }
 
+// ipToSockaddr should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - github.com/database64128/tfo-go/v2
+//   - github.com/metacubex/tfo-go
+//   - github.com/sagernet/tfo-go
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname ipToSockaddr
 func ipToSockaddr(family int, ip IP, port int, zone string) (syscall.Sockaddr, error) {
        switch family {
        case syscall.AF_INET:
index deaeea40818a3f7fdb26b9a525b90ab0c185b4d9..02687edbe6a8c648df1ed87896bc4378fc72895a 100644 (file)
@@ -94,6 +94,7 @@ import (
        "sync"
        "syscall"
        "time"
+       _ "unsafe" // for linkname
 )
 
 // Addr represents a network end point address.
@@ -372,6 +373,18 @@ var listenerBacklogCache struct {
 }
 
 // listenerBacklog is a caching wrapper around maxListenerBacklog.
+//
+// listenerBacklog should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - github.com/database64128/tfo-go/v2
+//   - github.com/metacubex/tfo-go
+//   - github.com/sagernet/tfo-go
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname listenerBacklog
 func listenerBacklog() int {
        listenerBacklogCache.Do(func() { listenerBacklogCache.val = maxListenerBacklog() })
        return listenerBacklogCache.val
index 62c5675158abc684e36f7d7619445f4a60e7e4f9..eb701bff033d145739d704b0fd6ecf185a38dafc 100644 (file)
@@ -6,13 +6,16 @@ package reflect
 
 import (
        "internal/abi"
+       "unsafe"
        _ "unsafe"
 )
 
 // Widely used packages access these symbols using linkname,
 // most notably:
-//     - github.com/goccy/go-json
-//     - github.com/goccy/go-reflect
+//  - github.com/goccy/go-json
+//  - github.com/goccy/go-reflect
+//  - github.com/sohaha/zlsgo
+//  - github.com/undefinedlabs/go-mpatch
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401
@@ -122,3 +125,6 @@ func badlinkname_rtype_String(*rtype) string
 
 //go:linkname badlinkname_rtype_ptrTo reflect.(*rtype).ptrTo
 func badlinkname_rtype_ptrTo(*rtype) *abi.Type
+
+//go:linkname badlinkname_Value_pointer reflect.(*Value).pointer
+func badlinkname_Value_pointer(Value) unsafe.Pointer
index af2d8ecf256a4e209fb3983b439482db565668c4..07e2bf16447bbb94238f5f07dc098ae29f949a00 100644 (file)
@@ -523,6 +523,15 @@ func resolveTextOff(rtype unsafe.Pointer, off int32) unsafe.Pointer
 // It returns a new ID that can be used as a typeOff or textOff, and will
 // be resolved correctly. Implemented in the runtime package.
 //
+// addReflectOff should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - github.com/goplus/reflectx
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname addReflectOff
 //go:noescape
 func addReflectOff(ptr unsafe.Pointer) int32
 
@@ -939,6 +948,7 @@ func canRangeFunc2(t *abi.Type) bool {
 // add should be an internal detail (and is trivially copyable),
 // but widely used packages access it using linkname.
 // Notable members of the hall of shame include:
+//   - github.com/pinpoint-apm/pinpoint-go-agent
 //   - github.com/vmware/govmomi
 //
 // Do not remove or change the type signature.
@@ -2924,6 +2934,7 @@ func appendVarint(x []byte, v uintptr) []byte {
 //   - fortio.org/log
 //   - github.com/goccy/go-json
 //   - github.com/goccy/go-reflect
+//   - github.com/sohaha/zlsgo
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
index c55f916a7a44b6073ae870436d4f648551199887..bfb9fa1d297bcac7288cee7c90d55a6c12ea0c7d 100644 (file)
@@ -57,6 +57,9 @@ var useAeshash bool
 //   - github.com/puzpuzpuz/xsync/v2
 //   - github.com/puzpuzpuz/xsync/v3
 //   - github.com/segmentio/parquet-go
+//   - github.com/parquet-go/parquet-go
+//   - github.com/authzed/spicedb
+//   - github.com/pingcap/badger
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
@@ -68,6 +71,7 @@ func memhash(p unsafe.Pointer, h, s uintptr) uintptr
 // but widely used packages access it using linkname.
 // Notable members of the hall of shame include:
 //   - github.com/segmentio/parquet-go
+//   - github.com/parquet-go/parquet-go
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
@@ -79,6 +83,7 @@ func memhash32(p unsafe.Pointer, h uintptr) uintptr
 // but widely used packages access it using linkname.
 // Notable members of the hall of shame include:
 //   - github.com/segmentio/parquet-go
+//   - github.com/parquet-go/parquet-go
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
@@ -94,6 +99,7 @@ func memhash64(p unsafe.Pointer, h uintptr) uintptr
 //   - github.com/bytedance/go-tagexpr/v2
 //   - github.com/cloudwego/frugal
 //   - github.com/cloudwego/dynamicgo
+//   - github.com/v2fly/v2ray-core/v5
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
@@ -414,6 +420,16 @@ func ifaceeq(tab *itab, x, y unsafe.Pointer) bool {
 }
 
 // Testing adapters for hash quality tests (see hash_test.go)
+//
+// stringHash should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - github.com/k14s/starlark-go
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname stringHash
 func stringHash(s string, seed uintptr) uintptr {
        return strhash(noescape(unsafe.Pointer(&s)), seed)
 }
index 4094e0b9b2abe6fff7e95c05f449c611fe36f223..b195bebbda6923ad62ac818b178741d904b0cd29 100644 (file)
@@ -6,26 +6,17 @@ package runtime
 
 import _ "unsafe"
 
-// As of Go 1.22, the symbols below are found to be pulled via
-// linkname in the wild. We provide a push linkname here, to
-// keep them accessible with pull linknames.
-// This may change in the future. Please do not depend on them
-// in new code.
-
 // These should be an internal details
 // but widely used packages access them using linkname.
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
 
-//go:linkname fastexprand
-//go:linkname gopanic
-//go:linkname sched
-//go:linkname startTheWorld
-//go:linkname stopTheWorld
-//go:linkname stringHash
-
 // Notable members of the hall of shame include:
 //   - github.com/dgraph-io/ristretto
 //   - github.com/outcaste-io/ristretto
 //   - github.com/clubpay/ronykit
 //go:linkname cputicks
+
+// Notable members of the hall of shame include:
+//   - gvisor.dev/gvisor (from assembly)
+//go:linkname sched
index 997a949a30839a237ec6234f49636894cc8164d3..100a78258a2cd8965107425673caf6fa40553c0b 100644 (file)
@@ -213,6 +213,7 @@ func CPUProfile() []byte {
 // but widely used packages access it using linkname.
 // Notable members of the hall of shame include:
 //   - github.com/grafana/pyroscope-go/godeltaprof
+//   - github.com/pyroscope-io/godeltaprof
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
@@ -230,6 +231,14 @@ func pprof_cyclesPerSecond() int64 {
 // The returned data contains a whole number of records, and tags contains
 // exactly one entry per record.
 //
+// runtime_pprof_readProfile should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - github.com/pyroscope-io/pyroscope
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
 //go:linkname runtime_pprof_readProfile runtime/pprof.readProfile
 func runtime_pprof_readProfile() ([]uint64, []unsafe.Pointer, bool) {
        lock(&cpuprof.lock)
index 9dcc25cf232a0297643a3b42a5655d6c7194a733..41a10ae01215d82cb9bd72aeca9e42633d2c31e2 100644 (file)
@@ -665,6 +665,7 @@ var emptyInterfaceSwitchCache = abi.InterfaceSwitchCache{Mask: 0}
 // Notable members of the hall of shame include:
 //   - gitee.com/quant1x/gox
 //   - github.com/modern-go/reflect2
+//   - github.com/v2pro/plz
 //
 // Do not remove or change the type signature.
 //
index 39217b68a4fd2d58ef1a8c1f07622779195da146..dd7f67425103e3b0898f3c56aef71cfe2be8e282 100644 (file)
@@ -9,9 +9,6 @@ import _ "unsafe"
 // used in internal/godebug and syscall
 //go:linkname write
 
-// used in internal/runtime/atomic
-//go:linkname goarm
-
 // used by cgo
 //go:linkname _cgo_panic_internal
 //go:linkname cgoAlwaysFalse
index 810841952930b545ada1cd1a52f4d8f2baac9b75..b92a213245d4f721220534eac8b05989a891a8a5 100644 (file)
@@ -1392,6 +1392,7 @@ func newobject(typ *_type) unsafe.Pointer {
 //   - gitee.com/quant1x/gox
 //   - github.com/goccy/json
 //   - github.com/modern-go/reflect2
+//   - github.com/v2pro/plz
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
@@ -1439,6 +1440,7 @@ func newarray(typ *_type, n int) unsafe.Pointer {
 //   - github.com/modern-go/reflect2
 //   - github.com/segmentio/encoding
 //   - github.com/segmentio/kafka-go
+//   - github.com/v2pro/plz
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
index 8757f18b3bfb2f370587911ab827cca7b960d410..112084f5a74091401e5e8729d7c1fe073a41adff 100644 (file)
@@ -868,6 +868,7 @@ search:
 //   - github.com/RomiChan/protobuf
 //   - github.com/segmentio/encoding
 //   - github.com/ugorji/go/codec
+//   - github.com/wI2L/jettison
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
@@ -1394,6 +1395,7 @@ func advanceEvacuationMark(h *hmap, t *maptype, newbit uintptr) {
 //   - github.com/goccy/go-json
 //   - github.com/RomiChan/protobuf
 //   - github.com/segmentio/encoding
+//   - github.com/v2pro/plz
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
@@ -1442,6 +1444,7 @@ func reflect_makemap(t *maptype, cap int) *hmap {
 // Notable members of the hall of shame include:
 //   - gitee.com/quant1x/gox
 //   - github.com/modern-go/reflect2
+//   - github.com/v2pro/plz
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
@@ -1470,6 +1473,7 @@ func reflect_mapaccess_faststr(t *maptype, h *hmap, key string) unsafe.Pointer {
 // but widely used packages access it using linkname.
 // Notable members of the hall of shame include:
 //   - gitee.com/quant1x/gox
+//   - github.com/v2pro/plz
 //
 // Do not remove or change the type signature.
 //
@@ -1500,6 +1504,8 @@ func reflect_mapdelete_faststr(t *maptype, h *hmap, key string) {
 // Notable members of the hall of shame include:
 //   - github.com/modern-go/reflect2
 //   - gitee.com/quant1x/gox
+//   - github.com/v2pro/plz
+//   - github.com/wI2L/jettison
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
@@ -1515,6 +1521,8 @@ func reflect_mapiterinit(t *maptype, h *hmap, it *hiter) {
 //   - gitee.com/quant1x/gox
 //   - github.com/modern-go/reflect2
 //   - github.com/goccy/go-json
+//   - github.com/v2pro/plz
+//   - github.com/wI2L/jettison
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
@@ -1556,6 +1564,7 @@ func reflect_mapiterelem(it *hiter) unsafe.Pointer {
 // but widely used packages access it using linkname.
 // Notable members of the hall of shame include:
 //   - github.com/goccy/go-json
+//   - github.com/wI2L/jettison
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
index b4fc48977f3f75aebb923eb68a63285be8bb0edb..7dc8a1a5e56df78db5347b8e057f16cb49f2fc55 100644 (file)
@@ -216,6 +216,7 @@ func wbMove(typ *_type, dst, src unsafe.Pointer) {
 //   - github.com/goccy/json
 //   - github.com/modern-go/reflect2
 //   - github.com/ugorji/go/codec
+//   - github.com/v2pro/plz
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
@@ -340,6 +341,7 @@ func typedslicecopy(typ *_type, dstPtr unsafe.Pointer, dstLen int, srcPtr unsafe
 //   - github.com/modern-go/reflect2
 //   - github.com/RomiChan/protobuf
 //   - github.com/segmentio/encoding
+//   - github.com/v2pro/plz
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
index 6929862a7dbffd20958358aef2e988bf38f32fbb..98e96b12bf522c7865b4d52a0a63be8ce9c906f7 100644 (file)
@@ -720,6 +720,18 @@ func (*PanicNilError) RuntimeError() {}
 var panicnil = &godebugInc{name: "panicnil"}
 
 // The implementation of the predeclared function panic.
+// The compiler emits calls to this function.
+//
+// gopanic should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - go.undefinedlabs.com/scopeagent
+//   - github.com/goplus/igop
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname gopanic
 func gopanic(e any) {
        if e == nil {
                if debug.panicnil.Load() != 1 {
@@ -1036,6 +1048,7 @@ func sync_fatal(s string) {
 //   - github.com/outcaste-io/ristretto
 //   - github.com/pingcap/br
 //   - gvisor.dev/gvisor
+//   - github.com/sagernet/gvisor
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
index 9574628ee20ed051f27907854c6e29aaf7973213..c4f175b0b76b220cf1c5f99f3801b38c1055f7f4 100644 (file)
@@ -398,6 +398,7 @@ func goschedIfBusy() {
 // but widely used packages access it using linkname.
 // Notable members of the hall of shame include:
 //   - gvisor.dev/gvisor
+//   - github.com/sagernet/gvisor
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
@@ -433,6 +434,7 @@ func goparkunlock(lock *mutex, reason waitReason, traceReason traceBlockReason,
 // but widely used packages access it using linkname.
 // Notable members of the hall of shame include:
 //   - gvisor.dev/gvisor
+//   - github.com/sagernet/gvisor
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
@@ -4218,6 +4220,7 @@ func preemptPark(gp *g) {
 // but widely used packages access it using linkname.
 // Notable members of the hall of shame include:
 //   - gvisor.dev/gvisor
+//   - github.com/sagernet/gvisor
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
@@ -7123,6 +7126,7 @@ func sync_atomic_runtime_procUnpin() {
 // but widely used packages access it using linkname.
 // Notable members of the hall of shame include:
 //   - github.com/livekit/protocol
+//   - github.com/sagernet/gvisor
 //   - gvisor.dev/gvisor
 //
 // Do not remove or change the type signature.
@@ -7149,6 +7153,7 @@ func sync_runtime_canSpin(i int) bool {
 // but widely used packages access it using linkname.
 // Notable members of the hall of shame include:
 //   - github.com/livekit/protocol
+//   - github.com/sagernet/gvisor
 //   - gvisor.dev/gvisor
 //
 // Do not remove or change the type signature.
index 7e313c19bde91158eff3e323d0bf612de36f0676..021883dab1b128334c5355ed8eb8026126034452 100644 (file)
@@ -182,6 +182,7 @@ func randn(n uint32) uint32 {
 // but widely used packages access it using linkname.
 // Notable members of the hall of shame include:
 //   - github.com/bytedance/gopkg
+//   - github.com/zhangyunhao116/fastrand
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
@@ -222,6 +223,15 @@ func cheaprand() uint32 {
 // the rule is that other packages using runtime-provided
 // randomness must always use rand.
 //
+// cheaprand64 should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - github.com/zhangyunhao116/fastrand
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname cheaprand64
 //go:nosplit
 func cheaprand64() int64 {
        return int64(cheaprand())<<31 ^ int64(cheaprand())
index 6086d3a0d890bc1ae72739f6c4e2629bd74b132c..c74f6d2c72a44375a5311715e693fa151846be71 100644 (file)
@@ -621,6 +621,9 @@ func releasem(mp *m) {
 //   - github.com/goccy/json
 //   - github.com/modern-go/reflect2
 //   - github.com/vmware/govmomi
+//   - github.com/pinpoint-apm/pinpoint-go-agent
+//   - github.com/timandy/routine
+//   - github.com/v2pro/plz
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
@@ -659,6 +662,8 @@ func reflect_resolveNameOff(ptrInModule unsafe.Pointer, off int32) unsafe.Pointe
 // Notable members of the hall of shame include:
 //   - gitee.com/quant1x/gox
 //   - github.com/modern-go/reflect2
+//   - github.com/v2pro/plz
+//   - github.com/timandy/routine
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
index 470b82991233acf83c98f55cb83285c8f5b142af..8645532ae03e0e6693922fbdff75c4c511757ede 100644 (file)
@@ -1250,8 +1250,21 @@ var (
        // Set on startup in asm_{386,amd64}.s
        processorVersionInfo uint32
        isIntel              bool
+)
 
-       // set by cmd/link on arm systems
+// set by cmd/link on arm systems
+// accessed using linkname by internal/runtime/atomic.
+//
+// goarm should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - github.com/creativeprojects/go-selfupdate
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname goarm
+var (
        goarm       uint8
        goarmsoftfp uint8
 )
index 0eb3c31a9fc2d1f44daa7e22663ea2aff2149d35..f6b1b84f5f12fbf1c88116fb0f1ce9a542907ee0 100644 (file)
@@ -61,6 +61,7 @@ func (t *semTable) rootFor(addr *uint32) *semaRoot {
 // but widely used packages access it using linkname.
 // Notable members of the hall of shame include:
 //   - gvisor.dev/gvisor
+//   - github.com/sagernet/gvisor
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
@@ -79,6 +80,7 @@ func poll_runtime_Semacquire(addr *uint32) {
 // but widely used packages access it using linkname.
 // Notable members of the hall of shame include:
 //   - gvisor.dev/gvisor
+//   - github.com/sagernet/gvisor
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
index d3f75bfcac669429d722a8ba581b8535b06e9ec1..2aeb4774b97218f28c18eb2acd0098dd540abbaa 100644 (file)
@@ -137,6 +137,7 @@ func reflect_memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr) {
 //   - github.com/tetratelabs/wazero
 //   - github.com/ugorji/go/codec
 //   - gvisor.dev/gvisor
+//   - github.com/sagernet/gvisor
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
index 993b29d5c041787c356a0242a99b47eaa62787b2..10cdcf9c6ee8b4c1feb3f62d67fe395febbed4f8 100644 (file)
@@ -238,6 +238,7 @@ func runtime_FrameSymbolName(f *Frame) string {
 // but widely used packages access it using linkname.
 // Notable members of the hall of shame include:
 //   - github.com/grafana/pyroscope-go/godeltaprof
+//   - github.com/pyroscope-io/godeltaprof
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
index 3a3c31402914190d2bea66fee64caa60d63e8bac..2ed83a4fad2a5a2e66d950d4ce06175b006c4b1d 100644 (file)
@@ -21,13 +21,3 @@ import _ "unsafe"
 // used by cmd/link
 //go:linkname msync
 //go:linkname fcntl
-
-// mmap should be an internal detail,
-// but widely used packages access it using linkname.
-// Notable members of the hall of shame include:
-//   - modernc.org/memory
-//
-// Do not remove or change the type signature.
-// See go.dev/issue/67401.
-//
-//go:linkname mmap
index ffd5c138e30fa2dbda89df2d089d87487afff233..5f5c517ab585992dfe1a7aaae8ac60a3c08f2db3 100644 (file)
@@ -13,13 +13,3 @@ import _ "unsafe"
 //go:linkname openat
 //go:linkname fstatat
 //go:linkname getentropy
-
-// mmap should be an internal detail,
-// but widely used packages access it using linkname.
-// Notable members of the hall of shame include:
-//   - modernc.org/memory
-//
-// Do not remove or change the type signature.
-// See go.dev/issue/67401.
-//
-//go:linkname mmap
diff --git a/src/syscall/linkname_unix.go b/src/syscall/linkname_unix.go
new file mode 100644 (file)
index 0000000..c4d187c
--- /dev/null
@@ -0,0 +1,20 @@
+// Copyright 2024 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build unix
+
+package syscall
+
+import _ "unsafe" // for linkname
+
+// mmap should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - modernc.org/memory
+//   - github.com/ncruces/go-sqlite3
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname mmap
index 27ff975784a2702926fb6ff26a9da8995559ae11..43efe4b11d0d1c3975799941eef8031181cd8600 100644 (file)
@@ -1152,6 +1152,9 @@ func runtimeNano() int64
 // (Callers may want to use 0 as "time not set".)
 var startNano int64 = runtimeNano() - 1
 
+// x/tools uses a linkname of time.Now in its tests. No harm done.
+//go:linkname Now
+
 // Now returns the current local time.
 func Now() Time {
        sec, nsec, mono := now()