Commit 46f99ce7 authored by Jay Conrod's avatar Jay Conrod

cmd/go: look for __go_buildinfo section when looking for Mach-O version

This mirrors the ELF fix in CL 188957. TestScript/version failed on
darwin after that change.

Fixes #31861

Change-Id: I4ce953ebec8dd5fa47e26d373c59d7e290b75a34
Reviewed-on: https://go-review.googlesource.com/c/go/+/189159
Run-TryBot: Jay Conrod <jayconrod@google.com>
Reviewed-by: default avatarBryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 8e82624e
......@@ -213,7 +213,13 @@ func (x *machoExe) ReadData(addr, size uint64) ([]byte, error) {
}
func (x *machoExe) DataStart() uint64 {
// Assume data is first non-empty writable segment.
// Look for section named "__go_buildinfo".
for _, sec := range x.f.Sections {
if sec.Name == "__go_buildinfo" {
return sec.Addr
}
}
// Try the first non-empty writable segment.
const RW = 3
for _, load := range x.f.Loads {
seg, ok := load.(*macho.Segment)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment