Commit 3bd79713 authored by Alex Brainman's avatar Alex Brainman

cmd/link: introduce and use peFile.addDWARF

Change-Id: I2c217e03779772605aa0b5a33ef80459333eeebc
Reviewed-on: https://go-review.googlesource.com/59790Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent 0e2cde7c
......@@ -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)
}
}
}
......@@ -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)
......
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