Skip to content

cortex-m-rt: ensure the stack is 8-byte aligned. #463

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions cortex-m-rt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,10 +573,12 @@ cfg_global_asm! {
isb",

// Push `lr` to the stack for debuggers, to prevent them unwinding past Reset.
// See https://sourceware.org/binutils/docs/as/CFI-directives.html.
// Push a dummy `r4` (which is always 0xFFFF_FFFF) to ensure the stack stays 8-byte aligned.
// For CFI information, see https://sourceware.org/binutils/docs/as/CFI-directives.html.
// For 8 byte alignment, see https://github.com/ARM-software/abi-aa/blob/edd7460d87493fff124b8b5713acf71ffc06ee91/aapcs32/aapcs32.rst#6212stack-constraints-at-a-public-interface.
".cfi_def_cfa sp, 0
push {{lr}}
.cfi_offset lr, 0",
push {{r4, lr}}
.cfi_offset lr, 4",

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