Commit 8f2560cf authored by Torsten Rasmussen's avatar Torsten Rasmussen Committed by Benjamin Cabé
Browse files

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: default avatarTorsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
parent 493be790
Loading
Loading
Loading
Loading
+1 −6
Changes for CMakeLists.txt: 1 added line, 6 removed lines.
Original line number Diff line number Diff line
@@ -1729,13 +1729,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()
+0 −6
Changes for include/zephyr/arch/x86/ia32/linker.ld: 0 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -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
+0 −6
Changes for include/zephyr/arch/x86/intel64/linker.ld: 0 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -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
+4 −0
Changes for include/zephyr/linker/cplusplus-rom.ld: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -28,3 +28,7 @@
#endif /* CONFIG_CPP_EXCEPTIONS */

#endif /* CONFIG_CPP */

#if !defined(CONFIG_CPP_EXCEPTIONS)
	/DISCARD/ : { *(.eh_frame) }
#endif