]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.link] cmd/compile: mark stmp and stkobj symbols as static
authorThan McIntosh <thanm@google.com>
Tue, 30 Jun 2020 11:55:16 +0000 (07:55 -0400)
committerThan McIntosh <thanm@google.com>
Wed, 8 Jul 2020 16:04:06 +0000 (16:04 +0000)
Mark compiler-generated ".stmp_%d" and "<fn>.stkobj" symbols as
AttrStatic, so as to tell the linker that they do not need to be
inserted into its name lookup tables.

Change-Id: I59ffd11659b2c54c2d0ad41275d05c3f919e3b88
Reviewed-on: https://go-review.googlesource.com/c/go/+/240497
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/compile/internal/gc/obj.go
src/cmd/compile/internal/gc/sinit.go
src/cmd/internal/obj/plist.go
src/cmd/internal/obj/sym.go

index 01126dc0489efe59c16d8b8debf98a8ba7184e89..4f511f9c7b8f9e8aa28ef1e00c39dfbe6f9112cd 100644 (file)
@@ -291,10 +291,8 @@ func addGCLocals() {
                }
                if x := s.Func.StackObjects; x != nil {
                        attr := int16(obj.RODATA)
-                       if s.DuplicateOK() {
-                               attr |= obj.DUPOK
-                       }
                        ggloblsym(x, int32(len(x.P)), attr)
+                       x.Set(obj.AttrStatic, true)
                }
                if x := s.Func.OpenCodedDeferInfo; x != nil {
                        ggloblsym(x, int32(len(x.P)), obj.RODATA|obj.DUPOK)
index 3c7571819e00cf902b68c545f4ec249f710dc980..83274bf6a3eb2eb4496fd803b319c07b616edc1a 100644 (file)
@@ -6,6 +6,7 @@ package gc
 
 import (
        "cmd/compile/internal/types"
+       "cmd/internal/obj"
        "fmt"
 )
 
@@ -360,7 +361,7 @@ var statuniqgen int // name generator for static temps
 // returned node for readonly nodes.
 func staticname(t *types.Type) *Node {
        // Don't use lookupN; it interns the resulting string, but these are all unique.
-       n := newname(lookup(fmt.Sprintf(".stmp_%d", statuniqgen)))
+       n := newname(lookup(fmt.Sprintf("%s%d", obj.StaticNamePref, statuniqgen)))
        statuniqgen++
        addvar(n, t, PEXTERN)
        return n
index d4f9089a2e750b4c64a5ba0e775bf7d866043a38..b27e6c163d563f983cf55ee6902915a08f77a4b4 100644 (file)
@@ -170,6 +170,9 @@ func (ctxt *Link) Globl(s *LSym, size int64, flag int) {
        } else if flag&TLSBSS != 0 {
                s.Type = objabi.STLSBSS
        }
+       if strings.HasPrefix(s.Name, "\"\"."+StaticNamePref) {
+               s.Set(AttrStatic, true)
+       }
 }
 
 // EmitEntryLiveness generates PCDATA Progs after p to switch to the
index bfc405cffbf2ec2cf5d64152421c90d3c35c18ac..7f5d9ebeea8b135ec2dd52a1585b0fdbd92830bc 100644 (file)
@@ -264,6 +264,11 @@ func isNonPkgSym(ctxt *Link, s *LSym) bool {
        return false
 }
 
+// StaticNamePref is the prefix the front end applies to static temporary
+// variables. When turned into LSyms, these can be tagged as static so
+// as to avoid inserting them into the linker's name lookup tables.
+const StaticNamePref = ".stmp_"
+
 type traverseFlag uint32
 
 const (