diff --git a/CMakeLists.txt b/CMakeLists.txt index c9738b6a0f2..c1ab71b076f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1385,6 +1385,17 @@ if(CONFIG_OUTPUT_PRINT_MEMORY_USAGE) endif() endif() +if(NOT CONFIG_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}) + list(APPEND remove_sections_argument_list + $${section}) +endforeach() + if(CONFIG_BUILD_OUTPUT_HEX OR BOARD_FLASH_RUNNER STREQUAL openocd) get_property(elfconvert_formats TARGET bintools PROPERTY elfconvert_formats) if(ihex IN_LIST elfconvert_formats) @@ -1394,9 +1405,7 @@ if(CONFIG_BUILD_OUTPUT_HEX OR BOARD_FLASH_RUNNER STREQUAL openocd) $ ${GAP_FILL} $ihex - $.comment - $COMMON - $.eh_frame + ${remove_sections_argument_list} $${KERNEL_ELF_NAME} $${KERNEL_HEX_NAME} $ @@ -1418,9 +1427,7 @@ if(CONFIG_BUILD_OUTPUT_BIN) $ ${GAP_FILL} $binary - $.comment - $COMMON - $.eh_frame + ${remove_sections_argument_list} $${KERNEL_ELF_NAME} $${KERNEL_BIN_NAME} $