[dev.link] cmd/link: fix aux symbol handling in Funcdata

If a Go symbol is cloned to external, we should preserve its Aux
symbols for FuncInfo, etc.. We already do this in
loader.FuncInfo, but not in FuncInfo.Funcdata. Do it in the
latter as well. In fact, since FuncInfo and Funcdata should use
the same set of auxs, just record the auxs and reuse.

Should fix PPC64 build.

Change-Id: Iab9020eaca15d98fe3bb41f50f0d5bdb4999e8c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/227848
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
Cherry Zhang 2020-04-10 14:12:44 -04:00
parent 53a2a6a7fc
commit 84fb045763
2 changed files with 6 additions and 7 deletions

View file

@ -1532,6 +1532,7 @@ type FuncInfo struct {
l *Loader
r *oReader
data []byte
auxs []goobj2.Aux
lengths goobj2.FuncInfoLengths
}
@ -1603,7 +1604,7 @@ func (fi *FuncInfo) Funcdataoff(k int) int64 {
return (*goobj2.FuncInfo)(nil).ReadFuncdataoff(fi.data, fi.lengths.FuncdataoffOff, uint32(k))
}
func (fi *FuncInfo) Funcdata(fnsym Sym, syms []Sym) []Sym {
func (fi *FuncInfo) Funcdata(syms []Sym) []Sym {
if !fi.lengths.Initialized {
panic("need to call Preload first")
}
@ -1612,10 +1613,8 @@ func (fi *FuncInfo) Funcdata(fnsym Sym, syms []Sym) []Sym {
} else {
syms = syms[:0]
}
r, li := fi.l.toLocal(fnsym)
auxs := r.Auxs(li)
for j := range auxs {
a := &auxs[j]
for j := range fi.auxs {
a := &fi.auxs[j]
if a.Type() == goobj2.AuxFuncdata {
syms = append(syms, fi.l.resolve(fi.r, a.Sym()))
}
@ -1686,7 +1685,7 @@ func (l *Loader) FuncInfo(i Sym) FuncInfo {
a := &auxs[j]
if a.Type() == goobj2.AuxFuncInfo {
b := r.Data(int(a.Sym().SymIdx))
return FuncInfo{l, r, b, goobj2.FuncInfoLengths{}}
return FuncInfo{l, r, b, auxs, goobj2.FuncInfoLengths{}}
}
}
return FuncInfo{}