From d7bf8b0950cf00267ea169f1ff63813a0fda4e70 Mon Sep 17 00:00:00 2001 From: Marcus Comstedt Date: Fri, 10 Mar 2023 23:23:50 +0100 Subject: [PATCH 1/2] runtime/cgo: fix crosscall2 on linux/ppc64 (big endian) The "elf ABI v1" code in crosscall2 was incorrect because fn is not a C function but a go function, and therefore does not comply with the ELF ABI. --- src/runtime/cgo/asm_ppc64x.s | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/runtime/cgo/asm_ppc64x.s b/src/runtime/cgo/asm_ppc64x.s index c20100504443ca..18647572785b96 100644 --- a/src/runtime/cgo/asm_ppc64x.s +++ b/src/runtime/cgo/asm_ppc64x.s @@ -30,10 +30,11 @@ TEXT crosscall2(SB),NOSPLIT|NOFRAME,$0 BL runtimeĀ·reginit(SB) BL runtimeĀ·load_g(SB) -#ifdef GOARCH_ppc64 +#ifdef GOOS_aix // ppc64 use elf ABI v1. we must get the real entry address from // first slot of the function descriptor before call. - // Same for AIX. + // This applies only for AIX; on Linux go functions are represented + // by a raw pointer regardless of elf ABI version MOVD 8(R3), R2 MOVD (R3), R3 #endif From dcae630440de46b2399335e52221ee6f313fd39f Mon Sep 17 00:00:00 2001 From: Marcus Comstedt Date: Fri, 10 Mar 2023 23:27:49 +0100 Subject: [PATCH 2/2] cmd/link: enable external linking on linux/ppc64 --- src/cmd/link/internal/ld/config.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/cmd/link/internal/ld/config.go b/src/cmd/link/internal/ld/config.go index 7cce28dac52059..080315b8a15a6c 100644 --- a/src/cmd/link/internal/ld/config.go +++ b/src/cmd/link/internal/ld/config.go @@ -211,10 +211,5 @@ func determineLinkMode(ctxt *Link) { if extNeeded { Exitf("internal linking requested %sbut external linking required: %s", via, extReason) } - case LinkExternal: - switch { - case buildcfg.GOARCH == "ppc64" && buildcfg.GOOS != "aix": - Exitf("external linking not supported for %s/ppc64", buildcfg.GOOS) - } } }