From e0f7e196f250fbcc073f60a8f9f2fc3f511282a0 Mon Sep 17 00:00:00 2001 From: Alexey Gerenkov Date: Tue, 28 Aug 2018 12:22:12 +0800 Subject: [PATCH] =?UTF-8?q?cxx:=20don=E2=80=99t=20define=20stubs=20for=20?= =?UTF-8?q?=5F=5Fthrow=5F*=20functions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If exception support is disabled in IDF, and libstdc++ tries to throw an exception, it will call __cxa_allocate_exception which is replaced with abort in IDF. We have a dramatically size reduction of the RO-section in binary when using '__throw_'-stubs in GCC5 In the case of using GCC8, we are faced with 'multiple definition' errors when using '__throw_'-stubs. Good that we don't have the size problem due to gcc8 --- components/cxx/cxx_exception_stubs.cpp | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/components/cxx/cxx_exception_stubs.cpp b/components/cxx/cxx_exception_stubs.cpp index b67bc2ad3..f09f946dd 100644 --- a/components/cxx/cxx_exception_stubs.cpp +++ b/components/cxx/cxx_exception_stubs.cpp @@ -36,42 +36,26 @@ extern "C" void __cxx_fatal_exception_int(int i) abort(); } +#if !GCC_NOT_5_2_0 void std::__throw_bad_exception(void) __attribute__((alias("__cxx_fatal_exception"))); - void std::__throw_bad_alloc(void) __attribute__((alias("__cxx_fatal_exception"))); - void std::__throw_bad_cast(void) __attribute__((alias("__cxx_fatal_exception"))); - void std::__throw_bad_typeid(void) __attribute__((alias("__cxx_fatal_exception"))); - void std::__throw_logic_error(const char*) __attribute__((alias("__cxx_fatal_exception_message"))); - void std::__throw_domain_error(const char*) __attribute__((alias("__cxx_fatal_exception_message"))); - void std::__throw_invalid_argument(const char*) __attribute__((alias("__cxx_fatal_exception_message"))); - void std::__throw_length_error(const char*) __attribute__((alias("__cxx_fatal_exception_message"))); - void std::__throw_out_of_range(const char*) __attribute__((alias("__cxx_fatal_exception_message"))); - void std::__throw_out_of_range_fmt(const char*, ...) __attribute__((alias("__cxx_fatal_exception_message_va"))); - void std::__throw_runtime_error(const char*) __attribute__((alias("__cxx_fatal_exception_message"))); - void std::__throw_range_error(const char*) __attribute__((alias("__cxx_fatal_exception_message"))); - void std::__throw_overflow_error(const char*) __attribute__((alias("__cxx_fatal_exception_message"))); - void std::__throw_underflow_error(const char*) __attribute__((alias("__cxx_fatal_exception_message"))); - void std::__throw_ios_failure(const char*) __attribute__((alias("__cxx_fatal_exception_message"))); - void std::__throw_system_error(int) __attribute__((alias("__cxx_fatal_exception_int"))); - void std::__throw_bad_function_call(void) __attribute__((alias("__cxx_fatal_exception"))); - void std::__throw_future_error(int) __attribute__((alias("__cxx_fatal_exception_int"))); - +#endif /* The following definitions are needed because libstdc++ is also compiled with __throw_exception_again defined to throw, and some other exception code in a few places.