From 38ffb98f1b4372e57eeb6a0e969ee373c06bdd48 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Sat, 26 Jan 2019 11:23:31 -0600 Subject: [PATCH] Kconfig files, binfmt/libelf, libs/libc/machin, libs/libxx: Correct libcxx exception handling by introducing the generic config(CXX_EXCEPTION and CXX_LIBSUPCXX) --- arch/arm/src/armv7-m/Kconfig | 4 ++-- binfmt/libelf/Kconfig | 2 +- binfmt/libelf/libelf_load.c | 4 ++-- libs/libc/machine/arm/armv7-m/arch_elf.c | 18 ------------------ libs/libxx/Kconfig | 14 ++++++++++---- libs/libxx/Makefile | 6 +----- libs/libxx/libxx__gnu_unwind_find_exidx.cxx | 4 +++- libs/libxx/libxx__gnu_unwind_find_exidx.hxx | 1 - 8 files changed, 19 insertions(+), 34 deletions(-) diff --git a/arch/arm/src/armv7-m/Kconfig b/arch/arm/src/armv7-m/Kconfig index 703c59bf3c..37e64bb194 100644 --- a/arch/arm/src/armv7-m/Kconfig +++ b/arch/arm/src/armv7-m/Kconfig @@ -211,8 +211,8 @@ config ARMV7M_OABI_TOOLCHAIN config ARMV7M_TARGET2_PREL bool "R_ARM_TARGET2 is PC relative" - default n if !UCLIBCXX_EXCEPTION - default y if UCLIBCXX_EXCEPTION + default n if !CXX_EXCEPTION + default y if CXX_EXCEPTION depends on ELF ---help--- Perform a PC relative relocation for relocation type R_ARM_TARGET2 diff --git a/binfmt/libelf/Kconfig b/binfmt/libelf/Kconfig index 5580a70a47..6ce47eb795 100644 --- a/binfmt/libelf/Kconfig +++ b/binfmt/libelf/Kconfig @@ -42,7 +42,7 @@ config ELF_DUMPBUFFER config ELF_EXIDX_SECTNAME string "ELF Section Name for Exception Index" default ".ARM.exidx" - depends on UCLIBCXX_EXCEPTION + depends on CXX_EXCEPTION ---help--- Set the name string for the exception index section on the ELF modules to be loaded by the ELF binary loader. diff --git a/binfmt/libelf/libelf_load.c b/binfmt/libelf/libelf_load.c index 1ca4fc33a6..9808aca6ec 100644 --- a/binfmt/libelf/libelf_load.c +++ b/binfmt/libelf/libelf_load.c @@ -244,7 +244,7 @@ static inline int elf_loadfile(FAR struct elf_loadinfo_s *loadinfo) int elf_load(FAR struct elf_loadinfo_s *loadinfo) { size_t heapsize; -#ifdef CONFIG_UCLIBCXX_EXCEPTION +#ifdef CONFIG_CXX_EXCEPTION int exidx; #endif int ret; @@ -330,7 +330,7 @@ int elf_load(FAR struct elf_loadinfo_s *loadinfo) } #endif -#ifdef CONFIG_UCLIBCXX_EXCEPTION +#ifdef CONFIG_CXX_EXCEPTION exidx = elf_findsection(loadinfo, CONFIG_ELF_EXIDX_SECTNAME); if (exidx < 0) { diff --git a/libs/libc/machine/arm/armv7-m/arch_elf.c b/libs/libc/machine/arm/armv7-m/arch_elf.c index b582189fca..383e053a70 100644 --- a/libs/libc/machine/arm/armv7-m/arch_elf.c +++ b/libs/libc/machine/arm/armv7-m/arch_elf.c @@ -46,14 +46,6 @@ #include #include -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -#ifdef CONFIG_UCLIBCXX_EXCEPTION -extern void init_unwind_exidx(Elf32_Addr start, Elf32_Addr end); -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -472,13 +464,3 @@ int up_relocateadd(FAR const Elf32_Rela *rel, FAR const Elf32_Sym *sym, berr("ERROR: RELA relocation not supported\n"); return -ENOSYS; } - -#ifdef CONFIG_UCLIBCXX_EXCEPTION -int up_init_exidx(Elf32_Addr address, Elf32_Word size) -{ - init_unwind_exidx(address, size); - - return OK; -} -#endif - diff --git a/libs/libxx/Kconfig b/libs/libxx/Kconfig index 838bcc78d1..9eaee3d3a7 100644 --- a/libs/libxx/Kconfig +++ b/libs/libxx/Kconfig @@ -30,6 +30,12 @@ config CXX_NEWLONG C++ library routines because the NuttX size_t might not have the same underlying type as your toolchain's size_t. +config CXX_EXCEPTION + bool + +config CXX_LIBSUPCXX + bool + comment "LLVM C++ Library (libcxx)" config LIBCXX @@ -45,14 +51,12 @@ if LIBCXX config LIBCXX_EXCEPTION bool "Enable Exception Suppport" default y - -config LIBCXX_IOSTREAM_BUFSIZE - int "IO Stream Buffer Size" - default 32 + select CXX_EXCEPTION config LIBCXX_HAVE_LIBSUPCXX bool "Have libsupc++ (required)" default y + select CXX_LIBSUPCXX ---help--- Select if your toolchain provides libsupc++. This option is required at present because the built-in libsupc++ support is incomplete. @@ -74,6 +78,7 @@ if UCLIBCXX config UCLIBCXX_EXCEPTION bool "Enable Exception Suppport" default y + select CXX_EXCEPTION config UCLIBCXX_IOSTREAM_BUFSIZE int "IO Stream Buffer Size" @@ -82,6 +87,7 @@ config UCLIBCXX_IOSTREAM_BUFSIZE config UCLIBCXX_HAVE_LIBSUPCXX bool "Have libsupc++ (required)" default y + select CXX_LIBSUPCXX ---help--- Select if your toolchain provides libsupc++. This option is required at present because the built-in libsupc++ support is incomplete. diff --git a/libs/libxx/Makefile b/libs/libxx/Makefile index 20a9ebc20b..172d1468d8 100644 --- a/libs/libxx/Makefile +++ b/libs/libxx/Makefile @@ -47,7 +47,7 @@ ASRCS = CSRCS = CXXSRCS = libxx_cxapurevirtual.cxx libxx_eabi_atexit.cxx libxx_cxa_atexit.cxx -ifneq (,$(findstring y,$(CONFIG_UCLIBCXX_EXCEPTION) $(CONFIG_LIBCXX_EXCEPTION))) +ifeq ($(CONFIG_CXX_EXCEPTION),y) CXXSRCS += libxx__gnu_unwind_find_exidx.cxx endif @@ -58,10 +58,6 @@ ifeq (,$(findstring y,$(CONFIG_UCLIBCXX) $(CONFIG_LIBCXX))) CXXSRCS += libxx_delete.cxx libxx_delete_sized.cxx libxx_deletea.cxx CXXSRCS += libxx_deletea_sized.cxx libxx_new.cxx libxx_newa.cxx CXXSRCS += libxx_stdthrow.cxx -else -ifeq (,$(findstring y,$(CONFIG_UCLIBCXX_EXCEPTION) $(CONFIG_LIBCXX_EXCEPTION))) -CXXSRCS += libxx_stdthrow.cxx -endif endif # uClibc++ doesn't need this file diff --git a/libs/libxx/libxx__gnu_unwind_find_exidx.cxx b/libs/libxx/libxx__gnu_unwind_find_exidx.cxx index 68c086f465..7f2ed19fd5 100644 --- a/libs/libxx/libxx__gnu_unwind_find_exidx.cxx +++ b/libs/libxx/libxx__gnu_unwind_find_exidx.cxx @@ -37,6 +37,7 @@ // Included Files //*************************************************************************** +#include #include "libxx__gnu_unwind_find_exidx.hxx" //*************************************************************************** @@ -84,10 +85,11 @@ extern "C" { - void init_unwind_exidx(Elf32_Addr start, Elf32_Word size) + int up_init_exidx(Elf32_Addr start, Elf32_Word size) { __exidx_start_elf = (__EIT_entry *) start; __exidx_end_elf = __exidx_start_elf + size; + return 0; } _Unwind_Ptr __gnu_Unwind_Find_exidx (_Unwind_Ptr return_address, int *nrecp) diff --git a/libs/libxx/libxx__gnu_unwind_find_exidx.hxx b/libs/libxx/libxx__gnu_unwind_find_exidx.hxx index 9156874a6c..63925b070d 100644 --- a/libs/libxx/libxx__gnu_unwind_find_exidx.hxx +++ b/libs/libxx/libxx__gnu_unwind_find_exidx.hxx @@ -42,7 +42,6 @@ extern "C" // Included Files //*************************************************************************** -#include #include //***************************************************************************