Added DT_OS_NEEDED_MODULE

This commit is contained in:
georgemoralis 2023-06-11 15:35:04 +03:00
parent 6e0cf378d2
commit 6fcfe38e26
3 changed files with 32 additions and 6 deletions

View File

@ -163,6 +163,7 @@ 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++)
{
@ -221,22 +222,22 @@ void Linker::LoadDynamicInfo(Module* m)
LOG_WARN_IF(debug_loader, "DT_SCE_RELAENT is NOT 0x18 should check!");
}
break;
case DT_INIT_ARRAY:
case DT_INIT_ARRAY:// Address of the array of pointers to initialization functions
m->dynamic_info->init_array_virtual_addr = dyn->d_un.d_ptr;
break;
case DT_FINI_ARRAY:
case DT_FINI_ARRAY: // Address of the array of pointers to termination functions
m->dynamic_info->fini_array_virtual_addr = dyn->d_un.d_ptr;
break;
case DT_INIT_ARRAYSZ:
case DT_INIT_ARRAYSZ://Size in bytes of the array of initialization functions
m->dynamic_info->init_array_size = dyn->d_un.d_val;
break;
case DT_FINI_ARRAYSZ:
case DT_FINI_ARRAYSZ://Size in bytes of the array of terminationfunctions
m->dynamic_info->fini_array_size = dyn->d_un.d_val;
break;
case DT_PREINIT_ARRAY:
case DT_PREINIT_ARRAY://Address of the array of pointers to pre - initialization functions
m->dynamic_info->preinit_array_virtual_addr = dyn->d_un.d_ptr;
break;
case DT_PREINIT_ARRAYSZ:
case DT_PREINIT_ARRAYSZ://Size in bytes of the array of pre - initialization functions
m->dynamic_info->preinit_array_size = dyn->d_un.d_val;
break;
case DT_SCE_SYMENT: //The size of symbol table entries
@ -269,6 +270,14 @@ 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:
{
ModuleInfo info{};
info.value = dyn->d_un.d_val;
info.name = m->dynamic_info->str_table + info.name_offset;
needed_modules.push_back(info);
}
break;
default:
LOG_INFO_IF(debug_loader, "unsupported dynamic tag ..........: {:#018x}\n", dyn->d_tag);
}

View File

@ -16,6 +16,22 @@ struct Module
DynamicModuleInfo* dynamic_info = nullptr;
};
struct ModuleInfo
{
std::string name;
union
{
u64 value;
struct
{
u32 name_offset;
u08 version_minor;
u08 version_major;
u16 id;
};
};
};
struct DynamicModuleInfo
{
void* hash_table = nullptr;

View File

@ -338,6 +338,7 @@ 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_HASH = 0x61000025;
constexpr s64 DT_SCE_PLTGOT = 0x61000027;
constexpr s64 DT_SCE_JMPREL = 0x61000029;