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

[dev.link] cmd/compile, cmd/link: move DWARF info sym to anonymous aux data

Switch the primary subprogram die DWARF symbol emitted by the compiler
from named+dupOK to anonymous aux. This should help performance wise
by not having to add these symbols to the linker's symbol name lookup
tables.

Change-Id: Idf66662b8bf60b3dee9a55e6cd5137b24a9f5ab6
Reviewed-on: https://go-review.googlesource.com/c/go/+/223669
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-16 08:13:16 -04:00
parent 62b0790a79
commit 673a02a235
6 changed files with 19 additions and 11 deletions

View File

@ -207,7 +207,9 @@ func (ctxt *Link) dwarfSym(s *LSym) (dwarfInfoSym, dwarfLocSym, dwarfRangesSym,
ctxt.Diag("dwarfSym of non-TEXT %v", s)
}
if s.Func.dwarfInfoSym == nil {
s.Func.dwarfInfoSym = ctxt.LookupDerived(s, dwarf.InfoPrefix+s.Name)
s.Func.dwarfInfoSym = &LSym{
Type: objabi.SDWARFINFO,
}
if ctxt.Flag_locationlists {
s.Func.dwarfLocSym = &LSym{
Type: objabi.SDWARFLOC,

View File

@ -299,7 +299,7 @@ func (w *writer) Aux(s *LSym) {
o.Write(w.Writer)
}
if s.Func.dwarfInfoSym != nil {
if s.Func.dwarfInfoSym != nil && s.Func.dwarfInfoSym.Size != 0 {
o := goobj2.Aux{
Type: goobj2.AuxDwarfInfo,
Sym: makeSymRef(s.Func.dwarfInfoSym),
@ -339,7 +339,7 @@ func nAuxSym(s *LSym) int {
if s.Func != nil {
// FuncInfo is an aux symbol, each Funcdata is an aux symbol
n += 1 + len(s.Func.Pcln.Funcdata)
if s.Func.dwarfInfoSym != nil {
if s.Func.dwarfInfoSym != nil && s.Func.dwarfInfoSym.Size != 0 {
n++
}
if s.Func.dwarfLocSym != nil && s.Func.dwarfLocSym.Size != 0 {
@ -419,7 +419,7 @@ func genFuncInfoSyms(ctxt *Link) {
s.Func.FuncInfoSym = isym
b.Reset()
dwsyms := []*LSym{s.Func.dwarfRangesSym, s.Func.dwarfLocSym, s.Func.dwarfDebugLinesSym}
dwsyms := []*LSym{s.Func.dwarfRangesSym, s.Func.dwarfLocSym, s.Func.dwarfDebugLinesSym, s.Func.dwarfInfoSym}
for _, s := range dwsyms {
if s == nil || s.Size == 0 {
continue

View File

@ -139,10 +139,7 @@ func (ctxt *Link) InitTextSym(s *LSym, flag int) {
ctxt.Text = append(ctxt.Text, s)
// Set up DWARF entries for s.
info, _, _, _, _ := ctxt.dwarfSym(s)
info.Type = objabi.SDWARFINFO
info.Set(AttrDuplicateOK, s.DuplicateOK())
ctxt.Data = append(ctxt.Data, info)
ctxt.dwarfSym(s)
}
func (ctxt *Link) Globl(s *LSym, size int64, flag int) {

View File

@ -330,7 +330,7 @@ func (ctxt *Link) traverseFuncAux(flag traverseFlag, fsym *LSym, fn func(parent
fn(fsym, filesym)
}
}
dwsyms := []*LSym{fsym.Func.dwarfRangesSym, fsym.Func.dwarfLocSym, fsym.Func.dwarfDebugLinesSym}
dwsyms := []*LSym{fsym.Func.dwarfRangesSym, fsym.Func.dwarfLocSym, fsym.Func.dwarfDebugLinesSym, fsym.Func.dwarfInfoSym}
for _, dws := range dwsyms {
if dws == nil || dws.Size == 0 {
continue

View File

@ -1912,6 +1912,9 @@ func dwarfGenerateDebugInfo(ctxt *Link) {
for _, s := range unit.Textp2 { // textp2 has been dead-code-eliminated already.
fnSym := loader.Sym(s)
infosym, _, rangesym, _ := d.ldr.GetFuncDwarfAuxSyms(fnSym)
if infosym == 0 {
continue
}
d.ldr.SetAttrNotInSymbolTable(infosym, true)
d.ldr.SetAttrReachable(infosym, true)

View File

@ -2140,11 +2140,17 @@ func loadObjSyms(l *Loader, syms *sym.Symbols, r *oReader) int {
osym := goobj2.Sym{}
osym.Read(r.Reader, r.SymOff(i))
name := strings.Replace(osym.Name, "\"\".", r.pkgprefix, -1)
if name == "" {
t := sym.AbiSymKindToSymKind[objabi.SymKind(osym.Type)]
// NB: for the test below, we can skip most anonymous symbols
// since they will never be turned into sym.Symbols (ex:
// funcdata), however DWARF subprogram DIE symbols (which are
// nameless) will eventually need to be turned into
// sym.Symbols (with relocations), so the simplest thing to do
// is include them as part of this loop.
if name == "" && t != sym.SDWARFINFO {
continue
}
ver := abiToVer(osym.ABI, r.version)
t := sym.AbiSymKindToSymKind[objabi.SymKind(osym.Type)]
if t == sym.SXREF {
log.Fatalf("bad sxref")
}