wutcrt: Setup a proper stack frame for _start.

This commit is contained in:
James Benton 2018-05-30 22:13:49 +01:00
parent 699aa5ca99
commit 1c3d26ab1b
2 changed files with 20 additions and 17 deletions

View File

@ -5,9 +5,11 @@
.global _start
_start:
stwu 1, -0x8(1)
stw 3, 0(1)
stw 4, 4(1)
stwu 1, -0x14(1)
mflr 0
stw 0, 0x18(1)
stw 3, 0xC(1)
stw 4, 0x10(1)
cmpwi 3, 2
beq unload
@ -15,17 +17,18 @@ load:
# Load
bl __init_wut
bl __eabi
lwz 3, 0(1)
lwz 4, 4(1)
lwz 3, 0xC(1)
lwz 4, 0x10(1)
bl rpl_main
addi 1, 1, 0x8
addi 1, 1, 0x14
blr
unload:
# Handle unload
lwz 3, 0(1)
lwz 4, 4(1)
lwz 3, 0xC(1)
lwz 4, 0x10(1)
bl rpl_main
bl __fini_wut
addi 1, 1, 0x8
addi 1, 1, 0x14
b exit

View File

@ -5,15 +5,15 @@
.global _start
_start:
stwu 1, -0x8(1)
stw 3, 0(1)
stw 4, 4(1)
stwu 1, -0x14(1)
mflr 0
stw 0, 0x18(1)
stw 3, 0xC(1)
stw 4, 0x10(1)
bl __init_wut
lwz 3, 0(1)
lwz 4, 4(1)
lwz 3, 0xC(1)
lwz 4, 0x10(1)
bl main
bl __fini_wut
# Calling __fini is leading to crashes!
# bl __fini
addi 1, 1, 0x8
addi 1, 1, 0x14
b exit