1
0
mirror of https://github.com/golang/go synced 2024-11-26 14:08:37 -07:00

cmd/cgo: use debug data for enums on windows

Use the debug data for enums on windows.

Fixes #4120.

R=alex.brainman
CC=golang-dev
https://golang.org/cl/6545047
This commit is contained in:
Joel Sing 2012-09-22 17:57:54 +10:00
parent 5373e8a8d7
commit 49aa74ef7f

View File

@ -830,15 +830,25 @@ func (p *Package) gccDebug(stdin []byte) (*dwarf.Data, binary.ByteOrder, []byte)
return d, f.ByteOrder, data
}
// Can skip debug data block in PE for now.
// The DWARF information is complete.
if f, err := pe.Open(gccTmp()); err == nil {
d, err := f.DWARF()
if err != nil {
fatalf("cannot load DWARF output from %s: %v", gccTmp(), err)
}
return d, binary.LittleEndian, nil
var data []byte
for _, s := range f.Symbols {
if s.Name == "_"+"__cgodebug_data" {
if i := int(s.SectionNumber) - 1; 0 <= i && i < len(f.Sections) {
sect := f.Sections[i]
if s.Value < sect.Size {
if sdat, err := sect.Data(); err == nil {
data = sdat[s.Value:]
}
}
}
}
}
return d, binary.LittleEndian, data
}
fatalf("cannot parse gcc output %s as ELF, Mach-O, PE object", gccTmp())