mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-28 00:35:47 +00:00
fix(libkernel): resolve renamed guest exports in the default scope
This commit is contained in:
1 parent
61b8742b6b
commit
2caefdb8ed
2 files changed
+13
No files matched your search
@@ -217,6 +217,8 @@ void* APS5_VABI dlsym_nid_postfix(void* handle, const char* name) {
|
||||
if (auto* result = DefaultScopeSymbol(name)) return result;
|
||||
const auto nid = Nid::ComputeNid(name, "");
|
||||
if (auto* result = DefaultScopeSymbol(nid.c_str())) return result;
|
||||
if (auto* result = DefaultScopeSymbol((std::string(name) + "#guest").c_str())) return result;
|
||||
if (auto* result = DefaultScopeSymbol((nid + "#guest").c_str())) return result;
|
||||
}
|
||||
#endif
|
||||
Error("dlsym: symbol not found in supported module scope");
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "prx/libc/include/general/VabiMacros.hpp"
|
||||
#include <array>
|
||||
#include <cstdlib>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
@@ -122,6 +123,16 @@ int main(int argc, char** argv) {
|
||||
void* hostAdd = ::dlsym(host, "3qcG+yBRS+s");
|
||||
Require(hostAdd != nullptr);
|
||||
Require(dlsym_nid_postfix(nullptr, "GuestModuleAdd") == hostAdd);
|
||||
void* hostMul = ::dlsym(host, "GuestModuleMul#guest");
|
||||
void* hostSub = ::dlsym(host, "BOyBJaKwOa8#guest");
|
||||
Require(hostMul != nullptr && hostSub != nullptr);
|
||||
for (void* scope : std::array<void*, 2>{nullptr, reinterpret_cast<void*>(-2)}) {
|
||||
auto defaultMul = reinterpret_cast<Add>(dlsym_nid_postfix(scope, "GuestModuleMul"));
|
||||
auto defaultSub = reinterpret_cast<Add>(dlsym_nid_postfix(scope, "GuestModuleSub"));
|
||||
Require(reinterpret_cast<void*>(defaultMul) == hostMul);
|
||||
Require(reinterpret_cast<void*>(defaultSub) == hostSub);
|
||||
Require(defaultMul(6, 7) == 42 && defaultSub(50, 8) == 42);
|
||||
}
|
||||
Require(dlsym_nid_postfix(nullptr, "malloc") == nullptr);
|
||||
Require(::dlclose(host) == 0);
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user