[dev.link] cmd/compile, cmd/link: move away from DWARF file renumbering

This patch moves the compiler and linker away from the current scheme
used to generate file references in DWARF subprogram dies.

Up until now the scheme has been to have the compiler emit a special
relocation on a DIE file reference that points to the file symbol in
question. The linker then reads this relocation and updates the addend
to the index of the appropriate file in the line table of the
compilation unit of the DIE (the linker emits the comp unit file
table, so it knows at that point what number use). The drawback of
this scheme is that it requires a lot of relocation processing.

With this patch, we switch to having the compiler emit the file index
directly, and then have the linker use the compiler-generated file
table to emit the line table file section (no renumbering, no
relocations, etc).

Change-Id: Id4fbe67b28a64200a083e3c5ea358dbe091ec917
Reviewed-on: https://go-review.googlesource.com/c/go/+/223318
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
Than McIntosh 2020-03-12 14:10:09 -04:00
parent 673a02a235
commit 0dff5b0b9e
3 changed files with 6 additions and 94 deletions

View file

@ -1955,29 +1955,6 @@ func (l *Loader) PropagateLoaderChangesToSymbols(toconvert []Sym, syms *sym.Symb
}
}
// If this symbol has any DWARF file relocations, we need to
// make sure that the relocations are copied back over, since
// DWARF-gen alters the offset values for these relocs. Also:
// if this is an info symbol and it refers to a previously
// unseen range/loc symbol, we'll need to fix up relocations
// for it as well.
relocs := l.Relocs(cand)
rslice = relocs.ReadSyms(rslice)
for ri := range rslice {
if rslice[ri].Type == objabi.R_DWARFFILEREF {
relfix = true
break
}
if st != sym.SDWARFINFO {
continue
}
rst := l.SymType(rslice[ri].Sym)
if rst == sym.SDWARFRANGE || rst == sym.SDWARFLOC {
relfix = true
break
}
}
if relfix {
relocfixup = append(relocfixup, cand)
}