Skip to content

Commit

Permalink
[rpcsx-os] linker: hack for lazy bind
Browse files Browse the repository at this point in the history
  • Loading branch information
DHrpcs3 committed Oct 17, 2023
1 parent 8d9869e commit 437d8e7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
4 changes: 4 additions & 0 deletions orbis-kernel/src/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
6 changes: 0 additions & 6 deletions rpcsx-os/iodev/dmem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 14 additions & 0 deletions rpcsx-os/linker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 {};
}

0 comments on commit 437d8e7

Please sign in to comment.