From ccb8db88c5c11be65343732ef61d9d1052e6838a Mon Sep 17 00:00:00 2001 From: "Paul E. Murphy" Date: Mon, 17 Apr 2023 09:25:45 -0500 Subject: [PATCH] cmd/link,cmd/internal/obj/ppc64: enable PCrel on power10/ppc64/linux A CI machine has been set up to verify GOPPC64=power10 on ppc64/linux. This should be sufficient to verify the PCrel relocation support works for BE. Note, power10/ppc64/linux is an oddball case. Today, it can only link internally. Furthermore, all PCrel relocs are resolved at link time, so it works despite ELFv1 having no official support for PCrel relocs today. Change-Id: Ibf79df69406ec6f9352c9d7d941ad946dba74e73 Reviewed-on: https://go-review.googlesource.com/c/go/+/485075 TryBot-Result: Gopher Robot Reviewed-by: Lynn Boger Reviewed-by: Cherry Mui Run-TryBot: Paul Murphy Reviewed-by: Bryan Mills --- src/cmd/internal/obj/ppc64/asm9.go | 5 ++--- src/cmd/link/internal/ppc64/asm.go | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/cmd/internal/obj/ppc64/asm9.go b/src/cmd/internal/obj/ppc64/asm9.go index 1091127210..1575bb66d0 100644 --- a/src/cmd/internal/obj/ppc64/asm9.go +++ b/src/cmd/internal/obj/ppc64/asm9.go @@ -1300,9 +1300,8 @@ func opset(a, b0 obj.As) { // Build the opcode table func buildop(ctxt *obj.Link) { - // PC-rel relocation support is available only for targets which support - // ELFv2 1.5 (only power10/ppc64le/linux today). - pfxEnabled = buildcfg.GOPPC64 >= 10 && buildcfg.GOOS == "linux" && buildcfg.GOARCH == "ppc64le" + // Limit PC-relative prefix instruction usage to supported and tested targets. + pfxEnabled = buildcfg.GOPPC64 >= 10 && buildcfg.GOOS == "linux" cfg := fmt.Sprintf("power%d/%s/%s", buildcfg.GOPPC64, buildcfg.GOARCH, buildcfg.GOOS) if cfg == buildOpCfg { // Already initialized to correct OS/cpu; stop now. diff --git a/src/cmd/link/internal/ppc64/asm.go b/src/cmd/link/internal/ppc64/asm.go index 333411a53d..445180bb79 100644 --- a/src/cmd/link/internal/ppc64/asm.go +++ b/src/cmd/link/internal/ppc64/asm.go @@ -45,8 +45,8 @@ import ( "strings" ) -// The build configuration supports PC-relative instructions and relocations. -var hasPCrel = buildcfg.GOPPC64 >= 10 && buildcfg.GOOS == "linux" && buildcfg.GOARCH == "ppc64le" +// The build configuration supports PC-relative instructions and relocations (limited to tested targets). +var hasPCrel = buildcfg.GOPPC64 >= 10 && buildcfg.GOOS == "linux" func genpltstub(ctxt *ld.Link, ldr *loader.Loader, r loader.Reloc, s loader.Sym) (sym loader.Sym, firstUse bool) { // The ppc64 ABI PLT has similar concepts to other -- 2.48.1