Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1714,13 +1714,8 @@ if(CONFIG_BUILD_OUTPUT_ADJUST_LMA)
)
endif()

if(NOT CONFIG_CPP_EXCEPTIONS)
set(eh_frame_section ".eh_frame")
else()
set(eh_frame_section "")
endif()
set(remove_sections_argument_list "")
foreach(section .comment COMMON ${eh_frame_section})
foreach(section .comment COMMON)
list(APPEND remove_sections_argument_list
$<TARGET_PROPERTY:bintools,elfconvert_flag_section_remove>${section})
endforeach()
Expand Down
8 changes: 3 additions & 5 deletions include/zephyr/arch/arm/cortex_a_r/scripts/linker.ld
Original file line number Diff line number Diff line change
Expand Up @@ -402,11 +402,9 @@ GROUP_END(OCM)
/* Must be last in romable region */
SECTION_PROLOGUE(.last_section,,)
{
#ifdef CONFIG_LINKER_LAST_SECTION_ID
/* Fill last section with a word to ensure location counter and actual rom
* region data usage match. */
LONG(CONFIG_LINKER_LAST_SECTION_ID_PATTERN)
#endif
/* .last_section contains a fixed word to ensure location counter and actual
* rom region data usage match when CONFIG_LINKER_LAST_SECTION_ID=y. */
KEEP(*(.last_section))
} GROUP_LINK_IN(ROMABLE_REGION)

/* To provide the image size as a const expression,
Expand Down
8 changes: 3 additions & 5 deletions include/zephyr/arch/arm/cortex_m/scripts/linker.ld
Original file line number Diff line number Diff line change
Expand Up @@ -488,11 +488,9 @@ GROUP_END(DTCM)
/* Must be last in romable region */
SECTION_PROLOGUE(.last_section,,)
{
#ifdef CONFIG_LINKER_LAST_SECTION_ID
/* Fill last section with a word to ensure location counter and actual rom
* region data usage match. */
LONG(CONFIG_LINKER_LAST_SECTION_ID_PATTERN)
#endif
/* .last_section contains a fixed word to ensure location counter and actual
* rom region data usage match when CONFIG_LINKER_LAST_SECTION_ID=y. */
KEEP(*(.last_section))
} GROUP_LINK_IN(ROMABLE_REGION)

/* To provide the image size as a const expression,
Expand Down
8 changes: 3 additions & 5 deletions include/zephyr/arch/arm64/scripts/linker.ld
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,9 @@ SECTIONS
/* Must be last in romable region */
SECTION_PROLOGUE(.last_section,,)
{
#ifdef CONFIG_LINKER_LAST_SECTION_ID
/* Fill last section with a word to ensure location counter and actual rom
* region data usage match. */
LONG(CONFIG_LINKER_LAST_SECTION_ID_PATTERN)
#endif
/* .last_section contains a fixed word to ensure location counter and actual
* rom region data usage match when CONFIG_LINKER_LAST_SECTION_ID=y. */
KEEP(*(.last_section))
} GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)

/* To provide the image size as a const expression,
Expand Down
8 changes: 3 additions & 5 deletions include/zephyr/arch/riscv/common/linker.ld
Original file line number Diff line number Diff line change
Expand Up @@ -454,15 +454,13 @@ GROUP_END(DTCM)
/* Must be last in romable region */
SECTION_PROLOGUE(.last_section,,)
{
#ifdef CONFIG_LINKER_LAST_SECTION_ID
/* Fill last section with a word to ensure location counter and actual rom
* region data usage match. */
LONG(CONFIG_LINKER_LAST_SECTION_ID_PATTERN)
/* .last_section contains a fixed word to ensure location counter and actual
* rom region data usage match when CONFIG_LINKER_LAST_SECTION_ID=y. */
KEEP(*(.last_section))
/* __rom_region_size is used when configuring the PMP entry of the ROM region.
* Addresses (pmpaddr) in PMP registers need to be aligned to 4. Align
* __rom_region_size to 4 to meet that requirement. */
MPU_MIN_SIZE_ALIGN
#endif
} GROUP_LINK_IN(ROMABLE_REGION)

/* To provide the image size as a const expression,
Expand Down
6 changes: 0 additions & 6 deletions include/zephyr/arch/x86/ia32/linker.ld
Original file line number Diff line number Diff line change
Expand Up @@ -557,12 +557,6 @@ SECTIONS
#include <zephyr/linker/debug-sections.ld>

/DISCARD/ : { *(.note.GNU-stack) }
/*
* eh_frame section won't be removed even with "--gc-sections" by LLVM lld.
*/
#if !defined(CONFIG_CPP_EXCEPTIONS)
/DISCARD/ : { *(.eh_frame) }
#endif

/*
* The sections below are still treated as warnings
Expand Down
6 changes: 0 additions & 6 deletions include/zephyr/arch/x86/intel64/linker.ld
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,6 @@ SECTIONS
*(.rel.*)
*(.rela.*)
}
/*
* eh_frame section won't be removed even with "--gc-sections" by LLVM lld.
*/
#if !defined(CONFIG_CPP_EXCEPTIONS)
/DISCARD/ : { *(.eh_frame) }
#endif

/*
* The sections below are still treated as warnings
Expand Down
4 changes: 4 additions & 0 deletions include/zephyr/linker/cplusplus-rom.ld
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@
#endif /* CONFIG_CPP_EXCEPTIONS */

#endif /* CONFIG_CPP */

#if !defined(CONFIG_CPP_EXCEPTIONS)
/DISCARD/ : { *(.eh_frame) }
#endif
2 changes: 2 additions & 0 deletions lib/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ zephyr_library_include_directories(
${ZEPHYR_BASE}/kernel/include
${ZEPHYR_BASE}/arch/${ARCH}/include
)

zephyr_sources_ifdef(CONFIG_LINKER_LAST_SECTION_ID last_section_id.c)
10 changes: 10 additions & 0 deletions lib/utils/last_section_id.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright (C) 2025, Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*
*/
#include <zephyr/types.h>

static uint32_t last_id __attribute__((section(".last_section"))) __attribute__((__used__)) =
CONFIG_LINKER_LAST_SECTION_ID_PATTERN;
8 changes: 3 additions & 5 deletions soc/andestech/ae350/linker.ld
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,9 @@ GROUP_END(DTCM)
/* Must be last in romable region */
SECTION_PROLOGUE(.last_section,,)
{
#ifdef CONFIG_LINKER_LAST_SECTION_ID
/* Fill last section with a word to ensure location counter and actual rom
* region data usage match. */
LONG(CONFIG_LINKER_LAST_SECTION_ID_PATTERN)
#endif
/* .last_section contains a fixed word to ensure location counter and actual
* rom region data usage match when CONFIG_LINKER_LAST_SECTION_ID=y. */
KEEP(*(.last_section))
} GROUP_LINK_IN(ROMABLE_REGION)

/* Because ROMABLE_REGION != RAMABLE_REGION in XIP-system, it is valid
Expand Down
8 changes: 3 additions & 5 deletions soc/infineon/cat1b/cyw20829/linker.ld
Original file line number Diff line number Diff line change
Expand Up @@ -466,11 +466,9 @@ GROUP_END(DTCM)
/* Must be last in romable region */
SECTION_PROLOGUE(.last_section,,)
{
#ifdef CONFIG_LINKER_LAST_SECTION_ID
/* Fill last section with a word to ensure location counter and actual rom
* region data usage match. */
LONG(CONFIG_LINKER_LAST_SECTION_ID_PATTERN)
#endif
/* .last_section contains a fixed word to ensure location counter and actual
* rom region data usage match when CONFIG_LINKER_LAST_SECTION_ID=y. */
KEEP(*(.last_section))
} GROUP_LINK_IN(ROMABLE_REGION)

/* To provide the image size as a const expression,
Expand Down