Skip to content

Commit 51fcf94

Browse files
Implement std.start for powerpc64le
This is a bit hacky since we end up doing more than just grabbing the stack pointer in the inline assembly block. Ideally _start would be implemented in pure asm for powerpc64le, but this will do for now. Still to be implemented is powerpc, powerpc64, and powerpc64 (ELFv2) support. The latter will just require correctly determing target ABI for powerpc64 and enabling the existing powerpc64le implementation for it.
1 parent 8574861 commit 51fcf94

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lib/std/start.zig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,21 @@ fn _start() callconv(.Naked) noreturn {
116116
: [argc] "=r" (-> [*]usize)
117117
);
118118
},
119+
.powerpc64le => {
120+
// Before returning the stack pointer, we have to set up a backchain
121+
// and a few other registers required by the ELFv2 ABI.
122+
// TODO: Support powerpc64 (big endian) on ELFv2.
123+
starting_stack_ptr = asm (
124+
\\ mr 4, 1
125+
\\ subi 1, 1, 32
126+
\\ li 5, 0
127+
\\ std 5, 0(1)
128+
\\ mr %[argc], 4
129+
: [argc] "=r" (-> [*]usize)
130+
:
131+
: "r4", "r5"
132+
);
133+
},
119134
else => @compileError("unsupported arch"),
120135
}
121136
// If LLVM inlines stack variables into _start, they will overwrite

0 commit comments

Comments
 (0)