Improve exception wrapping

This commit is contained in:
Michael Scire 2019-12-08 03:29:47 -08:00
parent 3c7ece2f8b
commit 7472bc1c7f
13 changed files with 93 additions and 21 deletions

View file

@ -49,11 +49,16 @@ CXXWRAPS := -Wl,--wrap,__cxa_pure_virtual \
-Wl,--wrap,__cxa_throw \ -Wl,--wrap,__cxa_throw \
-Wl,--wrap,__cxa_rethrow \ -Wl,--wrap,__cxa_rethrow \
-Wl,--wrap,__cxa_allocate_exception \ -Wl,--wrap,__cxa_allocate_exception \
-Wl,--wrap,__cxa_free_exception \
-Wl,--wrap,__cxa_begin_catch \ -Wl,--wrap,__cxa_begin_catch \
-Wl,--wrap,__cxa_end_catch \ -Wl,--wrap,__cxa_end_catch \
-Wl,--wrap,__cxa_call_unexpected \ -Wl,--wrap,__cxa_call_unexpected \
-Wl,--wrap,__cxa_call_terminate \ -Wl,--wrap,__cxa_call_terminate \
-Wl,--wrap,__gxx_personality_v0 -Wl,--wrap,__gxx_personality_v0 \
-Wl,--wrap,_Unwind_Resume \
-Wl,--wrap,_ZSt19__throw_logic_errorPKc \
-Wl,--wrap,_ZSt20__throw_length_errorPKc \
-Wl,--wrap,_ZNSt11logic_errorC2EPKc
ASFLAGS := -g $(ARCH) ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) $(CXXWRAPS) -Wl,-Map,$(notdir $*.map) LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) $(CXXWRAPS) -Wl,-Map,$(notdir $*.map)

View file

@ -56,11 +56,16 @@ CXXWRAPS := -Wl,--wrap,__cxa_pure_virtual \
-Wl,--wrap,__cxa_throw \ -Wl,--wrap,__cxa_throw \
-Wl,--wrap,__cxa_rethrow \ -Wl,--wrap,__cxa_rethrow \
-Wl,--wrap,__cxa_allocate_exception \ -Wl,--wrap,__cxa_allocate_exception \
-Wl,--wrap,__cxa_free_exception \
-Wl,--wrap,__cxa_begin_catch \ -Wl,--wrap,__cxa_begin_catch \
-Wl,--wrap,__cxa_end_catch \ -Wl,--wrap,__cxa_end_catch \
-Wl,--wrap,__cxa_call_unexpected \ -Wl,--wrap,__cxa_call_unexpected \
-Wl,--wrap,__cxa_call_terminate \ -Wl,--wrap,__cxa_call_terminate \
-Wl,--wrap,__gxx_personality_v0 -Wl,--wrap,__gxx_personality_v0 \
-Wl,--wrap,_Unwind_Resume \
-Wl,--wrap,_ZSt19__throw_logic_errorPKc \
-Wl,--wrap,_ZSt20__throw_length_errorPKc \
-Wl,--wrap,_ZNSt11logic_errorC2EPKc
ASFLAGS := -g $(ARCH) ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) $(CXXWRAPS) -Wl,-Map,$(notdir $*.map) LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) $(CXXWRAPS) -Wl,-Map,$(notdir $*.map)

View file

@ -49,11 +49,16 @@ CXXWRAPS := -Wl,--wrap,__cxa_pure_virtual \
-Wl,--wrap,__cxa_throw \ -Wl,--wrap,__cxa_throw \
-Wl,--wrap,__cxa_rethrow \ -Wl,--wrap,__cxa_rethrow \
-Wl,--wrap,__cxa_allocate_exception \ -Wl,--wrap,__cxa_allocate_exception \
-Wl,--wrap,__cxa_free_exception \
-Wl,--wrap,__cxa_begin_catch \ -Wl,--wrap,__cxa_begin_catch \
-Wl,--wrap,__cxa_end_catch \ -Wl,--wrap,__cxa_end_catch \
-Wl,--wrap,__cxa_call_unexpected \ -Wl,--wrap,__cxa_call_unexpected \
-Wl,--wrap,__cxa_call_terminate \ -Wl,--wrap,__cxa_call_terminate \
-Wl,--wrap,__gxx_personality_v0 -Wl,--wrap,__gxx_personality_v0 \
-Wl,--wrap,_Unwind_Resume \
-Wl,--wrap,_ZSt19__throw_logic_errorPKc \
-Wl,--wrap,_ZSt20__throw_length_errorPKc \
-Wl,--wrap,_ZNSt11logic_errorC2EPKc
ASFLAGS := -g $(ARCH) ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) $(CXXWRAPS) -Wl,-Map,$(notdir $*.map) LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) $(CXXWRAPS) -Wl,-Map,$(notdir $*.map)

View file

@ -49,11 +49,16 @@ CXXWRAPS := -Wl,--wrap,__cxa_pure_virtual \
-Wl,--wrap,__cxa_throw \ -Wl,--wrap,__cxa_throw \
-Wl,--wrap,__cxa_rethrow \ -Wl,--wrap,__cxa_rethrow \
-Wl,--wrap,__cxa_allocate_exception \ -Wl,--wrap,__cxa_allocate_exception \
-Wl,--wrap,__cxa_free_exception \
-Wl,--wrap,__cxa_begin_catch \ -Wl,--wrap,__cxa_begin_catch \
-Wl,--wrap,__cxa_end_catch \ -Wl,--wrap,__cxa_end_catch \
-Wl,--wrap,__cxa_call_unexpected \ -Wl,--wrap,__cxa_call_unexpected \
-Wl,--wrap,__cxa_call_terminate \ -Wl,--wrap,__cxa_call_terminate \
-Wl,--wrap,__gxx_personality_v0 -Wl,--wrap,__gxx_personality_v0 \
-Wl,--wrap,_Unwind_Resume \
-Wl,--wrap,_ZSt19__throw_logic_errorPKc \
-Wl,--wrap,_ZSt20__throw_length_errorPKc \
-Wl,--wrap,_ZNSt11logic_errorC2EPKc
ASFLAGS := -g $(ARCH) ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) $(CXXWRAPS) -Wl,-Map,$(notdir $*.map) LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) $(CXXWRAPS) -Wl,-Map,$(notdir $*.map)

View file

@ -49,11 +49,16 @@ CXXWRAPS := -Wl,--wrap,__cxa_pure_virtual \
-Wl,--wrap,__cxa_throw \ -Wl,--wrap,__cxa_throw \
-Wl,--wrap,__cxa_rethrow \ -Wl,--wrap,__cxa_rethrow \
-Wl,--wrap,__cxa_allocate_exception \ -Wl,--wrap,__cxa_allocate_exception \
-Wl,--wrap,__cxa_free_exception \
-Wl,--wrap,__cxa_begin_catch \ -Wl,--wrap,__cxa_begin_catch \
-Wl,--wrap,__cxa_end_catch \ -Wl,--wrap,__cxa_end_catch \
-Wl,--wrap,__cxa_call_unexpected \ -Wl,--wrap,__cxa_call_unexpected \
-Wl,--wrap,__cxa_call_terminate \ -Wl,--wrap,__cxa_call_terminate \
-Wl,--wrap,__gxx_personality_v0 -Wl,--wrap,__gxx_personality_v0 \
-Wl,--wrap,_Unwind_Resume \
-Wl,--wrap,_ZSt19__throw_logic_errorPKc \
-Wl,--wrap,_ZSt20__throw_length_errorPKc \
-Wl,--wrap,_ZNSt11logic_errorC2EPKc
ASFLAGS := -g $(ARCH) ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) $(CXXWRAPS) -Wl,-Map,$(notdir $*.map) LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) $(CXXWRAPS) -Wl,-Map,$(notdir $*.map)

View file

@ -49,11 +49,16 @@ CXXWRAPS := -Wl,--wrap,__cxa_pure_virtual \
-Wl,--wrap,__cxa_throw \ -Wl,--wrap,__cxa_throw \
-Wl,--wrap,__cxa_rethrow \ -Wl,--wrap,__cxa_rethrow \
-Wl,--wrap,__cxa_allocate_exception \ -Wl,--wrap,__cxa_allocate_exception \
-Wl,--wrap,__cxa_free_exception \
-Wl,--wrap,__cxa_begin_catch \ -Wl,--wrap,__cxa_begin_catch \
-Wl,--wrap,__cxa_end_catch \ -Wl,--wrap,__cxa_end_catch \
-Wl,--wrap,__cxa_call_unexpected \ -Wl,--wrap,__cxa_call_unexpected \
-Wl,--wrap,__cxa_call_terminate \ -Wl,--wrap,__cxa_call_terminate \
-Wl,--wrap,__gxx_personality_v0 -Wl,--wrap,__gxx_personality_v0 \
-Wl,--wrap,_Unwind_Resume \
-Wl,--wrap,_ZSt19__throw_logic_errorPKc \
-Wl,--wrap,_ZSt20__throw_length_errorPKc \
-Wl,--wrap,_ZNSt11logic_errorC2EPKc
ASFLAGS := -g $(ARCH) ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) $(CXXWRAPS) -Wl,-Map,$(notdir $*.map) LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) $(CXXWRAPS) -Wl,-Map,$(notdir $*.map)

View file

@ -49,11 +49,16 @@ CXXWRAPS := -Wl,--wrap,__cxa_pure_virtual \
-Wl,--wrap,__cxa_throw \ -Wl,--wrap,__cxa_throw \
-Wl,--wrap,__cxa_rethrow \ -Wl,--wrap,__cxa_rethrow \
-Wl,--wrap,__cxa_allocate_exception \ -Wl,--wrap,__cxa_allocate_exception \
-Wl,--wrap,__cxa_free_exception \
-Wl,--wrap,__cxa_begin_catch \ -Wl,--wrap,__cxa_begin_catch \
-Wl,--wrap,__cxa_end_catch \ -Wl,--wrap,__cxa_end_catch \
-Wl,--wrap,__cxa_call_unexpected \ -Wl,--wrap,__cxa_call_unexpected \
-Wl,--wrap,__cxa_call_terminate \ -Wl,--wrap,__cxa_call_terminate \
-Wl,--wrap,__gxx_personality_v0 -Wl,--wrap,__gxx_personality_v0 \
-Wl,--wrap,_Unwind_Resume \
-Wl,--wrap,_ZSt19__throw_logic_errorPKc \
-Wl,--wrap,_ZSt20__throw_length_errorPKc \
-Wl,--wrap,_ZNSt11logic_errorC2EPKc
ASFLAGS := -g $(ARCH) ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) $(CXXWRAPS) -Wl,-Map,$(notdir $*.map) LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) $(CXXWRAPS) -Wl,-Map,$(notdir $*.map)

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();
} }

View file

@ -49,11 +49,16 @@ CXXWRAPS := -Wl,--wrap,__cxa_pure_virtual \
-Wl,--wrap,__cxa_throw \ -Wl,--wrap,__cxa_throw \
-Wl,--wrap,__cxa_rethrow \ -Wl,--wrap,__cxa_rethrow \
-Wl,--wrap,__cxa_allocate_exception \ -Wl,--wrap,__cxa_allocate_exception \
-Wl,--wrap,__cxa_free_exception \
-Wl,--wrap,__cxa_begin_catch \ -Wl,--wrap,__cxa_begin_catch \
-Wl,--wrap,__cxa_end_catch \ -Wl,--wrap,__cxa_end_catch \
-Wl,--wrap,__cxa_call_unexpected \ -Wl,--wrap,__cxa_call_unexpected \
-Wl,--wrap,__cxa_call_terminate \ -Wl,--wrap,__cxa_call_terminate \
-Wl,--wrap,__gxx_personality_v0 -Wl,--wrap,__gxx_personality_v0 \
-Wl,--wrap,_Unwind_Resume \
-Wl,--wrap,_ZSt19__throw_logic_errorPKc \
-Wl,--wrap,_ZSt20__throw_length_errorPKc \
-Wl,--wrap,_ZNSt11logic_errorC2EPKc
ASFLAGS := -g $(ARCH) ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) $(CXXWRAPS) -Wl,-Map,$(notdir $*.map) LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) $(CXXWRAPS) -Wl,-Map,$(notdir $*.map)

View file

@ -49,11 +49,16 @@ CXXWRAPS := -Wl,--wrap,__cxa_pure_virtual \
-Wl,--wrap,__cxa_throw \ -Wl,--wrap,__cxa_throw \
-Wl,--wrap,__cxa_rethrow \ -Wl,--wrap,__cxa_rethrow \
-Wl,--wrap,__cxa_allocate_exception \ -Wl,--wrap,__cxa_allocate_exception \
-Wl,--wrap,__cxa_free_exception \
-Wl,--wrap,__cxa_begin_catch \ -Wl,--wrap,__cxa_begin_catch \
-Wl,--wrap,__cxa_end_catch \ -Wl,--wrap,__cxa_end_catch \
-Wl,--wrap,__cxa_call_unexpected \ -Wl,--wrap,__cxa_call_unexpected \
-Wl,--wrap,__cxa_call_terminate \ -Wl,--wrap,__cxa_call_terminate \
-Wl,--wrap,__gxx_personality_v0 -Wl,--wrap,__gxx_personality_v0 \
-Wl,--wrap,_Unwind_Resume \
-Wl,--wrap,_ZSt19__throw_logic_errorPKc \
-Wl,--wrap,_ZSt20__throw_length_errorPKc \
-Wl,--wrap,_ZNSt11logic_errorC2EPKc
ASFLAGS := -g $(ARCH) ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) $(CXXWRAPS) -Wl,-Map,$(notdir $*.map) LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) $(CXXWRAPS) -Wl,-Map,$(notdir $*.map)

View file

@ -49,11 +49,16 @@ CXXWRAPS := -Wl,--wrap,__cxa_pure_virtual \
-Wl,--wrap,__cxa_throw \ -Wl,--wrap,__cxa_throw \
-Wl,--wrap,__cxa_rethrow \ -Wl,--wrap,__cxa_rethrow \
-Wl,--wrap,__cxa_allocate_exception \ -Wl,--wrap,__cxa_allocate_exception \
-Wl,--wrap,__cxa_free_exception \
-Wl,--wrap,__cxa_begin_catch \ -Wl,--wrap,__cxa_begin_catch \
-Wl,--wrap,__cxa_end_catch \ -Wl,--wrap,__cxa_end_catch \
-Wl,--wrap,__cxa_call_unexpected \ -Wl,--wrap,__cxa_call_unexpected \
-Wl,--wrap,__cxa_call_terminate \ -Wl,--wrap,__cxa_call_terminate \
-Wl,--wrap,__gxx_personality_v0 -Wl,--wrap,__gxx_personality_v0 \
-Wl,--wrap,_Unwind_Resume \
-Wl,--wrap,_ZSt19__throw_logic_errorPKc \
-Wl,--wrap,_ZSt20__throw_length_errorPKc \
-Wl,--wrap,_ZNSt11logic_errorC2EPKc
ASFLAGS := -g $(ARCH) ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) $(CXXWRAPS) -Wl,-Map,$(notdir $*.map) LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) $(CXXWRAPS) -Wl,-Map,$(notdir $*.map)

View file

@ -49,11 +49,16 @@ CXXWRAPS := -Wl,--wrap,__cxa_pure_virtual \
-Wl,--wrap,__cxa_throw \ -Wl,--wrap,__cxa_throw \
-Wl,--wrap,__cxa_rethrow \ -Wl,--wrap,__cxa_rethrow \
-Wl,--wrap,__cxa_allocate_exception \ -Wl,--wrap,__cxa_allocate_exception \
-Wl,--wrap,__cxa_free_exception \
-Wl,--wrap,__cxa_begin_catch \ -Wl,--wrap,__cxa_begin_catch \
-Wl,--wrap,__cxa_end_catch \ -Wl,--wrap,__cxa_end_catch \
-Wl,--wrap,__cxa_call_unexpected \ -Wl,--wrap,__cxa_call_unexpected \
-Wl,--wrap,__cxa_call_terminate \ -Wl,--wrap,__cxa_call_terminate \
-Wl,--wrap,__gxx_personality_v0 -Wl,--wrap,__gxx_personality_v0 \
-Wl,--wrap,_Unwind_Resume \
-Wl,--wrap,_ZSt19__throw_logic_errorPKc \
-Wl,--wrap,_ZSt20__throw_length_errorPKc \
-Wl,--wrap,_ZNSt11logic_errorC2EPKc
ASFLAGS := -g $(ARCH) ASFLAGS := -g $(ARCH)

View file

@ -49,11 +49,16 @@ CXXWRAPS := -Wl,--wrap,__cxa_pure_virtual \
-Wl,--wrap,__cxa_throw \ -Wl,--wrap,__cxa_throw \
-Wl,--wrap,__cxa_rethrow \ -Wl,--wrap,__cxa_rethrow \
-Wl,--wrap,__cxa_allocate_exception \ -Wl,--wrap,__cxa_allocate_exception \
-Wl,--wrap,__cxa_free_exception \
-Wl,--wrap,__cxa_begin_catch \ -Wl,--wrap,__cxa_begin_catch \
-Wl,--wrap,__cxa_end_catch \ -Wl,--wrap,__cxa_end_catch \
-Wl,--wrap,__cxa_call_unexpected \ -Wl,--wrap,__cxa_call_unexpected \
-Wl,--wrap,__cxa_call_terminate \ -Wl,--wrap,__cxa_call_terminate \
-Wl,--wrap,__gxx_personality_v0 -Wl,--wrap,__gxx_personality_v0 \
-Wl,--wrap,_Unwind_Resume \
-Wl,--wrap,_ZSt19__throw_logic_errorPKc \
-Wl,--wrap,_ZSt20__throw_length_errorPKc \
-Wl,--wrap,_ZNSt11logic_errorC2EPKc
ASFLAGS := -g $(ARCH) ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) $(CXXWRAPS) -Wl,-Map,$(notdir $*.map) LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) $(CXXWRAPS) -Wl,-Map,$(notdir $*.map)