Skip to content

Commit 11c542a

Browse files
tejlmandcarlescufi
authored andcommitted
[nrf fromlist] linker: discard eh_frame when C++ exceptions are disabled
Discard the eh_frame section when C++ exceptions are disabled. In principle the eh_frame may be used for other purposes such as backtracing when linking C programs, then Zephyr compiles each source file with '-fno-asynchronous-unwind-tables', thus keeping the eh_frame in the elf output just takes up space. When using gcc/ld, then the eh_frame is generally generally discarded per default, however for clang/lld it will be included but give a warning that the section is auto-placed. Some platforms already discards the eh_frame, so unify this for all targets. As eh_frame is now discarded in linker scripts then post processing step of removing the section during hex or bin conversion can also be removed. Upstream PR #: 88970 Signed-off-by: Torsten Rasmussen <[email protected]>
1 parent be57ad0 commit 11c542a

File tree

4 files changed

+5
-18
lines changed

4 files changed

+5
-18
lines changed

CMakeLists.txt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,13 +1714,8 @@ if(CONFIG_BUILD_OUTPUT_ADJUST_LMA)
17141714
)
17151715
endif()
17161716

1717-
if(NOT CONFIG_CPP_EXCEPTIONS)
1718-
set(eh_frame_section ".eh_frame")
1719-
else()
1720-
set(eh_frame_section "")
1721-
endif()
17221717
set(remove_sections_argument_list "")
1723-
foreach(section .comment COMMON ${eh_frame_section})
1718+
foreach(section .comment COMMON)
17241719
list(APPEND remove_sections_argument_list
17251720
$<TARGET_PROPERTY:bintools,elfconvert_flag_section_remove>${section})
17261721
endforeach()

include/zephyr/arch/x86/ia32/linker.ld

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -557,12 +557,6 @@ SECTIONS
557557
#include <zephyr/linker/debug-sections.ld>
558558

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

567561
/*
568562
* The sections below are still treated as warnings

include/zephyr/arch/x86/intel64/linker.ld

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,6 @@ SECTIONS
223223
*(.rel.*)
224224
*(.rela.*)
225225
}
226-
/*
227-
* eh_frame section won't be removed even with "--gc-sections" by LLVM lld.
228-
*/
229-
#if !defined(CONFIG_CPP_EXCEPTIONS)
230-
/DISCARD/ : { *(.eh_frame) }
231-
#endif
232226

233227
/*
234228
* The sections below are still treated as warnings

include/zephyr/linker/cplusplus-rom.ld

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,7 @@
2424
#endif /* CONFIG_CPP_EXCEPTIONS */
2525

2626
#endif /* CONFIG_CPP */
27+
28+
#if !defined(CONFIG_CPP_EXCEPTIONS)
29+
/DISCARD/ : { *(.eh_frame) }
30+
#endif

0 commit comments

Comments
 (0)