cmd/link, cmd/internal/obj: use aux symbol for global variable DWARF info

Currently, for a global variable, its debug info symbol is a named
symbol with the variable's name with a special prefix. And the
linker looks it up by name. This CL makes the debug info symbol an
aux symbol of the variable symbol.

Change-Id: I55614d0ef2af9c53eb40144ad80e09339bf3cbee
Reviewed-on: https://go-review.googlesource.com/c/go/+/490816
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
Cherry Mui 2023-04-28 21:35:31 -04:00
parent 04f059f9ef
commit 4e8c6af239
6 changed files with 62 additions and 24 deletions

View file

@ -1685,6 +1685,15 @@ func (l *Loader) GetFuncDwarfAuxSyms(fnSymIdx Sym) (auxDwarfInfo, auxDwarfLoc, a
return
}
func (l *Loader) GetVarDwarfAuxSym(i Sym) Sym {
aux := l.aux1(i, goobj.AuxDwarfInfo)
if aux != 0 && l.SymType(aux) != sym.SDWARFVAR {
fmt.Println(l.SymName(i), l.SymType(i), l.SymType(aux), sym.SDWARFVAR)
panic("aux dwarf info sym with wrong type")
}
return aux
}
// AddInteriorSym sets up 'interior' as an interior symbol of
// container/payload symbol 'container'. An interior symbol does not
// itself have data, but gives a name to a subrange of the data in its