call5 on arm called C with SP at whatever alignment the calling Go
frame left. Go keeps arm frames only 4-byte aligned and call5 never
masked SP, so the C function could start with SP 4 mod 8, against the
AAPCS requirement of 8-byte alignment at public interfaces. This
happened to x_cgo_init's pthread_attr_init call at startup, and C code
that relies on 8-byte aligned stack objects, such as LDREXD on a 64-bit
local, faults there.
call5 also stored the 5th argument relative to SP before moving SP
down, so the callee read its 5th argument from a different slot. Every
current caller passes 0 for it.
Save SP in R4, which C preserves, then allocate and align the outgoing
argument area with SUB and BIC, store the 5th argument at its bottom,
and restore SP after the call, as call5 does on amd64. Also name the
result ret+24(FP), which go vet expects.
Closes #557
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>