// InfoPrefix is the prefix for all the symbols containing DWARF info entries.
const InfoPrefix = "go.info."
-// RangePrefix is the prefix for all the symbols containing DWARF location lists.
-const LocPrefix = "go.loc."
-
-// RangePrefix is the prefix for all the symbols containing DWARF range lists.
-const RangePrefix = "go.range."
-
// DebugLinesPrefix is the prefix for all the symbols containing DWARF debug_line information from the compiler.
const DebugLinesPrefix = "go.debuglines."
if s.Func.dwarfInfoSym == nil {
s.Func.dwarfInfoSym = ctxt.LookupDerived(s, dwarf.InfoPrefix+s.Name)
if ctxt.Flag_locationlists {
- s.Func.dwarfLocSym = ctxt.LookupDerived(s, dwarf.LocPrefix+s.Name)
+ s.Func.dwarfLocSym = &LSym{
+ Type: objabi.SDWARFLOC,
+ }
+ }
+ s.Func.dwarfRangesSym = &LSym{
+ Type: objabi.SDWARFRANGE,
}
- s.Func.dwarfRangesSym = ctxt.LookupDerived(s, dwarf.RangePrefix+s.Name)
if s.WasInlined() {
s.Func.dwarfAbsFnSym = ctxt.DwFixups.AbsFuncDwarfSym(s)
}
}
o.Write(w.Writer)
}
- if s.Func.dwarfLocSym != nil {
+ if s.Func.dwarfLocSym != nil && s.Func.dwarfLocSym.Size != 0 {
o := goobj2.Aux{
Type: goobj2.AuxDwarfLoc,
Sym: makeSymRef(s.Func.dwarfLocSym),
}
o.Write(w.Writer)
}
- if s.Func.dwarfRangesSym != nil {
+ if s.Func.dwarfRangesSym != nil && s.Func.dwarfRangesSym.Size != 0 {
o := goobj2.Aux{
Type: goobj2.AuxDwarfRanges,
Sym: makeSymRef(s.Func.dwarfRangesSym),
if s.Func.dwarfInfoSym != nil {
n++
}
- if s.Func.dwarfLocSym != nil {
+ if s.Func.dwarfLocSym != nil && s.Func.dwarfLocSym.Size != 0 {
n++
}
- if s.Func.dwarfRangesSym != nil {
+ if s.Func.dwarfRangesSym != nil && s.Func.dwarfRangesSym.Size != 0 {
n++
}
if s.Func.dwarfDebugLinesSym != nil {
infosyms = append(infosyms, isym)
s.Func.FuncInfoSym = isym
b.Reset()
+
+ dwsyms := []*LSym{s.Func.dwarfRangesSym, s.Func.dwarfLocSym}
+ for _, s := range dwsyms {
+ if s == nil || s.Size == 0 {
+ continue
+ }
+ s.PkgIdx = goobj2.PkgIdxSelf
+ s.SymIdx = symidx
+ s.Set(AttrIndexed, true)
+ symidx++
+ infosyms = append(infosyms, s)
+ }
}
ctxt.defs = append(ctxt.defs, infosyms...)
}
ctxt.Text = append(ctxt.Text, s)
// Set up DWARF entries for s.
- info, loc, ranges, _, lines := ctxt.dwarfSym(s)
+ info, _, _, _, lines := ctxt.dwarfSym(s)
info.Type = objabi.SDWARFINFO
info.Set(AttrDuplicateOK, s.DuplicateOK())
- if loc != nil {
- loc.Type = objabi.SDWARFLOC
- loc.Set(AttrDuplicateOK, s.DuplicateOK())
- ctxt.Data = append(ctxt.Data, loc)
- }
- ranges.Type = objabi.SDWARFRANGE
- ranges.Set(AttrDuplicateOK, s.DuplicateOK())
- ctxt.Data = append(ctxt.Data, info, ranges)
+ ctxt.Data = append(ctxt.Data, info)
lines.Type = objabi.SDWARFLINES
lines.Set(AttrDuplicateOK, s.DuplicateOK())
ctxt.Data = append(ctxt.Data, lines)
r := &relocs[ri]
if r.Type == objabi.R_DWARFSECREF {
rsym := r.Sym
- // NB: there should be a better way to do this that doesn't involve materializing the symbol name and doing string prefix+suffix checks.
rsn := d.ldr.SymName(rsym)
+ if len(rsn) == 0 {
+ continue
+ }
+ // NB: there should be a better way to do this that doesn't involve materializing the symbol name and doing string prefix+suffix checks.
if strings.HasPrefix(rsn, dwarf.InfoPrefix) && strings.HasSuffix(rsn, dwarf.AbstractFuncSuffix) && !d.ldr.AttrOnList(rsym) {
// abstract function
d.ldr.SetAttrOnList(rsym, true)
if reloc.Type != objabi.R_DWARFSECREF {
continue
}
- sn := d.ldr.SymName(reloc.Sym)
- if strings.HasPrefix(sn, dwarf.LocPrefix) {
+ if d.ldr.SymType(reloc.Sym) == sym.SDWARFLOC {
d.ldr.SetAttrReachable(reloc.Sym, true)
d.ldr.SetAttrNotInSymbolTable(reloc.Sym, true)
syms = append(syms, reloc.Sym)
sn := l.SymName(cand)
sv := l.SymVersion(cand)
+ st := l.SymType(cand)
if sv < 0 {
sv = anonVerReplacement
}
if sn == "" {
// Don't install anonymous symbols in the lookup tab.
if s == nil {
- s := l.allocSym(sn, sv)
+ s = l.allocSym(sn, sv)
l.installSym(cand, s)
}
isnew = true
// Always copy these from new to old.
s.Value = l.SymValue(cand)
- s.Type = l.SymType(cand)
+ s.Type = st
// If the data for a symbol has increased in size, make sure
// we bring the new content across.
// 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.
+ // 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 {
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 {