From cfa421c9a62e171db3c0cd5f0ba9de255e0514d6 Mon Sep 17 00:00:00 2001 From: Cherry Zhang Date: Fri, 11 Oct 2019 21:51:01 -0400 Subject: [PATCH] [dev.link] cmd/link: on AIX, use relocation to locate target symbol from TOC symbol On AIX, a TOC symbol always has a relocation to its target symbol. Instead of using name lookup to locate the target symbol, we can just use the relocation. Using name lookup, besides being less efficient, needs to provide the right symbol version. In this particular case, we are looking for a data symbol so it is almost always version 0. But in case that it is a text symbol, we may get an ABIALIAS symbol, which does not have its Sect set. Change-Id: I1ecfd284b04a86bbbc450059ee89d99d40493e51 Reviewed-on: https://go-review.googlesource.com/c/go/+/201019 Reviewed-by: Than McIntosh Run-TryBot: Cherry Zhang TryBot-Result: Gobot Gobot --- src/cmd/link/internal/ppc64/asm.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/link/internal/ppc64/asm.go b/src/cmd/link/internal/ppc64/asm.go index ad91be3dade..cf6a2846dec 100644 --- a/src/cmd/link/internal/ppc64/asm.go +++ b/src/cmd/link/internal/ppc64/asm.go @@ -550,7 +550,7 @@ func archreloctoc(ctxt *ld.Link, r *sym.Reloc, s *sym.Symbol, val int64) int64 { const prefix = "TOC." var tarSym *sym.Symbol if strings.HasPrefix(r.Sym.Name, prefix) { - tarSym = ctxt.Syms.ROLookup(strings.TrimPrefix(r.Sym.Name, prefix), 0) + tarSym = r.Sym.R[0].Sym } else { ld.Errorf(s, "archreloctoc called for a symbol without TOC anchor") }