diff options
author | Cherry Mui <cherryyz@google.com> | 2021-09-30 18:09:24 -0400 |
---|---|---|
committer | Cherry Mui <cherryyz@google.com> | 2021-10-01 15:59:38 +0000 |
commit | e5ad363fff6e602bf72ce7bf5084297c0d1a2e51 (patch) | |
tree | 7254c4ecc9cb68d1aa99dd190b0a8dd38f30f1af /src/cmd/link | |
parent | 8d494b08189cda1b66b9f851d4d7088c77ac7b6b (diff) | |
download | go-e5ad363fff6e602bf72ce7bf5084297c0d1a2e51.tar.gz go-e5ad363fff6e602bf72ce7bf5084297c0d1a2e51.zip |
cmd/link: correct type..importpath symbol handling
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>
Diffstat (limited to 'src/cmd/link')
-rw-r--r-- | src/cmd/link/internal/ld/symtab.go | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/src/cmd/link/internal/ld/symtab.go b/src/cmd/link/internal/ld/symtab.go index 4d099b1133..1e5c73c573 100644 --- a/src/cmd/link/internal/ld/symtab.go +++ b/src/cmd/link/internal/ld/symtab.go @@ -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. } } |