function to start modules
This commit is contained in:
parent
bc7228fcb2
commit
1a7f5f7b31
|
@ -604,6 +604,27 @@ void Linker::Resolve(const std::string& name, Loader::SymbolType sym_type, Modul
|
||||||
|
|
||||||
using exit_func_t = PS4_SYSV_ABI void (*)();
|
using exit_func_t = PS4_SYSV_ABI void (*)();
|
||||||
using entry_func_t = PS4_SYSV_ABI void (*)(EntryParams* params, exit_func_t atexit_func);
|
using entry_func_t = PS4_SYSV_ABI void (*)(EntryParams* params, exit_func_t atexit_func);
|
||||||
|
using module_ini_func_t = PS4_SYSV_ABI int (*)(size_t args, const void* argp, module_func_t func);
|
||||||
|
|
||||||
|
static PS4_SYSV_ABI int run_module(uint64_t addr, size_t args, const void* argp,
|
||||||
|
module_func_t func) {
|
||||||
|
return reinterpret_cast<module_ini_func_t>(addr)(args, argp, 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);
|
||||||
|
return run_module(m->dynamic_info.init_virtual_addr + m->base_virtual_addr, args, argp, func);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Linker::StartAllModules() {
|
||||||
|
std::scoped_lock lock{m_mutex};
|
||||||
|
|
||||||
|
for (auto& m : m_modules) {
|
||||||
|
if (m->elf.IsSharedLib()) {
|
||||||
|
StartModule(m.get(), 0, nullptr, nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static PS4_SYSV_ABI void ProgramExitFunc() {
|
static PS4_SYSV_ABI void ProgramExitFunc() {
|
||||||
fmt::print("exit function called\n");
|
fmt::print("exit function called\n");
|
||||||
|
@ -638,15 +659,20 @@ void Linker::Execute() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::Libraries::LibKernel::pthreadInitSelfMainThread();
|
Core::Libraries::LibKernel::pthreadInitSelfMainThread();
|
||||||
|
//relocate all modules
|
||||||
for (const auto& m : m_modules) {
|
for (const auto& m : m_modules) {
|
||||||
Relocate(m.get());
|
Relocate(m.get());
|
||||||
}
|
}
|
||||||
|
StartAllModules();
|
||||||
EntryParams p{};
|
EntryParams p{};
|
||||||
p.argc = 1;
|
p.argc = 1;
|
||||||
p.argv[0] = "eboot.bin"; // hmm should be ok?
|
p.argv[0] = "eboot.bin"; // hmm should be ok?
|
||||||
|
|
||||||
const auto& module = m_modules.at(0);
|
for (auto& m : m_modules) {
|
||||||
RunMainEntry(module->elf.GetElfEntry() + module->base_virtual_addr, &p, ProgramExitFunc);
|
if (!m->elf.IsSharedLib()) {
|
||||||
|
RunMainEntry(m->elf.GetElfEntry() + m->base_virtual_addr, &p, ProgramExitFunc);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Linker::DebugDump() {
|
void Linker::DebugDump() {
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#include "core/loader/symbols_resolver.h"
|
#include "core/loader/symbols_resolver.h"
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
using module_func_t = int (*)(size_t args, const void* argp);
|
||||||
struct DynamicModuleInfo;
|
struct DynamicModuleInfo;
|
||||||
class Linker;
|
class Linker;
|
||||||
|
|
||||||
|
@ -142,6 +142,8 @@ private:
|
||||||
const ModuleInfo* FindModule(const Module& m, const std::string& id);
|
const ModuleInfo* FindModule(const Module& m, const std::string& id);
|
||||||
const LibraryInfo* FindLibrary(const Module& program, const std::string& id);
|
const LibraryInfo* FindLibrary(const Module& program, const std::string& id);
|
||||||
Module* FindExportedModule(const ModuleInfo& m, const LibraryInfo& l);
|
Module* FindExportedModule(const ModuleInfo& m, const LibraryInfo& l);
|
||||||
|
int StartModule(Module* m, size_t args, const void* argp, module_func_t func);
|
||||||
|
void StartAllModules();
|
||||||
|
|
||||||
std::vector<std::unique_ptr<Module>> m_modules;
|
std::vector<std::unique_ptr<Module>> m_modules;
|
||||||
Loader::SymbolsResolver m_hle_symbols{};
|
Loader::SymbolsResolver m_hle_symbols{};
|
||||||
|
|
Loading…
Reference in New Issue