small fixes , cleanups

This commit is contained in:
whereismyfoodat 2024-03-27 08:41:14 +02:00 committed by georgemoralis
parent 9d4149f006
commit e272b152ed
5 changed files with 9 additions and 20 deletions

View File

@ -89,11 +89,11 @@ void load(const std::filesystem::path& path) {
} }
} }
if (data.contains("LLE")) { if (data.contains("LLE")) {
auto generalResult = toml::expect<toml::value>(data.at("LLE")); auto lleResult = toml::expect<toml::value>(data.at("LLE"));
if (generalResult.is_ok()) { if (lleResult.is_ok()) {
auto general = generalResult.unwrap(); auto lle = lleResult.unwrap();
isLibc = toml::find_or<toml::boolean>(general, "libc", true); isLibc = toml::find_or<toml::boolean>(lle, "libc", true);
} }
} }
} }

View File

@ -27,9 +27,7 @@ namespace Core::Libraries::LibKernel {
static u64 g_stack_chk_guard = 0xDEADBEEF54321ABC; // dummy return static u64 g_stack_chk_guard = 0xDEADBEEF54321ABC; // dummy return
static void* PS4_SYSV_ABI sceKernelGetProcParam() { static void* PS4_SYSV_ABI sceKernelGetProcParam() {
auto* linker = Common::Singleton<Core::Linker>::Instance(); auto* linker = Common::Singleton<Core::Linker>::Instance();
return reinterpret_cast<void*>(linker->GetProcParam()); return reinterpret_cast<void*>(linker->GetProcParam());
} }

View File

@ -84,14 +84,6 @@ Module* Linker::LoadModule(const std::filesystem::path& elf_name) {
return m.get(); return m.get();
} }
Module* Linker::FindModule(u32 id) {
// TODO atm we only have 1 module so we don't need to iterate on vector
if (m_modules.empty()) [[unlikely]] {
return nullptr;
}
return m_modules[0].get();
}
void Linker::LoadModuleToMemory(Module* m) { void Linker::LoadModuleToMemory(Module* m) {
// get elf header, program header // get elf header, program header
const auto elf_header = m->elf.GetElfHeader(); const auto elf_header = m->elf.GetElfHeader();
@ -628,7 +620,7 @@ static PS4_SYSV_ABI int run_module(uint64_t addr, size_t args, const void* argp,
} }
int Linker::StartModule(Module* m, size_t args, const void* argp, module_func_t func) { int Linker::StartModule(Module* m, size_t args, const void* argp, module_func_t func) {
LOG_INFO(Core_Linker, "Module started : {}\n", m->file_name); LOG_INFO(Core_Linker, "Module started : {}", m->file_name);
return run_module(m->dynamic_info.init_virtual_addr + m->base_virtual_addr, args, argp, func); return run_module(m->dynamic_info.init_virtual_addr + m->base_virtual_addr, args, argp, func);
} }

View File

@ -126,7 +126,6 @@ public:
virtual ~Linker(); virtual ~Linker();
Module* LoadModule(const std::filesystem::path& elf_name); Module* LoadModule(const std::filesystem::path& elf_name);
Module* FindModule(u32 id = 0);
void LoadModuleToMemory(Module* m); void LoadModuleToMemory(Module* m);
void LoadDynamicInfo(Module* m); void LoadDynamicInfo(Module* m);
void LoadSymbols(Module* m); void LoadSymbols(Module* m);

View File

@ -9,6 +9,7 @@
#include <cstdio> #include <cstdio>
#include <thread> #include <thread>
#include <common/logging/log.h>
#include <core/hle/libraries/libc/libc.h> #include <core/hle/libraries/libc/libc.h>
#include <core/hle/libraries/libkernel/thread_management.h> #include <core/hle/libraries/libkernel/thread_management.h>
#include "common/config.h" #include "common/config.h"
@ -53,13 +54,12 @@ int main(int argc, char* argv[]) {
// check if there is a libc.prx in sce_module folder // check if there is a libc.prx in sce_module folder
bool found = false; bool found = false;
if (Config::isLleLibc()) { if (Config::isLleLibc()) {
std::filesystem::path sce_module_folder = std::filesystem::path sce_module_folder = p.parent_path() / "sce_module";
std::string(p.parent_path().string() + "\\sce_module"); if (std::filesystem::is_directory(sce_module_folder)) {
if (std::filesystem::exists(sce_module_folder)) {
for (const auto& entry : std::filesystem::directory_iterator(sce_module_folder)) { for (const auto& entry : std::filesystem::directory_iterator(sce_module_folder)) {
if (entry.path().filename() == "libc.prx") { if (entry.path().filename() == "libc.prx") {
found = true; found = true;
printf("%s\n", entry.path().string().c_str()); LOG_INFO(Loader, "Loading {}", entry.path().string().c_str());
linker->LoadModule(entry.path().string().c_str()); linker->LoadModule(entry.path().string().c_str());
} }
} }