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)
- }
- }
-}
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,
pefile.bssSect = b
}
- if !*FlagS {
- dwarfaddpeheaders(ctxt)
- }
+ pefile.addDWARF()
if Linkmode == LinkExternal {
pefile.ctorsSect = pefile.addInitArray(ctxt)