From 470881dc112ae172dbbf2488a86f603bce2e7e60 Mon Sep 17 00:00:00 2001 From: Stefanos Kornilios Mitsis Poiitidis Date: Sat, 14 Oct 2023 19:07:38 +0300 Subject: [PATCH] Stubs: Log nids for unknown ones --- src/Core/PS4/Linker.cpp | 6 +++--- src/Core/PS4/Stubs.cpp | 23 ++++++++++++++++------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/Core/PS4/Linker.cpp b/src/Core/PS4/Linker.cpp index fc009261..bbd97cf7 100644 --- a/src/Core/PS4/Linker.cpp +++ b/src/Core/PS4/Linker.cpp @@ -623,11 +623,11 @@ void Linker::Resolve(const std::string& name, int Symtype, Module* m, SymbolReco if (aeronid) { return_info->name = aeronid->name; return_info->virtual_address = GetStub(aeronid->nid); - LOG_ERROR_IF(debug_loader, "Linker: Stub resolved {} as {} (lib: {}, mod: {}) \n", sr.name, return_info->name, library->name, module->name); } else { - return_info->virtual_address = (u64)&UnresolvedStub; - return_info->name = "Unresolved!!!"; + return_info->virtual_address = GetStub(sr.name.c_str()); + return_info->name = "Unknown !!!"; } + LOG_ERROR_IF(debug_loader, "Linker: Stub resolved {} as {} (lib: {}, mod: {}) \n", sr.name, return_info->name, library->name, module->name); } } else diff --git a/src/Core/PS4/Stubs.cpp b/src/Core/PS4/Stubs.cpp index 6b613c63..f1e9602b 100644 --- a/src/Core/PS4/Stubs.cpp +++ b/src/Core/PS4/Stubs.cpp @@ -19,23 +19,27 @@ #define MAX_STUBS 128 u64 UnresolvedStub() { - LOG_ERROR("Unknown Stub: called, returning zero\n"); + LOG_ERROR("Unresolved Stub: called, returning zero\n"); return 0; } static u64 UnknownStub() { - LOG_ERROR("Unknown Stub: called, returning zero\n"); + LOG_ERROR("Stub: Unknown (nid: Unknown) called, returning zero\n"); return 0; } static aerolib::nid_entry* stub_nids[MAX_STUBS]; +static std::string stub_nids_unknown[MAX_STUBS]; template static u64 CommonStub() { auto entry = stub_nids[stub_index]; - - LOG_ERROR("Stub: {} ({}) called, returning zero\n", entry->name, entry->nid); + if (entry) { + LOG_ERROR("Stub: {} (nid: {}) called, returning zero\n", entry->name, entry->nid); + } else { + LOG_ERROR("Stub: Unknown (nid: {}) called, returning zero\n", stub_nids_unknown[stub_index]); + } return 0; } @@ -61,11 +65,16 @@ static u64 (*stub_handlers[MAX_STUBS])() = { }; u64 GetStub(const char* nid) { - auto entry = aerolib::find_by_nid(nid); - if (!entry || UsedStubEntries >= MAX_STUBS) { + if (UsedStubEntries >= MAX_STUBS) { return (u64)&UnknownStub; + } + + auto entry = aerolib::find_by_nid(nid); + if (!entry) { + stub_nids_unknown[UsedStubEntries] = nid; } else { stub_nids[UsedStubEntries] = entry; - return (u64)stub_handlers[UsedStubEntries++]; } + + return (u64)stub_handlers[UsedStubEntries++]; } \ No newline at end of file