]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: provide and use a GO_PPC64X_HAS_FUNCDESC define
authorJoel Sing <joel@sing.id.au>
Tue, 14 Mar 2023 09:50:38 +0000 (20:50 +1100)
committerJoel Sing <joel@sing.id.au>
Sat, 18 Mar 2023 06:28:23 +0000 (06:28 +0000)
Rather than implying that all ppc64 GOARCHs use function descriptors,
provide a define for platforms that make use of function descriptors.
Condition on GO_PPC64X_HAS_FUNCDESC when choosing whether or not
to load the entry address from the first slot of the function
descriptor.

Updates #56001.

Change-Id: I9cdc788f2de70a1262c17d8485b555383d1374b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/476117
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/runtime/asm_ppc64x.h
src/runtime/asm_ppc64x.s
src/runtime/cgo/asm_ppc64x.s

index 5e55055fdbc61ac00ef4003aee25e45c5f0412f4..cce5537a9cb59b7e060170a654d45099af13ff83 100644 (file)
 // and currently always use that much, PIC on ppc64 would need to use 48).
 
 #define FIXED_FRAME 32
+
+// aix/ppc64 uses XCOFF which has function descriptors.
+#ifdef GOOS_aix
+#ifdef GOARCH_ppc64
+#define GO_PPC64X_HAS_FUNCDESC
+#endif
+#endif
+
+// linux/ppc64 uses ELFv1 which has function descriptors.
+#ifdef GOOS_linux
+#ifdef GOARCH_ppc64
+#define GO_PPC64X_HAS_FUNCDESC
+#endif
+#endif
index 37472c0f794554a2bb5caf71daed7a6ba00be3cd..96a25f4047ed3ee89bd1e96d7133ae27da55085e 100644 (file)
@@ -38,13 +38,13 @@ TEXT runtime·rt0_go(SB),NOSPLIT|TOPFRAME,$0
        MOVD    R3, (g_stack+stack_lo)(g)
        MOVD    R1, (g_stack+stack_hi)(g)
 
-       // if there is a _cgo_init, call it using the gcc ABI.
+       // If there is a _cgo_init, call it using the gcc ABI.
        MOVD    _cgo_init(SB), R12
        CMP     R0, R12
        BEQ     nocgo
-#ifdef GOARCH_ppc64
-       // ppc64 use elf ABI v1. we must get the real entry address from
-       // first slot of the function descriptor before call.
+
+#ifdef GO_PPC64X_HAS_FUNCDESC
+       // Load the real entry address from the first slot of the function descriptor.
        MOVD    8(R12), R2
        MOVD    (R12), R12
 #endif
@@ -597,10 +597,8 @@ g0:
        // This is a "global call", so put the global entry point in r12
        MOVD    R3, R12
 
-#ifdef GOARCH_ppc64
-       // ppc64 use elf ABI v1. we must get the real entry address from
-       // first slot of the function descriptor before call.
-       // Same for AIX.
+#ifdef GO_PPC64X_HAS_FUNCDESC
+       // Load the real entry address from the first slot of the function descriptor.
        MOVD    8(R12), R2
        MOVD    (R12), R12
 #endif
index c20100504443ca0f1d8b2e4c6f553836944336aa..fea749670b828c07421168d7e1733da6b6a341ed 100644 (file)
@@ -30,10 +30,8 @@ TEXT crosscall2(SB),NOSPLIT|NOFRAME,$0
        BL      runtime·reginit(SB)
        BL      runtime·load_g(SB)
 
-#ifdef GOARCH_ppc64
-       // ppc64 use elf ABI v1. we must get the real entry address from
-       // first slot of the function descriptor before call.
-       // Same for AIX.
+#ifdef GO_PPC64X_HAS_FUNCDESC
+       // Load the real entry address from the first slot of the function descriptor.
        MOVD    8(R3), R2
        MOVD    (R3), R3
 #endif