diff options
| author | qmuntal <quimmuntal@gmail.com> | 2025-10-08 16:21:21 +0200 |
|---|---|---|
| committer | Quim Muntal <quimmuntal@gmail.com> | 2025-10-20 09:41:43 -0700 |
| commit | 4ad5585c2c2dc3e4387c10c297669c57449156c9 (patch) | |
| tree | 24cb4f9b62c970e4199306cc586b878fe94d48f0 /src/runtime | |
| parent | a5f55a441ef497d8e2a12610f4ec2bd32fdc04b2 (diff) | |
| download | go-4ad5585c2c2dc3e4387c10c297669c57449156c9.tar.xz | |
runtime: fix _rt0_ppc64x_lib on aix
CL 706395 refactored the ppc64 library entry point and missed some
important aix-specific characteristics:
- _rt0_ppc64x_lib should account for the function descriptor when
getting the callback pointer.
- _rt0_ppc64x_lib should only call _cgo_sys_thread_create when
built as a c-archive.
Fixes #75801
Cq-Include-Trybots: luci.golang.try:gotip-linux-ppc64_power10
Change-Id: I343ca09d3b9688ffa585668a6c52f0ad519d6203
Reviewed-on: https://go-review.googlesource.com/c/go/+/710175
Reviewed-by: Paul Murphy <paumurph@redhat.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Diffstat (limited to 'src/runtime')
| -rw-r--r-- | src/runtime/asm_ppc64x.s | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/runtime/asm_ppc64x.s b/src/runtime/asm_ppc64x.s index 88d03dcc72..127010ef97 100644 --- a/src/runtime/asm_ppc64x.s +++ b/src/runtime/asm_ppc64x.s @@ -14,8 +14,14 @@ // This is called using the host ABI. argc and argv arguments // should be in R3 and R4 respectively. TEXT _rt0_ppc64x_lib(SB),NOSPLIT|NOFRAME,$0 - // Convert to Go ABI, and Allocate argument storage for call to newosproc0. - STACK_AND_SAVE_HOST_TO_GO_ABI(16) + // Start with standard C stack frame layout and linkage, allocate + // 16 bytes of argument space, save callee-save regs, and set R0 to $0. + // Allocate an extra 16 bytes to account for the larger fixed frame size + // of aix/elfv1 (48 vs 32) to ensure 16 bytes of parameter save space. + STACK_AND_SAVE_HOST_TO_GO_ABI(32) + // The above will not preserve R2 (TOC). Save it in case Go is + // compiled without a TOC pointer (e.g -buildmode=default). + MOVD R2, 24(R1) MOVD R3, _rt0_ppc64x_lib_argc<>(SB) MOVD R4, _rt0_ppc64x_lib_argv<>(SB) @@ -28,14 +34,28 @@ TEXT _rt0_ppc64x_lib(SB),NOSPLIT|NOFRAME,$0 MOVD R12, CTR BL (CTR) +#ifdef GOOS_aix + // See runtime/cgo/gcc_aix_ppc64.c + MOVBZ runtime·isarchive(SB), R3 // Check buildmode = c-archive + CMP $0, R3 + BEQ done +#endif + // Create a new thread to do the runtime initialization and return. + // _cgo_sys_thread_create is a C function. MOVD _cgo_sys_thread_create(SB), R12 CMP $0, R12 BEQ nocgo MOVD $_rt0_ppc64x_lib_go(SB), R3 MOVD $0, R4 +#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 MOVD R12, CTR BL (CTR) + MOVD 24(R1), R2 // Restore the old frame, and R2. BR done nocgo: @@ -48,7 +68,7 @@ nocgo: BL (CTR) done: - UNSTACK_AND_RESTORE_GO_TO_HOST_ABI(16) + UNSTACK_AND_RESTORE_GO_TO_HOST_ABI(32) RET #ifdef GO_PPC64X_HAS_FUNCDESC |
