]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/cgo: use debug data for enums on windows
authorJoel Sing <jsing@google.com>
Sat, 22 Sep 2012 07:57:54 +0000 (17:57 +1000)
committerJoel Sing <jsing@google.com>
Sat, 22 Sep 2012 07:57:54 +0000 (17:57 +1000)
Use the debug data for enums on windows.

Fixes #4120.

R=alex.brainman
CC=golang-dev
https://golang.org/cl/6545047

src/cmd/cgo/gcc.go

index eee7602307c77f45614121738358808a3e62ad19..963efa58deb32786df4b154bc21fe1c8aac90253 100644 (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())