mirror of
https://github.com/golang/go
synced 2024-11-17 22:24:47 -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:
parent
62b0790a79
commit
673a02a235
@ -207,7 +207,9 @@ func (ctxt *Link) dwarfSym(s *LSym) (dwarfInfoSym, dwarfLocSym, dwarfRangesSym,
|
|||||||
ctxt.Diag("dwarfSym of non-TEXT %v", s)
|
ctxt.Diag("dwarfSym of non-TEXT %v", s)
|
||||||
}
|
}
|
||||||
if s.Func.dwarfInfoSym == nil {
|
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 {
|
if ctxt.Flag_locationlists {
|
||||||
s.Func.dwarfLocSym = &LSym{
|
s.Func.dwarfLocSym = &LSym{
|
||||||
Type: objabi.SDWARFLOC,
|
Type: objabi.SDWARFLOC,
|
||||||
|
@ -299,7 +299,7 @@ func (w *writer) Aux(s *LSym) {
|
|||||||
o.Write(w.Writer)
|
o.Write(w.Writer)
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.Func.dwarfInfoSym != nil {
|
if s.Func.dwarfInfoSym != nil && s.Func.dwarfInfoSym.Size != 0 {
|
||||||
o := goobj2.Aux{
|
o := goobj2.Aux{
|
||||||
Type: goobj2.AuxDwarfInfo,
|
Type: goobj2.AuxDwarfInfo,
|
||||||
Sym: makeSymRef(s.Func.dwarfInfoSym),
|
Sym: makeSymRef(s.Func.dwarfInfoSym),
|
||||||
@ -339,7 +339,7 @@ func nAuxSym(s *LSym) int {
|
|||||||
if s.Func != nil {
|
if s.Func != nil {
|
||||||
// FuncInfo is an aux symbol, each Funcdata is an aux symbol
|
// FuncInfo is an aux symbol, each Funcdata is an aux symbol
|
||||||
n += 1 + len(s.Func.Pcln.Funcdata)
|
n += 1 + len(s.Func.Pcln.Funcdata)
|
||||||
if s.Func.dwarfInfoSym != nil {
|
if s.Func.dwarfInfoSym != nil && s.Func.dwarfInfoSym.Size != 0 {
|
||||||
n++
|
n++
|
||||||
}
|
}
|
||||||
if s.Func.dwarfLocSym != nil && s.Func.dwarfLocSym.Size != 0 {
|
if s.Func.dwarfLocSym != nil && s.Func.dwarfLocSym.Size != 0 {
|
||||||
@ -419,7 +419,7 @@ func genFuncInfoSyms(ctxt *Link) {
|
|||||||
s.Func.FuncInfoSym = isym
|
s.Func.FuncInfoSym = isym
|
||||||
b.Reset()
|
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 {
|
for _, s := range dwsyms {
|
||||||
if s == nil || s.Size == 0 {
|
if s == nil || s.Size == 0 {
|
||||||
continue
|
continue
|
||||||
|
@ -139,10 +139,7 @@ func (ctxt *Link) InitTextSym(s *LSym, flag int) {
|
|||||||
ctxt.Text = append(ctxt.Text, s)
|
ctxt.Text = append(ctxt.Text, s)
|
||||||
|
|
||||||
// Set up DWARF entries for s.
|
// Set up DWARF entries for s.
|
||||||
info, _, _, _, _ := ctxt.dwarfSym(s)
|
ctxt.dwarfSym(s)
|
||||||
info.Type = objabi.SDWARFINFO
|
|
||||||
info.Set(AttrDuplicateOK, s.DuplicateOK())
|
|
||||||
ctxt.Data = append(ctxt.Data, info)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ctxt *Link) Globl(s *LSym, size int64, flag int) {
|
func (ctxt *Link) Globl(s *LSym, size int64, flag int) {
|
||||||
|
@ -330,7 +330,7 @@ func (ctxt *Link) traverseFuncAux(flag traverseFlag, fsym *LSym, fn func(parent
|
|||||||
fn(fsym, filesym)
|
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 {
|
for _, dws := range dwsyms {
|
||||||
if dws == nil || dws.Size == 0 {
|
if dws == nil || dws.Size == 0 {
|
||||||
continue
|
continue
|
||||||
|
@ -1912,6 +1912,9 @@ func dwarfGenerateDebugInfo(ctxt *Link) {
|
|||||||
for _, s := range unit.Textp2 { // textp2 has been dead-code-eliminated already.
|
for _, s := range unit.Textp2 { // textp2 has been dead-code-eliminated already.
|
||||||
fnSym := loader.Sym(s)
|
fnSym := loader.Sym(s)
|
||||||
infosym, _, rangesym, _ := d.ldr.GetFuncDwarfAuxSyms(fnSym)
|
infosym, _, rangesym, _ := d.ldr.GetFuncDwarfAuxSyms(fnSym)
|
||||||
|
if infosym == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
d.ldr.SetAttrNotInSymbolTable(infosym, true)
|
d.ldr.SetAttrNotInSymbolTable(infosym, true)
|
||||||
d.ldr.SetAttrReachable(infosym, true)
|
d.ldr.SetAttrReachable(infosym, true)
|
||||||
|
|
||||||
|
@ -2140,11 +2140,17 @@ func loadObjSyms(l *Loader, syms *sym.Symbols, r *oReader) int {
|
|||||||
osym := goobj2.Sym{}
|
osym := goobj2.Sym{}
|
||||||
osym.Read(r.Reader, r.SymOff(i))
|
osym.Read(r.Reader, r.SymOff(i))
|
||||||
name := strings.Replace(osym.Name, "\"\".", r.pkgprefix, -1)
|
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
|
continue
|
||||||
}
|
}
|
||||||
ver := abiToVer(osym.ABI, r.version)
|
ver := abiToVer(osym.ABI, r.version)
|
||||||
t := sym.AbiSymKindToSymKind[objabi.SymKind(osym.Type)]
|
|
||||||
if t == sym.SXREF {
|
if t == sym.SXREF {
|
||||||
log.Fatalf("bad sxref")
|
log.Fatalf("bad sxref")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user