Skip to content
Snippets Groups Projects
Commit 5e3836b0 authored by Avi Kivity's avatar Avi Kivity
Browse files

elf: add elf_memory_image

Used to encapsulate an already-loaded image, for providing symbols to later
objects.
parent 45b49b0d
No related branches found
No related tags found
No related merge requests found
...@@ -24,6 +24,15 @@ namespace elf { ...@@ -24,6 +24,15 @@ namespace elf {
load_program_headers(); load_program_headers();
} }
elf_memory_image::elf_memory_image(void* base)
{
set_base(base);
_ehdr = *static_cast<Elf64_Ehdr*>(base);
auto p = static_cast<Elf64_Phdr*>(base + _ehdr.e_phoff);
assert(_ehdr.e_phentsize == sizeof(*p));
_phdrs.assign(p, p + _ehdr.e_phnum);
}
void elf_file::load_elf_header() void elf_file::load_elf_header()
{ {
_f.read(&_ehdr, 0, sizeof(_ehdr)); _f.read(&_ehdr, 0, sizeof(_ehdr));
......
...@@ -233,6 +233,11 @@ namespace elf { ...@@ -233,6 +233,11 @@ namespace elf {
::file& _f; ::file& _f;
}; };
class elf_memory_image : public elf_object {
public:
explicit elf_memory_image(void* base);
};
} }
void load_elf(file& f, void* addr = reinterpret_cast<void*>(64 << 20)); void load_elf(file& f, void* addr = reinterpret_cast<void*>(64 << 20));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment