Skip to content

Commit

Permalink
[crt0] fix initial stack setup
Browse files Browse the repository at this point in the history
has to be 128-bit aligned
  • Loading branch information
stnolting committed Sep 15, 2024
1 parent 2565645 commit 8f0f278
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions sw/common/crt0.S
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,9 @@ __crt0_pointer_init:
.option push
.option norelax
// setup pointers using linker script symbols
la x4, __crt0_stack_end // stack pointer
andi sp, x4, 0xfffffffc // word-aligned
la x5, __global_pointer$ // global pointer
andi gp, x5, 0xfffffffc // word-aligned
la x4, __crt0_ram_last // last address of RAM, stack starts here
andi sp, x4, 0xfffffff0 // align to 16-bytes / 128-bit according to RISC-V ABI
la gp, __global_pointer$ // global pointer
.option pop

__crt0_reg_file_init:
Expand All @@ -51,7 +50,7 @@ __crt0_reg_file_init:
//addi x2, x0, 0 // stack pointer sp
//addi x3, x0, 0 // global pointer gp
//addi x4, x0, 0 // implicitly initialized within crt0
//addi x5, x0, 0 // implicitly initialized within crt0
addi x5, x0, 0
addi x6, x0, 0
addi x7, x0, 0
addi x8, x0, 0
Expand Down

0 comments on commit 8f0f278

Please sign in to comment.