From c97ad0f84620c2564967093b4a1f1e8bed95fbcd Mon Sep 17 00:00:00 2001 From: Jan Van Winkel Date: Sat, 7 Sep 2019 13:09:45 +0200 Subject: [PATCH 1/3] tests: cxx: Enable exceptions Added test run with exceptions enabled. Boards colibri_imx7d_m4, warp7_m4 and pico_pi_m4 have been excluded from test run as they do not have sufficient ROM. Signed-off-by: Jan Van Winkel --- tests/application_development/libcxx/testcase.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/application_development/libcxx/testcase.yaml b/tests/application_development/libcxx/testcase.yaml index 17cdd168c54de..ece7243e46d08 100644 --- a/tests/application_development/libcxx/testcase.yaml +++ b/tests/application_development/libcxx/testcase.yaml @@ -3,3 +3,10 @@ tests: arch_exclude: posix platform_exclude: qemu_x86_coverage qemu_x86_64 tags: cpp + misc.app_dev.libcxx.exceptions: + arch_exclude: posix + platform_exclude: qemu_x86_coverage qemu_x86_64 96b_meerkat96 + colibri_imx7d_m4 warp7_m4 pico_pi_m4 qemu_x86_long + tags: cpp + extra_configs: + - CONFIG_EXCEPTIONS=y From 2e0cbb2ec6849c7826c7e15cba6c4cce9d7d54c8 Mon Sep 17 00:00:00 2001 From: Jan Van Winkel Date: Sat, 7 Sep 2019 14:51:35 +0200 Subject: [PATCH 2/3] linker: cxx: xtensa: Added .gcc_except_table.* Make sure that all sub-sections of .gcc_except_table are mapped in rodata else C++ builds with exceptions enabled will generate warnings due to orphan sections. Signed-off-by: Jan Van Winkel --- soc/xtensa/esp32/linker.ld | 2 +- soc/xtensa/intel_s1000/linker.ld | 2 +- soc/xtensa/sample_controller/linker.ld | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/soc/xtensa/esp32/linker.ld b/soc/xtensa/esp32/linker.ld index 405e0ac6becbf..8085eda03bbe2 100644 --- a/soc/xtensa/esp32/linker.ld +++ b/soc/xtensa/esp32/linker.ld @@ -183,7 +183,7 @@ SECTIONS *(.rodata1) __XT_EXCEPTION_TABLE__ = ABSOLUTE(.); KEEP (*(.xt_except_table)) - KEEP (*(.gcc_except_table)) + KEEP (*(.gcc_except_table .gcc_except_table.*)) *(.gnu.linkonce.e.*) *(.gnu.version_r) KEEP (*(.eh_frame)) diff --git a/soc/xtensa/intel_s1000/linker.ld b/soc/xtensa/intel_s1000/linker.ld index 3bb372ea171fd..251cae3e115e2 100644 --- a/soc/xtensa/intel_s1000/linker.ld +++ b/soc/xtensa/intel_s1000/linker.ld @@ -357,7 +357,7 @@ SECTIONS *(.rodata1) __XT_EXCEPTION_TABLE__ = ABSOLUTE(.); KEEP (*(.xt_except_table)) - KEEP (*(.gcc_except_table)) + KEEP (*(.gcc_except_table .gcc_except_table.*)) *(.gnu.linkonce.e.*) *(.gnu.version_r) KEEP (*(.eh_frame)) diff --git a/soc/xtensa/sample_controller/linker.ld b/soc/xtensa/sample_controller/linker.ld index 9f792c5db954c..72370478d5336 100644 --- a/soc/xtensa/sample_controller/linker.ld +++ b/soc/xtensa/sample_controller/linker.ld @@ -447,7 +447,7 @@ SECTIONS *(.rodata1) __XT_EXCEPTION_TABLE__ = ABSOLUTE(.); KEEP (*(.xt_except_table)) - KEEP (*(.gcc_except_table)) + KEEP (*(.gcc_except_table .gcc_except_table.*)) *(.gnu.linkonce.e.*) *(.gnu.version_r) KEEP (*(.eh_frame)) From 6a39b5993ba5d8307d1e5e2b7460f004f868596f Mon Sep 17 00:00:00 2001 From: Jan Van Winkel Date: Sat, 7 Sep 2019 15:10:45 +0200 Subject: [PATCH 3/3] linker: cxx: Include .gcc_except_table sections Include .gcc_except_table (sub-)sections in linker files to support C++ with exceptions enabled. If these sections are not mapped warnings will be generated for orphaned sections at link time. Signed-off-by: Jan Van Winkel --- include/arch/arc/v2/linker.ld | 3 +++ include/arch/arm/cortex_m/scripts/linker.ld | 3 +++ include/arch/arm/cortex_r/scripts/linker.ld | 4 ++++ include/arch/nios2/linker.ld | 4 ++++ include/arch/riscv/common/linker.ld | 4 ++++ include/arch/x86/ia32/linker.ld | 3 +++ include/arch/x86/intel64/linker.ld | 6 +++++- include/linker/cplusplus-ram.ld | 12 ++++++++++++ include/linker/cplusplus-rom.ld | 12 ++++++++++++ soc/riscv/openisa_rv32m1/linker.ld | 3 +++ 10 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 include/linker/cplusplus-ram.ld create mode 100644 include/linker/cplusplus-rom.ld diff --git a/include/arch/arc/v2/linker.ld b/include/arch/arc/v2/linker.ld index c2113e54aa385..ef4db72ae89b4 100644 --- a/include/arch/arc/v2/linker.ld +++ b/include/arch/arc/v2/linker.ld @@ -132,6 +132,8 @@ SECTIONS { } GROUP_LINK_IN(ROMABLE_REGION) +#include + _image_rodata_end = .; MPU_ALIGN(_image_rodata_end - _image_rom_start); _image_rom_end = .; @@ -227,6 +229,7 @@ SECTIONS { #include #include +#include __data_ram_end = .; diff --git a/include/arch/arm/cortex_m/scripts/linker.ld b/include/arch/arm/cortex_m/scripts/linker.ld index 8a0852fc86254..d92293a69ec22 100644 --- a/include/arch/arm/cortex_m/scripts/linker.ld +++ b/include/arch/arm/cortex_m/scripts/linker.ld @@ -273,6 +273,8 @@ SECTIONS . = ALIGN(4); } GROUP_LINK_IN(ROMABLE_REGION) +#include + _image_rodata_end = .; MPU_ALIGN(_image_rodata_end -_image_rom_start); _image_rom_end = .; @@ -411,6 +413,7 @@ SECTIONS #include #include +#include __data_ram_end = .; diff --git a/include/arch/arm/cortex_r/scripts/linker.ld b/include/arch/arm/cortex_r/scripts/linker.ld index e4a8e9fdaa790..0685fbd3d6c74 100644 --- a/include/arch/arm/cortex_r/scripts/linker.ld +++ b/include/arch/arm/cortex_r/scripts/linker.ld @@ -272,6 +272,8 @@ SECTIONS . = ALIGN(4); } GROUP_LINK_IN(ROMABLE_REGION) +#include + _image_rodata_end = .; MPU_ALIGN(_image_rodata_end -_image_rom_start); _image_rom_end = .; @@ -412,6 +414,8 @@ SECTIONS #include +#include + __data_ram_end = .; diff --git a/include/arch/nios2/linker.ld b/include/arch/nios2/linker.ld index 3b4b70899f88d..cb2ecdc39d25d 100644 --- a/include/arch/nios2/linker.ld +++ b/include/arch/nios2/linker.ld @@ -163,6 +163,8 @@ SECTIONS . = ALIGN(4); } GROUP_LINK_IN(ROMABLE_REGION) +#include + _image_rom_end = .; __data_rom_start = ALIGN(4); /* XIP imaged DATA ROM start addr */ @@ -280,6 +282,8 @@ SECTIONS } GROUP_LINK_IN(RAMABLE_REGION) +#include + /* Define linker symbols */ _image_ram_end = .; _end = .; /* end of image */ diff --git a/include/arch/riscv/common/linker.ld b/include/arch/riscv/common/linker.ld index c429a17bb2ce4..753fdabf6a143 100644 --- a/include/arch/riscv/common/linker.ld +++ b/include/arch/riscv/common/linker.ld @@ -120,6 +120,8 @@ SECTIONS } GROUP_LINK_IN(ROMABLE_REGION) +#include + _image_rom_end = .; __data_rom_start = .; @@ -196,6 +198,8 @@ SECTIONS } GROUP_LINK_IN(RAMABLE_REGION) +#include + _image_ram_end = .; _end = .; /* end of image */ diff --git a/include/arch/x86/ia32/linker.ld b/include/arch/x86/ia32/linker.ld index 4dd3ff4dbf84d..47d08f6492326 100644 --- a/include/arch/x86/ia32/linker.ld +++ b/include/arch/x86/ia32/linker.ld @@ -160,6 +160,8 @@ SECTIONS #include } GROUP_LINK_IN(ROMABLE_REGION) +#include + MMU_PAGE_ALIGN /* ROM ends here, position counter will now be in RAM areas */ _image_rom_end = .; @@ -348,6 +350,7 @@ SECTIONS #include #include +#include MMU_PAGE_ALIGN __data_ram_end = .; diff --git a/include/arch/x86/intel64/linker.ld b/include/arch/x86/intel64/linker.ld index 62e404839360c..230852a5e1da3 100644 --- a/include/arch/x86/intel64/linker.ld +++ b/include/arch/x86/intel64/linker.ld @@ -54,9 +54,12 @@ SECTIONS #include #endif /* CONFIG_CUSTOM_RODATA_LD */ + } GROUP_LINK_IN(ROMABLE_REGION) + +#include + _image_rodata_end = .; _image_rodata_size = _image_rodata_end - _image_rodata_start; - } GROUP_LINK_IN(ROMABLE_REGION) SECTION_PROLOGUE(_DATA_SECTION_NAME,,ALIGN(16)) { @@ -70,6 +73,7 @@ SECTIONS #include #include +#include SECTION_PROLOGUE(_BSS_SECTION_NAME, (NOLOAD), ALIGN(16)) { diff --git a/include/linker/cplusplus-ram.ld b/include/linker/cplusplus-ram.ld new file mode 100644 index 0000000000000..64474e79dbd8b --- /dev/null +++ b/include/linker/cplusplus-ram.ld @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2019 Jan Van Winkel + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#if defined (CONFIG_CPLUSPLUS) + SECTION_PROLOGUE(.gcc_except_table,,ONLY_IF_RW) + { + *(.gcc_except_table .gcc_except_table.*) + } GROUP_LINK_IN(RAMABLE_REGION) +#endif diff --git a/include/linker/cplusplus-rom.ld b/include/linker/cplusplus-rom.ld new file mode 100644 index 0000000000000..bb41e50d171e3 --- /dev/null +++ b/include/linker/cplusplus-rom.ld @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2019 Jan Van Winkel + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#if defined (CONFIG_CPLUSPLUS) + SECTION_PROLOGUE(.gcc_except_table,,ONLY_IF_RO) + { + *(.gcc_except_table .gcc_except_table.*) + } GROUP_LINK_IN(ROMABLE_REGION) +#endif diff --git a/soc/riscv/openisa_rv32m1/linker.ld b/soc/riscv/openisa_rv32m1/linker.ld index 0800b57fd0813..c8e86e3f9e489 100644 --- a/soc/riscv/openisa_rv32m1/linker.ld +++ b/soc/riscv/openisa_rv32m1/linker.ld @@ -163,6 +163,8 @@ SECTIONS } GROUP_LINK_IN(ROMABLE_REGION) +#include + _image_rodata_end = .; _image_rom_end = .; @@ -202,6 +204,7 @@ SECTIONS } GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) #include +#include __data_ram_end = .; __data_rom_start = LOADADDR(_DATA_SECTION_NAME);