Skip to content

Commit 4a7c8f4

Browse files
tejlmandrlubos
authored andcommitted
[nrf fromtree] 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. Signed-off-by: Torsten Rasmussen <[email protected]> (cherry picked from commit 8f2560cf3ec73b8fdf88c53c1cddbaa47698aba6)
1 parent f445ed0 commit 4a7c8f4

File tree

4 files changed

+5
-18
lines changed

4 files changed

+5
-18
lines changed

CMakeLists.txt

+1-6
Original file line numberDiff line numberDiff line change
@@ -1729,13 +1729,8 @@ if(CONFIG_BUILD_OUTPUT_ADJUST_LMA)
17291729
)
17301730
endif()
17311731

1732-
if(NOT CONFIG_CPP_EXCEPTIONS)
1733-
set(eh_frame_section ".eh_frame")
1734-
else()
1735-
set(eh_frame_section "")
1736-
endif()
17371732
set(remove_sections_argument_list "")
1738-
foreach(section .comment COMMON ${eh_frame_section})
1733+
foreach(section .comment COMMON)
17391734
list(APPEND remove_sections_argument_list
17401735
$<TARGET_PROPERTY:bintools,elfconvert_flag_section_remove>${section})
17411736
endforeach()

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

-6
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

-6
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

+4
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,7 @@
2828
#endif /* CONFIG_CPP_EXCEPTIONS */
2929

3030
#endif /* CONFIG_CPP */
31+
32+
#if !defined(CONFIG_CPP_EXCEPTIONS)
33+
/DISCARD/ : { *(.eh_frame) }
34+
#endif

0 commit comments

Comments
 (0)