]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: correct type..importpath symbol handling
authorCherry Mui <cherryyz@google.com>
Thu, 30 Sep 2021 22:09:24 +0000 (18:09 -0400)
committerCherry Mui <cherryyz@google.com>
Fri, 1 Oct 2021 15:59:38 +0000 (15:59 +0000)
The linker specially handles go.importpath symbols. But the
compiler doesn't actually generate such symbols. Instead, it
generates type..importpath symbols. It is already in the type
section as the name starts with "type.". Also set its alignment
to 1, as it is string data.

Change-Id: I771f5529a0ff41a5bb476b3a02c8cc75729792de
Reviewed-on: https://go-review.googlesource.com/c/go/+/353489
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
src/cmd/link/internal/ld/symtab.go

index 4d099b1133f7fad92c0e8c0a66c6010ccd318f57..1e5c73c57323c764c3f16e4ab871dae034bf7346 100644 (file)
@@ -540,11 +540,6 @@ func (ctxt *Link) symtab(pcln *pclntab) []sym.SymKind {
                align := int32(1)
                name := ldr.SymName(s)
                switch {
-               case strings.HasPrefix(name, "go.importpath.") && ctxt.UseRelro():
-                       // Keep go.importpath symbols in the same section as types and
-                       // names, as they can be referred to by a section offset.
-                       symGroupType[s] = sym.STYPERELRO
-
                case strings.HasPrefix(name, "go.string."):
                        symGroupType[s] = sym.SGOSTRING
                        ldr.SetAttrNotInSymbolTable(s, true)
@@ -611,7 +606,7 @@ func (ctxt *Link) symtab(pcln *pclntab) []sym.SymKind {
                                        ldr.SetCarrierSym(s, symtype)
                                }
                        }
-                       if strings.HasPrefix(name, "type..namedata.") && ldr.SymAlign(s) == 0 {
+                       if (strings.HasPrefix(name, "type..namedata.") || strings.HasPrefix(name, "type..importpath.")) && ldr.SymAlign(s) == 0 {
                                ldr.SetSymAlign(s, 1) // String data is just bytes, no padding.
                        }
                }