From 82de010886dfc0d5d2130152387518bd549a77f3 Mon Sep 17 00:00:00 2001 From: Shenghou Ma Date: Sat, 22 Sep 2012 05:54:22 +1000 Subject: [PATCH] [release-branch.go1] cmd/cgo: use 1 as last entry for __cgodebug_data MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ««« backport aeaab9df5600 cmd/cgo: use 1 as last entry for __cgodebug_data LLVM-based gcc will place all-zero data in a zero-filled section, but our debug/macho can't handle that. Fixes #3821. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/6444049 »»» --- src/cmd/cgo/gcc.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cmd/cgo/gcc.go b/src/cmd/cgo/gcc.go index 98a847e6fa..34af07cecf 100644 --- a/src/cmd/cgo/gcc.go +++ b/src/cmd/cgo/gcc.go @@ -508,7 +508,12 @@ func (p *Package) loadDWARF(f *File, names []*Name) { fmt.Fprintf(&b, "\t0,\n") } } - fmt.Fprintf(&b, "\t0\n") + // for the last entry, we can not use 0, otherwise + // in case all __cgodebug_data is zero initialized, + // LLVM-based gcc will place the it in the __DATA.__common + // zero-filled section (our debug/macho doesn't support + // this) + fmt.Fprintf(&b, "\t1\n") fmt.Fprintf(&b, "};\n") d, bo, debugData := p.gccDebug(b.Bytes())