]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/cgo: use 1 as last entry for __cgodebug_data
authorShenghou Ma <minux.ma@gmail.com>
Mon, 30 Jul 2012 22:44:48 +0000 (18:44 -0400)
committerShenghou Ma <minux.ma@gmail.com>
Mon, 30 Jul 2012 22:44:48 +0000 (18:44 -0400)
        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

index 93ecb3e3d080d53e36e1c63f3676ef5c897c4b1b..18be64fc7c334bb9f82c1d01a08cb1e88ee0d4f8 100644 (file)
@@ -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())