mirror of
https://github.com/golang/go
synced 2024-11-18 11:55:01 -07:00
[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:
parent
5aa59c6a99
commit
516c29a79f
@ -78,7 +78,7 @@ func makeWritable(s *sym.Symbol) {
|
||||
}
|
||||
}
|
||||
|
||||
func adddynrel2(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, s loader.Sym, r *loader.Reloc2, rIdx int) bool {
|
||||
func adddynrel2(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, s loader.Sym, r loader.Reloc2, rIdx int) bool {
|
||||
targ := r.Sym()
|
||||
var targType sym.SymKind
|
||||
if targ != 0 {
|
||||
@ -242,7 +242,7 @@ func adddynrel2(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, s load
|
||||
|
||||
// Reread the reloc to incorporate any changes in type above.
|
||||
relocs := ldr.Relocs(s)
|
||||
*r = relocs.At2(rIdx)
|
||||
r = relocs.At2(rIdx)
|
||||
|
||||
switch r.Type() {
|
||||
case objabi.R_CALL,
|
||||
|
@ -103,7 +103,7 @@ func braddoff(a int32, b int32) int32 {
|
||||
return int32((uint32(a))&0xff000000 | 0x00ffffff&uint32(a+b))
|
||||
}
|
||||
|
||||
func adddynrel2(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, s loader.Sym, r *loader.Reloc2, rIdx int) bool {
|
||||
func adddynrel2(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, s loader.Sym, r loader.Reloc2, rIdx int) bool {
|
||||
|
||||
targ := r.Sym()
|
||||
var targType sym.SymKind
|
||||
@ -216,7 +216,7 @@ func adddynrel2(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, s load
|
||||
|
||||
// Reread the reloc to incorporate any changes in type above.
|
||||
relocs := ldr.Relocs(s)
|
||||
*r = relocs.At2(rIdx)
|
||||
r = relocs.At2(rIdx)
|
||||
|
||||
switch r.Type() {
|
||||
case objabi.R_CALLARM:
|
||||
|
@ -78,7 +78,7 @@ func gentext2(ctxt *ld.Link, ldr *loader.Loader) {
|
||||
initfunc.AddReloc(rel2)
|
||||
}
|
||||
|
||||
func adddynrel2(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, s loader.Sym, r *loader.Reloc2, rIdx int) bool {
|
||||
func adddynrel2(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, s loader.Sym, r loader.Reloc2, rIdx int) bool {
|
||||
|
||||
targ := r.Sym()
|
||||
var targType sym.SymKind
|
||||
@ -213,7 +213,7 @@ func adddynrel2(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, s load
|
||||
|
||||
// Reread the reloc to incorporate any changes in type above.
|
||||
relocs := ldr.Relocs(s)
|
||||
*r = relocs.At2(rIdx)
|
||||
r = relocs.At2(rIdx)
|
||||
|
||||
switch r.Type() {
|
||||
case objabi.R_CALL,
|
||||
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
@ -233,7 +233,7 @@ type Arch struct {
|
||||
Dragonflydynld string
|
||||
Solarisdynld string
|
||||
Adddynrel func(*Target, *loader.Loader, *ArchSyms, *sym.Symbol, *sym.Reloc) bool
|
||||
Adddynrel2 func(*Target, *loader.Loader, *ArchSyms, loader.Sym, *loader.Reloc2, int) bool
|
||||
Adddynrel2 func(*Target, *loader.Loader, *ArchSyms, loader.Sym, loader.Reloc2, int) bool
|
||||
Archinit func(*Link)
|
||||
// Archreloc is an arch-specific hook that assists in relocation processing
|
||||
// (invoked by 'relocsym'); it handles target-specific relocation tasks.
|
||||
|
@ -1109,7 +1109,7 @@ func (f *xcoffFile) adddynimpsym(ctxt *Link, s loader.Sym) {
|
||||
|
||||
// Xcoffadddynrel adds a dynamic relocation in a XCOFF file.
|
||||
// This relocation will be made by the loader.
|
||||
func Xcoffadddynrel2(target *Target, ldr *loader.Loader, syms *ArchSyms, s loader.Sym, r *loader.Reloc2, rIdx int) bool {
|
||||
func Xcoffadddynrel2(target *Target, ldr *loader.Loader, syms *ArchSyms, s loader.Sym, r loader.Reloc2, rIdx int) bool {
|
||||
if target.IsExternal() {
|
||||
return true
|
||||
}
|
||||
|
@ -267,7 +267,7 @@ func gencallstub2(ctxt *ld.Link, ldr *loader.Loader, abicase int, stub *loader.S
|
||||
stub.AddUint32(ctxt.Arch, 0x4e800420) // bctr
|
||||
}
|
||||
|
||||
func adddynrel2(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, s loader.Sym, r *loader.Reloc2, rIdx int) bool {
|
||||
func adddynrel2(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, s loader.Sym, r loader.Reloc2, rIdx int) bool {
|
||||
if target.IsElf() {
|
||||
return addelfdynrel2(target, ldr, syms, s, r, rIdx)
|
||||
} else if target.IsAIX() {
|
||||
@ -276,7 +276,7 @@ func adddynrel2(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, s load
|
||||
return false
|
||||
}
|
||||
|
||||
func addelfdynrel2(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, s loader.Sym, r *loader.Reloc2, rIdx int) bool {
|
||||
func addelfdynrel2(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, s loader.Sym, r loader.Reloc2, rIdx int) bool {
|
||||
targ := r.Sym()
|
||||
var targType sym.SymKind
|
||||
if targ != 0 {
|
||||
|
@ -75,7 +75,7 @@ func gentext2(ctxt *ld.Link, ldr *loader.Loader) {
|
||||
initfunc.AddUint32(ctxt.Arch, 0)
|
||||
}
|
||||
|
||||
func adddynrel2(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, s loader.Sym, r *loader.Reloc2, rIdx int) bool {
|
||||
func adddynrel2(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, s loader.Sym, r loader.Reloc2, rIdx int) bool {
|
||||
targ := r.Sym()
|
||||
var targType sym.SymKind
|
||||
if targ != 0 {
|
||||
|
@ -129,7 +129,7 @@ func gentext2(ctxt *ld.Link, ldr *loader.Loader) {
|
||||
o(0xc3)
|
||||
}
|
||||
|
||||
func adddynrel2(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, s loader.Sym, r *loader.Reloc2, rIdx int) bool {
|
||||
func adddynrel2(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, s loader.Sym, r loader.Reloc2, rIdx int) bool {
|
||||
targ := r.Sym()
|
||||
var targType sym.SymKind
|
||||
if targ != 0 {
|
||||
@ -281,7 +281,7 @@ func adddynrel2(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, s load
|
||||
|
||||
// Reread the reloc to incorporate any changes in type above.
|
||||
relocs := ldr.Relocs(s)
|
||||
*r = relocs.At2(rIdx)
|
||||
r = relocs.At2(rIdx)
|
||||
|
||||
switch r.Type() {
|
||||
case objabi.R_CALL,
|
||||
|
Loading…
Reference in New Issue
Block a user