aboutsummaryrefslogtreecommitdiff
path: root/src/debug
diff options
context:
space:
mode:
authorNikola Jokic <jokicnikola07@gmail.com>2023-03-06 09:52:12 +0100
committerGopher Robot <gobot@golang.org>2023-03-08 15:57:58 +0000
commit8b3961264120d188c3c9739370826e346d8748c2 (patch)
tree54cee9f9555cbe35f45a8d827e92cf6675891742 /src/debug
parent99f811ecca5674a6e6f423b97ea79f0a6eedf4b6 (diff)
downloadgo-8b3961264120d188c3c9739370826e346d8748c2.tar.xz
debug/buildinfo: recognize macOS fat binary in go version
buildinfo did not check for fat magic, which caused go version to report unrecognized file format. This change reads the fat file and passes the first arch file to machoExe. Fixes #58796 Change-Id: I45cd26729352e46cc7ecfb13f2e9a8d96d62e0a0 Reviewed-on: https://go-review.googlesource.com/c/go/+/473615 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/debug')
-rw-r--r--src/debug/buildinfo/buildinfo.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/debug/buildinfo/buildinfo.go b/src/debug/buildinfo/buildinfo.go
index a7019a666e..3409356f01 100644
--- a/src/debug/buildinfo/buildinfo.go
+++ b/src/debug/buildinfo/buildinfo.go
@@ -126,6 +126,12 @@ func readRawBuildInfo(r io.ReaderAt) (vers, mod string, err error) {
return "", "", errUnrecognizedFormat
}
x = &machoExe{f}
+ case bytes.HasPrefix(ident, []byte("\xCA\xFE\xBA\xBE")) || bytes.HasPrefix(ident, []byte("\xCA\xFE\xBA\xBF")):
+ f, err := macho.NewFatFile(r)
+ if err != nil || len(f.Arches) == 0 {
+ return "", "", errUnrecognizedFormat
+ }
+ x = &machoExe{f.Arches[0].File}
case bytes.HasPrefix(ident, []byte{0x01, 0xDF}) || bytes.HasPrefix(ident, []byte{0x01, 0xF7}):
f, err := xcoff.NewFile(r)
if err != nil {
@@ -423,5 +429,4 @@ func (x *plan9objExe) ReadData(addr, size uint64) ([]byte, error) {
}
}
return nil, errors.New("address not mapped")
-
}