Reordering stack corrupt message on springbok crt0 Change-Id: I04d508fb6da8b68769c90e1e5afafeb770dfac49
diff --git a/springbok/crt0.S b/springbok/crt0.S index d4ce006..68351ce 100644 --- a/springbok/crt0.S +++ b/springbok/crt0.S
@@ -117,8 +117,25 @@ # Check the stack, and fix it if it's broken jal ra, _check_stack - # Save check_stack's return value - mv s1, a0 + # Was the stack corrupted? + beq a0, zero, 1f + + # The stack was corrupted! + # These strings are stored in instruction memory like + # this so they can't ever be corrupted. + li t0, 0x63617473 # "stac" + li t1, 0x6f63206b # "k co" + li t2, 0x70757272 # "rrup" + li t3, 0x00646574 # "ted\0" + addi sp, sp, -16 + sw t0, 0(sp) + sw t1, 4(sp) + sw t2, 8(sp) + sw t3, 12(sp) + li t4, 0 # ERROR logging level + .word 0x00A10EFB # simprint t4, sp, a0 (encoded as custom3<func3=0>) + addi sp, sp, 16 +1: # Restore the application's return value mv a0, s0 @@ -139,25 +156,6 @@ .word 0x00A10EFB # simprint t4, sp, a0 (encoded as custom3<func3=0>) addi sp, sp, 16 - # Was the stack corrupted? - beq s1, zero, _finish - - # The stack was corrupted! - li t0, 0x63617473 # "stac" - li t1, 0x6f63206b # "k co" - li t2, 0x70757272 # "rrup" - li t3, 0x00646574 # "ted\0" - addi sp, sp, -16 - sw t0, 0(sp) - sw t1, 4(sp) - sw t2, 8(sp) - sw t3, 12(sp) - mv a0, s1 - li t4, 0 # ERROR logging level - .word 0x00A10EFB # simprint t4, sp, a0 (encoded as custom3<func3=0>) - addi sp, sp, 16 - mv a0, s0 - _finish: # Store the application's return value onto the stack addi sp, sp, -8 @@ -247,6 +245,8 @@ .weak exception_handler exception_handler: # Exception occurred + # These strings are stored in instruction memory like + # this so they can't ever be corrupted. li t0, 0x65637845 # "Exce" li t1, 0x6f697470 # "ptio" li t2, 0x636f206e # "n oc"