mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-10-06 16:05:42 +00:00
checkpoint on simplified / stripped down dwarf -> rdi, and dwarf parsing helpers
This commit is contained in:
+17
-14
@@ -125,13 +125,16 @@ internal U64
|
||||
elf_base_addr_from_bin(ELF_Bin *bin)
|
||||
{
|
||||
U64 base_vaddr = 0;
|
||||
for EachIndex(phdr_idx, bin->phdrs.count)
|
||||
if(bin->hdr.e_type != ELF_Type_Dyn)
|
||||
{
|
||||
ELF_Phdr64 *phdr = &bin->phdrs.v[phdr_idx];
|
||||
if(phdr->p_type == ELF_PType_Load &&
|
||||
(base_vaddr == 0 || phdr->p_vaddr < base_vaddr))
|
||||
for EachIndex(phdr_idx, bin->phdrs.count)
|
||||
{
|
||||
base_vaddr = phdr->p_vaddr;
|
||||
ELF_Phdr64 *phdr = &bin->phdrs.v[phdr_idx];
|
||||
if(phdr->p_type == ELF_PType_Load &&
|
||||
(base_vaddr == 0 || phdr->p_vaddr < base_vaddr))
|
||||
{
|
||||
base_vaddr = phdr->p_vaddr;
|
||||
}
|
||||
}
|
||||
}
|
||||
return base_vaddr;
|
||||
@@ -169,42 +172,42 @@ internal ELF_NoteList
|
||||
elf_parse_note(Arena *arena, String8 raw_note, ELF_Class elf_class, ELF_MachineKind e_machine)
|
||||
{
|
||||
ELF_NoteList result = {0};
|
||||
|
||||
|
||||
for (U64 cursor = 0; cursor < raw_note.size; ) {
|
||||
U32 owner_size;
|
||||
U64 owner_size_size = str8_deserial_read_struct(raw_note, cursor, &owner_size);
|
||||
if (owner_size_size == 0) { goto exit; }
|
||||
cursor += owner_size_size;
|
||||
|
||||
|
||||
U32 desc_size;
|
||||
U64 desc_size_size = str8_deserial_read_struct(raw_note, cursor, &desc_size);
|
||||
if (desc_size_size == 0) { goto exit; }
|
||||
cursor += desc_size_size;
|
||||
|
||||
|
||||
ELF_NoteType type;
|
||||
U64 type_size = str8_deserial_read_struct(raw_note, cursor, &type);
|
||||
if (type_size == 0) { goto exit; }
|
||||
cursor += type_size;
|
||||
|
||||
|
||||
if (cursor + owner_size > raw_note.size) { goto exit; }
|
||||
String8 owner = str8_cstring_capped(raw_note.str + cursor, raw_note.str + cursor + owner_size);
|
||||
cursor += owner_size;
|
||||
|
||||
|
||||
if (cursor + desc_size > raw_note.size) { goto exit; }
|
||||
String8 desc = str8_substr(raw_note, r1u64(cursor, cursor + desc_size));
|
||||
cursor += desc_size;
|
||||
cursor = AlignPow2(cursor, 4);
|
||||
|
||||
|
||||
ELF_NoteNode *n = push_array(arena, ELF_NoteNode, 1);
|
||||
n->v.owner = owner;
|
||||
n->v.desc = desc;
|
||||
n->v.type = type;
|
||||
|
||||
|
||||
SLLQueuePush(result.first, result.last, n);
|
||||
result.count += 1;
|
||||
}
|
||||
|
||||
exit:;
|
||||
|
||||
exit:;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user