]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.link] cmd/link: convert inltree syms to anonymous in pclntab
authorThan McIntosh <thanm@google.com>
Fri, 10 Apr 2020 17:07:08 +0000 (13:07 -0400)
committerThan McIntosh <thanm@google.com>
Mon, 13 Apr 2020 00:37:11 +0000 (00:37 +0000)
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>
src/cmd/link/internal/ld/pcln.go
src/cmd/link/internal/ld/symtab.go

index 8f1e0a423bcc2543e1cfe4d58af720e82e810c92..9e2a4b2ffa169300a9f2c2143ed92e9f68893884 100644 (file)
@@ -192,17 +192,17 @@ func (state *pclnState) computeDeferReturn(target *Target, s loader.Sym) uint32
        return deferreturn
 }
 
-// genInlTreeSym generates the InlTree sym for the a given function symbol
-// with name 'sn'.
-func (state *pclnState) genInlTreeSym(sn string, fi loader.FuncInfo, arch *sys.Arch) loader.Sym {
-       itsName := "inltree." + sn
+// genInlTreeSym generates the InlTree sym for a function with the
+// specified FuncInfo.
+func (state *pclnState) genInlTreeSym(fi loader.FuncInfo, arch *sys.Arch) loader.Sym {
        ldr := state.ldr
-       if ldr.Lookup(itsName, 0) != 0 {
-               panic("should not exist yet")
-       }
-       its := ldr.LookupOrCreateSym(itsName, 0)
+       its := ldr.CreateExtSym("", 0)
        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)
        ninl := fi.NumInlTree()
        for i := 0; i < int(ninl); i++ {
@@ -453,7 +453,7 @@ func (ctxt *Link) pclntab() loader.Bitmap {
                }
 
                if fi.Valid() && fi.NumInlTree() > 0 {
-                       its := state.genInlTreeSym(sn, fi, ctxt.Arch)
+                       its := state.genInlTreeSym(fi, ctxt.Arch)
                        funcdata[objabi.FUNCDATA_InlTree] = its
                        pcdata[objabi.PCDATA_InlTreeIndex] = sym.Pcdata{P: fi.Pcinline()}
                }
index 290bf5edaa56ec37b0c22a7f2233057b216cf4ed..c7b83f2192beb76ef10bf921c14f4420cb087937 100644 (file)
@@ -451,7 +451,8 @@ func (ctxt *Link) symtab() {
                        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
                }
 
@@ -504,7 +505,7 @@ func (ctxt *Link) symtab() {
                case strings.HasPrefix(s.Name, "gcargs."),
                        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"):
                        s.Type = sym.SGOFUNC
                        s.Attr |= sym.AttrNotInSymbolTable