From 3a9cc6368370fbbd82a383110dec1458c3361c00 Mon Sep 17 00:00:00 2001 From: Dean Galvin Date: Tue, 13 Oct 2026 21:09:26 +1300 Subject: [PATCH] fix(libc): hand out the unwind cursor table through a _nid_no_patch export _Unwind_Context took its cursor table from LibcUnwind::CursorSlots, a C++ data symbol of libc. On Windows LibcUnwind::Frame holds an _Unwind_Context, so libSceAgcDriver, which builds frames for its worker sampler, imported _ZN10LibcUnwind11CursorSlotsE from libc.prx. The NID patcher renames that export in the patched libc and leaves the import alone, so the patched libSceAgcDriver, libSceAgc and libSceVideoOut failed to load with error 127 and patched_libraries failed. The table is now file-local and the context reads it through UnwindCursorSlots_nid_no_patch, which keeps its name on both sides. --- core/libs/prx/libc/include/exceptions/Unwind.hpp | 6 ++---- core/libs/prx/libc/src/exception/Unwind.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/core/libs/prx/libc/include/exceptions/Unwind.hpp b/core/libs/prx/libc/include/exceptions/Unwind.hpp index 7937252c1..bb7f08357 100644 --- a/core/libs/prx/libc/include/exceptions/Unwind.hpp +++ b/core/libs/prx/libc/include/exceptions/Unwind.hpp @@ -9,12 +9,10 @@ #include "prx/libc/include/General.hpp" #include "prx/libc/include/specifics/itanium/UnwindAbi.hpp" -namespace LibcUnwind { -extern const std::uintptr_t CursorSlots[]; -} +extern "C" const std::uintptr_t* UnwindCursorSlots_nid_no_patch(); struct _Unwind_Context { - const std::uintptr_t* cursor = LibcUnwind::CursorSlots; + const std::uintptr_t* cursor = UnwindCursorSlots_nid_no_patch(); std::uintptr_t registers[17] {}; #ifdef _WIN32 std::uintptr_t vectorRegisters[16][2] {}; diff --git a/core/libs/prx/libc/src/exception/Unwind.cpp b/core/libs/prx/libc/src/exception/Unwind.cpp index 7ae48a798..6aac4dddd 100644 --- a/core/libs/prx/libc/src/exception/Unwind.cpp +++ b/core/libs/prx/libc/src/exception/Unwind.cpp @@ -64,9 +64,7 @@ void APS5_VABI CursorUnsupported(_Unwind_Context*) { template std::uintptr_t Slot(Function function) { return reinterpret_cast(function); } -} -namespace LibcUnwind { const std::uintptr_t CursorSlots[] = { Slot(&CursorUnsupported), Slot(&CursorUnsupported), @@ -86,6 +84,10 @@ const std::uintptr_t CursorSlots[] = { }; } +const std::uintptr_t* UnwindCursorSlots_nid_no_patch() { + return CursorSlots; +} + #if defined(__linux__) || defined(_WIN32) || defined(__APPLE__) extern "C" _Unwind_Reason_Code __gxx_personality_v0(int, _Unwind_Action, std::uint64_t, _Unwind_Exception*, _Unwind_Context*);