Print this page
_locore_start needs to set up an 8-byte aligned stack
Sadly, during removal of special early-boot stacks
(027eb01d0ff8f66be55208b58ecd7cb2b7b27714) the stack passed into mlsetup
lost its 8-byte aligned-ness.
@@ -121,17 +121,22 @@
orr r0, #0x1000
orr r0, #0x400000
mcr p15, 0, r0, c1, c0, 0
/*
- * mlsetup() takes the struct regs as an argument. main doesn't take any
- * and should never return. After the push below, we should have a
- * 8-byte aligned stack pointer. This is why we subtracted four earlier
- * on if we were 8-byte aligned.
+ * mlsetup() takes the struct regs as an argument. main doesn't take
+ * any and should never return. Currently, we have an 8-byte aligned
+ * stack. We want to push a zero frame pointer to terminate any
+ * stack walking, but that would cause us to end up with only a
+ * 4-byte aligned stack. So, to keep things nice and correct, we
+ * push a zero value twice - it's similar to a typical function
+ * entry:
+ * push { r9, lr }
*/
mov r9,#0
- push { r9 }
+ push { r9 } /* link register */
+ push { r9 } /* frame pointer */
mov r0, sp
bl mlsetup
bl main
/* NOTREACHED */
ldr r0,=__return_from_main