DT_SCE_IMPORT_LIB,DT_SCE_ORIGINAL_FILENAME,DT_SCE_MODULE_INFO added. Dynamic loader should be ok for now
This commit is contained in:
parent
6fcfe38e26
commit
0682830e2f
|
@ -163,7 +163,6 @@ void Linker::LoadModuleToMemory(Module* m)
|
|||
void Linker::LoadDynamicInfo(Module* m)
|
||||
{
|
||||
m->dynamic_info = new DynamicModuleInfo;
|
||||
std::vector<ModuleInfo> needed_modules;
|
||||
|
||||
for (const auto* dyn = static_cast<elf_dynamic*>(m->m_dynamic); dyn->d_tag != DT_NULL; dyn++)
|
||||
{
|
||||
|
@ -270,14 +269,47 @@ void Linker::LoadDynamicInfo(Module* m)
|
|||
LOG_ERROR_IF(debug_loader, "DT_NEEDED str table is not loaded should check!");
|
||||
}
|
||||
break;
|
||||
case DT_OS_NEEDED_MODULE:
|
||||
case DT_SCE_NEEDED_MODULE:
|
||||
{
|
||||
ModuleInfo info{};
|
||||
info.value = dyn->d_un.d_val;
|
||||
info.name = m->dynamic_info->str_table + info.name_offset;
|
||||
needed_modules.push_back(info);
|
||||
m->dynamic_info->import_modules.push_back(info);
|
||||
}
|
||||
break;
|
||||
case DT_SCE_IMPORT_LIB:
|
||||
{
|
||||
LibraryInfo info{};
|
||||
info.value = dyn->d_un.d_val;
|
||||
info.name = m->dynamic_info->str_table + info.name_offset;
|
||||
m->dynamic_info->import_libs.push_back(info);
|
||||
}
|
||||
break;
|
||||
case DT_SCE_FINGERPRINT:
|
||||
//The fingerprint is a 24 byte (0x18) size buffer that contains a unique identifier for the given app.
|
||||
//How exactly this is generated isn't known, however it is not necessary to have a valid fingerprint.
|
||||
//While an invalid fingerprint will cause a warning to be printed to the kernel log, the ELF will still load and run.
|
||||
LOG_INFO_IF(debug_loader, "unsupported DT_SCE_FINGERPRINT value = ..........: {:#018x}\n", dyn->d_un.d_val);
|
||||
break;
|
||||
case DT_SCE_IMPORT_LIB_ATTR:
|
||||
//The upper 32-bits should contain the module index multiplied by 0x10000. The lower 32-bits should be a constant 0x9.
|
||||
LOG_INFO_IF(debug_loader, "unsupported DT_SCE_IMPORT_LIB_ATTR value = ..........: {:#018x}\n", dyn->d_un.d_val);
|
||||
break;
|
||||
case DT_SCE_ORIGINAL_FILENAME:
|
||||
m->dynamic_info->filename = m->dynamic_info->str_table + dyn->d_un.d_val;
|
||||
break;
|
||||
case DT_SCE_MODULE_INFO://probably only useable in shared modules
|
||||
{
|
||||
ModuleInfo info{};
|
||||
info.value = dyn->d_un.d_val;
|
||||
info.name = m->dynamic_info->str_table + info.name_offset;
|
||||
m->dynamic_info->export_modules.push_back(info);
|
||||
}
|
||||
break;
|
||||
case DT_SCE_MODULE_ATTR:
|
||||
//TODO?
|
||||
LOG_INFO_IF(debug_loader, "unsupported DT_SCE_MODULE_ATTR value = ..........: {:#018x}\n", dyn->d_un.d_val);
|
||||
break;
|
||||
default:
|
||||
LOG_INFO_IF(debug_loader, "unsupported dynamic tag ..........: {:#018x}\n", dyn->d_tag);
|
||||
}
|
||||
|
|
|
@ -32,6 +32,21 @@ struct ModuleInfo
|
|||
};
|
||||
};
|
||||
|
||||
struct LibraryInfo
|
||||
{
|
||||
std::string name;
|
||||
union
|
||||
{
|
||||
u64 value;
|
||||
struct
|
||||
{
|
||||
u32 name_offset;
|
||||
u16 version;
|
||||
u16 id;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
struct DynamicModuleInfo
|
||||
{
|
||||
void* hash_table = nullptr;
|
||||
|
@ -67,6 +82,11 @@ struct DynamicModuleInfo
|
|||
u64 flags = 0;
|
||||
|
||||
std::vector<const char*> needed;
|
||||
std::vector<ModuleInfo> import_modules;
|
||||
std::vector<ModuleInfo> export_modules;
|
||||
std::vector<LibraryInfo> import_libs;
|
||||
|
||||
std::string filename;//filename with absolute path
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -338,7 +338,13 @@ constexpr s64 DT_FINI_ARRAYSZ = 0x0000001c;
|
|||
constexpr s64 DT_FLAGS = 0x0000001e;
|
||||
constexpr s64 DT_PREINIT_ARRAY = 0x00000020;
|
||||
constexpr s64 DT_PREINIT_ARRAYSZ = 0x00000021;
|
||||
constexpr s64 DT_OS_NEEDED_MODULE= 0x6100000f;
|
||||
constexpr s64 DT_SCE_FINGERPRINT = 0x61000007;
|
||||
constexpr s64 DT_SCE_ORIGINAL_FILENAME = 0x61000009;
|
||||
constexpr s64 DT_SCE_MODULE_INFO = 0x6100000d;
|
||||
constexpr s64 DT_SCE_NEEDED_MODULE = 0x6100000f;
|
||||
constexpr s64 DT_SCE_MODULE_ATTR = 0x61000011;
|
||||
constexpr s64 DT_SCE_IMPORT_LIB = 0x61000015;
|
||||
constexpr s64 DT_SCE_IMPORT_LIB_ATTR = 0x61000019;
|
||||
constexpr s64 DT_SCE_HASH = 0x61000025;
|
||||
constexpr s64 DT_SCE_PLTGOT = 0x61000027;
|
||||
constexpr s64 DT_SCE_JMPREL = 0x61000029;
|
||||
|
|
Loading…
Reference in New Issue