diff --git a/components/cxx/CMakeLists.txt b/components/cxx/CMakeLists.txt index 228414599c..a14aa9b148 100644 --- a/components/cxx/CMakeLists.txt +++ b/components/cxx/CMakeLists.txt @@ -39,7 +39,9 @@ if(NOT CONFIG_CXX_EXCEPTIONS) _Unwind_Resume_or_Rethrow _Unwind_Backtrace __cxa_call_unexpected - __gxx_personality_v0) + __gxx_personality_v0 + __cxa_throw + __cxa_allocate_exception) foreach(wrap ${WRAP_FUNCTIONS}) target_link_libraries(${COMPONENT_LIB} INTERFACE "-Wl,--wrap=${wrap}") diff --git a/components/cxx/cxx_exception_stubs.cpp b/components/cxx/cxx_exception_stubs.cpp index 827d40dd81..7e794755c0 100644 --- a/components/cxx/cxx_exception_stubs.cpp +++ b/components/cxx/cxx_exception_stubs.cpp @@ -178,4 +178,16 @@ extern "C" _Unwind_Reason_Code __wrap___gxx_personality_v0(int version, return abort_return<_Unwind_Reason_Code>(); } +// Reduces binary size since the linker will drop some code due to --gc-sections. +extern "C" void __wrap___cxa_allocate_exception(void) +{ + abort(); +} + +// Reduces binary size since the linker will drop some code due to --gc-sections. +extern "C" void __wrap___cxa_throw(void) +{ + abort(); +} + #endif // CONFIG_COMPILER_CXX_EXCEPTIONS