[rpcsx-os] linker: hack for lazy bind

This commit is contained in:
DH 2023-10-18 02:22:29 +03:00
parent 8d9869eb7d
commit 437d8e78b8
3 changed files with 18 additions and 6 deletions

View file

@ -87,6 +87,10 @@ static orbis::SysResult doRelocation(orbis::Process *process,
auto &defModule = module->importedModules.at(symbol.moduleIndex);
if (!defModule) {
std::printf(
"'%s' ('%s') uses undefined symbol '%llx' in unloaded module\n",
module->moduleName, module->soName, (unsigned long long)symbol.id);
return std::pair(module, symbol.address);
}

View file

@ -59,12 +59,6 @@ static orbis::ErrorCode dmem_ioctl(orbis::File *file, std::uint64_t request,
return device->queryMaxFreeChunkSize(&args->searchStart, args->searchEnd,
args->alignment, &args->size);
ORBIS_LOG_WARNING("dmem getAvailableSize", device->index, argp, dmemSize);
// args->searchStart = device->nextOffset;
// args->size = dmemSize - device->nextOffset;
return {};
}
case 0xc0288011:

View file

@ -10,6 +10,7 @@
#include <bit>
#include <crypto/sha1.h>
#include <elf.h>
#include <fstream>
#include <map>
#include <orbis/thread/Process.hpp>
#include <sys/mman.h>
@ -959,6 +960,8 @@ Ref<orbis::Module> rx::linker::loadModuleFile(std::string_view path,
if (image[0] != std::byte{'\x7f'} || image[1] != std::byte{'E'} ||
image[2] != std::byte{'L'} || image[3] != std::byte{'F'}) {
image = unself(image.data(), image.size());
std::ofstream("a.out", std::ios::binary).write((const char *)image.data(), image.size());
}
return loadModule(image, thread->tproc);
@ -1051,5 +1054,16 @@ Ref<orbis::Module> rx::linker::loadModuleByName(std::string_view name,
}
}
// HACK: implement lazy bind support
for (auto path : { "/app0/Media/Modules/" }) {
auto filePath = std::string(path);
filePath += name;
filePath += ".prx";
if (auto result = rx::linker::loadModuleFile(filePath.c_str(), thread)) {
return result;
}
}
return {};
}