Skip to content

Commit 7dfda86

Browse files
committed
Fix stack end placement
The stack end / heap start is placed just after `.uninit` section. It is fine until a custom section is placed just after the `.uninit` section. If application places a custom section just after the `.uninit` section, there is a collision of the custom section and heap start / stack end. There is still a solution since both `__sheap` and `_stack_end` are designed to be overrided by an application, but changing their placement in the proposed way can save some debugging time. Proposed fix does not change behavior if no custom section added.
1 parent f97bfe8 commit 7dfda86

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

cortex-m-rt/link.x.in

+5-4
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,12 @@ SECTIONS
182182
__euninit = .;
183183
} > RAM
184184

185-
/* Place the heap right after `.uninit` in RAM */
186-
PROVIDE(__sheap = __euninit);
185+
/* Align `__sheap` and `_stack_end` pointers to 4 bytes */
186+
. = ALIGN(4);
187187

188-
/* Place stack end at the end of allocated RAM */
189-
PROVIDE(_stack_end = __euninit);
188+
/* Place the heap start and stack end at the end of allocated RAM */
189+
PROVIDE(__sheap = .);
190+
PROVIDE(_stack_end = .);
190191

191192
/* ## .got */
192193
/* Dynamic relocations are unsupported. This section is only used to detect relocatable code in

0 commit comments

Comments
 (0)