authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-08-09 02:20:55+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-08-09 17:53:03+02:00
logd8426e69c34768fda27c47078aafdec1f20f020b
treeb934d7853413a414c205a6a9724b90694ee77beb
parentc65e90d741b7f6016f907c4d1fd8717ab19240d1
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.os.linux.powerpc: respect ABI backchain requirements in clone assembly

The ABI says that a stack frame always starts with the backchain slot and the LR save slot. Actually respect that by storing the old stack pointer in the backchain slot and storing r29 and r30 in the locals area instead.

1 files changed, 5 insertions(+), 4 deletions(-)

lib/std/os/linux/powerpc.zig+5-4
......@@ -200,8 +200,9 @@ pub fn clone() callconv(.naked) u32 {
200200 asm volatile (
201201 \\ # store non-volatile regs r29, r30 on stack in order to put our
202202 \\ # start func and its arg there
203 \\ stwu 29, -16(1)
204 \\ stw 30, 4(1)
203 \\ stwu 1, -16(1)
204 \\ stw 29, 8(1)
205 \\ stw 30, 12(1)
205206 \\
206207 \\ # save r3 (func) into r29, and r6(arg) into r30
207208 \\ mr 29, 3
......@@ -234,8 +235,8 @@ pub fn clone() callconv(.naked) u32 {
234235 \\
235236 \\ # if not 0, restore stack and return
236237 \\ beq cr7, 2f
237 \\ lwz 29, 0(1)
238 \\ lwz 30, 4(1)
238 \\ lwz 29, 8(1)
239 \\ lwz 30, 12(1)
239240 \\ addi 1, 1, 16
240241 \\ blr
241242 \\