diff --git a/src/system/glue/arch/riscv64/crti.S b/src/system/glue/arch/riscv64/crti.S index 680b4f24a5..a810498c0f 100644 --- a/src/system/glue/arch/riscv64/crti.S +++ b/src/system/glue/arch/riscv64/crti.S @@ -21,8 +21,12 @@ .section .init FUNCTION(_init): + addi sp, sp, -16 + sd ra, 8(sp) // crtbegin.o stuff comes here .section .fini FUNCTION(_fini): - // crtbegin.o stuff comes here + addi sp, sp, -16 + sd ra, 8(sp) + // crtend.o stuff comes here diff --git a/src/system/glue/arch/riscv64/crtn.S b/src/system/glue/arch/riscv64/crtn.S index 48e3dc6170..572f60e156 100644 --- a/src/system/glue/arch/riscv64/crtn.S +++ b/src/system/glue/arch/riscv64/crtn.S @@ -9,9 +9,12 @@ */ .section .init - // the image ID and program args are still on the stack + ld ra, 8(sp) + addi sp, sp, 16 + ret .section .fini - // the image ID and program args are still on the stack - + ld ra, 8(sp) + addi sp, sp, 16 + ret