diff --git a/libraries/libstratosphere/source/ams/ams_environment.cpp b/libraries/libstratosphere/source/ams/ams_environment.cpp index 597a46277..ce4237f6e 100644 --- a/libraries/libstratosphere/source/ams/ams_environment.cpp +++ b/libraries/libstratosphere/source/ams/ams_environment.cpp @@ -153,29 +153,14 @@ namespace ams { ::ams::ExceptionHandler(&ams_ctx); } - inline NORETURN void AbortImpl() { - /* Just perform a data abort. */ - register u64 addr __asm__("x27") = FatalErrorContext::StdAbortMagicAddress; - register u64 val __asm__("x28") = FatalErrorContext::StdAbortMagicValue; - while (true) { - __asm__ __volatile__ ( - "str %[val], [%[addr]]" - : - : [val]"r"(val), [addr]"r"(addr) - ); - } - __builtin_unreachable(); - } + NORETURN void AbortImpl(); } extern "C" { - /* Redefine abort to trigger these handlers. */ - void abort(); - /* Redefine C++ exception handlers. Requires wrap linker flag. */ - #define WRAP_ABORT_FUNC(func) void NORETURN __wrap_##func(void) { abort(); __builtin_unreachable(); } + #define WRAP_ABORT_FUNC(func) void NORETURN __wrap_##func(void) { ::ams::AbortImpl(); __builtin_unreachable(); } WRAP_ABORT_FUNC(__cxa_throw) WRAP_ABORT_FUNC(__cxa_rethrow) WRAP_ABORT_FUNC(__cxa_allocate_exception) @@ -195,9 +180,3 @@ extern "C" { #undef WRAP_ABORT_FUNC } - -/* Custom abort handler, so that std::abort will trigger these. */ -void abort() { - ams::AbortImpl(); - __builtin_unreachable(); -} diff --git a/libraries/libstratosphere/source/ams/ams_environment_weak.cpp b/libraries/libstratosphere/source/ams/ams_environment_weak.cpp index 284a725ea..d24cc4bb5 100644 --- a/libraries/libstratosphere/source/ams/ams_environment_weak.cpp +++ b/libraries/libstratosphere/source/ams/ams_environment_weak.cpp @@ -44,15 +44,38 @@ namespace ams { __builtin_unreachable(); } + NOINLINE NORETURN void AbortImpl() { + /* Just perform a data abort. */ + register u64 addr __asm__("x27") = FatalErrorContext::StdAbortMagicAddress; + register u64 val __asm__("x28") = FatalErrorContext::StdAbortMagicValue; + while (true) { + __asm__ __volatile__ ( + "str %[val], [%[addr]]" + : + : [val]"r"(val), [addr]"r"(addr) + ); + } + __builtin_unreachable(); + } + } extern "C" { + /* Redefine abort to trigger these handlers. */ + void abort(); + /* Redefine C++ exception handlers. Requires wrap linker flag. */ - #define WRAP_ABORT_FUNC(func) void NORETURN __wrap_##func(void) { abort(); __builtin_unreachable(); } + #define WRAP_ABORT_FUNC(func) void NORETURN __wrap_##func(void) { ::ams::AbortImpl(); __builtin_unreachable(); } WRAP_ABORT_FUNC(__cxa_pure_virtual) #undef WRAP_ABORT_FUNC void NORETURN __wrap_exit(int rc) { ::ams::Exit(rc); __builtin_unreachable(); } } + +/* Custom abort handler, so that std::abort will trigger these. */ +void abort() { + ams::AbortImpl(); + __builtin_unreachable(); +}