[dev.link] cmd/link: pass reloc by value to Adddynrel2

Adddynrel2 is a function pointer. In dynrelocsym we pass &r to
it, which will cause r to escape. Pass it by value instead.

Linking cmd/compile,

name           old alloc/op   new alloc/op   delta
Dodata_GC        15.8MB ± 0%     5.9MB ± 0%  -62.55%  (p=0.008 n=5+5)

Change-Id: Ib86005d1026ebaca57777b27ead037e613585f44
Reviewed-on: https://go-review.googlesource.com/c/go/+/231045
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
This commit is contained in:
Cherry Zhang 2020-04-30 01:32:48 -04:00
parent 5aa59c6a99
commit 516c29a79f
9 changed files with 15 additions and 15 deletions

View file

@ -714,7 +714,7 @@ func dynrelocsym2(ctxt *Link, s loader.Sym) {
// It's expected that some relocations will be done
// later by relocsym (R_TLS_LE, R_ADDROFF), so
// don't worry if Adddynrel returns false.
thearch.Adddynrel2(target, ldr, syms, s, &r, ri)
thearch.Adddynrel2(target, ldr, syms, s, r, ri)
continue
}
@ -723,7 +723,7 @@ func dynrelocsym2(ctxt *Link, s loader.Sym) {
if rSym != 0 && !ldr.AttrReachable(rSym) {
ctxt.Errorf(s, "dynamic relocation to unreachable symbol %s", ldr.SymName(rSym))
}
if !thearch.Adddynrel2(target, ldr, syms, s, &r, ri) {
if !thearch.Adddynrel2(target, ldr, syms, s, r, ri) {
ctxt.Errorf(s, "unsupported dynamic relocation for symbol %s (type=%d (%s) stype=%d (%s))", ldr.SymName(rSym), r.Type(), sym.RelocName(ctxt.Arch, r.Type()), ldr.SymType(rSym), ldr.SymType(rSym))
}
}