diff options
author | Josh Bleecher Snyder <josharian@gmail.com> | 2021-09-24 13:50:22 -0700 |
---|---|---|
committer | Josh Bleecher Snyder <josharian@gmail.com> | 2021-10-05 15:47:07 +0000 |
commit | cfd74f7727f6ad5a81d574c28cbee52cc13fdc52 (patch) | |
tree | 685d4822219674969d09bc9076af3e060afb273b /src/cmd/link | |
parent | 7983830423ca0017dc5d990532e28df13862dc2d (diff) | |
download | go-cfd74f7727f6ad5a81d574c28cbee52cc13fdc52.tar.gz go-cfd74f7727f6ad5a81d574c28cbee52cc13fdc52.zip |
cmd/link: move all FUNCDATA refs into go.func.*
This change moves all symbols referred to by FUNCDATA
into go.func.* and go.funcrel.*.
Surprisingly (because it inhibits some content-addressability),
it shrinks binaries by a little bit, about 0.1%.
This paves the way for a subsequent change to change
FUNCDATA relocations to offsets.
Change-Id: I70e487205073699f442192b0791cc92da5663057
Reviewed-on: https://go-review.googlesource.com/c/go/+/352189
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Diffstat (limited to 'src/cmd/link')
-rw-r--r-- | src/cmd/link/internal/ld/symtab.go | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/cmd/link/internal/ld/symtab.go b/src/cmd/link/internal/ld/symtab.go index 5e7eeeb94f..7fddc59bb5 100644 --- a/src/cmd/link/internal/ld/symtab.go +++ b/src/cmd/link/internal/ld/symtab.go @@ -507,13 +507,9 @@ func (ctxt *Link) symtab(pcln *pclntab) []sym.SymKind { symgcbits = groupSym("runtime.gcbits.*", sym.SGCBITS) ) - var symgofuncrel loader.Sym - if !ctxt.DynlinkingGo() { - if ctxt.UseRelro() { - symgofuncrel = groupSym("go.funcrel.*", sym.SGOFUNCRELRO) - } else { - symgofuncrel = symgofunc - } + symgofuncrel := symgofunc + if ctxt.UseRelro() { + symgofuncrel = groupSym("go.funcrel.*", sym.SGOFUNCRELRO) } symt := ldr.CreateSymForUpdate("runtime.symtab", 0) @@ -555,7 +551,7 @@ func (ctxt *Link) symtab(pcln *pclntab) []sym.SymKind { } if ctxt.UseRelro() { symGroupType[s] = sym.SGOFUNCRELRO - if symgofuncrel != 0 { + if !ctxt.DynlinkingGo() { ldr.SetCarrierSym(s, symgofuncrel) } } else { @@ -569,10 +565,17 @@ func (ctxt *Link) symtab(pcln *pclntab) []sym.SymKind { ldr.SymType(s) == sym.SGOFUNC && s != symgofunc, // inltree, see pcln.go strings.HasSuffix(name, ".opendefer"), strings.HasSuffix(name, ".arginfo0"), - strings.HasSuffix(name, ".arginfo1"): - symGroupType[s] = sym.SGOFUNC + strings.HasSuffix(name, ".arginfo1"), + strings.HasSuffix(name, ".args_stackmap"), + strings.HasSuffix(name, ".stkobj"): ldr.SetAttrNotInSymbolTable(s, true) - ldr.SetCarrierSym(s, symgofunc) + if ctxt.UseRelro() && strings.HasSuffix(name, ".stkobj") { + symGroupType[s] = sym.SGOFUNCRELRO + ldr.SetCarrierSym(s, symgofuncrel) + } else { + symGroupType[s] = sym.SGOFUNC + ldr.SetCarrierSym(s, symgofunc) + } if ctxt.Debugvlog != 0 { align := ldr.SymAlign(s) liveness += (ldr.SymSize(s) + int64(align) - 1) &^ (int64(align) - 1) |