]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: introduce and use peFile.addDWARF
authorAlex Brainman <alex.brainman@gmail.com>
Tue, 29 Aug 2017 03:09:59 +0000 (13:09 +1000)
committerAlex Brainman <alex.brainman@gmail.com>
Wed, 30 Aug 2017 01:35:29 +0000 (01:35 +0000)
Change-Id: I2c217e03779772605aa0b5a33ef80459333eeebc
Reviewed-on: https://go-review.googlesource.com/59790
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/cmd/link/internal/ld/dwarf.go
src/cmd/link/internal/ld/pe.go

index 27d78c4ad898cc294af00d2c015772a247abc479..582aec83b5f63cbc019d53ea1330070153c12cbb 100644 (file)
@@ -1658,19 +1658,3 @@ func dwarfaddelfsectionsyms(ctxt *Link) {
                putelfsectionsym(sym, sym.Sect.Elfsect.shnum)
        }
 }
-
-/*
- * Windows PE
- */
-func dwarfaddpeheaders(ctxt *Link) {
-       if *FlagW { // disable dwarf
-               return
-       }
-       for _, sect := range Segdwarf.Sections {
-               h := pefile.addDWARFSection(sect.Name, int(sect.Length))
-               fileoff := sect.Vaddr - Segdwarf.Vaddr + Segdwarf.Fileoff
-               if uint64(h.PointerToRawData) != fileoff {
-                       Exitf("%s.PointerToRawData = %#x, want %#x", sect.Name, h.PointerToRawData, fileoff)
-               }
-       }
-}
index 2add05f67f0f8324be1c68220f8fe2798f90b9b9..5820c087a0c37069dafd138d57a16b004ab7e25d 100644 (file)
@@ -428,6 +428,23 @@ func (f *peFile) addDWARFSection(name string, size int) *peSection {
        return h
 }
 
+// addDWARF adds DWARF information to the COFF file f.
+func (f *peFile) addDWARF() {
+       if *FlagS { // disable symbol table
+               return
+       }
+       if *FlagW { // disable dwarf
+               return
+       }
+       for _, sect := range Segdwarf.Sections {
+               h := f.addDWARFSection(sect.Name, int(sect.Length))
+               fileoff := sect.Vaddr - Segdwarf.Vaddr + Segdwarf.Fileoff
+               if uint64(h.PointerToRawData) != fileoff {
+                       Exitf("%s.PointerToRawData = %#x, want %#x", sect.Name, h.PointerToRawData, fileoff)
+               }
+       }
+}
+
 // addInitArray adds .ctors COFF section to the file f.
 func (f *peFile) addInitArray(ctxt *Link) *peSection {
        // The size below was determined by the specification for array relocations,
@@ -1307,9 +1324,7 @@ func Asmbpe(ctxt *Link) {
                pefile.bssSect = b
        }
 
-       if !*FlagS {
-               dwarfaddpeheaders(ctxt)
-       }
+       pefile.addDWARF()
 
        if Linkmode == LinkExternal {
                pefile.ctorsSect = pefile.addInitArray(ctxt)