1
0
mirror of https://github.com/golang/go synced 2024-11-23 16:50:06 -07:00

runtime: provide and use a GO_PPC64X_HAS_FUNCDESC define

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>
This commit is contained in:
Joel Sing 2023-03-14 20:50:38 +11:00
parent ada6ffca83
commit 6827f0d772
3 changed files with 22 additions and 12 deletions

View File

@ -23,3 +23,17 @@
// 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

View 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

View 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