Skip to content

Commit f97bfe8

Browse files
authoredFeb 9, 2025
Merge pull request #577 from tlevora/fix/stack_end-usage-and-doc
Fix _stack_end usage and doc
2 parents de61182 + 30ed294 commit f97bfe8

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed
 

‎cortex-m-rt/src/lib.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,10 @@
6767
//! `_stack_end` which is automatically placed after the end of statically allocated RAM.
6868
//!
6969
//! **NOTE:** If you change `_stack_start`, make sure to also set `_stack_end` correctly to match
70-
//! new stack area if you are using it, e.g for MSPLIM. The `_stack_end` is not used internally by
71-
//! `cortex-m-rt` and is only for application use.
70+
//! new stack area if you are using it, e.g for MSPLIM.
71+
//!
72+
//! The `_stack_end` is checked by linker script to be less than or equal to `_stack_start` and is
73+
//! used as a bound in `paint-stack` feature.
7274
//!
7375
//! For Cortex-M, the `_stack_start` must always be aligned to 8 bytes, which is enforced by
7476
//! the linker script. If you override it, ensure that whatever value you set is a multiple
@@ -193,7 +195,7 @@
193195
//!
194196
//! ## `paint-stack`
195197
//!
196-
//! Everywhere between `__sheap` and `_stack_start` is painted with the fixed value
198+
//! Everywhere between `_stack_end` and `_stack_start` is painted with the fixed value
197199
//! `STACK_PAINT_VALUE`, which is `0xCCCC_CCCC`.
198200
//! You can then inspect memory during debugging to determine how much of the stack has been used -
199201
//! where the stack has been used the 'paint' will have been 'scrubbed off' and the memory will
@@ -573,9 +575,9 @@ cfg_global_asm! {
573575
1:",
574576

575577
// If enabled, paint stack/heap RAM with 0xcccccccc.
576-
// `__sheap` and `_stack_start` come from the linker script.
578+
// `_stack_end` and `_stack_start` come from the linker script.
577579
#[cfg(feature = "paint-stack")]
578-
"ldr r0, =__sheap
580+
"ldr r0, =_stack_end
579581
ldr r1, =_stack_start
580582
ldr r2, =0xcccccccc // This must match STACK_PAINT_VALUE
581583
0:

0 commit comments

Comments
 (0)
Failed to load comments.