1
0
mirror of https://github.com/golang/go synced 2024-11-18 09:24:54 -07:00

[dev.link] cmd/link: convert inltree syms to anonymous in pclntab

The pclntab phase generates a series of "inltree.*" symbols with
inlining related pcdata; these symbols previously were given names and
enterered into the symbol lookup table, but there is no real reason to
do this, since they never need to be looked up when pcln generation is
done. Switch them over to anonymous symbols.

So as to insure that the later symtab phase picks them up correctly,
assign them a type of SGOFUNC instead of SRODATA, and change symtab to
look for this when assigning symbols to groups.

Change-Id: I38225dbb130ad7aea5d16f79cef3d8d388c61c2b
Reviewed-on: https://go-review.googlesource.com/c/go/+/227845
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
Than McIntosh 2020-04-10 13:07:08 -04:00
parent 2f9decbe95
commit ad6fcf6993
2 changed files with 13 additions and 12 deletions

View File

@ -192,17 +192,17 @@ func (state *pclnState) computeDeferReturn(target *Target, s loader.Sym) uint32
return deferreturn return deferreturn
} }
// genInlTreeSym generates the InlTree sym for the a given function symbol // genInlTreeSym generates the InlTree sym for a function with the
// with name 'sn'. // specified FuncInfo.
func (state *pclnState) genInlTreeSym(sn string, fi loader.FuncInfo, arch *sys.Arch) loader.Sym { func (state *pclnState) genInlTreeSym(fi loader.FuncInfo, arch *sys.Arch) loader.Sym {
itsName := "inltree." + sn
ldr := state.ldr ldr := state.ldr
if ldr.Lookup(itsName, 0) != 0 { its := ldr.CreateExtSym("", 0)
panic("should not exist yet")
}
its := ldr.LookupOrCreateSym(itsName, 0)
inlTreeSym := ldr.MakeSymbolUpdater(its) inlTreeSym := ldr.MakeSymbolUpdater(its)
inlTreeSym.SetType(sym.SRODATA) // Note: the generated symbol is given a type of sym.SGOFUNC, as a
// signal to the symtab() phase that it needs to be grouped in with
// other similar symbols (gcdata, etc); the dodata() phase will
// eventually switch the type back to SRODATA.
inlTreeSym.SetType(sym.SGOFUNC)
ldr.SetAttrReachable(its, true) ldr.SetAttrReachable(its, true)
ninl := fi.NumInlTree() ninl := fi.NumInlTree()
for i := 0; i < int(ninl); i++ { for i := 0; i < int(ninl); i++ {
@ -453,7 +453,7 @@ func (ctxt *Link) pclntab() loader.Bitmap {
} }
if fi.Valid() && fi.NumInlTree() > 0 { if fi.Valid() && fi.NumInlTree() > 0 {
its := state.genInlTreeSym(sn, fi, ctxt.Arch) its := state.genInlTreeSym(fi, ctxt.Arch)
funcdata[objabi.FUNCDATA_InlTree] = its funcdata[objabi.FUNCDATA_InlTree] = its
pcdata[objabi.PCDATA_InlTreeIndex] = sym.Pcdata{P: fi.Pcinline()} pcdata[objabi.PCDATA_InlTreeIndex] = sym.Pcdata{P: fi.Pcinline()}
} }

View File

@ -451,7 +451,8 @@ func (ctxt *Link) symtab() {
s.Attr |= sym.AttrNotInSymbolTable s.Attr |= sym.AttrNotInSymbolTable
} }
if !s.Attr.Reachable() || s.Attr.Special() || s.Type != sym.SRODATA { if !s.Attr.Reachable() || s.Attr.Special() ||
(s.Type != sym.SRODATA && s.Type != sym.SGOFUNC) {
continue continue
} }
@ -504,7 +505,7 @@ func (ctxt *Link) symtab() {
case strings.HasPrefix(s.Name, "gcargs."), case strings.HasPrefix(s.Name, "gcargs."),
strings.HasPrefix(s.Name, "gclocals."), strings.HasPrefix(s.Name, "gclocals."),
strings.HasPrefix(s.Name, "gclocals·"), strings.HasPrefix(s.Name, "gclocals·"),
strings.HasPrefix(s.Name, "inltree."), s.Type == sym.SGOFUNC && s != symgofunc,
strings.HasSuffix(s.Name, ".opendefer"): strings.HasSuffix(s.Name, ".opendefer"):
s.Type = sym.SGOFUNC s.Type = sym.SGOFUNC
s.Attr |= sym.AttrNotInSymbolTable s.Attr |= sym.AttrNotInSymbolTable