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)
|
void Linker::LoadDynamicInfo(Module* m)
|
||||||
{
|
{
|
||||||
m->dynamic_info = new DynamicModuleInfo;
|
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++)
|
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!");
|
LOG_ERROR_IF(debug_loader, "DT_NEEDED str table is not loaded should check!");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DT_OS_NEEDED_MODULE:
|
case DT_SCE_NEEDED_MODULE:
|
||||||
{
|
{
|
||||||
ModuleInfo info{};
|
ModuleInfo info{};
|
||||||
info.value = dyn->d_un.d_val;
|
info.value = dyn->d_un.d_val;
|
||||||
info.name = m->dynamic_info->str_table + info.name_offset;
|
info.name = m->dynamic_info->str_table + info.name_offset;
|
||||||
needed_modules.push_back(info);
|
m->dynamic_info->import_modules.push_back(info);
|
||||||
}
|
}
|
||||||
break;
|
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:
|
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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,21 @@ struct ModuleInfo
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct LibraryInfo
|
||||||
|
{
|
||||||
|
std::string name;
|
||||||
|
union
|
||||||
|
{
|
||||||
|
u64 value;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
u32 name_offset;
|
||||||
|
u16 version;
|
||||||
|
u16 id;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
struct DynamicModuleInfo
|
struct DynamicModuleInfo
|
||||||
{
|
{
|
||||||
void* hash_table = nullptr;
|
void* hash_table = nullptr;
|
||||||
|
@ -67,6 +82,11 @@ struct DynamicModuleInfo
|
||||||
u64 flags = 0;
|
u64 flags = 0;
|
||||||
|
|
||||||
std::vector<const char*> needed;
|
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
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -324,35 +324,41 @@ struct elf_program_id_header
|
||||||
u08 digest[32];
|
u08 digest[32];
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr s64 DT_NULL = 0;
|
constexpr s64 DT_NULL = 0;
|
||||||
constexpr s64 DT_NEEDED = 0x00000001;
|
constexpr s64 DT_NEEDED = 0x00000001;
|
||||||
constexpr s64 DT_RELA = 0x00000007;
|
constexpr s64 DT_RELA = 0x00000007;
|
||||||
constexpr s64 DT_INIT = 0x0000000c;
|
constexpr s64 DT_INIT = 0x0000000c;
|
||||||
constexpr s64 DT_FINI = 0x0000000d;
|
constexpr s64 DT_FINI = 0x0000000d;
|
||||||
constexpr s64 DT_DEBUG = 0x00000015;
|
constexpr s64 DT_DEBUG = 0x00000015;
|
||||||
constexpr s64 DT_TEXTREL = 0x00000016;
|
constexpr s64 DT_TEXTREL = 0x00000016;
|
||||||
constexpr s64 DT_INIT_ARRAY = 0x00000019;
|
constexpr s64 DT_INIT_ARRAY = 0x00000019;
|
||||||
constexpr s64 DT_FINI_ARRAY = 0x0000001a;
|
constexpr s64 DT_FINI_ARRAY = 0x0000001a;
|
||||||
constexpr s64 DT_INIT_ARRAYSZ = 0x0000001b;
|
constexpr s64 DT_INIT_ARRAYSZ = 0x0000001b;
|
||||||
constexpr s64 DT_FINI_ARRAYSZ = 0x0000001c;
|
constexpr s64 DT_FINI_ARRAYSZ = 0x0000001c;
|
||||||
constexpr s64 DT_FLAGS = 0x0000001e;
|
constexpr s64 DT_FLAGS = 0x0000001e;
|
||||||
constexpr s64 DT_PREINIT_ARRAY = 0x00000020;
|
constexpr s64 DT_PREINIT_ARRAY = 0x00000020;
|
||||||
constexpr s64 DT_PREINIT_ARRAYSZ = 0x00000021;
|
constexpr s64 DT_PREINIT_ARRAYSZ = 0x00000021;
|
||||||
constexpr s64 DT_OS_NEEDED_MODULE= 0x6100000f;
|
constexpr s64 DT_SCE_FINGERPRINT = 0x61000007;
|
||||||
constexpr s64 DT_SCE_HASH = 0x61000025;
|
constexpr s64 DT_SCE_ORIGINAL_FILENAME = 0x61000009;
|
||||||
constexpr s64 DT_SCE_PLTGOT = 0x61000027;
|
constexpr s64 DT_SCE_MODULE_INFO = 0x6100000d;
|
||||||
constexpr s64 DT_SCE_JMPREL = 0x61000029;
|
constexpr s64 DT_SCE_NEEDED_MODULE = 0x6100000f;
|
||||||
constexpr s64 DT_SCE_PLTREL = 0x6100002b;
|
constexpr s64 DT_SCE_MODULE_ATTR = 0x61000011;
|
||||||
constexpr s64 DT_SCE_PLTRELSZ = 0x6100002d;
|
constexpr s64 DT_SCE_IMPORT_LIB = 0x61000015;
|
||||||
constexpr s64 DT_SCE_RELA = 0x6100002f;
|
constexpr s64 DT_SCE_IMPORT_LIB_ATTR = 0x61000019;
|
||||||
constexpr s64 DT_SCE_RELASZ = 0x61000031;
|
constexpr s64 DT_SCE_HASH = 0x61000025;
|
||||||
constexpr s64 DT_SCE_RELAENT = 0x61000033;
|
constexpr s64 DT_SCE_PLTGOT = 0x61000027;
|
||||||
constexpr s64 DT_SCE_SYMENT = 0x6100003b;
|
constexpr s64 DT_SCE_JMPREL = 0x61000029;
|
||||||
constexpr s64 DT_SCE_HASHSZ = 0x6100003d;
|
constexpr s64 DT_SCE_PLTREL = 0x6100002b;
|
||||||
constexpr s64 DT_SCE_STRTAB = 0x61000035;
|
constexpr s64 DT_SCE_PLTRELSZ = 0x6100002d;
|
||||||
constexpr s64 DT_SCE_STRSZ = 0x61000037;
|
constexpr s64 DT_SCE_RELA = 0x6100002f;
|
||||||
constexpr s64 DT_SCE_SYMTAB = 0x61000039;
|
constexpr s64 DT_SCE_RELASZ = 0x61000031;
|
||||||
constexpr s64 DT_SCE_SYMTABSZ = 0x6100003f;
|
constexpr s64 DT_SCE_RELAENT = 0x61000033;
|
||||||
|
constexpr s64 DT_SCE_SYMENT = 0x6100003b;
|
||||||
|
constexpr s64 DT_SCE_HASHSZ = 0x6100003d;
|
||||||
|
constexpr s64 DT_SCE_STRTAB = 0x61000035;
|
||||||
|
constexpr s64 DT_SCE_STRSZ = 0x61000037;
|
||||||
|
constexpr s64 DT_SCE_SYMTAB = 0x61000039;
|
||||||
|
constexpr s64 DT_SCE_SYMTABSZ = 0x6100003f;
|
||||||
|
|
||||||
|
|
||||||
struct elf_dynamic
|
struct elf_dynamic
|
||||||
|
|
Loading…
Reference in New Issue