added DT_INIT.DT_FINI,DT_OS_PLTGOT,DT_OS_SYMTAB,DT_OS_SYMTABSZ

This commit is contained in:
georgemoralis 2023-06-08 19:05:03 +03:00
parent 8932be618b
commit d995a0e286
3 changed files with 45 additions and 5 deletions

View File

@ -180,6 +180,21 @@ void Linker::LoadDynamicInfo(Module* m)
case DT_OS_STRSZ:
m->dynamic_info->str_table_size = dyn->d_un.d_val;
break;
case DT_OS_SYMTAB:
m->dynamic_info->symbol_table = reinterpret_cast<elf_symbol*>(static_cast<uint8_t*>(m->m_dynamic_data) + dyn->d_un.d_ptr);
break;
case DT_OS_SYMTABSZ:
m->dynamic_info->symbol_table_total_size = dyn->d_un.d_val;
break;
case DT_INIT:
m->dynamic_info->init_virtual_addr = dyn->d_un.d_ptr;
break;
case DT_FINI:
m->dynamic_info->fini_virtual_addr = dyn->d_un.d_ptr;
break;
case DT_OS_PLTGOT:
m->dynamic_info->pltgot_virtual_addr = dyn->d_un.d_ptr;
break;
default:
LOG_INFO_IF(debug_loader, "unsupported dynamic tag ..........: {:#018x}\n", dyn->d_tag);
}

View File

@ -23,6 +23,14 @@ struct DynamicModuleInfo
char* str_table = nullptr;
u64 str_table_size = 0;
elf_symbol* symbol_table = nullptr;
u64 symbol_table_total_size = 0;
u64 init_virtual_addr = 0;
u64 fini_virtual_addr = 0;
u64 pltgot_virtual_addr = 0;
};
class Linker

View File

@ -324,11 +324,17 @@ struct elf_program_id_header
u08 digest[32];
};
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;
constexpr s64 DT_NULL = 0;
constexpr s64 DT_INIT = 0x0000000c;
constexpr s64 DT_FINI = 0x0000000d;
constexpr s64 DT_OS_HASH = 0x61000025;
constexpr s64 DT_OS_PLTGOT = 0x61000027;
constexpr s64 DT_OS_HASHSZ = 0x6100003d;
constexpr s64 DT_OS_STRTAB = 0x61000035;
constexpr s64 DT_OS_STRSZ = 0x61000037;
constexpr s64 DT_OS_SYMTAB = 0x61000039;
constexpr s64 DT_OS_SYMTABSZ = 0x6100003f;
struct elf_dynamic
{
@ -339,6 +345,17 @@ struct elf_dynamic
u64 d_ptr;
} d_un;
};
struct elf_symbol
{
u32 st_name;
u08 st_info;
u08 st_other;
u16 st_shndx;
u64 st_value;
u64 st_size;
};
class Elf
{
public: