1
0
mirror of https://github.com/golang/go synced 2024-11-17 17:54:48 -07:00

[dev.link] cmd/link: remove unnecessary file processing from writelines

The linker DWARF-gen's line table writing routine contains a loop that
walks all abstract function DIEs looking for files that aren't
referenced in concrete function DIEs. Turns out this loop is no longer
necessary, most likely because the compiler emits an explicit DWARF
file table into the object file.

This patch removes the offending loop. This is a prelude to some
additional work that will hopefully get rid of file renumbering in
writelines altogether (still WIP).

Change-Id: I3b3a9acce1bae7dda878ab6de2d3436de302712e
Reviewed-on: https://go-review.googlesource.com/c/go/+/223145
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
Than McIntosh 2020-03-12 11:04:36 -04:00
parent 2a5bf32638
commit a6ae6d35e6

View File

@ -1211,35 +1211,6 @@ func (d *dwctxt2) writelines(unit *sym.CompilationUnit, ls loader.Sym) {
}
}
// Grab files for inlined functions.
// TODO: With difficulty, this could be moved into the compiler.
rslice := []loader.Reloc{}
for _, s := range unit.Textp2 {
fnSym := loader.Sym(s)
infosym, _, _, _ := d.ldr.GetFuncDwarfAuxSyms(fnSym)
drelocs := d.ldr.Relocs(infosym)
rslice = drelocs.ReadSyms(rslice)
for ri := 0; ri < len(rslice); ri++ {
r := &rslice[ri]
if r.Type != objabi.R_DWARFFILEREF {
continue
}
fname, ok := expandedFiles[r.Sym]
if !ok {
fname = expandFileSym(d.ldr, r.Sym)
expandedFiles[r.Sym] = fname
}
if _, ok := fileNums[fname]; ok {
continue
}
fileNums[fname] = len(fileNums) + 1
d.AddString(lsDwsym, fname)
lsu.AddUint8(0)
lsu.AddUint8(0)
lsu.AddUint8(0)
}
}
// 4 zeros: the string termination + 3 fields.
lsu.AddUint8(0)
// terminate file_names.
@ -1247,6 +1218,7 @@ func (d *dwctxt2) writelines(unit *sym.CompilationUnit, ls loader.Sym) {
// Output the state machine for each function remaining.
var lastAddr int64
rslice := []loader.Reloc{}
for _, s := range unit.Textp2 {
fnSym := loader.Sym(s)
@ -1318,7 +1290,8 @@ func (d *dwctxt2) writelines(unit *sym.CompilationUnit, ls loader.Sym) {
fname, ok := expandedFiles[r.Sym]
if !ok {
panic("bad")
fname = expandFileSym(d.ldr, r.Sym)
expandedFiles[r.Sym] = fname
}
idx, ok := fileNums[fname]
@ -1339,7 +1312,6 @@ func (d *dwctxt2) writelines(unit *sym.CompilationUnit, ls loader.Sym) {
d.ldr.SetAttrReachable(r.Sym, true)
d.ldr.SetAttrNotInSymbolTable(r.Sym, true)
r.Add = int64(idx) // record the index in r.Add, we'll apply it in the reloc phase.
} else {
sv := d.ldr.SymValue(r.Sym)