Commit 49aa74ef authored by Joel Sing's avatar Joel Sing

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
parent 5373e8a8
...@@ -830,15 +830,25 @@ func (p *Package) gccDebug(stdin []byte) (*dwarf.Data, binary.ByteOrder, []byte) ...@@ -830,15 +830,25 @@ func (p *Package) gccDebug(stdin []byte) (*dwarf.Data, binary.ByteOrder, []byte)
return d, f.ByteOrder, data 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 { if f, err := pe.Open(gccTmp()); err == nil {
d, err := f.DWARF() d, err := f.DWARF()
if err != nil { if err != nil {
fatalf("cannot load DWARF output from %s: %v", gccTmp(), err) 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()) fatalf("cannot parse gcc output %s as ELF, Mach-O, PE object", gccTmp())
......
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