diff options
| author | Russ Cox <rsc@golang.org> | 2024-05-22 23:06:30 -0400 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2024-05-29 17:58:53 +0000 |
| commit | 2a7ca156b8189c68c0a29b4c66194a42c5ce3c9b (patch) | |
| tree | 7ac6dc198ebad85420719774562d29b7b59c6684 /src/debug | |
| parent | 5121b45d7426687076c20ae0f4fcae1238f3ed47 (diff) | |
| download | go-2a7ca156b8189c68c0a29b4c66194a42c5ce3c9b.tar.xz | |
all: document legacy //go:linkname for final round of modules
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>
Diffstat (limited to 'src/debug')
| -rw-r--r-- | src/debug/buildinfo/buildinfo.go | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/src/debug/buildinfo/buildinfo.go b/src/debug/buildinfo/buildinfo.go index 1bfdd02a67..1dd70a9f33 100644 --- a/src/debug/buildinfo/buildinfo.go +++ b/src/debug/buildinfo/buildinfo.go @@ -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") +// 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 = errors.New("not a Go executable") +// 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). - buildInfoMagic = []byte("\xff Go buildinf:") -) +// 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 |
