initial work on relocations

This commit is contained in:
georgemoralis 2023-07-04 18:34:23 +03:00
parent bc2facaee4
commit 6717482662
3 changed files with 26 additions and 0 deletions

View file

@ -78,6 +78,7 @@ Module* Linker::LoadModule(const std::string& elf_name)
LoadModuleToMemory(m);
LoadDynamicInfo(m);
LoadSymbols(m);
Relocate(m);
}
else
{
@ -495,4 +496,25 @@ void Linker::LoadSymbols(Module* m)
}
}
}
}
void Linker::Relocate(Module* m)
{
u32 idx = 0;
for (auto* rel = m->dynamic_info->relocation_table; reinterpret_cast<u08*>(rel) < reinterpret_cast<u08*>(m->dynamic_info->relocation_table) + m->dynamic_info->relocation_table_size; rel++, idx++)
{
auto type = rel->GetType();
auto symbol = rel->GetSymbol();
auto addend = rel->rel_addend;
LOG_INFO_IF(debug_loader, "rel type {:#010x} rel symbol : {:#010x}\n", type, symbol);
}
idx = 0;
for (auto* rel = m->dynamic_info->jmp_relocation_table; reinterpret_cast<u08*>(rel) < reinterpret_cast<u08*>(m->dynamic_info->jmp_relocation_table) + m->dynamic_info->jmp_relocation_table_size; rel++, idx++)
{
auto type = rel->GetType();
auto symbol = rel->GetSymbol();
auto addend = rel->rel_addend;
LOG_INFO_IF(debug_loader, "jmprel type {:#010x} rel symbol : {:#010x}\n", type, symbol);
}
}