mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-01-02 14:50:05 +01:00
[rpcsx-os] linker: avoid loading library twice
This commit is contained in:
parent
8daa57cffe
commit
a32c0afcf5
|
|
@ -32,6 +32,10 @@ loadPrx(orbis::Thread *thread, std::string_view name, bool relocate,
|
|||
std::map<std::string, Module *, std::less<>> &loadedObjects,
|
||||
std::map<std::string, Module *, std::less<>> &loadedModules,
|
||||
std::string_view expectedName) {
|
||||
if (auto it = loadedObjects.find(expectedName); it != loadedObjects.end()) {
|
||||
return {{}, it->second};
|
||||
}
|
||||
|
||||
if (auto it = loadedObjects.find(name); it != loadedObjects.end()) {
|
||||
return {{}, it->second};
|
||||
}
|
||||
|
|
@ -106,7 +110,7 @@ loadPrx(orbis::Thread *thread, std::string_view name, bool relocate,
|
|||
}
|
||||
|
||||
static std::pair<SysResult, Ref<Module>>
|
||||
loadPrx(orbis::Thread *thread, std::string_view name, bool relocate) {
|
||||
loadPrx(orbis::Thread *thread, std::string_view path, bool relocate) {
|
||||
std::map<std::string, Module *, std::less<>> loadedObjects;
|
||||
std::map<std::string, Module *, std::less<>> loadedModules;
|
||||
|
||||
|
|
@ -115,8 +119,21 @@ loadPrx(orbis::Thread *thread, std::string_view name, bool relocate) {
|
|||
loadedModules[module->moduleName] = module;
|
||||
}
|
||||
|
||||
return loadPrx(thread, name, relocate, loadedObjects, loadedModules, {});
|
||||
};
|
||||
std::string expectedName;
|
||||
if (auto sep = path.rfind('/'); sep != std::string_view::npos) {
|
||||
auto tmpExpectedName = path.substr(sep + 1);
|
||||
|
||||
if (tmpExpectedName.ends_with(".sprx")) {
|
||||
tmpExpectedName.remove_suffix(5);
|
||||
}
|
||||
|
||||
expectedName += tmpExpectedName;
|
||||
expectedName += ".prx";
|
||||
}
|
||||
|
||||
return loadPrx(thread, path, relocate, loadedObjects, loadedModules,
|
||||
expectedName);
|
||||
}
|
||||
|
||||
orbis::SysResult mmap(orbis::Thread *thread, orbis::caddr_t addr,
|
||||
orbis::size_t len, orbis::sint prot, orbis::sint flags,
|
||||
|
|
|
|||
Loading…
Reference in a new issue