Improve exception wrapping

This commit is contained in:
Michael Scire 2019-12-08 03:29:47 -08:00
parent 93d4f69168
commit 6fafa541cc

View File

@ -136,6 +136,7 @@ namespace ams {
: [val]"r"(val), [addr]"r"(addr) : [val]"r"(val), [addr]"r"(addr)
); );
} }
__builtin_unreachable();
} }
} }
@ -146,19 +147,30 @@ extern "C" {
void abort(); void abort();
/* Redefine C++ exception handlers. Requires wrap linker flag. */ /* Redefine C++ exception handlers. Requires wrap linker flag. */
void __wrap___cxa_pure_virtual(void) { abort(); } #define WRAP_ABORT_FUNC(func) void NORETURN __wrap_##func(void) { abort(); __builtin_unreachable(); }
void __wrap___cxa_throw(void) { abort(); } WRAP_ABORT_FUNC(__cxa_pure_virtual)
void __wrap___cxa_rethrow(void) { abort(); } WRAP_ABORT_FUNC(__cxa_throw)
void __wrap___cxa_allocate_exception(void) { abort(); } WRAP_ABORT_FUNC(__cxa_rethrow)
void __wrap___cxa_begin_catch(void) { abort(); } WRAP_ABORT_FUNC(__cxa_allocate_exception)
void __wrap___cxa_end_catch(void) { abort(); } WRAP_ABORT_FUNC(__cxa_free_exception)
void __wrap___cxa_call_unexpected(void) { abort(); } WRAP_ABORT_FUNC(__cxa_begin_catch)
void __wrap___cxa_call_terminate(void) { abort(); } WRAP_ABORT_FUNC(__cxa_end_catch)
void __wrap___gxx_personality_v0(void) { abort(); } WRAP_ABORT_FUNC(__cxa_call_unexpected)
WRAP_ABORT_FUNC(__cxa_call_terminate)
WRAP_ABORT_FUNC(__gxx_personality_v0)
WRAP_ABORT_FUNC(_ZSt19__throw_logic_errorPKc)
WRAP_ABORT_FUNC(_ZSt20__throw_length_errorPKc)
WRAP_ABORT_FUNC(_ZNSt11logic_errorC2EPKc)
/* TODO: We may wish to consider intentionally not defining an _Unwind_Resume wrapper. */
/* This would mean that a failure to wrap all exception functions is a linker error. */
WRAP_ABORT_FUNC(_Unwind_Resume)
#undef WRAP_ABORT_FUNC
} }
/* Custom abort handler, so that std::abort will trigger these. */ /* Custom abort handler, so that std::abort will trigger these. */
void abort() { void abort() {
ams::AbortImpl(); ams::AbortImpl();
__builtin_unreachable();
} }