mirror of
https://github.com/golang/go
synced 2024-11-17 17:04:47 -07:00
[dev.link] cmd/link: demote DWARF line symbols to anonymous aux
Convert DWARF .debug_line symbols to anonymous aux syms, so as to save space in object files and reduce the number of symbols that have to be added to the linker's lookup tables. Change-Id: I5b350f036e21a7a7128cb08148ab7c243aaf0d0b Reviewed-on: https://go-review.googlesource.com/c/go/+/223018 Reviewed-by: Jeremy Faller <jeremy@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
c44af2d4a2
commit
ad92148058
@ -21,9 +21,6 @@ import (
|
||||
// InfoPrefix is the prefix for all the symbols containing DWARF info entries.
|
||||
const InfoPrefix = "go.info."
|
||||
|
||||
// DebugLinesPrefix is the prefix for all the symbols containing DWARF debug_line information from the compiler.
|
||||
const DebugLinesPrefix = "go.debuglines."
|
||||
|
||||
// ConstInfoPrefix is the prefix for all symbols containing DWARF info
|
||||
// entries that contain constants.
|
||||
const ConstInfoPrefix = "go.constinfo."
|
||||
|
@ -219,7 +219,9 @@ func (ctxt *Link) dwarfSym(s *LSym) (dwarfInfoSym, dwarfLocSym, dwarfRangesSym,
|
||||
if s.WasInlined() {
|
||||
s.Func.dwarfAbsFnSym = ctxt.DwFixups.AbsFuncDwarfSym(s)
|
||||
}
|
||||
s.Func.dwarfDebugLinesSym = ctxt.LookupDerived(s, dwarf.DebugLinesPrefix+s.Name)
|
||||
s.Func.dwarfDebugLinesSym = &LSym{
|
||||
Type: objabi.SDWARFLINES,
|
||||
}
|
||||
}
|
||||
return s.Func.dwarfInfoSym, s.Func.dwarfLocSym, s.Func.dwarfRangesSym, s.Func.dwarfAbsFnSym, s.Func.dwarfDebugLinesSym
|
||||
}
|
||||
|
@ -320,7 +320,7 @@ func (w *writer) Aux(s *LSym) {
|
||||
}
|
||||
o.Write(w.Writer)
|
||||
}
|
||||
if s.Func.dwarfDebugLinesSym != nil {
|
||||
if s.Func.dwarfDebugLinesSym != nil && s.Func.dwarfDebugLinesSym.Size != 0 {
|
||||
o := goobj2.Aux{
|
||||
Type: goobj2.AuxDwarfLines,
|
||||
Sym: makeSymRef(s.Func.dwarfDebugLinesSym),
|
||||
@ -348,7 +348,7 @@ func nAuxSym(s *LSym) int {
|
||||
if s.Func.dwarfRangesSym != nil && s.Func.dwarfRangesSym.Size != 0 {
|
||||
n++
|
||||
}
|
||||
if s.Func.dwarfDebugLinesSym != nil {
|
||||
if s.Func.dwarfDebugLinesSym != nil && s.Func.dwarfDebugLinesSym.Size != 0 {
|
||||
n++
|
||||
}
|
||||
}
|
||||
@ -419,7 +419,7 @@ func genFuncInfoSyms(ctxt *Link) {
|
||||
s.Func.FuncInfoSym = isym
|
||||
b.Reset()
|
||||
|
||||
dwsyms := []*LSym{s.Func.dwarfRangesSym, s.Func.dwarfLocSym}
|
||||
dwsyms := []*LSym{s.Func.dwarfRangesSym, s.Func.dwarfLocSym, s.Func.dwarfDebugLinesSym}
|
||||
for _, s := range dwsyms {
|
||||
if s == nil || s.Size == 0 {
|
||||
continue
|
||||
|
@ -139,13 +139,10 @@ func (ctxt *Link) InitTextSym(s *LSym, flag int) {
|
||||
ctxt.Text = append(ctxt.Text, s)
|
||||
|
||||
// Set up DWARF entries for s.
|
||||
info, _, _, _, lines := ctxt.dwarfSym(s)
|
||||
info, _, _, _, _ := ctxt.dwarfSym(s)
|
||||
info.Type = objabi.SDWARFINFO
|
||||
info.Set(AttrDuplicateOK, s.DuplicateOK())
|
||||
ctxt.Data = append(ctxt.Data, info)
|
||||
lines.Type = objabi.SDWARFLINES
|
||||
lines.Set(AttrDuplicateOK, s.DuplicateOK())
|
||||
ctxt.Data = append(ctxt.Data, lines)
|
||||
}
|
||||
|
||||
func (ctxt *Link) Globl(s *LSym, size int64, flag int) {
|
||||
|
@ -325,7 +325,7 @@ func (ctxt *Link) traverseFuncAux(fsym *LSym, fn func(parent *LSym, aux *LSym))
|
||||
fn(fsym, filesym)
|
||||
}
|
||||
}
|
||||
dwsyms := []*LSym{fsym.Func.dwarfRangesSym, fsym.Func.dwarfLocSym}
|
||||
dwsyms := []*LSym{fsym.Func.dwarfRangesSym, fsym.Func.dwarfLocSym, fsym.Func.dwarfDebugLinesSym}
|
||||
for _, dws := range dwsyms {
|
||||
if dws == nil || dws.Size == 0 {
|
||||
continue
|
||||
|
Loading…
Reference in New Issue
Block a user