mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-07-31 11:20:03 +00:00
went over COFF string table and changed the parser code accept to String8
This commit is contained in:
+6
-5
@@ -208,11 +208,12 @@ rc_context_from_cmd_line(Arena *arena, CmdLine *cmdl)
|
||||
}
|
||||
|
||||
if (driver == RC_Driver_Null || driver == RC_Driver_Dwarf) {
|
||||
PE_BinInfo pe = pe_bin_info_from_data(scratch.arena, pe_data);
|
||||
String8 raw_sections = str8_substr(pe_data, rng_1u64(pe.section_array_off, pe.section_array_off+sizeof(COFF_SectionHeader)*pe.section_count));
|
||||
U64 section_count = raw_sections.size / sizeof(COFF_SectionHeader);
|
||||
COFF_SectionHeader *section_array = (COFF_SectionHeader *)raw_sections.str;
|
||||
if (dw_is_dwarf_present_coff_section_table(pe_data, pe.string_table_off, section_count, section_array)) {
|
||||
PE_BinInfo pe = pe_bin_info_from_data(scratch.arena, pe_data);
|
||||
String8 raw_section_table = str8_substr(pe_data, pe.section_table_range);
|
||||
String8 string_table = str8_substr(pe_data, pe.string_table_range);
|
||||
U64 section_count = raw_section_table.size / sizeof(COFF_SectionHeader);
|
||||
COFF_SectionHeader *section_table = (COFF_SectionHeader *)raw_section_table.str;
|
||||
if (dw_is_dwarf_present_coff_section_table(pe_data, string_table, section_count, section_table)) {
|
||||
driver = RC_Driver_Dwarf;
|
||||
debug_name = pe_name;
|
||||
debug_data = pe_data;
|
||||
|
||||
@@ -56,7 +56,7 @@ c2r_rdi_binary_section_flags_from_coff_section_flags(COFF_SectionFlags flags)
|
||||
}
|
||||
|
||||
internal RDIM_BinarySectionList
|
||||
c2r_rdi_binary_sections_from_coff_sections(Arena *arena, String8 image_data, U64 string_table_off, U64 sectab_count, COFF_SectionHeader *sectab)
|
||||
c2r_rdi_binary_sections_from_coff_sections(Arena *arena, String8 image_data, String8 string_table, U64 sectab_count, COFF_SectionHeader *sectab)
|
||||
{
|
||||
ProfBeginFunction();
|
||||
|
||||
@@ -66,7 +66,7 @@ c2r_rdi_binary_sections_from_coff_sections(Arena *arena, String8 image_data, U64
|
||||
COFF_SectionHeader *coff_sec = §ab[isec];
|
||||
RDIM_BinarySection *sec = rdim_binary_section_list_push(arena, &binary_sections);
|
||||
|
||||
sec->name = coff_name_from_section_header(image_data, coff_sec, string_table_off);
|
||||
sec->name = coff_name_from_section_header(string_table, coff_sec);
|
||||
sec->flags = c2r_rdi_binary_section_flags_from_coff_section_flags(coff_sec->flags);
|
||||
sec->voff_first = coff_sec->voff;
|
||||
sec->voff_opl = coff_sec->voff + coff_sec->vsize;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
internal RDI_Arch c2r_rdi_arch_from_coff_machine(COFF_MachineType machine);
|
||||
internal RDI_BinarySectionFlags c2r_rdi_binary_section_flags_from_coff_section_flags(COFF_SectionFlags flags);
|
||||
internal RDIM_BinarySectionList c2r_rdi_binary_sections_from_coff_sections(Arena *arena, String8 image_data, U64 string_table_off, U64 sectab_count, COFF_SectionHeader *sectab);
|
||||
internal RDIM_BinarySectionList c2r_rdi_binary_sections_from_coff_sections(Arena *arena, String8 image_data, String8 string_table, U64 sectab_count, COFF_SectionHeader *sectab);
|
||||
|
||||
#endif // RADCON_COFF_H
|
||||
|
||||
|
||||
@@ -1101,15 +1101,16 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in)
|
||||
image_base = pe.image_base;
|
||||
|
||||
// get image sections
|
||||
String8 raw_sections = str8_substr(in->image_data, rng_1u64(pe.section_array_off, pe.section_array_off+sizeof(COFF_SectionHeader)*pe.section_count));
|
||||
String8 raw_sections = str8_substr(in->image_data, pe.section_table_range);
|
||||
U64 section_count = raw_sections.size / sizeof(COFF_SectionHeader);
|
||||
COFF_SectionHeader *section_array = (COFF_SectionHeader *)raw_sections.str;
|
||||
COFF_SectionHeader *section_table = (COFF_SectionHeader *)raw_sections.str;
|
||||
|
||||
// convert sections
|
||||
binary_sections = c2r_rdi_binary_sections_from_coff_sections(arena, in->image_data, pe.string_table_off, section_count, section_array);
|
||||
String8 string_table = str8_substr(in->image_data, pe.string_table_range);
|
||||
binary_sections = c2r_rdi_binary_sections_from_coff_sections(arena, in->image_data, string_table, section_count, section_table);
|
||||
|
||||
// make DWARF input
|
||||
input = dw_input_from_coff_section_table(scratch.arena, in->image_data, pe.string_table_off, section_count, section_array);
|
||||
input = dw_input_from_coff_section_table(scratch.arena, in->image_data, string_table, section_count, section_table);
|
||||
} else if (in->image == Image_Elf32 || in->image == Image_Elf64) {
|
||||
ELF_BinInfo elf = elf_bin_from_data(in->debug_data);
|
||||
|
||||
|
||||
@@ -2366,7 +2366,7 @@ p2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in)
|
||||
//////////////////////////////////////////////////////////////
|
||||
//- rjf: build binary sections list
|
||||
//
|
||||
RDIM_BinarySectionList binary_sections = c2r_rdi_binary_sections_from_coff_sections(arena, str8_zero(), 0, coff_sections.count, coff_sections.v);
|
||||
RDIM_BinarySectionList binary_sections = c2r_rdi_binary_sections_from_coff_sections(arena, str8_zero(), str8_zero(), coff_sections.count, coff_sections.v);
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//- rjf: produce top-level-info
|
||||
|
||||
Reference in New Issue
Block a user