From d8426e69c34768fda27c47078aafdec1f20f020b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Sun, 9 Aug 2026 02:20:55 +0200 Subject: [PATCH] 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. --- lib/std/os/linux/powerpc.zig | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/std/os/linux/powerpc.zig b/lib/std/os/linux/powerpc.zig index 5bfaae2767ee33b4d0b1ff32ccafab0ed5f1a1b1..ae2574e52b07bd4856bfee02bf6fbeb7c1ae3e43 100644 --- a/lib/std/os/linux/powerpc.zig +++ b/lib/std/os/linux/powerpc.zig @@ -200,8 +200,9 @@ pub fn clone() callconv(.naked) u32 { asm volatile ( \\ # store non-volatile regs r29, r30 on stack in order to put our \\ # start func and its arg there - \\ stwu 29, -16(1) - \\ stw 30, 4(1) + \\ stwu 1, -16(1) + \\ stw 29, 8(1) + \\ stw 30, 12(1) \\ \\ # save r3 (func) into r29, and r6(arg) into r30 \\ mr 29, 3 @@ -234,8 +235,8 @@ pub fn clone() callconv(.naked) u32 { \\ \\ # if not 0, restore stack and return \\ beq cr7, 2f - \\ lwz 29, 0(1) - \\ lwz 30, 4(1) + \\ lwz 29, 8(1) + \\ lwz 30, 12(1) \\ addi 1, 1, 16 \\ blr \\ -- 2.54.0