parsing DT_OS_HASHZ, DT_OS_STRTAB , DT_OS_STRSZ for dynamic loader

This commit is contained in:
georgemoralis 2023-06-08 13:25:24 +03:00
parent 672e2b2d77
commit 8932be618b
3 changed files with 16 additions and 0 deletions

View File

@ -171,6 +171,15 @@ void Linker::LoadDynamicInfo(Module* m)
case DT_OS_HASH:
m->dynamic_info->hash_table = reinterpret_cast<void*>(static_cast<uint8_t*>(m->m_dynamic_data) + dyn->d_un.d_ptr);
break;
case DT_OS_HASHSZ:
m->dynamic_info->hash_table_size = dyn->d_un.d_val;
break;
case DT_OS_STRTAB:
m->dynamic_info->str_table = reinterpret_cast<char*>(static_cast<uint8_t*>(m->m_dynamic_data) + dyn->d_un.d_ptr);
break;
case DT_OS_STRSZ:
m->dynamic_info->str_table_size = dyn->d_un.d_val;
break;
default:
LOG_INFO_IF(debug_loader, "unsupported dynamic tag ..........: {:#018x}\n", dyn->d_tag);
}

View File

@ -19,6 +19,10 @@ struct Module
struct DynamicModuleInfo
{
void* hash_table = nullptr;
u64 hash_table_size = 0;
char* str_table = nullptr;
u64 str_table_size = 0;
};
class Linker

View File

@ -326,6 +326,9 @@ struct elf_program_id_header
constexpr s64 DT_NULL = 0;
constexpr s64 DT_OS_HASH = 0x61000025;
constexpr s64 DT_OS_HASHSZ = 0x6100003d;
constexpr s64 DT_OS_STRTAB = 0x61000035;
constexpr s64 DT_OS_STRSZ = 0x61000037;
struct elf_dynamic
{