From a0ace3561f25e3bfe38075579a94eb5efd45e85f Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Tue, 12 May 2026 19:58:15 -0700 Subject: [PATCH] eliminate d2r usage (1) from radbin --- src/radbin/radbin.c | 118 +++++++------------------------------------- 1 file changed, 17 insertions(+), 101 deletions(-) diff --git a/src/radbin/radbin.c b/src/radbin/radbin.c index b4a2c7f5..4d553846 100644 --- a/src/radbin/radbin.c +++ b/src/radbin/radbin.c @@ -708,7 +708,6 @@ rb_thread_entry_point(void *p) B32 convert_done = 0; RDIM_BakeParams pdb_bake_params = {0}; RDIM_BakeParams dwarf_bake_params = {0}; - RDIM_BakeParams dwarf_bake_params_2 = {0}; typedef struct RDIM_BakeParamsNode RDIM_BakeParamsNode; struct RDIM_BakeParamsNode { @@ -731,89 +730,7 @@ rb_thread_entry_point(void *p) else if(elf_w_dwarf) { log_infof("ELFs specified; converting DWARF data to RDI\n"); } // rjf: convert - D2R_ConvertParams convert_params = {0}; - { - B32 got_exe = 0; - B32 got_dbg = 0; - if(!got_exe && !got_dbg) - { - for(RB_FileNode *n = input_files_from_format_table[RB_FileFormat_PE].first; n != 0; n = n->next) - { - if(n->v->format_flags & RB_FileFormatFlag_HasDWARF) - { - got_exe = 1; - got_dbg = 1; - convert_params.dbg_name = n->v->path; - convert_params.dbg_data = n->v->data; - convert_params.exe_name = n->v->path; - convert_params.exe_data = n->v->data; - convert_params.exe_kind = ExecutableImageKind_CoffPe; - break; - } - } - } - if(!got_exe) - { - for(RB_FileNode *n = input_files_from_format_table[RB_FileFormat_ELF32].first; n != 0; n = n->next) - { - got_exe = 1; - convert_params.exe_name = n->v->path; - convert_params.exe_data = n->v->data; - convert_params.exe_kind = ExecutableImageKind_Elf32; - if(!(n->v->format_flags & RB_FileFormatFlag_HasDWARF)) - { - break; - } - } - } - if(!got_exe) - { - for(RB_FileNode *n = input_files_from_format_table[RB_FileFormat_ELF64].first; n != 0; n = n->next) - { - got_exe = 1; - convert_params.exe_name = n->v->path; - convert_params.exe_data = n->v->data; - convert_params.exe_kind = ExecutableImageKind_Elf64; - if(!(n->v->format_flags & RB_FileFormatFlag_HasDWARF)) - { - break; - } - } - } - if(!got_dbg) - { - for(RB_FileNode *n = input_files_from_format_table[RB_FileFormat_ELF32].first; n != 0; n = n->next) - { - if(n->v->format_flags & RB_FileFormatFlag_HasDWARF) - { - got_dbg = 1; - convert_params.dbg_name = n->v->path; - convert_params.dbg_data = n->v->data; - break; - } - } - } - if(!got_dbg) - { - for(RB_FileNode *n = input_files_from_format_table[RB_FileFormat_ELF64].first; n != 0; n = n->next) - { - if(n->v->format_flags & RB_FileFormatFlag_HasDWARF) - { - got_dbg = 1; - convert_params.dbg_name = n->v->path; - convert_params.dbg_data = n->v->data; - break; - } - } - } - convert_params.subset_flags = subset_flags; - convert_params.deterministic = cmd_line_has_flag(cmdline, str8_lit("deterministic")); - convert_params.is_parse_relaxed = 1; // TODO: switch - } - // ProfScope("convert") dwarf_bake_params = d2r_convert(arena, &convert_params); - - // rjf: convert [2] - D2R2_ConvertParams convert_params_2 = {0}; + D2R2_ConvertParams convert_params = {0}; { B32 got_exe = 0; B32 got_dbg = 0; @@ -903,11 +820,11 @@ rb_thread_entry_point(void *p) String8 raw_sections = str8_substr(exe_data, pe.section_table_range); COFF_SectionHeader *section_table = str8_deserial_get_raw_ptr(raw_sections, 0, sizeof(COFF_SectionHeader) * pe.section_count); String8 string_table = str8_substr(exe_data, pe.string_table_range); - convert_params_2.arch = pe.arch; - convert_params_2.base_vaddr = pe.image_base; - convert_params_2.raw = dw_input_from_coff_section_table(scratch.arena, exe_data, string_table, pe.section_count, section_table); - convert_params_2.path_style = PathStyle_WindowsAbsolute; - convert_params_2.binary_sections = c2r_rdi_binary_sections_from_coff_sections(arena, exe_data, string_table, pe.section_count, section_table); + convert_params.arch = pe.arch; + convert_params.base_vaddr = pe.image_base; + convert_params.raw = dw_input_from_coff_section_table(scratch.arena, exe_data, string_table, pe.section_count, section_table); + convert_params.path_style = PathStyle_WindowsAbsolute; + convert_params.binary_sections = c2r_rdi_binary_sections_from_coff_sections(arena, exe_data, string_table, pe.section_count, section_table); scratch_end(scratch); }break; case ExecutableImageKind_Elf32: @@ -915,20 +832,20 @@ rb_thread_entry_point(void *p) { Temp scratch = scratch_begin(&arena, 1); ELF_Bin bin = elf_bin_from_data(scratch.arena, dbg_data); - convert_params_2.arch = arch_from_elf_machine(bin.hdr.e_machine); - convert_params_2.base_vaddr = elf_base_addr_from_bin(&bin); - convert_params_2.raw = dw_input_from_elf_bin(scratch.arena, dbg_data, &bin); - convert_params_2.path_style = PathStyle_UnixAbsolute; - convert_params_2.binary_sections = e2r_rdi_binary_sections_from_elf_section_table(arena, dbg_data, &bin, &bin.shdrs); + convert_params.arch = arch_from_elf_machine(bin.hdr.e_machine); + convert_params.base_vaddr = elf_base_addr_from_bin(&bin); + convert_params.raw = dw_input_from_elf_bin(scratch.arena, dbg_data, &bin); + convert_params.path_style = PathStyle_UnixAbsolute; + convert_params.binary_sections = e2r_rdi_binary_sections_from_elf_section_table(arena, dbg_data, &bin, &bin.shdrs); scratch_end(scratch); }break; } - convert_params_2.exe_name = exe_name; - convert_params_2.exe_data = exe_data; - convert_params_2.subset_flags = subset_flags; - convert_params_2.deterministic = cmd_line_has_flag(cmdline, str8_lit("deterministic")); + convert_params.exe_name = exe_name; + convert_params.exe_data = exe_data; + convert_params.subset_flags = subset_flags; + convert_params.deterministic = cmd_line_has_flag(cmdline, str8_lit("deterministic")); } - ProfScope("convert [2]") dwarf_bake_params_2 = d2r2_convert(arena, &convert_params_2); + ProfScope("convert") dwarf_bake_params = d2r2_convert(arena, &convert_params); } //- rjf: PDB inputs => PDB -> RDI conversion @@ -1003,8 +920,7 @@ rb_thread_entry_point(void *p) { bake_params = push_array(arena, RDIM_BakeParams, 1); rdim_bake_params_concat_in_place(bake_params, &pdb_bake_params); - // rdim_bake_params_concat_in_place(bake_params, &dwarf_bake_params); - rdim_bake_params_concat_in_place(bake_params, &dwarf_bake_params_2); + rdim_bake_params_concat_in_place(bake_params, &dwarf_bake_params); for EachNode(n, RDIM_BakeParamsNode, first_rdi_bake_params) { rdim_bake_params_concat_in_place(bake_params, &n->v);