File tree Expand file tree Collapse file tree 3 files changed +17
-4
lines changed Expand file tree Collapse file tree 3 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77
88## [ Unreleased]
99
10+ - A linker error is generated if the initial stack pointer is not 8-byte aligned
11+ - The initial stack pointer is now forced to be 8-byte aligned in the linker script,
12+ to defend against it being overridden outside of the cortex-m-rt linker script
13+
1014## [ v0.7.2]
1115
1216- MSRV is now Rust 1.59.
Original file line number Diff line number Diff line change @@ -68,8 +68,12 @@ SECTIONS
6868 {
6969 __vector_table = .;
7070
71- /* Initial Stack Pointer (SP) value */
72- LONG(_stack_start);
71+ /* Initial Stack Pointer (SP) value.
72+ * We mask the bottom three bits to force 8-byte alignment.
73+ * Despite having an assert for this later, it's possible that a separate
74+ * linker script could override _stack_start after the assert is checked.
75+ */
76+ LONG(_stack_start & 0xFFFFFFF8);
7377
7478 /* Reset vector */
7579 KEEP(*(.vector_table.reset_vector)); /* this is the `__RESET_VECTOR` symbol */
Original file line number Diff line number Diff line change 5656//!
5757//! This optional symbol can be used to indicate where the call stack of the program should be
5858//! placed. If this symbol is not used then the stack will be placed at the *end* of the `RAM`
59- //! region -- the stack grows downwards towards smaller address. This symbol can be used to place
60- //! the stack in a different memory region, for example:
59+ //! region -- the stack grows downwards towards smaller address.
60+ //!
61+ //! For Cortex-M, the `_stack_start` must always be aligned to 8 bytes, which is enforced by
62+ //! the linker script. If you override it, ensure that whatever value you set is a multiple
63+ //! of 8 bytes.
64+ //!
65+ //! This symbol can be used to place the stack in a different memory region, for example:
6166//!
6267//! ```text
6368//! /* Linker script for the STM32F303VCT6 */
You can’t perform that action at this time.
0 commit comments