File tree Expand file tree Collapse file tree 8 files changed +30
-30
lines changed Expand file tree Collapse file tree 8 files changed +30
-30
lines changed Original file line number Diff line number Diff line change @@ -402,11 +402,9 @@ GROUP_END(OCM)
402402 /* Must be last in romable region */
403403 SECTION_PROLOGUE (.last_section ,,)
404404 {
405- #ifdef CONFIG_LINKER_LAST_SECTION_ID
406- /* Fill last section with a word to ensure location counter and actual rom
407- * region data usage match. */
408- LONG (CONFIG_LINKER_LAST_SECTION_ID_PATTERN)
409- #endif
405+ /* .last_section contains a fixed word to ensure location counter and actual
406+ * rom region data usage match when CONFIG_LINKER_LAST_SECTION_ID=y. */
407+ KEEP (*(.last_section ))
410408 } GROUP_LINK_IN (ROMABLE_REGION)
411409
412410 /* To provide the image size as a const expression,
Original file line number Diff line number Diff line change @@ -488,11 +488,9 @@ GROUP_END(DTCM)
488488/* Must be last in romable region */
489489SECTION_PROLOGUE (.last_section ,,)
490490{
491- #ifdef CONFIG_LINKER_LAST_SECTION_ID
492- /* Fill last section with a word to ensure location counter and actual rom
493- * region data usage match. */
494- LONG (CONFIG_LINKER_LAST_SECTION_ID_PATTERN)
495- #endif
491+ /* .last_section contains a fixed word to ensure location counter and actual
492+ * rom region data usage match when CONFIG_LINKER_LAST_SECTION_ID=y. */
493+ KEEP (*(.last_section ))
496494} GROUP_LINK_IN (ROMABLE_REGION)
497495
498496/* To provide the image size as a const expression,
Original file line number Diff line number Diff line change @@ -351,11 +351,9 @@ SECTIONS
351351 /* Must be last in romable region */
352352 SECTION_PROLOGUE (.last_section ,,)
353353 {
354- #ifdef CONFIG_LINKER_LAST_SECTION_ID
355- /* Fill last section with a word to ensure location counter and actual rom
356- * region data usage match. */
357- LONG (CONFIG_LINKER_LAST_SECTION_ID_PATTERN)
358- #endif
354+ /* .last_section contains a fixed word to ensure location counter and actual
355+ * rom region data usage match when CONFIG_LINKER_LAST_SECTION_ID=y. */
356+ KEEP (*(.last_section ))
359357 } GROUP_ROM_LINK_IN (RAMABLE_REGION, ROMABLE_REGION)
360358
361359 /* To provide the image size as a const expression,
Original file line number Diff line number Diff line change @@ -454,15 +454,13 @@ GROUP_END(DTCM)
454454/* Must be last in romable region */
455455SECTION_PROLOGUE (.last_section ,,)
456456{
457- #ifdef CONFIG_LINKER_LAST_SECTION_ID
458- /* Fill last section with a word to ensure location counter and actual rom
459- * region data usage match. */
460- LONG (CONFIG_LINKER_LAST_SECTION_ID_PATTERN)
457+ /* .last_section contains a fixed word to ensure location counter and actual
458+ * rom region data usage match when CONFIG_LINKER_LAST_SECTION_ID=y. */
459+ KEEP (*(.last_section ))
461460 /* __rom_region_size is used when configuring the PMP entry of the ROM region.
462461 * Addresses (pmpaddr) in PMP registers need to be aligned to 4. Align
463462 * __rom_region_size to 4 to meet that requirement. */
464463 MPU_MIN_SIZE_ALIGN
465- #endif
466464} GROUP_LINK_IN (ROMABLE_REGION)
467465
468466/* To provide the image size as a const expression,
Original file line number Diff line number Diff line change @@ -25,3 +25,5 @@ zephyr_library_include_directories(
2525 ${ZEPHYR_BASE} /kernel/include
2626 ${ZEPHYR_BASE} /arch/${ARCH} /include
2727)
28+
29+ zephyr_sources_ifdef(CONFIG_LINKER_LAST_SECTION_ID last_section_id.c)
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (C) 2025, Nordic Semiconductor ASA
3+ *
4+ * SPDX-License-Identifier: Apache-2.0
5+ *
6+ */
7+ #include <zephyr/types.h>
8+
9+ static uint32_t last_id __attribute__((section (".last_section" ))) __attribute__((__used__ )) =
10+ CONFIG_LINKER_LAST_SECTION_ID_PATTERN ;
Original file line number Diff line number Diff line change @@ -412,11 +412,9 @@ GROUP_END(DTCM)
412412/* Must be last in romable region */
413413SECTION_PROLOGUE (.last_section ,,)
414414{
415- #ifdef CONFIG_LINKER_LAST_SECTION_ID
416- /* Fill last section with a word to ensure location counter and actual rom
417- * region data usage match. */
418- LONG (CONFIG_LINKER_LAST_SECTION_ID_PATTERN)
419- #endif
415+ /* .last_section contains a fixed word to ensure location counter and actual
416+ * rom region data usage match when CONFIG_LINKER_LAST_SECTION_ID=y. */
417+ KEEP (*(.last_section ))
420418} GROUP_LINK_IN (ROMABLE_REGION)
421419
422420/* Because ROMABLE_REGION != RAMABLE_REGION in XIP-system, it is valid
Original file line number Diff line number Diff line change @@ -466,11 +466,9 @@ GROUP_END(DTCM)
466466/* Must be last in romable region */
467467SECTION_PROLOGUE (.last_section ,,)
468468{
469- #ifdef CONFIG_LINKER_LAST_SECTION_ID
470- /* Fill last section with a word to ensure location counter and actual rom
471- * region data usage match. */
472- LONG (CONFIG_LINKER_LAST_SECTION_ID_PATTERN)
473- #endif
469+ /* .last_section contains a fixed word to ensure location counter and actual
470+ * rom region data usage match when CONFIG_LINKER_LAST_SECTION_ID=y. */
471+ KEEP (*(.last_section ))
474472} GROUP_LINK_IN (ROMABLE_REGION)
475473
476474/* To provide the image size as a const expression,
You can’t perform that action at this time.
0 commit comments