From 2369e01234d97e85e9919ef7d30bc0f8f4111f69 Mon Sep 17 00:00:00 2001 From: Cherry Zhang Date: Tue, 28 Jul 2020 13:33:47 -0400 Subject: [PATCH] [dev.link] cmd/link: fix accidental escape in extreloc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We accidentally passed the address of a local to a function pointer, where we should pass the address of a global. Linking cmd/compile with external linking: Asmb2_GC 32.5ms ± 5% 21.6ms ± 3% -33.57% (p=0.016 n=5+4) Asmb2_GC 29.2MB ± 0% 6.4MB ± 0% -78.20% (p=0.008 n=5+5) Asmb2_GC 1.43M ± 0% 0.00M ± 4% -99.98% (p=0.008 n=5+5) Change-Id: I4754189bcc20f824627d95858ba35285d53c614d Reviewed-on: https://go-review.googlesource.com/c/go/+/245337 Run-TryBot: Cherry Zhang TryBot-Result: Gobot Gobot Reviewed-by: Jeremy Faller --- src/cmd/link/internal/ld/data.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cmd/link/internal/ld/data.go b/src/cmd/link/internal/ld/data.go index f06aa422d9..2a3d6e7fe7 100644 --- a/src/cmd/link/internal/ld/data.go +++ b/src/cmd/link/internal/ld/data.go @@ -540,7 +540,7 @@ func (st *relocSymState) relocsym(s loader.Sym, P []byte) { // Convert a Go relocation to an external relocation. func extreloc(ctxt *Link, ldr *loader.Loader, s loader.Sym, r loader.Reloc2, ri int) (loader.ExtReloc, bool) { var rr loader.ExtReloc - target := ctxt.Target + target := &ctxt.Target siz := int32(r.Siz()) if siz == 0 { // informational relocation - no work to do return rr, false @@ -563,7 +563,7 @@ func extreloc(ctxt *Link, ldr *loader.Loader, s loader.Sym, r loader.Reloc2, ri switch rt { default: - return thearch.Extreloc(&target, ldr, r, s) + return thearch.Extreloc(target, ldr, r, s) case objabi.R_TLS_LE, objabi.R_TLS_IE: if target.IsElf() {