diff --git a/src/dwarf/dwarf_dump.c b/src/dwarf/dwarf_dump.c index 32dfa9d9..93438e39 100644 --- a/src/dwarf/dwarf_dump.c +++ b/src/dwarf/dwarf_dump.c @@ -1545,7 +1545,7 @@ dw_print_debug_str_offsets(Arena *arena, String8List *out, String8 indent, DW_In //~ rjf: Dump Entry Point internal String8List -dw_dump_list_from_sections(Arena *arena, DW_Input *input, Arch arch, ExecutableImageKind image_type, DW_DumpSubsetFlags subset_flags) +dw_dump_list_from_sections(Arena *arena, DW_Input *input, Arch arch, DW_DumpSubsetFlags subset_flags) { String8List strings = {0}; String8 indent = str8_lit(" "); @@ -1805,7 +1805,7 @@ dw_dump_list_from_sections(Arena *arena, DW_Input *input, Arch arch, ExecutableI if(attrib_id == 0) { break; } String8 attrib_str = dw_string_from_attrib_kind(temp.arena, DW_Version_Last, DW_Ext_All, attrib_id); String8 form_str = dw_string_from_form_kind(temp.arena, DW_Version_Last, form_id); - rd_printf(" attrib: { offset: 0x%I64x, kind: %S, form_kind: %S }\n", attrib_off, attrib_str, form_str); + dumpf(" attrib: { offset: 0x%I64x, kind: %S, form_kind: %S }\n", attrib_off, attrib_str, form_str); } dumpf("}\n"); temp_end(temp); diff --git a/src/dwarf/dwarf_dump.h b/src/dwarf/dwarf_dump.h index c93faa53..394386f3 100644 --- a/src/dwarf/dwarf_dump.h +++ b/src/dwarf/dwarf_dump.h @@ -78,6 +78,6 @@ internal void dw_print_debug_str_offsets(Arena *arena, String8List *out, String8 //////////////////////////////// //~ rjf: Dump Entry Point -internal String8List dw_dump_list_from_sections(Arena *arena, DW_Input *input, Arch arch, ExecutableImageKind image_type, DW_DumpSubsetFlags subset_flags); +internal String8List dw_dump_list_from_sections(Arena *arena, DW_Input *input, Arch arch, DW_DumpSubsetFlags subset_flags); #endif // DWARF_DUMP_H diff --git a/src/radbin/radbin.c b/src/radbin/radbin.c index fed78b97..1106bb06 100644 --- a/src/radbin/radbin.c +++ b/src/radbin/radbin.c @@ -845,6 +845,7 @@ rb_entry_point(CmdLine *cmdline) #define X(name, name_lower, title) fprintf(stderr, " - " #name_lower "\n"); RDI_DumpSubset_XList #undef X + fprintf(stderr, "\n"); fprintf(stderr, "-------------------------------------------------------------------------------\n\n"); @@ -852,6 +853,7 @@ rb_entry_point(CmdLine *cmdline) #define X(name, name_lower, title) fprintf(stderr, " - " #name_lower "\n"); DW_DumpSubset_XList #undef X + fprintf(stderr, "\n"); } //- rjf: unpack dump subset flags @@ -888,12 +890,46 @@ rb_entry_point(CmdLine *cmdline) } //- rjf: dump input files in order - String8List dump = {0}; for(RB_FileNode *n = input_files.first; n != 0; n = n->next) { RB_File *f = n->v; str8_list_pushf(arena, &output_blobs, "// %S (%S)\n\n", deterministic ? str8_skip_last_slash(f->path) : f->path, f->format ? rb_file_format_display_name_table[f->format] : str8_lit("Unsupported format")); + //- rjf: unpack file parses + Arch arch = Arch_Null; + PE_BinInfo pe = {0}; + ELF_BinInfo elf = {0}; + DW_Input dw = {0}; + { + if(f->format == RB_FileFormat_PE) + { + pe = pe_bin_info_from_data(arena, f->data); + arch = pe.arch; + } + if(f->format == RB_FileFormat_ELF32 || + f->format == RB_FileFormat_ELF64) + { + elf = elf_bin_from_data(f->data); + arch = arch_from_elf_machine(elf.hdr.e_machine); + } + if(f->format_flags & RB_FileFormatFlag_HasDWARF) + { + if(f->format == RB_FileFormat_PE) + { + String8 raw_sections = str8_substr(f->data, pe.section_table_range); + U64 section_count = raw_sections.size / sizeof(COFF_SectionHeader); + COFF_SectionHeader *section_table = (COFF_SectionHeader *)raw_sections.str; + String8 string_table = str8_substr(f->data, pe.string_table_range); + dw = dw_input_from_coff_section_table(arena, f->data, string_table, section_count, section_table); + } + else if(f->format == RB_FileFormat_ELF32 || + f->format == RB_FileFormat_ELF64) + { + dw = dw_input_from_elf_section_table(arena, f->data, &elf); + } + } + } + //- rjf: dump file info based on format switch(f->format) { @@ -964,14 +1000,11 @@ rb_entry_point(CmdLine *cmdline) { str8_list_pushf(arena, &output_blobs, "// %S (%S) (DWARF)\n\n", deterministic ? str8_skip_last_slash(f->path) : f->path, f->format ? rb_file_format_display_name_table[f->format] : str8_lit("Unsupported format")); { - - String8List dump = dw_dump_list_from_sections(); + String8List dump = dw_dump_list_from_sections(arena, &dw, arch, dw_dump_subset_flags); + str8_list_concat_in_place(&output_blobs, &dump); } } } - - //- rjf: join with output - str8_list_concat_in_place(&output_blobs, &dump); }break; }