mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-14 09:18:09 +00:00
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:
+2
-2
@@ -46,8 +46,8 @@ load_paths =
|
||||
commands =
|
||||
{
|
||||
//- rjf: [raddbg]
|
||||
.f1 = { .win = "raddbg_stable --ipc kill_all && build raddbg meta telemetry", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
|
||||
// .f1 = { .win = "raddbg_stable --ipc kill_all && build radbin debug telemetry", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
|
||||
// .f1 = { .win = "raddbg_stable --ipc kill_all && build raddbg meta telemetry", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
|
||||
.f1 = { .win = "raddbg_stable --ipc kill_all && build radbin debug telemetry", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
|
||||
|
||||
//- rjf: [raddbg wsl]
|
||||
// .f1 = { .win = "wsl ./build.sh raddbg", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
|
||||
|
||||
@@ -489,7 +489,7 @@ dw_string_list_from_cfi_program(Arena *arena,
|
||||
}
|
||||
}
|
||||
|
||||
exit:;
|
||||
exit:;
|
||||
scratch_end(scratch);
|
||||
return list;
|
||||
}
|
||||
|
||||
+112
-105
@@ -12,12 +12,17 @@ internal U64
|
||||
str8_deserial_read_dwarf_packed_size(String8 string, U64 off, U64 *size_out)
|
||||
{
|
||||
U64 bytes_read = 0;
|
||||
if (str8_deserial_read(string, off, size_out, sizeof(U32), sizeof(U32))) {
|
||||
if (*size_out == max_U32) {
|
||||
if (str8_deserial_read_struct(string, off+sizeof(U32), size_out)) {
|
||||
if(str8_deserial_read(string, off, size_out, sizeof(U32), sizeof(U32)))
|
||||
{
|
||||
if(*size_out == max_U32)
|
||||
{
|
||||
if(str8_deserial_read_struct(string, off+sizeof(U32), size_out))
|
||||
{
|
||||
bytes_read = sizeof(U32) + sizeof(U64);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
*size_out &= (U64)max_U32;
|
||||
bytes_read = sizeof(U32);
|
||||
}
|
||||
@@ -29,15 +34,18 @@ internal U64
|
||||
str8_deserial_read_dwarf_uint(String8 string, U64 off, DW_Format format, U64 *uint_out)
|
||||
{
|
||||
U64 bytes_read = 0;
|
||||
switch (format) {
|
||||
switch(format)
|
||||
{
|
||||
case DW_Format_Null: break;
|
||||
case DW_Format_32Bit: {
|
||||
case DW_Format_32Bit:
|
||||
{
|
||||
*uint_out &= (U64)max_U32;
|
||||
bytes_read = str8_deserial_read(string, off, uint_out, sizeof(U32), sizeof(U32));
|
||||
} break;
|
||||
case DW_Format_64Bit: {
|
||||
}break;
|
||||
case DW_Format_64Bit:
|
||||
{
|
||||
bytes_read = str8_deserial_read_struct(string, off, uint_out);
|
||||
} break;
|
||||
}break;
|
||||
}
|
||||
return bytes_read;
|
||||
}
|
||||
@@ -196,27 +204,26 @@ internal Rng1U64List
|
||||
dw_unit_ranges_from_data(Arena *arena, String8 data)
|
||||
{
|
||||
Rng1U64List result = {0};
|
||||
|
||||
for (U64 cursor = 0; cursor < data.size; ) {
|
||||
// read CU size
|
||||
for(U64 cursor = 0; cursor < data.size;)
|
||||
{
|
||||
// rjf: read CU size; bad read -> terminate
|
||||
U64 cu_size = 0;
|
||||
U64 cu_size_size = str8_deserial_read_dwarf_packed_size(data, cursor, &cu_size);
|
||||
|
||||
// was read ok?
|
||||
if (cu_size_size == 0) {
|
||||
if(cu_size_size == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (cu_size > 0) {
|
||||
// push unit range
|
||||
// rjf: push
|
||||
if(cu_size > 0)
|
||||
{
|
||||
rng1u64_list_push(arena, &result, rng_1u64(cursor, cursor+cu_size+cu_size_size));
|
||||
}
|
||||
|
||||
// advance
|
||||
// rjf: advance
|
||||
cursor += cu_size_size;
|
||||
cursor += cu_size;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -2420,15 +2427,7 @@ dw_read_line_file_array(Arena *arena,
|
||||
}
|
||||
|
||||
internal U64
|
||||
dw_read_line_vm_header(Arena *arena,
|
||||
String8 line_data,
|
||||
U64 line_off,
|
||||
DW_Input *input,
|
||||
String8 cu_dir,
|
||||
String8 cu_name,
|
||||
U8 cu_address_size,
|
||||
DW_ListUnit *cu_str_offsets,
|
||||
DW_LineVMHeader *header_out)
|
||||
dw_read_line_vm_header(Arena *arena, String8 line_data, U64 line_off, DW_Input *input, String8 cu_dir, String8 cu_name, U8 cu_address_size, DW_ListUnit *cu_str_offsets, DW_LineVMHeader *header_out)
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
|
||||
@@ -2824,37 +2823,35 @@ dw_path_from_file_idx(Arena *arena, DW_LineVMHeader *vm, U64 file_idx)
|
||||
}
|
||||
|
||||
internal DW_LineTableParseResult
|
||||
dw_parsed_line_table_from_data(Arena *arena,
|
||||
String8 unit_data,
|
||||
DW_Input *input,
|
||||
String8 cu_dir,
|
||||
String8 cu_name,
|
||||
U8 cu_address_size,
|
||||
DW_ListUnit *cu_str_offsets)
|
||||
dw_parsed_line_table_from_data(Arena *arena, String8 unit_data, DW_Input *input, String8 cu_dir, String8 cu_name, U8 cu_address_size, DW_ListUnit *cu_str_offsets)
|
||||
{
|
||||
DW_LineVMHeader vm_header = {0};
|
||||
U64 vm_header_size = dw_read_line_vm_header(arena, unit_data, 0, input, cu_dir, cu_name, cu_address_size, cu_str_offsets, &vm_header);
|
||||
|
||||
U64 unit_cursor = vm_header_size;
|
||||
U64 unit_cursor_opl = Min(unit_data.size, vm_header.unit_range.max);
|
||||
|
||||
//- rjf: prep state for VM
|
||||
DW_LineVMState vm_state = {0};
|
||||
dw_line_vm_reset(&vm_state, vm_header.default_is_stmt);
|
||||
|
||||
//- rjf: VM loop; build output list
|
||||
DW_LineTableParseResult result = { .vm_header = vm_header };
|
||||
DW_LineTableParseResult result = {.vm_header = vm_header};
|
||||
B32 end_of_seq = 0;
|
||||
B32 error = 0;
|
||||
for (; !error && unit_cursor < unit_data.size; ) {
|
||||
for(;!error && unit_cursor < unit_cursor_opl;)
|
||||
{
|
||||
//- rjf: parse opcode
|
||||
U8 opcode = 0;
|
||||
unit_cursor += str8_deserial_read_struct(unit_data, unit_cursor, &opcode);
|
||||
|
||||
//- rjf: do opcode action
|
||||
switch (opcode) {
|
||||
default: {
|
||||
//- rjf: special opcode case
|
||||
if (opcode >= vm_header.opcode_base) {
|
||||
switch(opcode)
|
||||
{
|
||||
//- rjf: special opcode cases
|
||||
default:
|
||||
{
|
||||
if(opcode >= vm_header.opcode_base)
|
||||
{
|
||||
U32 adjusted_opcode = (U32)(opcode - vm_header.opcode_base);
|
||||
U32 op_advance = adjusted_opcode / vm_header.line_range;
|
||||
S32 line_inc = (S32)vm_header.line_base + ((S32)adjusted_opcode) % (S32)vm_header.line_range;
|
||||
@@ -2884,25 +2881,31 @@ dw_parsed_line_table_from_data(Arena *arena,
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Skipping unknown opcode. This is a valid case and
|
||||
// it works because compiler stores operand lengths.
|
||||
else {
|
||||
if (0 < opcode && opcode <= vm_header.num_opcode_lens) {
|
||||
else
|
||||
{
|
||||
if(0 < opcode && opcode <= vm_header.num_opcode_lens)
|
||||
{
|
||||
U8 num_operands = vm_header.opcode_lens[opcode - 1];
|
||||
for (U8 i = 0; i < num_operands; ++i) {
|
||||
for(U8 i = 0; i < num_operands; i += 1)
|
||||
{
|
||||
U64 operand = 0;
|
||||
unit_cursor += str8_deserial_read_uleb128(unit_data, unit_cursor, &operand);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
error = 1;
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
}break;
|
||||
|
||||
//- Standard opcodes
|
||||
|
||||
case DW_StdOpcode_Copy: {
|
||||
//- standard opcodes
|
||||
case DW_StdOpcode_Copy:
|
||||
{
|
||||
if(vm_state.is_stmt)
|
||||
{
|
||||
dw_push_line(arena, &result, &vm_state, end_of_seq);
|
||||
@@ -2912,68 +2915,69 @@ dw_parsed_line_table_from_data(Arena *arena,
|
||||
vm_state.basic_block = 0;
|
||||
vm_state.prologue_end = 0;
|
||||
vm_state.epilogue_begin = 0;
|
||||
} break;
|
||||
|
||||
case DW_StdOpcode_AdvancePc: {
|
||||
}break;
|
||||
case DW_StdOpcode_AdvancePc:
|
||||
{
|
||||
U64 advance = 0;
|
||||
unit_cursor += str8_deserial_read_uleb128(unit_data, unit_cursor, &advance);
|
||||
dw_line_vm_advance(&vm_state, advance, vm_header.min_inst_len, vm_header.max_ops_for_inst);
|
||||
} break;
|
||||
|
||||
case DW_StdOpcode_AdvanceLine: {
|
||||
}break;
|
||||
case DW_StdOpcode_AdvanceLine:
|
||||
{
|
||||
S64 s = 0;
|
||||
unit_cursor += str8_deserial_read_sleb128(unit_data, unit_cursor, &s);
|
||||
vm_state.line += s;
|
||||
} break;
|
||||
|
||||
case DW_StdOpcode_SetFile: {
|
||||
}break;
|
||||
case DW_StdOpcode_SetFile:
|
||||
{
|
||||
U64 file_index = 0;
|
||||
unit_cursor += str8_deserial_read_uleb128(unit_data, unit_cursor, &file_index);
|
||||
vm_state.file_index = file_index;
|
||||
} break;
|
||||
|
||||
case DW_StdOpcode_SetColumn: {
|
||||
}break;
|
||||
case DW_StdOpcode_SetColumn:
|
||||
{
|
||||
U64 column = 0;
|
||||
unit_cursor += str8_deserial_read_uleb128(unit_data, unit_cursor, &column);
|
||||
vm_state.column = column;
|
||||
} break;
|
||||
|
||||
case DW_StdOpcode_NegateStmt: {
|
||||
}break;
|
||||
case DW_StdOpcode_NegateStmt:
|
||||
{
|
||||
vm_state.is_stmt = !vm_state.is_stmt;
|
||||
} break;
|
||||
|
||||
case DW_StdOpcode_SetBasicBlock: {
|
||||
}break;
|
||||
case DW_StdOpcode_SetBasicBlock:
|
||||
{
|
||||
vm_state.basic_block = 1;
|
||||
} break;
|
||||
|
||||
case DW_StdOpcode_ConstAddPc: {
|
||||
}break;
|
||||
case DW_StdOpcode_ConstAddPc:
|
||||
{
|
||||
U64 advance = (0xffu - vm_header.opcode_base) / vm_header.line_range;
|
||||
dw_line_vm_advance(&vm_state, advance, vm_header.min_inst_len, vm_header.max_ops_for_inst);
|
||||
} break;
|
||||
|
||||
case DW_StdOpcode_FixedAdvancePc: {
|
||||
}break;
|
||||
case DW_StdOpcode_FixedAdvancePc:
|
||||
{
|
||||
U16 operand = 0;
|
||||
unit_cursor += str8_deserial_read_struct(unit_data, unit_cursor, &operand);
|
||||
vm_state.address += operand;
|
||||
vm_state.op_index = 0;
|
||||
} break;
|
||||
|
||||
case DW_StdOpcode_SetPrologueEnd: {
|
||||
}break;
|
||||
case DW_StdOpcode_SetPrologueEnd:
|
||||
{
|
||||
vm_state.prologue_end = 1;
|
||||
} break;
|
||||
|
||||
case DW_StdOpcode_SetEpilogueBegin: {
|
||||
}break;
|
||||
case DW_StdOpcode_SetEpilogueBegin:
|
||||
{
|
||||
vm_state.epilogue_begin = 1;
|
||||
} break;
|
||||
|
||||
case DW_StdOpcode_SetIsa: {
|
||||
}break;
|
||||
case DW_StdOpcode_SetIsa:
|
||||
{
|
||||
U64 v = 0;
|
||||
unit_cursor += str8_deserial_read_uleb128(unit_data, unit_cursor, &v);
|
||||
vm_state.isa = v;
|
||||
} break;
|
||||
}break;
|
||||
|
||||
//- Extended opcodes
|
||||
case DW_StdOpcode_ExtendedOpcode: {
|
||||
//- extended opcodes
|
||||
case DW_StdOpcode_ExtendedOpcode:
|
||||
{
|
||||
U64 length = 0;
|
||||
unit_cursor += str8_deserial_read_uleb128(unit_data, unit_cursor, &length);
|
||||
|
||||
@@ -2981,8 +2985,12 @@ dw_parsed_line_table_from_data(Arena *arena,
|
||||
U8 extended_opcode = 0;
|
||||
unit_cursor += str8_deserial_read_struct(unit_data, unit_cursor, &extended_opcode);
|
||||
|
||||
switch (extended_opcode) {
|
||||
case DW_ExtOpcode_EndSequence: {
|
||||
switch(extended_opcode)
|
||||
{
|
||||
default:{}break;
|
||||
|
||||
case DW_ExtOpcode_EndSequence:
|
||||
{
|
||||
vm_state.end_sequence = 1;
|
||||
if(vm_state.is_stmt)
|
||||
{
|
||||
@@ -2990,16 +2998,18 @@ dw_parsed_line_table_from_data(Arena *arena,
|
||||
}
|
||||
dw_line_vm_reset(&vm_state, vm_header.default_is_stmt);
|
||||
end_of_seq = 1;
|
||||
} break;
|
||||
}break;
|
||||
|
||||
case DW_ExtOpcode_SetAddress: {
|
||||
case DW_ExtOpcode_SetAddress:
|
||||
{
|
||||
U64 address = 0;
|
||||
unit_cursor += str8_deserial_read(unit_data, unit_cursor, &address, vm_header.address_size, vm_header.address_size);
|
||||
vm_state.address = address;
|
||||
vm_state.op_index = 0;
|
||||
} break;
|
||||
}break;
|
||||
|
||||
case DW_ExtOpcode_DefineFile: {
|
||||
case DW_ExtOpcode_DefineFile:
|
||||
{
|
||||
String8 file_name = {0};
|
||||
U64 dir_index = 0;
|
||||
U64 modify_time = 0;
|
||||
@@ -3017,25 +3027,22 @@ dw_parsed_line_table_from_data(Arena *arena,
|
||||
//
|
||||
// See the DWARF V4 spec (June 10, 2010), page 122.
|
||||
error = 1;
|
||||
AssertAlways(!"UNHANDLED DEFINE FILE!!!");
|
||||
} break;
|
||||
// AssertAlways(!"UNHANDLED DEFINE FILE!!!");
|
||||
}break;
|
||||
|
||||
case DW_ExtOpcode_SetDiscriminator: {
|
||||
case DW_ExtOpcode_SetDiscriminator:
|
||||
{
|
||||
U64 v = 0;
|
||||
unit_cursor += str8_deserial_read_uleb128(unit_data, unit_cursor, &v);
|
||||
vm_state.discriminator = v;
|
||||
} break;
|
||||
|
||||
default: break;
|
||||
}break;
|
||||
}
|
||||
|
||||
unit_cursor = extended_opl;
|
||||
} break;
|
||||
}break;
|
||||
}
|
||||
}
|
||||
|
||||
exit:;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -3375,7 +3382,7 @@ dw_parse_descriptor_entry_header(String8 data, U64 off, DW_DescriptorEntry *desc
|
||||
desc_out->cie_pointer = id;
|
||||
desc_out->cie_pointer_off = length_size;
|
||||
|
||||
exit:;
|
||||
exit:;
|
||||
return length + length_size;
|
||||
}
|
||||
|
||||
@@ -3444,7 +3451,7 @@ dw_parse_cie(String8 data, DW_Format format, Arch arch, DW_CIE *cie_out)
|
||||
cie_out->segment_selector_size = segment_selector_size;
|
||||
|
||||
is_parsed = 1;
|
||||
exit:;
|
||||
exit:;
|
||||
return is_parsed;
|
||||
}
|
||||
|
||||
@@ -3483,7 +3490,7 @@ dw_parse_fde(String8 data, DW_Format format, DW_CIE *cie, DW_FDE *fde_out)
|
||||
fde_out->insts = str8_skip(data, cursor);
|
||||
|
||||
is_parsed = 1;
|
||||
exit:;
|
||||
exit:;
|
||||
return is_parsed;
|
||||
}
|
||||
|
||||
@@ -3785,7 +3792,7 @@ dw_parse_cfa_inst(String8 data,
|
||||
|
||||
error_code = DW_CFA_ParseErrorCode_NewInst;
|
||||
|
||||
exit:;
|
||||
exit:;
|
||||
return error_code;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -216,7 +216,7 @@ enum
|
||||
ELF_SectionIndex_MIPS_SUndefined = 0xff04,
|
||||
};
|
||||
|
||||
typedef U32 ELF_SectionFlag;
|
||||
typedef U32 ELF_SectionFlags;
|
||||
enum
|
||||
{
|
||||
ELF_Shf_Write = (1 << 0),
|
||||
|
||||
@@ -58,14 +58,11 @@ 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, String8 string_table, U64 sectab_count, COFF_SectionHeader *sectab)
|
||||
{
|
||||
ProfBeginFunction();
|
||||
|
||||
RDIM_BinarySectionList binary_sections = {0};
|
||||
|
||||
for (U64 isec = 0; isec < sectab_count; ++isec) {
|
||||
COFF_SectionHeader *coff_sec = §ab[isec];
|
||||
for EachIndex(idx, sectab_count)
|
||||
{
|
||||
COFF_SectionHeader *coff_sec = §ab[idx];
|
||||
RDIM_BinarySection *sec = rdim_binary_section_list_push(arena, &binary_sections);
|
||||
|
||||
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;
|
||||
@@ -73,7 +70,5 @@ c2r_rdi_binary_sections_from_coff_sections(Arena *arena, String8 image_data, Str
|
||||
sec->foff_first = coff_sec->foff;
|
||||
sec->foff_opl = coff_sec->foff + coff_sec->fsize;
|
||||
}
|
||||
|
||||
ProfEnd();
|
||||
return binary_sections;
|
||||
}
|
||||
|
||||
+422
-276
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,11 @@
|
||||
// Copyright (c) Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
#pragma once
|
||||
#ifndef RDI_FROM_DWARF_H
|
||||
#define RDI_FROM_DWARF_H
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Conversion Stage Inputs
|
||||
|
||||
typedef struct D2R_ConvertParams D2R_ConvertParams;
|
||||
struct D2R_ConvertParams
|
||||
@@ -15,6 +19,9 @@ struct D2R_ConvertParams
|
||||
B32 deterministic;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Conversion Helper Types
|
||||
|
||||
typedef struct D2R_TypeTable
|
||||
{
|
||||
HashTable *ht;
|
||||
@@ -104,9 +111,6 @@ internal RDIM_Type * d2r_type_from_offset(D2R_TypeTable *type_table, U64 i
|
||||
internal RDIM_Type * d2r_type_from_attrib(D2R_TypeTable *type_table, DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
|
||||
internal Rng1U64List d2r_range_list_from_tag(Arena *arena, DW_Input *input, DW_CompUnit *cu, U64 image_base, DW_Tag tag);
|
||||
internal RDIM_Type ** d2r_collect_proc_params(Arena *arena, D2R_TypeTable *type_table, DW_Input *input, DW_CompUnit *cu, DW_TagNode *cur_node, U64 *param_count_out);
|
||||
internal RDI_TypeKind d2r_unsigned_type_kind_from_size(U64 byte_size);
|
||||
internal RDI_TypeKind d2r_signed_type_kind_from_size(U64 byte_size);
|
||||
internal RDI_EvalTypeGroup d2r_type_group_from_type_kind(RDI_TypeKind x);
|
||||
|
||||
////////////////////////////////
|
||||
//~ RDIM Bytecode Helpers
|
||||
@@ -134,15 +138,14 @@ internal void d2r_push_relational_op(Arena *arena, D2R_ValueTypeStack *
|
||||
|
||||
internal RDIM_EvalBytecode d2r_bytecode_from_expression(Arena *arena, DW_Input *input, U64 image_base, U64 address_size, Arch arch, DW_ListUnit *addr_lu, String8 expr, DW_CompUnit *cu, D2R_ValueType *result_type_out);
|
||||
internal RDIM_Location * d2r_transpile_expression(Arena *arena, RDIM_LocationChunkList *locations, DW_Input *input, U64 image_base, U64 address_size, Arch arch, DW_ListUnit *addr_lu, DW_CompUnit *cu, String8 expr);
|
||||
internal RDIM_Location * d2r_location_from_attrib(Arena *arena, RDIM_LocationChunkList *locations, DW_Input *input, DW_CompUnit *cu, U64 image_base, Arch arch, DW_Tag tag, DW_AttribKind kind);
|
||||
internal RDIM_LocationCaseList d2r_locset_from_attrib(Arena *arena, RDIM_ScopeChunkList *scopes, RDIM_Scope *curr_scope, RDIM_LocationChunkList *locations, DW_Input *input, DW_CompUnit *cu, U64 image_base, Arch arch, DW_Tag tag, DW_AttribKind kind);
|
||||
internal RDIM_LocationCaseList d2r_var_locset_from_tag(Arena *arena, RDIM_ScopeChunkList *scopes, RDIM_Scope *curr_scope, RDIM_LocationChunkList *locations, DW_Input *input, DW_CompUnit *cu, U64 image_base, Arch arch, DW_Tag tag);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Compilation Unit / Scope Conversion Helpers
|
||||
|
||||
internal D2R_CompUnitContribMap d2r_cu_contrib_map_from_aranges(Arena *arena, DW_Input *input, U64 image_base);
|
||||
internal RDIM_Rng1U64ChunkList d2r_voff_ranges_from_cu_info_off(D2R_CompUnitContribMap map, U64 info_off);
|
||||
internal RDIM_Scope *d2r_push_scope(Arena *arena, RDIM_ScopeChunkList *scopes, U64 scope_chunk_cap, D2R_TagFrame *tag_stack, Rng1U64List ranges);
|
||||
|
||||
////////////////////////////////
|
||||
//~ Tag Iterator
|
||||
@@ -159,6 +162,8 @@ internal DW_Tag d2r_tag_iterator_parent_tag(D2R_TagIterator *iter);
|
||||
internal void d2r_flag_converted_tag(DW_TagNode *tag_node);
|
||||
internal B8 d2r_is_tag_converted(DW_TagNode *tag_node);
|
||||
|
||||
internal RDIM_Type *d2r_find_or_convert_type(Arena *arena, D2R_TypeTable *type_table, DW_Input *input, DW_CompUnit *cu, DW_Language cu_lang, U64 arch_addr_size, DW_Tag tag, DW_AttribKind kind);
|
||||
|
||||
internal void d2r_convert_types(Arena *arena, D2R_TypeTable *type_table, DW_Input *input, DW_CompUnit *cu, DW_Language cu_lang, U64 arch_addr_size, DW_TagNode *root);
|
||||
internal void d2r_convert_udts(Arena *arena, D2R_TypeTable *type_table, DW_Input *input, DW_CompUnit *cu, DW_Language cu_lang, U64 arch_addr_size, DW_TagNode *root);
|
||||
internal void d2r_convert_symbols(Arena *arena, D2R_TypeTable *type_table, RDIM_Scope *global_scope, DW_Input *input, DW_CompUnit *cu, DW_Language cu_lang, U64 arch_addr_size, U64 image_base, Arch arch, DW_TagNode *root);
|
||||
@@ -167,3 +172,5 @@ internal void d2r_convert_symbols(Arena *arena, D2R_TypeTable *type_table, RDIM_
|
||||
//~ rjf: Main Conversion Entry Point
|
||||
|
||||
internal RDIM_BakeParams d2r_convert(Arena *arena, D2R_ConvertParams *params);
|
||||
|
||||
#endif // RDI_FROM_DWARF_H
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#define RDI_FROM_PDB_H
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Conversion Stage Inputs/Outputs
|
||||
//~ rjf: Conversion Stage Inputs
|
||||
|
||||
typedef struct P2R_ConvertParams P2R_ConvertParams;
|
||||
struct P2R_ConvertParams
|
||||
@@ -19,7 +19,7 @@ struct P2R_ConvertParams
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Shared Conversion State
|
||||
//~ rjf: Conversion Helper Types
|
||||
|
||||
//- rjf: link name map (voff -> string)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user