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.
This commit is contained in:
Shawn Anastasio 2020-07-01 16:13:14 -05:00
parent 8574861ca0
commit 51fcf949f9

View File

@ -116,6 +116,21 @@ fn _start() callconv(.Naked) noreturn {
: [argc] "=r" (-> [*]usize)
);
},
.powerpc64le => {
// Before returning the stack pointer, we have to set up a backchain
// and a few other registers required by the ELFv2 ABI.
// TODO: Support powerpc64 (big endian) on ELFv2.
starting_stack_ptr = asm (
\\ mr 4, 1
\\ subi 1, 1, 32
\\ li 5, 0
\\ std 5, 0(1)
\\ mr %[argc], 4
: [argc] "=r" (-> [*]usize)
:
: "r4", "r5"
);
},
else => @compileError("unsupported arch"),
}
// If LLVM inlines stack variables into _start, they will overwrite