diff --git a/libraries/config/templates/stratosphere.mk b/libraries/config/templates/stratosphere.mk index 63b90af9e..1d62d0750 100644 --- a/libraries/config/templates/stratosphere.mk +++ b/libraries/config/templates/stratosphere.mk @@ -82,7 +82,7 @@ export LIBS := -lstratosphere -lnx else ifeq ($(ATMOSPHERE_BOARD),generic_windows) export LIBS := -lstratosphere -lwinmm -lws2_32 -lbcrypt -lbfd -liberty -lintl -lz else ifeq ($(ATMOSPHERE_BOARD),generic_linux) -export LIBS := -lstratosphere -pthread -lbfd -liberty -ldl +export LIBS := -lstratosphere -pthread -lbfd else ifeq ($(ATMOSPHERE_BOARD),generic_macos) export LIBS := -lstratosphere -pthread else diff --git a/libraries/libstratosphere/source/diag/diag_assertion_impl.cpp b/libraries/libstratosphere/source/diag/diag_assertion_impl.cpp index ad0472dea..bd1cb43b6 100644 --- a/libraries/libstratosphere/source/diag/diag_assertion_impl.cpp +++ b/libraries/libstratosphere/source/diag/diag_assertion_impl.cpp @@ -14,6 +14,7 @@ * along with this program. If not, see . */ #include +#include "impl/diag_get_all_backtrace.hpp" #include "impl/diag_invoke_abort.hpp" namespace ams::diag { @@ -179,6 +180,9 @@ namespace ams::diag { std::scoped_lock lk(g_abort_mutex); + /* Set the abort impl return address. */ + impl::SetAbortImplReturnAddress(reinterpret_cast(__builtin_return_address(0))); + /* Create abort info. */ std::va_list cvl; va_copy(cvl, vl); diff --git a/libraries/libstratosphere/source/diag/impl/diag_get_all_backtrace.cpp b/libraries/libstratosphere/source/diag/impl/diag_get_all_backtrace.cpp index a96f8c5e4..c79973fe0 100644 --- a/libraries/libstratosphere/source/diag/impl/diag_get_all_backtrace.cpp +++ b/libraries/libstratosphere/source/diag/impl/diag_get_all_backtrace.cpp @@ -23,6 +23,10 @@ namespace ams::diag::impl { } + void SetAbortImplReturnAddress(uintptr_t address) { + g_abort_impl_return_address = address; + } + size_t GetAllBacktrace(uintptr_t *out, size_t out_size, ::ams::diag::Backtrace &bt) { size_t count = 0; do { diff --git a/libraries/libstratosphere/source/diag/impl/diag_get_all_backtrace.hpp b/libraries/libstratosphere/source/diag/impl/diag_get_all_backtrace.hpp index 1a5a7636f..7ee2aaaab 100644 --- a/libraries/libstratosphere/source/diag/impl/diag_get_all_backtrace.hpp +++ b/libraries/libstratosphere/source/diag/impl/diag_get_all_backtrace.hpp @@ -18,7 +18,7 @@ namespace ams::diag::impl { - void SetAbortImplAddress(uintptr_t address); + void SetAbortImplReturnAddress(uintptr_t address); size_t GetAllBacktrace(uintptr_t *out, size_t out_size, ::ams::diag::Backtrace &bt); diff --git a/libraries/libstratosphere/source/diag/impl/diag_symbol_impl.os.generic.cpp b/libraries/libstratosphere/source/diag/impl/diag_symbol_impl.os.generic.cpp index a5a8afe49..aa6144c54 100644 --- a/libraries/libstratosphere/source/diag/impl/diag_symbol_impl.os.generic.cpp +++ b/libraries/libstratosphere/source/diag/impl/diag_symbol_impl.os.generic.cpp @@ -35,8 +35,7 @@ extern "C" char __init_array_start; #endif -#define HAVE_DECL_BASENAME 1 -#include +#include namespace ams::diag::impl { @@ -219,7 +218,10 @@ namespace ams::diag::impl { /* Print the symbol. */ const char *name = bfd_asymbol_name(*symbol); - if (auto *demangled = bfd_demangle(m_handle, name, DMGL_ANSI | DMGL_PARAMS); demangled != nullptr) { + + int cpp_name_status = 0; + if (char *demangled = abi::__cxa_demangle(name, nullptr, 0, std::addressof(cpp_name_status)); cpp_name_status == 0) { + AMS_ASSERT(demangled != nullptr); util::TSNPrintf(dst, dst_size, "%s", demangled); std::free(demangled); } else {