start dwarf -> rdi cleanup; eliminate some assertions-as-validation, remove incorrect assumption that line info addresses are vaddrs (they seem to be voffs)

This commit is contained in:
Ryan Fleury
2025-11-10 15:06:52 -08:00
parent efb4731ace
commit f396b2eaa3
11 changed files with 1433 additions and 1250 deletions
+29 -2
View File
@@ -1,9 +1,36 @@
// Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
internal RDIM_BinarySectionList
e2r_rdi_binary_sections_from_elf_section_table(Arena *arena, ELF_Shdr64Array shdrs)
internal RDI_BinarySectionFlags
e2r_rdi_binary_section_flags_from_elf(ELF_SectionFlags f)
{
RDI_BinarySectionFlags result = RDI_BinarySectionFlag_Read;
if(f & ELF_Shf_Write)
{
result |= RDI_BinarySectionFlag_Write;
}
if(f & ELF_Shf_ExecInstr)
{
result |= RDI_BinarySectionFlag_Execute;
}
return result;
}
internal RDIM_BinarySectionList
e2r_rdi_binary_sections_from_elf_section_table(Arena *arena, String8 data, ELF_Bin *bin, ELF_Shdr64Array shdrs)
{
RDIM_BinarySectionList result = {0};
U64 base_vaddr = elf_base_addr_from_bin(bin);
for EachIndex(idx, shdrs.count)
{
ELF_Shdr64 *src = &shdrs.v[idx];
RDIM_BinarySection *dst = rdim_binary_section_list_push(arena, &result);
dst->name = elf_name_from_shdr64(data, bin, src);
dst->flags = e2r_rdi_binary_section_flags_from_elf(src->sh_flags);
dst->voff_first = src->sh_addr - base_vaddr;
dst->voff_opl = dst->voff_first + src->sh_size;
dst->foff_first = src->sh_offset;
dst->foff_opl = dst->foff_first + src->sh_size;
}
return result;
}
+2 -1
View File
@@ -4,6 +4,7 @@
#ifndef RDI_FROM_ELF_H
#define RDI_FROM_ELF_H
internal RDIM_BinarySectionList e2r_rdi_binary_sections_from_elf_section_table(Arena *arena, ELF_Shdr64Array shdrs);
internal RDI_BinarySectionFlags e2r_rdi_binary_section_flags_from_elf(ELF_SectionFlags f);
internal RDIM_BinarySectionList e2r_rdi_binary_sections_from_elf_section_table(Arena *arena, String8 data, ELF_Bin *bin, ELF_Shdr64Array shdrs);
#endif // RDI_FROM_ELF_H