Skip to content

Commit 3bd7971

Browse files
committed
cmd/link: introduce and use peFile.addDWARF
Change-Id: I2c217e03779772605aa0b5a33ef80459333eeebc Reviewed-on: https://go-review.googlesource.com/59790 Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 0e2cde7 commit 3bd7971

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

src/cmd/link/internal/ld/dwarf.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1658,19 +1658,3 @@ func dwarfaddelfsectionsyms(ctxt *Link) {
16581658
putelfsectionsym(sym, sym.Sect.Elfsect.shnum)
16591659
}
16601660
}
1661-
1662-
/*
1663-
* Windows PE
1664-
*/
1665-
func dwarfaddpeheaders(ctxt *Link) {
1666-
if *FlagW { // disable dwarf
1667-
return
1668-
}
1669-
for _, sect := range Segdwarf.Sections {
1670-
h := pefile.addDWARFSection(sect.Name, int(sect.Length))
1671-
fileoff := sect.Vaddr - Segdwarf.Vaddr + Segdwarf.Fileoff
1672-
if uint64(h.PointerToRawData) != fileoff {
1673-
Exitf("%s.PointerToRawData = %#x, want %#x", sect.Name, h.PointerToRawData, fileoff)
1674-
}
1675-
}
1676-
}

src/cmd/link/internal/ld/pe.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,23 @@ func (f *peFile) addDWARFSection(name string, size int) *peSection {
428428
return h
429429
}
430430

431+
// addDWARF adds DWARF information to the COFF file f.
432+
func (f *peFile) addDWARF() {
433+
if *FlagS { // disable symbol table
434+
return
435+
}
436+
if *FlagW { // disable dwarf
437+
return
438+
}
439+
for _, sect := range Segdwarf.Sections {
440+
h := f.addDWARFSection(sect.Name, int(sect.Length))
441+
fileoff := sect.Vaddr - Segdwarf.Vaddr + Segdwarf.Fileoff
442+
if uint64(h.PointerToRawData) != fileoff {
443+
Exitf("%s.PointerToRawData = %#x, want %#x", sect.Name, h.PointerToRawData, fileoff)
444+
}
445+
}
446+
}
447+
431448
// addInitArray adds .ctors COFF section to the file f.
432449
func (f *peFile) addInitArray(ctxt *Link) *peSection {
433450
// The size below was determined by the specification for array relocations,
@@ -1307,9 +1324,7 @@ func Asmbpe(ctxt *Link) {
13071324
pefile.bssSect = b
13081325
}
13091326

1310-
if !*FlagS {
1311-
dwarfaddpeheaders(ctxt)
1312-
}
1327+
pefile.addDWARF()
13131328

13141329
if Linkmode == LinkExternal {
13151330
pefile.ctorsSect = pefile.addInitArray(ctxt)

0 commit comments

Comments
 (0)