mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-10 01:28:44 +02:00
feat(libc): export the __sce_v2 _Xbad_function_call and sized aligned delete
PPSA16064 (Minecraft Dungeons II) ships its own libc.prx, which imports two C++ runtime symbols from libSceLibcInternal that no host library exported, so the title failed to load: - std::__sce_v2::_Xbad_function_call() (_ZNSt8__sce_v219_Xbad_function_callEv), the inline-namespace spelling of the existing std::_Xbad_function_call. It throws std::bad_function_call the same way. - operator delete(void*, std::size_t, std::align_val_t) (_ZdlPvmSt11align_val_t), the sized form of the existing aligned delete. It frees the pointer the same way and ignores the size. application_heap_default frees an aligned block through the sized form and checks that a null pointer frees nothing. exception_runtime checks that the new thrower throws a standard exception; it is built only on Linux and was not run here (Windows 11, MinGW GCC 15.2).
This commit is contained in:
@@ -105,4 +105,9 @@ void APS5_VABI _ZdlPvSt11align_val_t_nid_postfix(void* pointer, std::size_t alig
|
||||
if (pointer != nullptr) ApplicationHeapFree_nid_no_patch(pointer);
|
||||
}
|
||||
|
||||
void APS5_VABI _ZdlPvmSt11align_val_t_nid_postfix(void* pointer, std::size_t, std::size_t alignment) {
|
||||
(void)alignment;
|
||||
if (pointer != nullptr) ApplicationHeapFree_nid_no_patch(pointer);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -289,6 +289,7 @@ const char* APS5_VABI _ZNKSt8ios_base7failure4whatEv_nid_postfix(const LibcExcep
|
||||
[[noreturn]] void APS5_VABI _ZSt18_Xinvalid_argumentPKc_nid_postfix(const char* message) { LibcException::ThrowMessage(_ZTVSt16invalid_argument_nid_postfix, message); }
|
||||
[[noreturn]] void APS5_VABI _ZSt13_Xrange_errorPKc_nid_postfix(const char* message) { LibcException::ThrowMessage(_ZTVSt11range_error_nid_postfix, message); }
|
||||
[[noreturn]] void APS5_VABI _ZSt19_Xbad_function_callv_nid_postfix() { LibcException::ThrowPlain(_ZTVSt17bad_function_call_nid_postfix); }
|
||||
[[noreturn]] void APS5_VABI _ZNSt8__sce_v219_Xbad_function_callEv_nid_postfix() { LibcException::ThrowPlain(_ZTVSt17bad_function_call_nid_postfix); }
|
||||
[[noreturn]] void APS5_VABI _ZSt13_Xregex_errorNSt15regex_constants10error_typeE_nid_postfix(std::regex_constants::error_type code) {
|
||||
struct RegexObject { LibcException::ExceptionObject base; std::regex_constants::error_type code; };
|
||||
auto* object = static_cast<RegexObject*>(__cxa_allocate_exception_nid_postfix(sizeof(RegexObject)));
|
||||
|
||||
@@ -16,6 +16,7 @@ void* APS5_VABI _ZnamRKSt9nothrow_t_nid_postfix(std::size_t, const void*);
|
||||
void APS5_VABI _ZdlPv_nid_postfix(void*);
|
||||
void APS5_VABI _ZdaPv_nid_postfix(void*);
|
||||
void APS5_VABI _ZdlPvSt11align_val_t_nid_postfix(void*, std::size_t);
|
||||
void APS5_VABI _ZdlPvmSt11align_val_t_nid_postfix(void*, std::size_t, std::size_t);
|
||||
void* ApplicationHeapRealign_nid_no_patch(void*, std::size_t, std::size_t);
|
||||
char* APS5_VABI strdup_nid_postfix(const char*);
|
||||
char* APS5_VABI strndup_nid_postfix(const char*, std::size_t);
|
||||
@@ -200,6 +201,11 @@ int main(int argc, char** argv) {
|
||||
require(frees == 5);
|
||||
_ZdlPvSt11align_val_t_nid_postfix(nullptr, 64);
|
||||
require(frees == 5);
|
||||
pointer = ApplicationHeapAlign_nid_no_patch(64, 37);
|
||||
_ZdlPvmSt11align_val_t_nid_postfix(pointer, 37, 64);
|
||||
require(frees == 6);
|
||||
_ZdlPvmSt11align_val_t_nid_postfix(nullptr, 37, 64);
|
||||
require(frees == 6);
|
||||
fail = true;
|
||||
reject([] { _Znwm_nid_postfix(8); });
|
||||
reject([] { ApplicationHeapAlign_nid_no_patch(4, 64); });
|
||||
|
||||
@@ -18,6 +18,7 @@ extern "C" void __cxa_rethrow_primary_exception_nid_postfix(void*);
|
||||
|
||||
extern "C" [[noreturn]] void _ZSt14_Xout_of_rangePKc_nid_postfix(const char*);
|
||||
extern "C" [[noreturn]] void _ZSt13_Xrange_errorPKc_nid_postfix(const char*);
|
||||
extern "C" [[noreturn]] void _ZNSt8__sce_v219_Xbad_function_callEv_nid_postfix();
|
||||
extern "C" [[noreturn]] void __cxa_bad_cast_nid_postfix();
|
||||
extern "C" [[noreturn]] void _ZNKSt9exception6_RaiseEv_nid_postfix(const void*);
|
||||
extern "C" void* __cxa_vec_new3_nid_postfix(std::size_t, std::size_t, std::size_t, void(*)(void*), void(*)(void*), void*(*)(std::size_t), void(*)(void*, std::size_t));
|
||||
@@ -198,6 +199,10 @@ int main() {
|
||||
try { _ZSt13_Xrange_errorPKc_nid_postfix("not a logic error"); }
|
||||
catch (const std::logic_error&) { std::abort(); }
|
||||
catch (const std::range_error&) {}
|
||||
bool badFunctionCall = false;
|
||||
try { _ZNSt8__sce_v219_Xbad_function_callEv_nid_postfix(); }
|
||||
catch (const std::exception&) { badFunctionCall = true; }
|
||||
if (!badFunctionCall) std::abort();
|
||||
try { __cxa_bad_cast_nid_postfix(); }
|
||||
catch (const std::exception& value) { assert(value.what() != nullptr); }
|
||||
try { _ZNKSt9exception6_RaiseEv_nid_postfix(nullptr); assert(false); }
|
||||
|
||||
Reference in New Issue
Block a user