From 9a097ea8f2e7d00606481c4a5dcddfb8c519ce1b Mon Sep 17 00:00:00 2001 From: Than McIntosh Date: Mon, 4 May 2020 14:24:03 -0400 Subject: [PATCH] [dev.link] cmd/link: remove elderly ld bug workaround on arm64 The arm64 archreloc method contains a workaround for a 2015-era binutils/linker bug, https://sourceware.org/bugzilla/show_bug.cgi?id=18270. This bug has been fixed for some time now, so remove the workaround for it (the workaround includes some code that mutates a relocation type, which is something we want to void doing in the new linker). Change-Id: I9b7584e4daad240bbb85de673d704731705c8148 Reviewed-on: https://go-review.googlesource.com/c/go/+/232200 Run-TryBot: Than McIntosh TryBot-Result: Gobot Gobot Reviewed-by: Cherry Zhang --- src/cmd/link/internal/arm64/asm.go | 33 ++---------------------------- 1 file changed, 2 insertions(+), 31 deletions(-) diff --git a/src/cmd/link/internal/arm64/asm.go b/src/cmd/link/internal/arm64/asm.go index 7fedb04bc8..0d26878699 100644 --- a/src/cmd/link/internal/arm64/asm.go +++ b/src/cmd/link/internal/arm64/asm.go @@ -445,37 +445,8 @@ func archreloc(target *ld.Target, syms *ld.ArchSyms, r *sym.Reloc, s *sym.Symbol switch r.Type { default: return val, false - case objabi.R_ARM64_GOTPCREL: - var o1, o2 uint32 - if target.IsBigEndian() { - o1 = uint32(val >> 32) - o2 = uint32(val) - } else { - o1 = uint32(val) - o2 = uint32(val >> 32) - } - // Any relocation against a function symbol is redirected to - // be against a local symbol instead (see putelfsym in - // symtab.go) but unfortunately the system linker was buggy - // when confronted with a R_AARCH64_ADR_GOT_PAGE relocation - // against a local symbol until May 2015 - // (https://sourceware.org/bugzilla/show_bug.cgi?id=18270). So - // we convert the adrp; ld64 + R_ARM64_GOTPCREL into adrp; - // add + R_ADDRARM64. - if !(r.Sym.IsFileLocal() || r.Sym.Attr.VisibilityHidden() || r.Sym.Attr.Local()) && r.Sym.Type == sym.STEXT && target.IsDynlinkingGo() { - if o2&0xffc00000 != 0xf9400000 { - ld.Errorf(s, "R_ARM64_GOTPCREL against unexpected instruction %x", o2) - } - o2 = 0x91000000 | (o2 & 0x000003ff) - r.Type = objabi.R_ADDRARM64 - } - if target.IsBigEndian() { - val = int64(o1)<<32 | int64(o2) - } else { - val = int64(o2)<<32 | int64(o1) - } - fallthrough - case objabi.R_ADDRARM64: + case objabi.R_ARM64_GOTPCREL, + objabi.R_ADDRARM64: r.Done = false // set up addend for eventual relocation via outer symbol. -- 2.48.1