mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2024-12-29 11:06:07 +00:00
Initial symbol loading
This commit is contained in:
parent
d0931704ff
commit
cfa68f2f40
|
@ -48,6 +48,7 @@ Module* Linker::LoadModule(const std::string& elf_name)
|
||||||
{
|
{
|
||||||
LoadModuleToMemory(m);
|
LoadModuleToMemory(m);
|
||||||
LoadDynamicInfo(m);
|
LoadDynamicInfo(m);
|
||||||
|
LoadSymbols(m);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -310,9 +311,33 @@ void Linker::LoadDynamicInfo(Module* m)
|
||||||
//TODO?
|
//TODO?
|
||||||
LOG_INFO_IF(debug_loader, "unsupported DT_SCE_MODULE_ATTR value = ..........: {:#018x}\n", dyn->d_un.d_val);
|
LOG_INFO_IF(debug_loader, "unsupported DT_SCE_MODULE_ATTR value = ..........: {:#018x}\n", dyn->d_un.d_val);
|
||||||
break;
|
break;
|
||||||
|
case DT_SCE_EXPORT_LIB:
|
||||||
|
{
|
||||||
|
LibraryInfo info{};
|
||||||
|
info.value = dyn->d_un.d_val;
|
||||||
|
info.name = m->dynamic_info->str_table + info.name_offset;
|
||||||
|
m->dynamic_info->export_libs.push_back(info);
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
LOG_INFO_IF(debug_loader, "unsupported dynamic tag ..........: {:#018x}\n", dyn->d_tag);
|
LOG_INFO_IF(debug_loader, "unsupported dynamic tag ..........: {:#018x}\n", dyn->d_tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Linker::LoadSymbols(Module* m)
|
||||||
|
{
|
||||||
|
if (m->dynamic_info->symbol_table == nullptr || m->dynamic_info->str_table == nullptr || m->dynamic_info->symbol_table_total_size==0)
|
||||||
|
{
|
||||||
|
LOG_INFO_IF(debug_loader, "Symbol table not found!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (auto* sym = m->dynamic_info->symbol_table;
|
||||||
|
reinterpret_cast<uint8_t*>(sym) < reinterpret_cast<uint8_t*>(m->dynamic_info->symbol_table) + m->dynamic_info->symbol_table_total_size;
|
||||||
|
sym++)
|
||||||
|
{
|
||||||
|
std::string id = std::string(m->dynamic_info->str_table + sym->st_name);
|
||||||
|
LOG_INFO_IF(debug_loader, "symbol {}\n", id.c_str());
|
||||||
|
}
|
||||||
|
}
|
|
@ -85,6 +85,7 @@ struct DynamicModuleInfo
|
||||||
std::vector<ModuleInfo> import_modules;
|
std::vector<ModuleInfo> import_modules;
|
||||||
std::vector<ModuleInfo> export_modules;
|
std::vector<ModuleInfo> export_modules;
|
||||||
std::vector<LibraryInfo> import_libs;
|
std::vector<LibraryInfo> import_libs;
|
||||||
|
std::vector<LibraryInfo> export_libs;
|
||||||
|
|
||||||
std::string filename;//filename with absolute path
|
std::string filename;//filename with absolute path
|
||||||
|
|
||||||
|
@ -99,7 +100,8 @@ public:
|
||||||
Module* LoadModule(const std::string& elf_name);
|
Module* LoadModule(const std::string& elf_name);
|
||||||
Module* FindModule(/*u32 id*/);
|
Module* FindModule(/*u32 id*/);
|
||||||
void LoadModuleToMemory(Module* m);
|
void LoadModuleToMemory(Module* m);
|
||||||
void LoadDynamicInfo(Module* program);
|
void LoadDynamicInfo(Module* m);
|
||||||
|
void LoadSymbols(Module* m);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<Module*> m_modules;
|
std::vector<Module*> m_modules;
|
||||||
|
|
|
@ -343,6 +343,7 @@ constexpr s64 DT_SCE_ORIGINAL_FILENAME = 0x61000009;
|
||||||
constexpr s64 DT_SCE_MODULE_INFO = 0x6100000d;
|
constexpr s64 DT_SCE_MODULE_INFO = 0x6100000d;
|
||||||
constexpr s64 DT_SCE_NEEDED_MODULE = 0x6100000f;
|
constexpr s64 DT_SCE_NEEDED_MODULE = 0x6100000f;
|
||||||
constexpr s64 DT_SCE_MODULE_ATTR = 0x61000011;
|
constexpr s64 DT_SCE_MODULE_ATTR = 0x61000011;
|
||||||
|
constexpr s64 DT_SCE_EXPORT_LIB = 0x61000013;
|
||||||
constexpr s64 DT_SCE_IMPORT_LIB = 0x61000015;
|
constexpr s64 DT_SCE_IMPORT_LIB = 0x61000015;
|
||||||
constexpr s64 DT_SCE_IMPORT_LIB_ATTR = 0x61000019;
|
constexpr s64 DT_SCE_IMPORT_LIB_ATTR = 0x61000019;
|
||||||
constexpr s64 DT_SCE_HASH = 0x61000025;
|
constexpr s64 DT_SCE_HASH = 0x61000025;
|
||||||
|
|
Loading…
Reference in a new issue