From 6fcfe38e26f2d6ed185f421ba93bcd9d1e691281 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Sun, 11 Jun 2023 15:35:04 +0300 Subject: [PATCH] Added DT_OS_NEEDED_MODULE --- src/Core/PS4/Linker.cpp | 21 +++++++++++++++------ src/Core/PS4/Linker.h | 16 ++++++++++++++++ src/Loader/Elf.h | 1 + 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/Core/PS4/Linker.cpp b/src/Core/PS4/Linker.cpp index b25e8c4a..03bd89d6 100644 --- a/src/Core/PS4/Linker.cpp +++ b/src/Core/PS4/Linker.cpp @@ -163,6 +163,7 @@ void Linker::LoadModuleToMemory(Module* m) void Linker::LoadDynamicInfo(Module* m) { m->dynamic_info = new DynamicModuleInfo; + std::vector needed_modules; for (const auto* dyn = static_cast(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); } diff --git a/src/Core/PS4/Linker.h b/src/Core/PS4/Linker.h index 76aa8aea..ac8c9e93 100644 --- a/src/Core/PS4/Linker.h +++ b/src/Core/PS4/Linker.h @@ -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; diff --git a/src/Loader/Elf.h b/src/Loader/Elf.h index 97a92cf8..de7d61d5 100644 --- a/src/Loader/Elf.h +++ b/src/Loader/Elf.h @@ -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;