Commit 3cb92fcb authored by Aman Gupta's avatar Aman Gupta Committed by Ian Lance Taylor

cmd/link/internal/ld: fix c-archive mach-o compatibility

These workarounds predate proper DWARF support
and are no longer necessary.

Before this patch, running `/usr/bin/symbols go.o`
using the object in the c-archive would fail, causing
App Store rejections.

Fixes #31022 #28997

Change-Id: I6a210b6369c13038777c6e21e874e81afcb50c2f
Reviewed-on: https://go-review.googlesource.com/c/go/+/170377
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent 7b33b627
......@@ -5,6 +5,7 @@
package main
import (
"bytes"
cmddwarf "cmd/internal/dwarf"
"cmd/internal/objfile"
"debug/dwarf"
......@@ -86,6 +87,22 @@ func testDWARF(t *testing.T, buildmode string, expectDWARF bool, env ...string)
}
exe = filepath.Join(tmpDir, "go.o")
}
if runtime.GOOS == "darwin" {
if _, err = exec.LookPath("symbols"); err == nil {
// Ensure Apple's tooling can parse our object for symbols.
out, err = exec.Command("symbols", exe).CombinedOutput()
if err != nil {
t.Fatal(err)
} else {
if bytes.HasPrefix(out, []byte("Unable to find file")) {
// This failure will cause the App Store to reject our binaries.
t.Fatalf("/usr/bin/symbols %v: failed to parse file", filepath.Base(exe))
}
}
}
}
f, err := objfile.Open(exe)
if err != nil {
t.Fatal(err)
......@@ -148,6 +165,9 @@ func testDWARF(t *testing.T, buildmode string, expectDWARF bool, env ...string)
func TestDWARF(t *testing.T) {
testDWARF(t, "", true)
if runtime.GOOS == "darwin" {
testDWARF(t, "c-archive", true)
}
}
func TestDWARFiOS(t *testing.T) {
......
......@@ -560,12 +560,8 @@ func Asmbmacho(ctxt *Link) {
ms = newMachoSeg("", 40)
ms.fileoffset = Segtext.Fileoff
if ctxt.Arch.Family == sys.ARM || ctxt.BuildMode == BuildModeCArchive {
ms.filesize = Segdata.Fileoff + Segdata.Filelen - Segtext.Fileoff
} else {
ms.filesize = Segdwarf.Fileoff + Segdwarf.Filelen - Segtext.Fileoff
ms.vsize = Segdwarf.Vaddr + Segdwarf.Length - Segtext.Vaddr
}
ms.filesize = Segdwarf.Fileoff + Segdwarf.Filelen - Segtext.Fileoff
ms.vsize = Segdwarf.Vaddr + Segdwarf.Length - Segtext.Vaddr
}
/* segment for zero page */
......
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