1
0
mirror of https://github.com/golang/go synced 2024-11-22 09:24:41 -07:00

[release-branch.go1.23] runtime: on AIX, fix call to _cgo_sys_thread_create in _rt0_ppc64_aix_lib

The AIX ABI requires allocating parameter save space when calling
a function, even if the arguments are passed via registers.

gcc sometimes uses this space. In the case of the cgo c-archive
tests, it clobbered the storage space of argc/argv which prevented
the test program from running the expected test.

Fixes #68973

Change-Id: I8a267b463b1abb2b37ac85231f6c328f406b7515
Reviewed-on: https://go-review.googlesource.com/c/go/+/606895
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-on: https://go-review.googlesource.com/c/go/+/607195
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
This commit is contained in:
Paul E. Murphy 2024-08-19 15:08:14 -05:00 committed by Cherry Mui
parent 9166d2feec
commit 8002845759

View File

@ -41,6 +41,8 @@ TEXT _main(SB),NOSPLIT,$-8
MOVD R12, CTR
BR (CTR)
// Paramater save space required to cross-call into _cgo_sys_thread_create
#define PARAM_SPACE 16
TEXT _rt0_ppc64_aix_lib(SB),NOSPLIT,$-8
// Start with standard C stack frame layout and linkage.
@ -49,45 +51,45 @@ TEXT _rt0_ppc64_aix_lib(SB),NOSPLIT,$-8
MOVW CR, R0 // Save CR in caller's frame
MOVD R0, 8(R1)
MOVDU R1, -344(R1) // Allocate frame.
MOVDU R1, -344-PARAM_SPACE(R1) // Allocate frame.
// Preserve callee-save registers.
MOVD R14, 48(R1)
MOVD R15, 56(R1)
MOVD R16, 64(R1)
MOVD R17, 72(R1)
MOVD R18, 80(R1)
MOVD R19, 88(R1)
MOVD R20, 96(R1)
MOVD R21,104(R1)
MOVD R22, 112(R1)
MOVD R23, 120(R1)
MOVD R24, 128(R1)
MOVD R25, 136(R1)
MOVD R26, 144(R1)
MOVD R27, 152(R1)
MOVD R28, 160(R1)
MOVD R29, 168(R1)
MOVD g, 176(R1) // R30
MOVD R31, 184(R1)
FMOVD F14, 192(R1)
FMOVD F15, 200(R1)
FMOVD F16, 208(R1)
FMOVD F17, 216(R1)
FMOVD F18, 224(R1)
FMOVD F19, 232(R1)
FMOVD F20, 240(R1)
FMOVD F21, 248(R1)
FMOVD F22, 256(R1)
FMOVD F23, 264(R1)
FMOVD F24, 272(R1)
FMOVD F25, 280(R1)
FMOVD F26, 288(R1)
FMOVD F27, 296(R1)
FMOVD F28, 304(R1)
FMOVD F29, 312(R1)
FMOVD F30, 320(R1)
FMOVD F31, 328(R1)
MOVD R14, 48+PARAM_SPACE(R1)
MOVD R15, 56+PARAM_SPACE(R1)
MOVD R16, 64+PARAM_SPACE(R1)
MOVD R17, 72+PARAM_SPACE(R1)
MOVD R18, 80+PARAM_SPACE(R1)
MOVD R19, 88+PARAM_SPACE(R1)
MOVD R20, 96+PARAM_SPACE(R1)
MOVD R21,104+PARAM_SPACE(R1)
MOVD R22, 112+PARAM_SPACE(R1)
MOVD R23, 120+PARAM_SPACE(R1)
MOVD R24, 128+PARAM_SPACE(R1)
MOVD R25, 136+PARAM_SPACE(R1)
MOVD R26, 144+PARAM_SPACE(R1)
MOVD R27, 152+PARAM_SPACE(R1)
MOVD R28, 160+PARAM_SPACE(R1)
MOVD R29, 168+PARAM_SPACE(R1)
MOVD g, 176+PARAM_SPACE(R1) // R30
MOVD R31, 184+PARAM_SPACE(R1)
FMOVD F14, 192+PARAM_SPACE(R1)
FMOVD F15, 200+PARAM_SPACE(R1)
FMOVD F16, 208+PARAM_SPACE(R1)
FMOVD F17, 216+PARAM_SPACE(R1)
FMOVD F18, 224+PARAM_SPACE(R1)
FMOVD F19, 232+PARAM_SPACE(R1)
FMOVD F20, 240+PARAM_SPACE(R1)
FMOVD F21, 248+PARAM_SPACE(R1)
FMOVD F22, 256+PARAM_SPACE(R1)
FMOVD F23, 264+PARAM_SPACE(R1)
FMOVD F24, 272+PARAM_SPACE(R1)
FMOVD F25, 280+PARAM_SPACE(R1)
FMOVD F26, 288+PARAM_SPACE(R1)
FMOVD F27, 296+PARAM_SPACE(R1)
FMOVD F28, 304+PARAM_SPACE(R1)
FMOVD F29, 312+PARAM_SPACE(R1)
FMOVD F30, 320+PARAM_SPACE(R1)
FMOVD F31, 328+PARAM_SPACE(R1)
// Synchronous initialization.
MOVD $runtime·reginit(SB), R12
@ -130,44 +132,44 @@ nocgo:
done:
// Restore saved registers.
MOVD 48(R1), R14
MOVD 56(R1), R15
MOVD 64(R1), R16
MOVD 72(R1), R17
MOVD 80(R1), R18
MOVD 88(R1), R19
MOVD 96(R1), R20
MOVD 104(R1), R21
MOVD 112(R1), R22
MOVD 120(R1), R23
MOVD 128(R1), R24
MOVD 136(R1), R25
MOVD 144(R1), R26
MOVD 152(R1), R27
MOVD 160(R1), R28
MOVD 168(R1), R29
MOVD 176(R1), g // R30
MOVD 184(R1), R31
FMOVD 196(R1), F14
FMOVD 200(R1), F15
FMOVD 208(R1), F16
FMOVD 216(R1), F17
FMOVD 224(R1), F18
FMOVD 232(R1), F19
FMOVD 240(R1), F20
FMOVD 248(R1), F21
FMOVD 256(R1), F22
FMOVD 264(R1), F23
FMOVD 272(R1), F24
FMOVD 280(R1), F25
FMOVD 288(R1), F26
FMOVD 296(R1), F27
FMOVD 304(R1), F28
FMOVD 312(R1), F29
FMOVD 320(R1), F30
FMOVD 328(R1), F31
MOVD 48+PARAM_SPACE(R1), R14
MOVD 56+PARAM_SPACE(R1), R15
MOVD 64+PARAM_SPACE(R1), R16
MOVD 72+PARAM_SPACE(R1), R17
MOVD 80+PARAM_SPACE(R1), R18
MOVD 88+PARAM_SPACE(R1), R19
MOVD 96+PARAM_SPACE(R1), R20
MOVD 104+PARAM_SPACE(R1), R21
MOVD 112+PARAM_SPACE(R1), R22
MOVD 120+PARAM_SPACE(R1), R23
MOVD 128+PARAM_SPACE(R1), R24
MOVD 136+PARAM_SPACE(R1), R25
MOVD 144+PARAM_SPACE(R1), R26
MOVD 152+PARAM_SPACE(R1), R27
MOVD 160+PARAM_SPACE(R1), R28
MOVD 168+PARAM_SPACE(R1), R29
MOVD 176+PARAM_SPACE(R1), g // R30
MOVD 184+PARAM_SPACE(R1), R31
FMOVD 196+PARAM_SPACE(R1), F14
FMOVD 200+PARAM_SPACE(R1), F15
FMOVD 208+PARAM_SPACE(R1), F16
FMOVD 216+PARAM_SPACE(R1), F17
FMOVD 224+PARAM_SPACE(R1), F18
FMOVD 232+PARAM_SPACE(R1), F19
FMOVD 240+PARAM_SPACE(R1), F20
FMOVD 248+PARAM_SPACE(R1), F21
FMOVD 256+PARAM_SPACE(R1), F22
FMOVD 264+PARAM_SPACE(R1), F23
FMOVD 272+PARAM_SPACE(R1), F24
FMOVD 280+PARAM_SPACE(R1), F25
FMOVD 288+PARAM_SPACE(R1), F26
FMOVD 296+PARAM_SPACE(R1), F27
FMOVD 304+PARAM_SPACE(R1), F28
FMOVD 312+PARAM_SPACE(R1), F29
FMOVD 320+PARAM_SPACE(R1), F30
FMOVD 328+PARAM_SPACE(R1), F31
ADD $344, R1
ADD $344+PARAM_SPACE, R1
MOVD 8(R1), R0
MOVFL R0, $0xff