From 583eeaae509a01cc50955c4174044b9dac539ff6 Mon Sep 17 00:00:00 2001 From: Cherry Mui Date: Mon, 27 Sep 2021 15:55:53 -0400 Subject: [PATCH] cmd/internal/objfile: use aux symbol for pcdata references Pcdata are now separate aux symbols. Read them from aux, instead of using funcinfo. Change-Id: Ib3e4b5cff1e3329d0600504a8829a969a9c9f517 Reviewed-on: https://go-review.googlesource.com/c/go/+/352612 Trust: Cherry Mui Trust: Josh Bleecher Snyder Run-TryBot: Cherry Mui TryBot-Result: Go Bot Reviewed-by: Josh Bleecher Snyder --- src/cmd/internal/goobj/objfile.go | 2 ++ src/cmd/internal/objfile/goobj.go | 25 ++++++++++--------------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/cmd/internal/goobj/objfile.go b/src/cmd/internal/goobj/objfile.go index fc6dbb8af6e..2c44696f84c 100644 --- a/src/cmd/internal/goobj/objfile.go +++ b/src/cmd/internal/goobj/objfile.go @@ -357,6 +357,8 @@ type SymRef struct { SymIdx uint32 } +func (s SymRef) IsZero() bool { return s == SymRef{} } + // Hash64 type Hash64Type [Hash64Size]byte diff --git a/src/cmd/internal/objfile/goobj.go b/src/cmd/internal/objfile/goobj.go index dd21d223511..24d2d0bb5c7 100644 --- a/src/cmd/internal/objfile/goobj.go +++ b/src/cmd/internal/objfile/goobj.go @@ -250,26 +250,21 @@ func (f *goobjFile) PCToLine(pc uint64) (string, int, *gosym.Func) { if pc < addr || pc >= addr+uint64(osym.Siz()) { continue } - isym := ^uint32(0) - auxs := r.Auxs(i) - for j := range auxs { - a := &auxs[j] - if a.Type() != goobj.AuxFuncInfo { - continue + var pcfileSym, pclineSym goobj.SymRef + for _, a := range r.Auxs(i) { + switch a.Type() { + case goobj.AuxPcfile: + pcfileSym = a.Sym() + case goobj.AuxPcline: + pclineSym = a.Sym() } - if a.Sym().PkgIdx != goobj.PkgIdxSelf { - panic("funcinfo symbol not defined in current package") - } - isym = a.Sym().SymIdx } - if isym == ^uint32(0) { + if pcfileSym.IsZero() || pclineSym.IsZero() { continue } - b := r.BytesAt(r.DataOff(isym), r.DataSize(isym)) - var info *goobj.FuncInfo - pcline := getSymData(info.ReadPcline(b)) + pcline := getSymData(pclineSym) line := int(pcValue(pcline, pc-addr, f.arch)) - pcfile := getSymData(info.ReadPcfile(b)) + pcfile := getSymData(pcfileSym) fileID := pcValue(pcfile, pc-addr, f.arch) fileName := r.File(int(fileID)) // Note: we provide only the name in the Func structure.