[dev.link] cmd/link, cmd/compile: create content addressable pcdata syms

Switch pcdata over to content addressable symbols. This is the last
step before removing these from pclntab_old.

No meaningful benchmarks changes come from this work.

Change-Id: I3f74f3d6026a278babe437c8010e22992c92bd89
Reviewed-on: https://go-review.googlesource.com/c/go/+/247399
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
Jeremy Faller 2020-08-07 11:31:20 -04:00
parent 954db9fe51
commit 5387cdcb24
10 changed files with 181 additions and 131 deletions

View file

@ -236,7 +236,15 @@ func (f *goobjFile) PCToLine(pc uint64) (string, int, *gosym.Func) {
if arch == nil {
return "", 0, nil
}
pcdataBase := r.PcdataBase()
getSymData := func(s goobj.SymRef) []byte {
if s.PkgIdx != goobj.PkgIdxHashed {
// We don't need the data for non-hashed symbols, yet.
panic("not supported")
}
i := uint32(s.SymIdx + uint32(r.NSym()+r.NHashed64def()))
return r.BytesAt(r.DataOff(i), r.DataSize(i))
}
ndef := uint32(r.NSym() + r.NHashed64def() + r.NHasheddef() + r.NNonpkgdef())
for i := uint32(0); i < ndef; i++ {
osym := r.Sym(i)
@ -262,11 +270,9 @@ func (f *goobjFile) PCToLine(pc uint64) (string, int, *gosym.Func) {
b := r.BytesAt(r.DataOff(isym), r.DataSize(isym))
var info *goobj.FuncInfo
lengths := info.ReadFuncInfoLengths(b)
off, end := info.ReadPcline(b)
pcline := r.BytesAt(pcdataBase+off, int(end-off))
pcline := getSymData(info.ReadPcline(b))
line := int(pcValue(pcline, pc-addr, arch))
off, end = info.ReadPcfile(b)
pcfile := r.BytesAt(pcdataBase+off, int(end-off))
pcfile := getSymData(info.ReadPcfile(b))
fileID := pcValue(pcfile, pc-addr, arch)
globalFileID := info.ReadFile(b, lengths.FileOff, uint32(fileID))
fileName := r.File(int(globalFileID))