Skip to content

Commit dd9eb37

Browse files
PetervdPerk-NXPjhedberg
authored andcommitted
include: arch: arm: cortex_m: Move ITCM before .text
Reordered ITCM section to appear before .text in the ARM Cortex-M linker script. This allows functions placed in ITCM via *(.text.<function_name>) using snippets-itcm-section.ld to avoid being absorbed into the default .text section, enabling more flexible code placement. Signed-off-by: Peter van der Perk <[email protected]>
1 parent c63ec6b commit dd9eb37

File tree

1 file changed

+22
-22
lines changed
  • include/zephyr/arch/arm/cortex_m/scripts

1 file changed

+22
-22
lines changed

include/zephyr/arch/arm/cortex_m/scripts/linker.ld

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,28 @@ SECTIONS
141141

142142
#endif /* CONFIG_CODE_DATA_RELOCATION */
143143

144+
#if DT_NODE_HAS_STATUS(DT_CHOSEN(zephyr_itcm), okay)
145+
GROUP_START(ITCM)
146+
147+
SECTION_PROLOGUE(_ITCM_SECTION_NAME,,SUBALIGN(4))
148+
{
149+
__itcm_start = .;
150+
*(.itcm)
151+
*(".itcm.*")
152+
153+
/* Located in generated directory. This file is populated by the
154+
* zephyr_linker_sources() Cmake function. */
155+
#include <snippets-itcm-section.ld>
156+
157+
__itcm_end = .;
158+
} GROUP_LINK_IN(ITCM AT> ROMABLE_REGION)
159+
160+
__itcm_size = __itcm_end - __itcm_start;
161+
__itcm_load_start = LOADADDR(_ITCM_SECTION_NAME);
162+
163+
GROUP_END(ITCM)
164+
#endif
165+
144166
SECTION_PROLOGUE(_TEXT_SECTION_NAME,,)
145167
{
146168
__text_region_start = .;
@@ -321,28 +343,6 @@ SECTIONS
321343

322344
__data_region_end = .;
323345

324-
#if DT_NODE_HAS_STATUS(DT_CHOSEN(zephyr_itcm), okay)
325-
GROUP_START(ITCM)
326-
327-
SECTION_PROLOGUE(_ITCM_SECTION_NAME,,SUBALIGN(4))
328-
{
329-
__itcm_start = .;
330-
*(.itcm)
331-
*(".itcm.*")
332-
333-
/* Located in generated directory. This file is populated by the
334-
* zephyr_linker_sources() Cmake function. */
335-
#include <snippets-itcm-section.ld>
336-
337-
__itcm_end = .;
338-
} GROUP_LINK_IN(ITCM AT> ROMABLE_REGION)
339-
340-
__itcm_size = __itcm_end - __itcm_start;
341-
__itcm_load_start = LOADADDR(_ITCM_SECTION_NAME);
342-
343-
GROUP_END(ITCM)
344-
#endif
345-
346346
#if DT_NODE_HAS_STATUS(DT_CHOSEN(zephyr_dtcm), okay)
347347
GROUP_START(DTCM)
348348

0 commit comments

Comments
 (0)