segments loading (only elf atm)

This commit is contained in:
georgemoralis 2023-05-25 18:08:10 +03:00
parent 1ad70366c6
commit cc471a8535
3 changed files with 23 additions and 0 deletions

View file

@ -511,3 +511,21 @@ std::string Elf::ElfPHeaderStr(u16 no)
header += fmt::format("p_align ...: {:#018x}\n", (m_elf_phdr + no)->p_align);
return header;
}
void Elf::LoadSegment(u64 virtual_addr, u64 file_offset, u64 size)
{
if (m_self!=nullptr)
{
//it is self file //TODO
__debugbreak();
}
else
{
//it's elf file
m_f->Seek(file_offset, fsSeekMode::fsSeekSet);
m_f->Read(reinterpret_cast<void*>(static_cast<uintptr_t>(virtual_addr)), size);
}
}
u64 Elf::GetElfEntry()
{
return m_elf_header->e_entry;
}