Skip to content

Commit cf9adf4

Browse files
committed
cortex-m-rt: ensure the stack is 8-byte aligned.
Stack must be 8-byte aligned on ARM. Pushing 1 word makes it not aligned, so we push 2 words. This was breaking code that used LDRD/STRD on stack, since that needs 8-byte alignment.
1 parent ac8d42b commit cf9adf4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

cortex-m-rt/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -568,10 +568,11 @@ cfg_global_asm! {
568568
isb",
569569

570570
// Push `lr` to the stack for debuggers, to prevent them unwinding past Reset.
571+
// Push a dummy `r0` to ensure the stack stays 8-byte aligned.
571572
// See https://sourceware.org/binutils/docs/as/CFI-directives.html.
572573
".cfi_def_cfa sp, 0
573-
push {{lr}}
574-
.cfi_offset lr, 0",
574+
push {{r0, lr}}
575+
.cfi_offset lr, 4",
575576

576577
// Jump to user main function.
577578
// `bl` is used for the extended range, but the user main function should not return,

0 commit comments

Comments
 (0)