mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2024-12-28 10:36:06 +00:00
initial dynamic loader , parsing DT_HASH atm
This commit is contained in:
parent
e02c0a9398
commit
672e2b2d77
|
@ -47,6 +47,7 @@ Module* Linker::LoadModule(const std::string& elf_name)
|
|||
if (m->elf->isElfFile())
|
||||
{
|
||||
LoadModuleToMemory(m);
|
||||
LoadDynamicInfo(m);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -157,4 +158,22 @@ void Linker::LoadModuleToMemory(Module* m)
|
|||
offset += instruction.info.length;
|
||||
runtime_address += instruction.info.length;
|
||||
}
|
||||
}
|
||||
|
||||
void Linker::LoadDynamicInfo(Module* m)
|
||||
{
|
||||
m->dynamic_info = new DynamicModuleInfo;
|
||||
|
||||
for (const auto* dyn = static_cast<elf_dynamic*>(m->m_dynamic); dyn->d_tag != DT_NULL; dyn++)
|
||||
{
|
||||
switch (dyn->d_tag)
|
||||
{
|
||||
case DT_OS_HASH:
|
||||
m->dynamic_info->hash_table = reinterpret_cast<void*>(static_cast<uint8_t*>(m->m_dynamic_data) + dyn->d_un.d_ptr);
|
||||
break;
|
||||
default:
|
||||
LOG_INFO_IF(debug_loader, "unsupported dynamic tag ..........: {:#018x}\n", dyn->d_tag);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -2,6 +2,8 @@
|
|||
#include "../../Loader/Elf.h"
|
||||
#include <vector>
|
||||
|
||||
struct DynamicModuleInfo;
|
||||
|
||||
/*this struct keeps neccesary info about loaded modules.Main executeable is included too as well*/
|
||||
struct Module
|
||||
{
|
||||
|
@ -11,6 +13,12 @@ struct Module
|
|||
|
||||
void* m_dynamic = nullptr;
|
||||
void* m_dynamic_data = nullptr;
|
||||
DynamicModuleInfo* dynamic_info = nullptr;
|
||||
};
|
||||
|
||||
struct DynamicModuleInfo
|
||||
{
|
||||
void* hash_table = nullptr;
|
||||
};
|
||||
|
||||
class Linker
|
||||
|
@ -22,6 +30,7 @@ public:
|
|||
Module* LoadModule(const std::string& elf_name);
|
||||
Module* FindModule(/*u32 id*/);
|
||||
void LoadModuleToMemory(Module* m);
|
||||
void LoadDynamicInfo(Module* program);
|
||||
|
||||
private:
|
||||
std::vector<Module*> m_modules;
|
||||
|
|
|
@ -323,6 +323,19 @@ struct elf_program_id_header
|
|||
u64 firmver;
|
||||
u08 digest[32];
|
||||
};
|
||||
|
||||
constexpr s64 DT_NULL = 0;
|
||||
constexpr s64 DT_OS_HASH = 0x61000025;
|
||||
|
||||
struct elf_dynamic
|
||||
{
|
||||
s64 d_tag;
|
||||
union
|
||||
{
|
||||
u64 d_val;
|
||||
u64 d_ptr;
|
||||
} d_un;
|
||||
};
|
||||
class Elf
|
||||
{
|
||||
public:
|
||||
|
|
Loading…
Reference in a new issue