[dev.link] cmd/link: create symbol updated lazily in amd64 adddynrel

Tweak the code in the amd64 version of adddynrel to avoid creating a
symbol updated for the symbol being processed until it's clear we need
to alter its relocations. This should help performance for the
PIE+internal linking scenario.

Reviewed-on: https://go-review.googlesource.com/c/go/+/229866
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>

Change-Id: Id25adfd81a5bbd2dde0f80a83b976397ba6abfb5
Reviewed-on: https://go-review.googlesource.com/c/go/+/230026
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
Than McIntosh 2020-04-24 11:07:17 -04:00 committed by Cherry Zhang
parent 027055240f
commit 42cca1a7fe
2 changed files with 11 additions and 6 deletions

View file

@ -684,10 +684,6 @@ func dynrelocsym2(ctxt *Link, s loader.Sym) {
relocs := ldr.Relocs(s)
for ri := 0; ri < relocs.Count(); ri++ {
r := relocs.At2(ri)
// FIXME: the call to Adddynrel2 below is going to wind up
// eagerly promoting the symbol to external, which is not great--
// it would improve things for internal/PIE if we could
// create the symbol updater lazily.
if ctxt.BuildMode == BuildModePIE && ctxt.LinkMode == LinkInternal {
// It's expected that some relocations will be done
// later by relocsym (R_TLS_LE, R_ADDROFF), so