mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-14 17:28:07 +00:00
revert DWARF changes to commit bda3a71379
This commit is contained in:
+2
-68
@@ -2769,14 +2769,14 @@ str8_serial_push_string(Arena *arena, String8List *srl, String8 str){
|
|||||||
internal U64
|
internal U64
|
||||||
str8_deserial_read(String8 string, U64 off, void *read_dst, U64 read_size, U64 granularity)
|
str8_deserial_read(String8 string, U64 off, void *read_dst, U64 read_size, U64 granularity)
|
||||||
{
|
{
|
||||||
U64 bytes_left = string.size - Min(off, string.size);
|
U64 bytes_left = string.size-Min(off, string.size);
|
||||||
U64 actually_readable_size = Min(bytes_left, read_size);
|
U64 actually_readable_size = Min(bytes_left, read_size);
|
||||||
U64 legally_readable_size = actually_readable_size - actually_readable_size%granularity;
|
U64 legally_readable_size = actually_readable_size - actually_readable_size%granularity;
|
||||||
if(legally_readable_size > 0)
|
if(legally_readable_size > 0)
|
||||||
{
|
{
|
||||||
MemoryCopy(read_dst, string.str+off, legally_readable_size);
|
MemoryCopy(read_dst, string.str+off, legally_readable_size);
|
||||||
}
|
}
|
||||||
return actually_readable_size;
|
return legally_readable_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal U64
|
internal U64
|
||||||
@@ -2838,72 +2838,6 @@ str8_deserial_read_block(String8 string, U64 off, U64 size, String8 *block_out)
|
|||||||
return block_out->size;
|
return block_out->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal U64
|
|
||||||
str8_deserial_read_uleb128(String8 string, U64 off, U64 *value_out)
|
|
||||||
{
|
|
||||||
U64 value = 0;
|
|
||||||
U64 shift = 0;
|
|
||||||
U64 cursor = off;
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
U8 byte = 0;
|
|
||||||
U64 bytes_read = str8_deserial_read_struct(string, cursor, &byte);
|
|
||||||
if(bytes_read != sizeof(byte))
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
U8 val = byte & 0x7fu;
|
|
||||||
value |= ((U64)val) << shift;
|
|
||||||
cursor += bytes_read;
|
|
||||||
shift += 7u;
|
|
||||||
if((byte & 0x80u) == 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(value_out != 0)
|
|
||||||
{
|
|
||||||
*value_out = value;
|
|
||||||
}
|
|
||||||
U64 bytes_read = cursor - off;
|
|
||||||
return bytes_read;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal U64
|
|
||||||
str8_deserial_read_sleb128(String8 string, U64 off, S64 *value_out)
|
|
||||||
{
|
|
||||||
U64 value = 0;
|
|
||||||
U64 shift = 0;
|
|
||||||
U64 cursor = off;
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
U8 byte = 0;
|
|
||||||
U64 bytes_read = str8_deserial_read_struct(string, cursor, &byte);
|
|
||||||
if(bytes_read != sizeof(byte))
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
U8 val = byte & 0x7fu;
|
|
||||||
value |= ((U64)val) << shift;
|
|
||||||
cursor += bytes_read;
|
|
||||||
shift += 7u;
|
|
||||||
if((byte & 0x80u) == 0)
|
|
||||||
{
|
|
||||||
if(shift < sizeof(value) * 8 && (byte & 0x40u) != 0)
|
|
||||||
{
|
|
||||||
value |= -(S64)(1ull << shift);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(value_out != 0)
|
|
||||||
{
|
|
||||||
*value_out = value;
|
|
||||||
}
|
|
||||||
U64 bytes_read = cursor - off;
|
|
||||||
return bytes_read;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
internal int
|
internal int
|
||||||
|
|||||||
@@ -444,8 +444,6 @@ internal U64 str8_deserial_read_windows_utf16_string16(String8 string, U64 of
|
|||||||
internal U64 str8_deserial_read_block(String8 string, U64 off, U64 size, String8 *block_out);
|
internal U64 str8_deserial_read_block(String8 string, U64 off, U64 size, String8 *block_out);
|
||||||
#define str8_deserial_read_array(string, off, ptr, count) str8_deserial_read((string), (off), (ptr), sizeof(*(ptr))*(count), sizeof(*(ptr)))
|
#define str8_deserial_read_array(string, off, ptr, count) str8_deserial_read((string), (off), (ptr), sizeof(*(ptr))*(count), sizeof(*(ptr)))
|
||||||
#define str8_deserial_read_struct(string, off, ptr) str8_deserial_read_array(string, off, ptr, 1)
|
#define str8_deserial_read_struct(string, off, ptr) str8_deserial_read_array(string, off, ptr, 1)
|
||||||
internal U64 str8_deserial_read_uleb128(String8 string, U64 off, U64 *value_out);
|
|
||||||
internal U64 str8_deserial_read_sleb128(String8 string, U64 off, S64 *value_out);
|
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Basic String Hashes
|
//~ rjf: Basic String Hashes
|
||||||
|
|||||||
@@ -1978,7 +1978,7 @@ ctrl_unwind_step__dwarf(CTRL_Handle process_handle, CTRL_Handle module_handle, A
|
|||||||
// compute CIE address
|
// compute CIE address
|
||||||
U64 cie_delta_off = fde_format == DW_Format_32Bit ? 4 : 12;
|
U64 cie_delta_off = fde_format == DW_Format_32Bit ? 4 : 12;
|
||||||
U64 cie_delta = 0;
|
U64 cie_delta = 0;
|
||||||
U64 cie_delta_size = dw_str8_deserial_read_fmt_uint(fde_data, cie_delta_off, fde_format, &cie_delta);
|
U64 cie_delta_size = str8_deserial_read_dwarf_uint(fde_data, cie_delta_off, fde_format, &cie_delta);
|
||||||
if (cie_delta_size == 0) { goto eh_parse_exit; }
|
if (cie_delta_size == 0) { goto eh_parse_exit; }
|
||||||
cie_addr = (fde_addr + cie_delta_off) - cie_delta;
|
cie_addr = (fde_addr + cie_delta_off) - cie_delta;
|
||||||
}
|
}
|
||||||
|
|||||||
+72
-74
@@ -73,10 +73,10 @@ internal U64
|
|||||||
dw_reg_count_from_arch(Arch arch)
|
dw_reg_count_from_arch(Arch arch)
|
||||||
{
|
{
|
||||||
switch (arch) {
|
switch (arch) {
|
||||||
default: { NotImplemented; } // fall-through
|
default: { NotImplemented; } // fall-through
|
||||||
case Arch_Null: return 0;
|
case Arch_Null: return 0;
|
||||||
case Arch_x86: return DW_RegX86_Last;
|
case Arch_x86: return DW_RegX86_Last;
|
||||||
case Arch_x64: return DW_RegX64_Last;
|
case Arch_x64: return DW_RegX64_Last;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,10 +98,10 @@ internal U64
|
|||||||
dw_sp_from_arch(Arch arch)
|
dw_sp_from_arch(Arch arch)
|
||||||
{
|
{
|
||||||
switch (arch) {
|
switch (arch) {
|
||||||
default: NotImplemented;
|
default: NotImplemented;
|
||||||
case Arch_Null: return 0;
|
case Arch_Null: return 0;
|
||||||
case Arch_x86: return DW_RegX86_Esp;
|
case Arch_x86: return DW_RegX86_Esp;
|
||||||
case Arch_x64: return DW_RegX64_Rsp;
|
case Arch_x64: return DW_RegX64_Rsp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,7 +194,7 @@ dw_attrib_class_from_attrib_mips(DW_AttribKind k)
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal DW_AttribClass
|
internal DW_AttribClass
|
||||||
dw_attrib_class_from_kind(DW_Version ver, DW_Ext ext, DW_AttribKind k)
|
dw_attrib_class_from_attrib(DW_Version ver, DW_Ext ext, DW_AttribKind k)
|
||||||
{
|
{
|
||||||
DW_AttribClass result = DW_AttribClass_Null;
|
DW_AttribClass result = DW_AttribClass_Null;
|
||||||
|
|
||||||
@@ -278,64 +278,58 @@ internal B32
|
|||||||
dw_are_attrib_class_and_form_kind_compatible(DW_Version ver, DW_AttribClass attrib_class, DW_FormKind form_kind)
|
dw_are_attrib_class_and_form_kind_compatible(DW_Version ver, DW_AttribClass attrib_class, DW_FormKind form_kind)
|
||||||
{
|
{
|
||||||
DW_AttribClass compat_flags = dw_attrib_class_from_form_kind(ver, form_kind);
|
DW_AttribClass compat_flags = dw_attrib_class_from_form_kind(ver, form_kind);
|
||||||
B32 are_compat = (attrib_class & compat_flags) != 0;
|
B32 are_compat = (attrib_class & compat_flags) != 0;
|
||||||
return are_compat;
|
return are_compat;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal String8
|
internal String8
|
||||||
dw_name_string_from_section_kind(DW_SectionKind k)
|
dw_name_string_from_section_kind(DW_SectionKind k)
|
||||||
{
|
{
|
||||||
String8 result = {0};
|
switch (k) {
|
||||||
switch(k)
|
#define X(_N,_L,_M,_D) case DW_Section_##_N: return str8_lit(_L);
|
||||||
{
|
|
||||||
#define X(_N,_L,_M,_D) case DW_Section_##_N:{result = str8_lit(_L);}break;
|
|
||||||
DW_SectionKind_XList(X)
|
DW_SectionKind_XList(X)
|
||||||
#undef X
|
#undef X
|
||||||
}
|
}
|
||||||
return result;
|
return str8_zero();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal String8
|
internal String8
|
||||||
dw_mach_name_string_from_section_kind(DW_SectionKind k)
|
dw_mach_name_string_from_section_kind(DW_SectionKind k)
|
||||||
{
|
{
|
||||||
String8 result = {0};
|
switch (k) {
|
||||||
switch(k)
|
#define X(_N,_L,_M,_D) case DW_Section_##_N: return str8_lit(_M);
|
||||||
{
|
|
||||||
#define X(_N,_L,_M,_D) case DW_Section_##_N:{result = str8_lit(_M);}break;
|
|
||||||
DW_SectionKind_XList(X)
|
DW_SectionKind_XList(X)
|
||||||
#undef X
|
#undef X
|
||||||
}
|
}
|
||||||
return result;
|
return str8_zero();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal String8
|
internal String8
|
||||||
dw_dwo_name_string_from_section_kind(DW_SectionKind k)
|
dw_dwo_name_string_from_section_kind(DW_SectionKind k)
|
||||||
{
|
{
|
||||||
String8 result = {0};
|
switch (k) {
|
||||||
switch(k)
|
#define X(_N,_L,_M,_D) case DW_Section_##_N: return str8_lit(_D);
|
||||||
{
|
|
||||||
#define X(_N,_L,_M,_D) case DW_Section_##_N:{result = str8_lit(_D);}break;
|
|
||||||
DW_SectionKind_XList(X)
|
DW_SectionKind_XList(X)
|
||||||
#undef X
|
#undef X
|
||||||
}
|
}
|
||||||
return result;
|
return str8_zero();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal U64
|
internal U64
|
||||||
dw_size_from_format(DW_Format format)
|
dw_size_from_format(DW_Format format)
|
||||||
{
|
{
|
||||||
U64 result = 0;
|
U64 result = 0;
|
||||||
switch(format)
|
switch (format) {
|
||||||
{
|
case DW_Format_Null: break;
|
||||||
default:{}break;
|
|
||||||
case DW_Format_32Bit: result = 4; break;
|
case DW_Format_32Bit: result = 4; break;
|
||||||
case DW_Format_64Bit: result = 8; break;
|
case DW_Format_64Bit: result = 8; break;
|
||||||
|
default: InvalidPath; break;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal DW_AttribClass
|
internal DW_AttribClass
|
||||||
dw_pick_attrib_value_class(DW_Version ver, DW_Ext ext, DW_AttribKind attrib_kind, DW_FormKind form_kind)
|
dw_pick_attrib_value_class(DW_Version ver, DW_Ext ext, B32 relaxed, DW_AttribKind attrib_kind, DW_FormKind form_kind)
|
||||||
{
|
{
|
||||||
// NOTE(rjf): DWARF's spec specifies two mappings:
|
// NOTE(rjf): DWARF's spec specifies two mappings:
|
||||||
// (DW_AttribKind) => List(DW_AttribClass)
|
// (DW_AttribKind) => List(DW_AttribClass)
|
||||||
@@ -344,12 +338,16 @@ dw_pick_attrib_value_class(DW_Version ver, DW_Ext ext, DW_AttribKind attrib_kind
|
|||||||
// This function's purpose is to find the overlapping class between an
|
// This function's purpose is to find the overlapping class between an
|
||||||
// DW_AttribKind and DW_FormKind.
|
// DW_AttribKind and DW_FormKind.
|
||||||
|
|
||||||
DW_AttribClass attrib_class = dw_attrib_class_from_kind(ver, ext, attrib_kind);
|
DW_AttribClass attrib_class = dw_attrib_class_from_attrib(ver, ext, attrib_kind);
|
||||||
DW_AttribClass form_class = dw_attrib_class_from_form_kind(ver, form_kind);
|
DW_AttribClass form_class = dw_attrib_class_from_form_kind(ver, form_kind);
|
||||||
if(attrib_class == DW_AttribClass_Null || form_class == DW_AttribClass_Null)
|
|
||||||
|
if(relaxed)
|
||||||
{
|
{
|
||||||
attrib_class = dw_attrib_class_from_kind(DW_Version_Last, ext, attrib_kind);
|
if(attrib_class == DW_AttribClass_Null || form_class == DW_AttribClass_Null)
|
||||||
form_class = dw_attrib_class_from_form_kind(DW_Version_Last, form_kind);
|
{
|
||||||
|
attrib_class = dw_attrib_class_from_attrib(DW_Version_Last, ext, attrib_kind);
|
||||||
|
form_class = dw_attrib_class_from_form_kind(DW_Version_Last, form_kind);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DW_AttribClass result = DW_AttribClass_Null;
|
DW_AttribClass result = DW_AttribClass_Null;
|
||||||
@@ -430,11 +428,11 @@ dw_operand_count_from_expr_op(DW_ExprOp op)
|
|||||||
switch (op) {
|
switch (op) {
|
||||||
#define X(_N, _ID, _OPER_COUNT, _POP_COUNT, _PUSH_COUNT) case _ID: return _OPER_COUNT;
|
#define X(_N, _ID, _OPER_COUNT, _POP_COUNT, _PUSH_COUNT) case _ID: return _OPER_COUNT;
|
||||||
DW_Expr_V3_XList(X)
|
DW_Expr_V3_XList(X)
|
||||||
DW_Expr_V4_XList(X)
|
DW_Expr_V4_XList(X)
|
||||||
DW_Expr_V5_XList(X)
|
DW_Expr_V5_XList(X)
|
||||||
DW_Expr_GNU_XList(X)
|
DW_Expr_GNU_XList(X)
|
||||||
#undef X
|
#undef X
|
||||||
default: { NotImplemented; } break;
|
default: { NotImplemented; } break;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -445,11 +443,11 @@ dw_pop_count_from_expr_op(DW_ExprOp op)
|
|||||||
switch (op) {
|
switch (op) {
|
||||||
#define X(_N, _ID, _OPER_COUNT, _POP_COUNT, _PUSH_COUNT) case _ID: return _POP_COUNT;
|
#define X(_N, _ID, _OPER_COUNT, _POP_COUNT, _PUSH_COUNT) case _ID: return _POP_COUNT;
|
||||||
DW_Expr_V3_XList(X)
|
DW_Expr_V3_XList(X)
|
||||||
DW_Expr_V4_XList(X)
|
DW_Expr_V4_XList(X)
|
||||||
DW_Expr_V5_XList(X)
|
DW_Expr_V5_XList(X)
|
||||||
DW_Expr_GNU_XList(X)
|
DW_Expr_GNU_XList(X)
|
||||||
#undef X
|
#undef X
|
||||||
default: { NotImplemented; } break;
|
default: { NotImplemented; } break;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -460,11 +458,11 @@ dw_push_count_from_expr_op(DW_ExprOp op)
|
|||||||
switch (op) {
|
switch (op) {
|
||||||
#define X(_N, _ID, _OPER_COUNT, _POP_COUNT, _PUSH_COUNT) case _ID: return _PUSH_COUNT;
|
#define X(_N, _ID, _OPER_COUNT, _POP_COUNT, _PUSH_COUNT) case _ID: return _PUSH_COUNT;
|
||||||
DW_Expr_V3_XList(X)
|
DW_Expr_V3_XList(X)
|
||||||
DW_Expr_V4_XList(X)
|
DW_Expr_V4_XList(X)
|
||||||
DW_Expr_V5_XList(X)
|
DW_Expr_V5_XList(X)
|
||||||
DW_Expr_GNU_XList(X)
|
DW_Expr_GNU_XList(X)
|
||||||
#undef X
|
#undef X
|
||||||
default: { NotImplemented; } break;
|
default: { NotImplemented; } break;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -476,7 +474,7 @@ dw_operand_count_from_cfa_opcode(DW_CFA_Opcode opcode)
|
|||||||
#define X(_N, _ID, ...) case _ID: { local_persist DW_CFA_OperandType t[] = { DW_CFA_OperandType_Null, __VA_ARGS__ }; return ArrayCount(t)-1; }
|
#define X(_N, _ID, ...) case _ID: { local_persist DW_CFA_OperandType t[] = { DW_CFA_OperandType_Null, __VA_ARGS__ }; return ArrayCount(t)-1; }
|
||||||
DW_CFA_Kind_XList(X)
|
DW_CFA_Kind_XList(X)
|
||||||
#undef X
|
#undef X
|
||||||
default: { NotImplemented; } break;
|
default: { NotImplemented; } break;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -486,21 +484,21 @@ dw_is_cfa_expr_opcode_invalid(DW_ExprOp opcode)
|
|||||||
{
|
{
|
||||||
B32 is_invalid = 0;
|
B32 is_invalid = 0;
|
||||||
switch (opcode) {
|
switch (opcode) {
|
||||||
case DW_ExprOp_Addrx:
|
case DW_ExprOp_Addrx:
|
||||||
case DW_ExprOp_Call2:
|
case DW_ExprOp_Call2:
|
||||||
case DW_ExprOp_Call4:
|
case DW_ExprOp_Call4:
|
||||||
case DW_ExprOp_CallRef:
|
case DW_ExprOp_CallRef:
|
||||||
case DW_ExprOp_ConstType:
|
case DW_ExprOp_ConstType:
|
||||||
case DW_ExprOp_Constx:
|
case DW_ExprOp_Constx:
|
||||||
case DW_ExprOp_Convert:
|
case DW_ExprOp_Convert:
|
||||||
case DW_ExprOp_DerefType:
|
case DW_ExprOp_DerefType:
|
||||||
case DW_ExprOp_RegvalType:
|
case DW_ExprOp_RegvalType:
|
||||||
case DW_ExprOp_Reinterpret:
|
case DW_ExprOp_Reinterpret:
|
||||||
case DW_ExprOp_PushObjectAddress:
|
case DW_ExprOp_PushObjectAddress:
|
||||||
case DW_ExprOp_CallFrameCfa: {
|
case DW_ExprOp_CallFrameCfa: {
|
||||||
is_invalid = 1;
|
is_invalid = 1;
|
||||||
} break;
|
} break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
return is_invalid;
|
return is_invalid;
|
||||||
}
|
}
|
||||||
@@ -510,14 +508,14 @@ dw_is_new_row_cfa_opcode(DW_CFA_Opcode opcode)
|
|||||||
{
|
{
|
||||||
B32 is_new_row_op = 0;
|
B32 is_new_row_op = 0;
|
||||||
switch (opcode) {
|
switch (opcode) {
|
||||||
case DW_CFA_SetLoc:
|
case DW_CFA_SetLoc:
|
||||||
case DW_CFA_AdvanceLoc:
|
case DW_CFA_AdvanceLoc:
|
||||||
case DW_CFA_AdvanceLoc1:
|
case DW_CFA_AdvanceLoc1:
|
||||||
case DW_CFA_AdvanceLoc2:
|
case DW_CFA_AdvanceLoc2:
|
||||||
case DW_CFA_AdvanceLoc4: {
|
case DW_CFA_AdvanceLoc4: {
|
||||||
is_new_row_op = 1;
|
is_new_row_op = 1;
|
||||||
} break;
|
} break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
return is_new_row_op;
|
return is_new_row_op;
|
||||||
}
|
}
|
||||||
@@ -529,7 +527,7 @@ dw_operand_types_from_cfa_op(DW_CFA_Opcode opcode)
|
|||||||
#define X(_N, _ID, ...) case _ID: { local_persist DW_CFA_OperandType t[] = { DW_CFA_OperandType_Null, __VA_ARGS__ }; return &t[0] + 1; }
|
#define X(_N, _ID, ...) case _ID: { local_persist DW_CFA_OperandType t[] = { DW_CFA_OperandType_Null, __VA_ARGS__ }; return &t[0] + 1; }
|
||||||
DW_CFA_Kind_XList(X)
|
DW_CFA_Kind_XList(X)
|
||||||
#undef X
|
#undef X
|
||||||
default: { NotImplemented; } break;
|
default: { NotImplemented; } break;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -541,9 +539,9 @@ internal String8
|
|||||||
dw_string_from_format(DW_Format format)
|
dw_string_from_format(DW_Format format)
|
||||||
{
|
{
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case DW_Format_Null: return str8_zero();
|
case DW_Format_Null: return str8_zero();
|
||||||
case DW_Format_32Bit: return str8_lit("DWARF32");
|
case DW_Format_32Bit: return str8_lit("DWARF32");
|
||||||
case DW_Format_64Bit: return str8_lit("DWARF64");
|
case DW_Format_64Bit: return str8_lit("DWARF64");
|
||||||
}
|
}
|
||||||
return str8_zero();
|
return str8_zero();
|
||||||
}
|
}
|
||||||
@@ -826,7 +824,7 @@ dw_string_from_cfa_opcode(DW_CFA_Opcode opcode)
|
|||||||
#define X(_NAME, _ID, ...) case _ID: return str8_lit(Stringify(_NAME));
|
#define X(_NAME, _ID, ...) case _ID: return str8_lit(Stringify(_NAME));
|
||||||
DW_CFA_Kind_XList(X)
|
DW_CFA_Kind_XList(X)
|
||||||
#undef X
|
#undef X
|
||||||
default: InvalidPath; break;
|
default: InvalidPath; break;
|
||||||
}
|
}
|
||||||
return str8_zero();
|
return str8_zero();
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-7
@@ -478,7 +478,7 @@ X(GNU_RefAlt, DW_AttribClass_Undefined) \
|
|||||||
X(GNU_StrpAlt, DW_AttribClass_String)
|
X(GNU_StrpAlt, DW_AttribClass_String)
|
||||||
|
|
||||||
typedef U64 DW_FormKind;
|
typedef U64 DW_FormKind;
|
||||||
typedef enum DW_FormKindEnum
|
typedef enum DW_FormEnum
|
||||||
{
|
{
|
||||||
DW_Form_Null,
|
DW_Form_Null,
|
||||||
#define X(_N, _ID) DW_Form_##_N = _ID,
|
#define X(_N, _ID) DW_Form_##_N = _ID,
|
||||||
@@ -487,7 +487,7 @@ typedef enum DW_FormKindEnum
|
|||||||
DW_Form_V5_XList(X)
|
DW_Form_V5_XList(X)
|
||||||
DW_Form_GNU_XList(X)
|
DW_Form_GNU_XList(X)
|
||||||
#undef X
|
#undef X
|
||||||
} DW_FormKindEnum;
|
} DW_FormEnum;
|
||||||
|
|
||||||
//- Attributes DWARF2
|
//- Attributes DWARF2
|
||||||
|
|
||||||
@@ -1582,9 +1582,9 @@ typedef enum DW_ExprOpEnum
|
|||||||
{
|
{
|
||||||
#define X(_N, _ID, _OPER_COUNT, _POP_COUNT, _PUSH_COUNT) DW_ExprOp_##_N = _ID,
|
#define X(_N, _ID, _OPER_COUNT, _POP_COUNT, _PUSH_COUNT) DW_ExprOp_##_N = _ID,
|
||||||
DW_Expr_V3_XList(X)
|
DW_Expr_V3_XList(X)
|
||||||
DW_Expr_V4_XList(X)
|
DW_Expr_V4_XList(X)
|
||||||
DW_Expr_V5_XList(X)
|
DW_Expr_V5_XList(X)
|
||||||
DW_Expr_GNU_XList(X)
|
DW_Expr_GNU_XList(X)
|
||||||
#undef X
|
#undef X
|
||||||
} DW_ExprOpEnum;
|
} DW_ExprOpEnum;
|
||||||
|
|
||||||
@@ -1762,7 +1762,7 @@ internal DW_AttribClass dw_attrib_class_from_attrib_llvm (DW_AttribKind k);
|
|||||||
internal DW_AttribClass dw_attrib_class_from_attrib_apple(DW_AttribKind k);
|
internal DW_AttribClass dw_attrib_class_from_attrib_apple(DW_AttribKind k);
|
||||||
internal DW_AttribClass dw_attrib_class_from_attrib_mips (DW_AttribKind k);
|
internal DW_AttribClass dw_attrib_class_from_attrib_mips (DW_AttribKind k);
|
||||||
|
|
||||||
internal DW_AttribClass dw_attrib_class_from_kind(DW_Version ver, DW_Ext ext, DW_AttribKind v);
|
internal DW_AttribClass dw_attrib_class_from_attrib(DW_Version ver, DW_Ext ext, DW_AttribKind v);
|
||||||
|
|
||||||
//- Form Class Encodings
|
//- Form Class Encodings
|
||||||
|
|
||||||
@@ -1782,7 +1782,7 @@ internal U64 dw_size_from_format(DW_Format format);
|
|||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
internal DW_AttribClass dw_pick_attrib_value_class(DW_Version ver, DW_Ext ext, DW_AttribKind attrib, DW_FormKind form_kind);
|
internal DW_AttribClass dw_pick_attrib_value_class(DW_Version ver, DW_Ext ext, B32 relaxed, DW_AttribKind attrib, DW_FormKind form_kind);
|
||||||
|
|
||||||
internal U64 dw_pick_default_lower_bound(DW_Language lang);
|
internal U64 dw_pick_default_lower_bound(DW_Language lang);
|
||||||
|
|
||||||
|
|||||||
@@ -23,14 +23,14 @@ dw_is_dwarf_present_coff_section_table(String8 string_table, U64 section_count,
|
|||||||
return is_dwarf_present;
|
return is_dwarf_present;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal DW_Raw
|
internal DW_Input
|
||||||
dw_raw_from_coff_section_table(Arena *arena,
|
dw_input_from_coff_section_table(Arena *arena,
|
||||||
String8 raw_image,
|
String8 raw_image,
|
||||||
String8 string_table,
|
String8 string_table,
|
||||||
U64 section_count,
|
U64 section_count,
|
||||||
COFF_SectionHeader *section_table)
|
COFF_SectionHeader *section_table)
|
||||||
{
|
{
|
||||||
DW_Raw input = {0};
|
DW_Input input = {0};
|
||||||
B32 sect_status[ArrayCount(input.sec)] = {0};
|
B32 sect_status[ArrayCount(input.sec)] = {0};
|
||||||
|
|
||||||
for (U64 i = 0; i < section_count; ++i) {
|
for (U64 i = 0; i < section_count; ++i) {
|
||||||
@@ -51,6 +51,7 @@ dw_raw_from_coff_section_table(Arena *arena,
|
|||||||
} else {
|
} else {
|
||||||
sect_status[s] = 1;
|
sect_status[s] = 1;
|
||||||
DW_Section *d = &input.sec[s];
|
DW_Section *d = &input.sec[s];
|
||||||
|
d->name = push_str8_copy(arena, name);
|
||||||
d->data = str8_substr(raw_image, raw_data_range);
|
d->data = str8_substr(raw_image, raw_data_range);
|
||||||
d->is_dwo = is_dwo;
|
d->is_dwo = is_dwo;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#define DWARF_COFF_H
|
#define DWARF_COFF_H
|
||||||
|
|
||||||
internal B32 dw_is_dwarf_present_coff_section_table(String8 string_table, U64 section_count, COFF_SectionHeader *section_table);
|
internal B32 dw_is_dwarf_present_coff_section_table(String8 string_table, U64 section_count, COFF_SectionHeader *section_table);
|
||||||
internal DW_Raw dw_raw_from_coff_section_table(Arena *arena, String8 raw_image, String8 string_table, U64 section_count, COFF_SectionHeader *section_table);
|
internal DW_Input dw_input_from_coff_section_table(Arena *arena, String8 raw_image, String8 string_table, U64 section_count, COFF_SectionHeader *section_table);
|
||||||
|
|
||||||
#endif // DWARF_COFF_H
|
#endif // DWARF_COFF_H
|
||||||
|
|
||||||
|
|||||||
+219
-218
@@ -211,13 +211,13 @@ dw_string_list_from_expression(Arena *arena, String8 raw_data, U64 cu_base, U64
|
|||||||
} break;
|
} break;
|
||||||
case DW_ExprOp_CallRef: {
|
case DW_ExprOp_CallRef: {
|
||||||
U64 x = 0;
|
U64 x = 0;
|
||||||
cursor += dw_str8_deserial_read_fmt_uint(raw_data, cursor, format, &x);
|
cursor += str8_deserial_read_dwarf_uint(raw_data, cursor, format, &x);
|
||||||
op_value = push_str8f(scratch.arena, "%llu", x);
|
op_value = push_str8f(scratch.arena, "%llu", x);
|
||||||
} break;
|
} break;
|
||||||
case DW_ExprOp_ImplicitPointer:
|
case DW_ExprOp_ImplicitPointer:
|
||||||
case DW_ExprOp_GNU_ImplicitPointer: {
|
case DW_ExprOp_GNU_ImplicitPointer: {
|
||||||
U64 info_off = 0;
|
U64 info_off = 0;
|
||||||
cursor += dw_str8_deserial_read_fmt_uint(raw_data, cursor, format, &info_off);
|
cursor += str8_deserial_read_dwarf_uint(raw_data, cursor, format, &info_off);
|
||||||
S64 ptr = 0;
|
S64 ptr = 0;
|
||||||
cursor += str8_deserial_read_sleb128(raw_data, cursor, &ptr);
|
cursor += str8_deserial_read_sleb128(raw_data, cursor, &ptr);
|
||||||
|
|
||||||
@@ -368,118 +368,118 @@ dw_string_list_from_cfi_program(Arena *arena,
|
|||||||
U64 operand_count = dw_operand_count_from_cfa_opcode(inst.opcode);
|
U64 operand_count = dw_operand_count_from_cfa_opcode(inst.opcode);
|
||||||
for EachIndex(operand_idx, operand_count) {
|
for EachIndex(operand_idx, operand_count) {
|
||||||
switch (operand_types[operand_idx]) {
|
switch (operand_types[operand_idx]) {
|
||||||
case DW_CFA_OperandType_Null: break;
|
case DW_CFA_OperandType_Null: break;
|
||||||
case DW_CFA_OperandType_Value: break;
|
case DW_CFA_OperandType_Value: break;
|
||||||
case DW_CFA_OperandType_Register: {
|
case DW_CFA_OperandType_Register: {
|
||||||
if (inst.operands[operand_idx].u64 >= reg_max) {
|
if (inst.operands[operand_idx].u64 >= reg_max) {
|
||||||
str8_list_pushf(arena, &list, "ERROR: DW_CFA_%S @ 0x%I64x has an invalid register",
|
str8_list_pushf(arena, &list, "ERROR: DW_CFA_%S @ 0x%I64x has an invalid register",
|
||||||
dw_string_from_cfa_opcode(inst.opcode),
|
dw_string_from_cfa_opcode(inst.opcode),
|
||||||
cursor);
|
cursor);
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case DW_CFA_OperandType_Expression: {
|
||||||
|
DW_Expr expr = dw_expr_from_data(scratch.arena, format, cie->address_size, inst.operands[operand_idx].block);
|
||||||
|
for EachNode(inst, DW_ExprInst, expr.first) {
|
||||||
|
if (dw_is_cfa_expr_opcode_invalid(inst->opcode)) {
|
||||||
|
String8 expr_opcode_str = dw_string_from_expr_op(scratch.arena, ver, ext, inst->opcode);
|
||||||
|
str8_list_pushf(arena, &list, "ERROR: Exrepssion in DW_CFA_%S @ 0x%I64x has an invalid opcode DW_ExprOp_%S", expr_opcode_str);
|
||||||
}
|
}
|
||||||
} break;
|
}
|
||||||
case DW_CFA_OperandType_Expression: {
|
} break;
|
||||||
DW_Expr expr = dw_expr_from_data(scratch.arena, format, cie->address_size, inst.operands[operand_idx].block);
|
default: { InvalidPath; } break;
|
||||||
for EachNode(inst, DW_ExprInst, expr.first) {
|
|
||||||
if (dw_is_cfa_expr_opcode_invalid(inst->opcode)) {
|
|
||||||
String8 expr_opcode_str = dw_string_from_expr_op(scratch.arena, ver, ext, inst->opcode);
|
|
||||||
str8_list_pushf(arena, &list, "ERROR: Exrepssion in DW_CFA_%S @ 0x%I64x has an invalid opcode DW_ExprOp_%S", expr_opcode_str);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
default: { InvalidPath; } break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// format operands
|
// format operands
|
||||||
String8 operand_str = str8_lit("???");
|
String8 operand_str = str8_lit("???");
|
||||||
switch (inst.opcode) {
|
switch (inst.opcode) {
|
||||||
case DW_CFA_Nop: { operand_str = str8_zero(); } break;
|
case DW_CFA_Nop: { operand_str = str8_zero(); } break;
|
||||||
case DW_CFA_SetLoc: {
|
case DW_CFA_SetLoc: {
|
||||||
operand_str = str8f(arena, "0x%X", inst.operands[0].u64);
|
operand_str = str8f(arena, "0x%X", inst.operands[0].u64);
|
||||||
pc = inst.operands[0].u64;
|
pc = inst.operands[0].u64;
|
||||||
} break;
|
} break;
|
||||||
case DW_CFA_AdvanceLoc1: {
|
case DW_CFA_AdvanceLoc1: {
|
||||||
U64 delta = inst.operands[0].u64;
|
U64 delta = inst.operands[0].u64;
|
||||||
pc += delta;
|
pc += delta;
|
||||||
operand_str = str8f(arena, "%+u `PC 0x%I64x`", delta, pc);
|
operand_str = str8f(arena, "%+u `PC 0x%I64x`", delta, pc);
|
||||||
} break;
|
} break;
|
||||||
case DW_CFA_AdvanceLoc2: {
|
case DW_CFA_AdvanceLoc2: {
|
||||||
U64 delta = inst.operands[0].u64;
|
U64 delta = inst.operands[0].u64;
|
||||||
pc += delta;
|
pc += delta;
|
||||||
operand_str = str8f(arena, "%+u `PC 0x%I64x`", delta, pc);
|
operand_str = str8f(arena, "%+u `PC 0x%I64x`", delta, pc);
|
||||||
} break;
|
} break;
|
||||||
case DW_CFA_AdvanceLoc4: {
|
case DW_CFA_AdvanceLoc4: {
|
||||||
U64 delta = inst.operands[0].u64;
|
U64 delta = inst.operands[0].u64;
|
||||||
pc += delta;
|
pc += delta;
|
||||||
operand_str = str8f(arena, "%+u `PC 0x%I64x`", delta, pc);
|
operand_str = str8f(arena, "%+u `PC 0x%I64x`", delta, pc);
|
||||||
} break;
|
} break;
|
||||||
case DW_CFA_OffsetExt: {
|
case DW_CFA_OffsetExt: {
|
||||||
U64 reg = inst.operands[0].u64;
|
U64 reg = inst.operands[0].u64;
|
||||||
S64 offset = (S64)inst.operands[1].u64;
|
S64 offset = (S64)inst.operands[1].u64;
|
||||||
operand_str = dw_string_from_reg_off(arena, arch, reg, offset);
|
operand_str = dw_string_from_reg_off(arena, arch, reg, offset);
|
||||||
} break;
|
} break;
|
||||||
case DW_CFA_RestoreExt: { operand_str = str8_zero(); } break;
|
case DW_CFA_RestoreExt: { operand_str = str8_zero(); } break;
|
||||||
case DW_CFA_Undefined: {
|
case DW_CFA_Undefined: {
|
||||||
operand_str = str8f(arena, "%I64u", inst.operands[0].u64);
|
operand_str = str8f(arena, "%I64u", inst.operands[0].u64);
|
||||||
} break;
|
} break;
|
||||||
case DW_CFA_SameValue: {
|
case DW_CFA_SameValue: {
|
||||||
operand_str = dw_string_from_reg_off(arena, arch, inst.operands[0].u64, 0);
|
operand_str = dw_string_from_reg_off(arena, arch, inst.operands[0].u64, 0);
|
||||||
} break;
|
} break;
|
||||||
case DW_CFA_Register: {
|
case DW_CFA_Register: {
|
||||||
operand_str = dw_string_from_reg_off(arena, arch, inst.operands[0].u64, inst.operands[1].u64);
|
operand_str = dw_string_from_reg_off(arena, arch, inst.operands[0].u64, inst.operands[1].u64);
|
||||||
} break;
|
} break;
|
||||||
case DW_CFA_RememberState: { operand_str = str8_zero(); } break;
|
case DW_CFA_RememberState: { operand_str = str8_zero(); } break;
|
||||||
case DW_CFA_RestoreState: { operand_str = str8_zero(); } break;
|
case DW_CFA_RestoreState: { operand_str = str8_zero(); } break;
|
||||||
case DW_CFA_DefCfa: {
|
case DW_CFA_DefCfa: {
|
||||||
operand_str = dw_string_from_reg_off(arena, arch, inst.operands[0].u64, inst.operands[1].u64);
|
operand_str = dw_string_from_reg_off(arena, arch, inst.operands[0].u64, inst.operands[1].u64);
|
||||||
} break;
|
} break;
|
||||||
case DW_CFA_DefCfaRegister: {
|
case DW_CFA_DefCfaRegister: {
|
||||||
operand_str = dw_string_from_reg_off(arena, arch, inst.operands[0].u64, 0);
|
operand_str = dw_string_from_reg_off(arena, arch, inst.operands[0].u64, 0);
|
||||||
} break;
|
} break;
|
||||||
case DW_CFA_DefCfaOffset: {
|
case DW_CFA_DefCfaOffset: {
|
||||||
operand_str = str8f(arena, "+%I64u", inst.operands[0].u64);
|
operand_str = str8f(arena, "+%I64u", inst.operands[0].u64);
|
||||||
} break;
|
} break;
|
||||||
case DW_CFA_DefCfaExpr: {
|
case DW_CFA_DefCfaExpr: {
|
||||||
operand_str = dw_string_from_expression(arena, inst.operands[0].block, cu_base, cie->address_size, arch, ver, ext, format);
|
operand_str = dw_string_from_expression(arena, inst.operands[0].block, cu_base, cie->address_size, arch, ver, ext, format);
|
||||||
} break;
|
} break;
|
||||||
case DW_CFA_Expr: {
|
case DW_CFA_Expr: {
|
||||||
String8 reg_str = dw_string_from_reg_off(scratch.arena, arch, inst.operands[0].u64, 0);
|
String8 reg_str = dw_string_from_reg_off(scratch.arena, arch, inst.operands[0].u64, 0);
|
||||||
String8 expr_str = dw_string_from_expression(scratch.arena, inst.operands[1].block, cu_base, cie->address_size, arch, ver, ext, format);
|
String8 expr_str = dw_string_from_expression(scratch.arena, inst.operands[1].block, cu_base, cie->address_size, arch, ver, ext, format);
|
||||||
operand_str = str8f(arena, "%S expression %S", reg_str, expr_str);
|
operand_str = str8f(arena, "%S expression %S", reg_str, expr_str);
|
||||||
} break;
|
} break;
|
||||||
case DW_CFA_OffsetExtSf: {
|
case DW_CFA_OffsetExtSf: {
|
||||||
operand_str = dw_string_from_reg_off(arena, arch, inst.operands[0].u64, inst.operands[1].s64);
|
operand_str = dw_string_from_reg_off(arena, arch, inst.operands[0].u64, inst.operands[1].s64);
|
||||||
} break;
|
} break;
|
||||||
case DW_CFA_DefCfaSf: {
|
case DW_CFA_DefCfaSf: {
|
||||||
operand_str = dw_string_from_reg_off(arena, arch, inst.operands[0].u64, inst.operands[1].s64);
|
operand_str = dw_string_from_reg_off(arena, arch, inst.operands[0].u64, inst.operands[1].s64);
|
||||||
} break;
|
} break;
|
||||||
case DW_CFA_DefCfaOffsetSf: { operand_str = str8_zero(); } break;
|
case DW_CFA_DefCfaOffsetSf: { operand_str = str8_zero(); } break;
|
||||||
case DW_CFA_ValOffset: {
|
case DW_CFA_ValOffset: {
|
||||||
operand_str = str8f(arena, "value 0x%llx, offset %+I64d", inst.operands[0].u64, inst.operands[1].u64);
|
operand_str = str8f(arena, "value 0x%llx, offset %+I64d", inst.operands[0].u64, inst.operands[1].u64);
|
||||||
} break;
|
} break;
|
||||||
case DW_CFA_ValOffsetSf: {
|
case DW_CFA_ValOffsetSf: {
|
||||||
operand_str = str8f(arena, "value %llu, offset %+I64d", inst.operands[0].u64, inst.operands[1].s64);
|
operand_str = str8f(arena, "value %llu, offset %+I64d", inst.operands[0].u64, inst.operands[1].s64);
|
||||||
} break;
|
} break;
|
||||||
case DW_CFA_ValExpr: {
|
case DW_CFA_ValExpr: {
|
||||||
String8 expr_str = dw_string_from_expression(scratch.arena, inst.operands[1].block, cu_base, cie->address_size, arch, ver, ext, format);
|
String8 expr_str = dw_string_from_expression(scratch.arena, inst.operands[1].block, cu_base, cie->address_size, arch, ver, ext, format);
|
||||||
operand_str = str8f(arena, "value +%I64u, expression %S", inst.operands[0].u64, expr_str);
|
operand_str = str8f(arena, "value +%I64u, expression %S", inst.operands[0].u64, expr_str);
|
||||||
} break;
|
} break;
|
||||||
case DW_CFA_AdvanceLoc: {
|
case DW_CFA_AdvanceLoc: {
|
||||||
U64 delta = inst.operands[0].u64;
|
U64 delta = inst.operands[0].u64;
|
||||||
pc += delta;
|
pc += delta;
|
||||||
operand_str = str8f(arena, "+%I64u `PC 0x%I64x`", delta, pc);
|
operand_str = str8f(arena, "+%I64u `PC 0x%I64x`", delta, pc);
|
||||||
} break;
|
} break;
|
||||||
case DW_CFA_Offset: {
|
case DW_CFA_Offset: {
|
||||||
U64 reg = inst.operands[0].u64;
|
U64 reg = inst.operands[0].u64;
|
||||||
S64 offset = (S64)inst.operands[1].u64;
|
S64 offset = (S64)inst.operands[1].u64;
|
||||||
operand_str = dw_string_from_reg_off(arena, arch, reg, offset);
|
operand_str = dw_string_from_reg_off(arena, arch, reg, offset);
|
||||||
} break;
|
} break;
|
||||||
case DW_CFA_Restore: {
|
case DW_CFA_Restore: {
|
||||||
operand_str = dw_string_from_reg_off(arena, arch, inst.operands[0].u64, 0);
|
operand_str = dw_string_from_reg_off(arena, arch, inst.operands[0].u64, 0);
|
||||||
} break;
|
} break;
|
||||||
default: {
|
default: {
|
||||||
str8_list_pushf(arena, &list, "ERROR: unknown CFA opcode 0x%I64u", inst.opcode);
|
str8_list_pushf(arena, &list, "ERROR: unknown CFA opcode 0x%I64u", inst.opcode);
|
||||||
} goto exit;
|
} goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (operand_str.size) {
|
if (operand_str.size) {
|
||||||
@@ -489,7 +489,7 @@ dw_string_list_from_cfi_program(Arena *arena,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exit:;
|
exit:;
|
||||||
scratch_end(scratch);
|
scratch_end(scratch);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
@@ -499,10 +499,10 @@ dw_string_from_cfa(Arena *arena, Arch arch, U64 address_size, DW_Version version
|
|||||||
{
|
{
|
||||||
String8 cfa_str = str8_lit("???");
|
String8 cfa_str = str8_lit("???");
|
||||||
switch (cfa.rule) {
|
switch (cfa.rule) {
|
||||||
case DW_CFA_Rule_Null: {} break;
|
case DW_CFA_Rule_Null: {} break;
|
||||||
case DW_CFA_Rule_RegOff: { cfa_str = dw_string_from_reg_off(arena, arch, cfa.reg, cfa.off); } break;
|
case DW_CFA_Rule_RegOff: { cfa_str = dw_string_from_reg_off(arena, arch, cfa.reg, cfa.off); } break;
|
||||||
case DW_CFA_Rule_Expression: { cfa_str = dw_string_from_expression(arena, cfa.expr, max_U64, address_size, arch, version, ext, format); } break;
|
case DW_CFA_Rule_Expression: { cfa_str = dw_string_from_expression(arena, cfa.expr, max_U64, address_size, arch, version, ext, format); } break;
|
||||||
default: { InvalidPath; } break;
|
default: { InvalidPath; } break;
|
||||||
}
|
}
|
||||||
return cfa_str;
|
return cfa_str;
|
||||||
}
|
}
|
||||||
@@ -517,31 +517,31 @@ dw_string_from_cfi_row(Arena *arena, Arch arch, U64 address_size, DW_Version ver
|
|||||||
DW_CFI_Register *cfi_reg = &row->regs[reg_idx];
|
DW_CFI_Register *cfi_reg = &row->regs[reg_idx];
|
||||||
String8 rule_str = str8_lit("???");
|
String8 rule_str = str8_lit("???");
|
||||||
switch (cfi_reg->rule) {
|
switch (cfi_reg->rule) {
|
||||||
case DW_CFI_RegisterRule_Undefined: {
|
case DW_CFI_RegisterRule_Undefined: {
|
||||||
rule_str = str8f(scratch.arena, "Undefined(%S)", dw_string_from_reg(scratch.arena, arch, cfi_reg->n));
|
rule_str = str8f(scratch.arena, "Undefined(%S)", dw_string_from_reg(scratch.arena, arch, cfi_reg->n));
|
||||||
} break;
|
} break;
|
||||||
case DW_CFI_RegisterRule_SameValue: {
|
case DW_CFI_RegisterRule_SameValue: {
|
||||||
rule_str = str8_zero();
|
rule_str = str8_zero();
|
||||||
} break;
|
} break;
|
||||||
case DW_CFI_RegisterRule_Offset: {
|
case DW_CFI_RegisterRule_Offset: {
|
||||||
rule_str = str8f(scratch.arena, "[CFA%+I64d]", cfi_reg->n);
|
rule_str = str8f(scratch.arena, "[CFA%+I64d]", cfi_reg->n);
|
||||||
} break;
|
} break;
|
||||||
case DW_CFI_RegisterRule_ValOffset: {
|
case DW_CFI_RegisterRule_ValOffset: {
|
||||||
rule_str = str8f(scratch.arena, "Val(CFA%+I64d)", cfi_reg->n);
|
rule_str = str8f(scratch.arena, "Val(CFA%+I64d)", cfi_reg->n);
|
||||||
} break;
|
} break;
|
||||||
case DW_CFI_RegisterRule_Register: {
|
case DW_CFI_RegisterRule_Register: {
|
||||||
rule_str = str8f(scratch.arena, "Register(%S)", dw_string_from_reg(scratch.arena, arch, cfi_reg->n));
|
rule_str = str8f(scratch.arena, "Register(%S)", dw_string_from_reg(scratch.arena, arch, cfi_reg->n));
|
||||||
} break;
|
} break;
|
||||||
case DW_CFI_RegisterRule_Expression: {
|
case DW_CFI_RegisterRule_Expression: {
|
||||||
rule_str = str8f(scratch.arena, "Expression(%S)", dw_string_from_expression(scratch.arena, cfi_reg->expr, max_U64, address_size, arch, version, ext, format));
|
rule_str = str8f(scratch.arena, "Expression(%S)", dw_string_from_expression(scratch.arena, cfi_reg->expr, max_U64, address_size, arch, version, ext, format));
|
||||||
} break;
|
} break;
|
||||||
case DW_CFI_RegisterRule_ValExpression: {
|
case DW_CFI_RegisterRule_ValExpression: {
|
||||||
rule_str = str8f(scratch.arena, "ValExpression(%S)", dw_string_from_expression(scratch.arena, cfi_reg->expr, max_U64, address_size, arch, version, ext, format));
|
rule_str = str8f(scratch.arena, "ValExpression(%S)", dw_string_from_expression(scratch.arena, cfi_reg->expr, max_U64, address_size, arch, version, ext, format));
|
||||||
} break;
|
} break;
|
||||||
case DW_CFI_RegisterRule_Architectural: {
|
case DW_CFI_RegisterRule_Architectural: {
|
||||||
rule_str = str8_lit("???");
|
rule_str = str8_lit("???");
|
||||||
} break;
|
} break;
|
||||||
default: { InvalidPath; } break;
|
default: { InvalidPath; } break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rule_str.size) {
|
if (rule_str.size) {
|
||||||
@@ -680,7 +680,7 @@ dw_print_eh_frame(Arena *arena, String8List *out, String8 indent, String8 raw_eh
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
dw_print_debug_loc(Arena *arena, String8List *out, String8 indent, DW_Raw *input, Arch arch, ExecutableImageKind image_type, B32 relaxed)
|
dw_print_debug_loc(Arena *arena, String8List *out, String8 indent, DW_Input *input, Arch arch, ExecutableImageKind image_type, B32 relaxed)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
DW_Section info = input->sec[DW_Section_Info];
|
DW_Section info = input->sec[DW_Section_Info];
|
||||||
@@ -827,7 +827,7 @@ dw_print_debug_loc(Arena *arena, String8List *out, String8 indent, DW_Raw *input
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
dw_print_debug_ranges(Arena *arena, String8List *out, String8 indent, DW_Raw *input, Arch arch, ExecutableImageKind image_type, B32 relaxed)
|
dw_print_debug_ranges(Arena *arena, String8List *out, String8 indent, DW_Input *input, Arch arch, ExecutableImageKind image_type, B32 relaxed)
|
||||||
{
|
{
|
||||||
NotImplemented;
|
NotImplemented;
|
||||||
#if 0
|
#if 0
|
||||||
@@ -933,7 +933,7 @@ dw_print_debug_ranges(Arena *arena, String8List *out, String8 indent, DW_Raw *in
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
dw_print_debug_aranges(Arena *arena, String8List *out, String8 indent, DW_Raw *input)
|
dw_print_debug_aranges(Arena *arena, String8List *out, String8 indent, DW_Input *input)
|
||||||
{
|
{
|
||||||
NotImplemented;
|
NotImplemented;
|
||||||
#if 0
|
#if 0
|
||||||
@@ -1022,7 +1022,7 @@ dw_print_debug_aranges(Arena *arena, String8List *out, String8 indent, DW_Raw *i
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
dw_print_debug_addr(Arena *arena, String8List *out, String8 indent, DW_Raw *input)
|
dw_print_debug_addr(Arena *arena, String8List *out, String8 indent, DW_Input *input)
|
||||||
{
|
{
|
||||||
NotImplemented;
|
NotImplemented;
|
||||||
#if 0
|
#if 0
|
||||||
@@ -1131,7 +1131,7 @@ dw_based_range_read_address(void *base, Rng1U64 range, U64 offset, Rng1U64Array
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
dw_print_debug_loclists(Arena *arena, String8List *out, String8 indent, DW_Raw *input, Rng1U64Array segment_virtual_ranges, Arch arch)
|
dw_print_debug_loclists(Arena *arena, String8List *out, String8 indent, DW_Input *input, Rng1U64Array segment_virtual_ranges, Arch arch)
|
||||||
{
|
{
|
||||||
NotImplemented;
|
NotImplemented;
|
||||||
#if 0
|
#if 0
|
||||||
@@ -1284,7 +1284,7 @@ dw_print_debug_loclists(Arena *arena, String8List *out, String8 indent, DW_Raw *
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
dw_print_debug_rnglists(Arena *arena, String8List *out, String8 indent, DW_Raw *input, Rng1U64Array segment_ranges)
|
dw_print_debug_rnglists(Arena *arena, String8List *out, String8 indent, DW_Input *input, Rng1U64Array segment_ranges)
|
||||||
{
|
{
|
||||||
NotImplemented;
|
NotImplemented;
|
||||||
#if 0
|
#if 0
|
||||||
@@ -1423,7 +1423,7 @@ dw_print_debug_rnglists(Arena *arena, String8List *out, String8 indent, DW_Raw *
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
dw_format_string_table(Arena *arena, String8List *out, String8 indent, DW_Raw *input, DW_SectionKind sec)
|
dw_format_string_table(Arena *arena, String8List *out, String8 indent, DW_Input *input, DW_SectionKind sec)
|
||||||
{
|
{
|
||||||
NotImplemented;
|
NotImplemented;
|
||||||
#if 0
|
#if 0
|
||||||
@@ -1485,19 +1485,19 @@ dw_format_string_table(Arena *arena, String8List *out, String8 indent, DW_Raw *i
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
dw_print_debug_pubnames(Arena *arena, String8List *out, String8 indent, DW_Raw *input)
|
dw_print_debug_pubnames(Arena *arena, String8List *out, String8 indent, DW_Input *input)
|
||||||
{
|
{
|
||||||
dw_format_string_table(arena, out, indent, input, DW_Section_PubNames);
|
dw_format_string_table(arena, out, indent, input, DW_Section_PubNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
dw_print_debug_pubtypes(Arena *arena, String8List *out, String8 indent, DW_Raw *input)
|
dw_print_debug_pubtypes(Arena *arena, String8List *out, String8 indent, DW_Input *input)
|
||||||
{
|
{
|
||||||
dw_format_string_table(arena, out, indent, input, DW_Section_PubTypes);
|
dw_format_string_table(arena, out, indent, input, DW_Section_PubTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
dw_print_debug_line_str(Arena *arena, String8List *out, String8 indent, DW_Raw *input)
|
dw_print_debug_line_str(Arena *arena, String8List *out, String8 indent, DW_Input *input)
|
||||||
{
|
{
|
||||||
NotImplemented;
|
NotImplemented;
|
||||||
#if 0
|
#if 0
|
||||||
@@ -1527,7 +1527,7 @@ dw_print_debug_line_str(Arena *arena, String8List *out, String8 indent, DW_Raw *
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
dw_print_debug_str_offsets(Arena *arena, String8List *out, String8 indent, DW_Raw *input)
|
dw_print_debug_str_offsets(Arena *arena, String8List *out, String8 indent, DW_Input *input)
|
||||||
{
|
{
|
||||||
NotImplemented;
|
NotImplemented;
|
||||||
#if 0
|
#if 0
|
||||||
@@ -1598,7 +1598,7 @@ dw_print_debug_str_offsets(Arena *arena, String8List *out, String8 indent, DW_Ra
|
|||||||
//~ rjf: Dump Entry Point
|
//~ rjf: Dump Entry Point
|
||||||
|
|
||||||
internal String8
|
internal String8
|
||||||
dw_string_from_attrib_value(Arena *arena, DW_Raw *input, Arch arch, DW_CompUnit *unit, DW_LineVMHeader *line_vm, DW_Attrib *attrib)
|
dw_string_from_attrib_value(Arena *arena, DW_Input *input, Arch arch, DW_CompUnit *unit, DW_LineVMHeader *line_vm, DW_Attrib *attrib)
|
||||||
{
|
{
|
||||||
Temp scratch = scratch_begin(&arena, 1);
|
Temp scratch = scratch_begin(&arena, 1);
|
||||||
|
|
||||||
@@ -1737,7 +1737,7 @@ dw_string_from_attrib_value(Arena *arena, DW_Raw *input, Arch arch, DW_CompUnit
|
|||||||
|
|
||||||
internal String8List
|
internal String8List
|
||||||
dw_dump_list_from_sections(Arena *arena,
|
dw_dump_list_from_sections(Arena *arena,
|
||||||
DW_Raw *input,
|
DW_Input *input,
|
||||||
Arch arch,
|
Arch arch,
|
||||||
DW_DumpSubsetFlags subset_flags)
|
DW_DumpSubsetFlags subset_flags)
|
||||||
{
|
{
|
||||||
@@ -1748,17 +1748,18 @@ dw_dump_list_from_sections(Arena *arena,
|
|||||||
#define DumpSubset(name) if(subset_flags & DW_DumpSubsetFlag_##name) DeferLoop(dumpf("// %S\n\n", dw_name_title_from_dump_subset_table[DW_DumpSubset_##name]), dump(str8_lit("\n")))
|
#define DumpSubset(name) if(subset_flags & DW_DumpSubsetFlag_##name) DeferLoop(dumpf("// %S\n\n", dw_name_title_from_dump_subset_table[DW_DumpSubset_##name]), dump(str8_lit("\n")))
|
||||||
Temp scratch = scratch_begin(&arena, 1);
|
Temp scratch = scratch_begin(&arena, 1);
|
||||||
Rng1U64Array segment_vranges = {0};
|
Rng1U64Array segment_vranges = {0};
|
||||||
DW_ListUnitInput lu_input = dw_list_unit_input_from_raw(scratch.arena, input);
|
DW_ListUnitInput lu_input = dw_list_unit_input_from_input(scratch.arena, input);
|
||||||
|
B32 relaxed = 1;
|
||||||
|
|
||||||
DW_CompUnit *cu_arr;
|
DW_CompUnit *cu_arr;
|
||||||
{
|
{
|
||||||
DW_ListUnitInput lu_input = dw_list_unit_input_from_raw(scratch.arena, input);
|
DW_ListUnitInput lu_input = dw_list_unit_input_from_input(scratch.arena, input);
|
||||||
Rng1U64List cu_range_list = dw_unit_ranges_from_data(scratch.arena, input->sec[DW_Section_Info].data);
|
Rng1U64List cu_range_list = dw_unit_ranges_from_data(scratch.arena, input->sec[DW_Section_Info].data);
|
||||||
Rng1U64Array cu_ranges = rng1u64_array_from_list(scratch.arena, &cu_range_list);
|
Rng1U64Array cu_ranges = rng1u64_array_from_list(scratch.arena, &cu_range_list);
|
||||||
cu_arr = push_array(scratch.arena, DW_CompUnit, cu_ranges.count);
|
cu_arr = push_array(scratch.arena, DW_CompUnit, cu_ranges.count);
|
||||||
for EachIndex(cu_idx, cu_ranges.count)
|
for EachIndex(cu_idx, cu_ranges.count)
|
||||||
{
|
{
|
||||||
cu_arr[cu_idx] = dw_cu_from_info_off(scratch.arena, input, lu_input, cu_ranges.v[cu_idx].min);
|
cu_arr[cu_idx] = dw_cu_from_info_off(scratch.arena, input, lu_input, cu_ranges.v[cu_idx].min, relaxed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1779,7 +1780,7 @@ dw_dump_list_from_sections(Arena *arena,
|
|||||||
String8 unit_dir = dw_string_from_tag_attrib_kind(input, unit, unit->tag, DW_AttribKind_CompDir );
|
String8 unit_dir = dw_string_from_tag_attrib_kind(input, unit, unit->tag, DW_AttribKind_CompDir );
|
||||||
String8 unit_name = dw_string_from_tag_attrib_kind(input, unit, unit->tag, DW_AttribKind_Name );
|
String8 unit_name = dw_string_from_tag_attrib_kind(input, unit, unit->tag, DW_AttribKind_Name );
|
||||||
String8 stmt_list = dw_line_ptr_from_tag_attrib_kind(input, unit, unit->tag, DW_AttribKind_StmtList);
|
String8 stmt_list = dw_line_ptr_from_tag_attrib_kind(input, unit, unit->tag, DW_AttribKind_StmtList);
|
||||||
DW_LineVMHeader line_vm = {0};
|
DW_LineVMHeader line_vm = {0};
|
||||||
dw_read_line_vm_header(unit_temp.arena, stmt_list, 0, input, unit_dir, unit_name, unit->address_size, unit->str_offsets_lu, &line_vm);
|
dw_read_line_vm_header(unit_temp.arena, stmt_list, 0, input, unit_dir, unit_name, unit->address_size, unit->str_offsets_lu, &line_vm);
|
||||||
|
|
||||||
//- rjf: log top-level unit info
|
//- rjf: log top-level unit info
|
||||||
@@ -1832,11 +1833,11 @@ dw_dump_list_from_sections(Arena *arena,
|
|||||||
String8 value_str = dw_string_from_attrib_value(attrib_temp.arena, input, arch, unit, &line_vm, attrib);
|
String8 value_str = dw_string_from_attrib_value(attrib_temp.arena, input, arch, unit, &line_vm, attrib);
|
||||||
|
|
||||||
dumpf("%S attrib: { kind: %S, %.*sform_kind: %S, %.*svalue: %S, %.*s} // info_off: 0x%I64x\n",
|
dumpf("%S attrib: { kind: %S, %.*sform_kind: %S, %.*svalue: %S, %.*s} // info_off: 0x%I64x\n",
|
||||||
tag_indent,
|
tag_indent,
|
||||||
attrib_kind_str, attrib_name_max_size - attrib_kind_str.size, indent.str,
|
attrib_kind_str, attrib_name_max_size - attrib_kind_str.size, indent.str,
|
||||||
form_kind_str, form_kind_max_size - form_kind_str.size, indent.str,
|
form_kind_str, form_kind_max_size - form_kind_str.size, indent.str,
|
||||||
value_str, value_str.size < value_max_size ? value_max_size - value_str.size: 0, indent.str,
|
value_str, value_str.size < value_max_size ? value_max_size - value_str.size: 0, indent.str,
|
||||||
attrib->info_off, unit_idx, tag_idx);
|
attrib->info_off, unit_idx, tag_idx);
|
||||||
|
|
||||||
temp_end(attrib_temp);
|
temp_end(attrib_temp);
|
||||||
}
|
}
|
||||||
@@ -2228,71 +2229,71 @@ dw_dump_list_from_sections(Arena *arena,
|
|||||||
desc_size = dw_parse_descriptor_entry_header(debug_frame, cursor, &desc);
|
desc_size = dw_parse_descriptor_entry_header(debug_frame, cursor, &desc);
|
||||||
String8 raw_desc = str8_substr(debug_frame, desc.entry_range);
|
String8 raw_desc = str8_substr(debug_frame, desc.entry_range);
|
||||||
switch (desc.type) {
|
switch (desc.type) {
|
||||||
case DW_DescriptorEntryType_Null: {} break;
|
case DW_DescriptorEntryType_Null: {} break;
|
||||||
case DW_DescriptorEntryType_CIE: {
|
case DW_DescriptorEntryType_CIE: {
|
||||||
DW_CIE cie = {0};
|
DW_CIE cie = {0};
|
||||||
if (dw_parse_cie(raw_desc, desc.format, arch, &cie)) {
|
if (dw_parse_cie(raw_desc, desc.format, arch, &cie)) {
|
||||||
String8List init_insts_str_list = dw_string_list_from_cfi_program(scratch.arena, 0, arch, DW_Version_5, DW_Ext_All, cie.format, 0, &cie, dw_decode_ptr_debug_frame, &cie, cie.insts);
|
String8List init_insts_str_list = dw_string_list_from_cfi_program(scratch.arena, 0, arch, DW_Version_5, DW_Ext_All, cie.format, 0, &cie, dw_decode_ptr_debug_frame, &cie, cie.insts);
|
||||||
|
|
||||||
dumpf("CIE: // entry range: %r\n", desc.entry_range);
|
dumpf("CIE: // entry range: %r\n", desc.entry_range);
|
||||||
dumpf("{\n");
|
dumpf("{\n");
|
||||||
dumpf(" Format: %S\n", dw_string_from_format(desc.format));
|
dumpf(" Format: %S\n", dw_string_from_format(desc.format));
|
||||||
dumpf(" Version: %u\n", cie.version);
|
dumpf(" Version: %u\n", cie.version);
|
||||||
dumpf(" Aug string: \"%S\"\n", cie.aug_string);
|
dumpf(" Aug string: \"%S\"\n", cie.aug_string);
|
||||||
dumpf(" Code align: %I64u\n", cie.code_align_factor);
|
dumpf(" Code align: %I64u\n", cie.code_align_factor);
|
||||||
dumpf(" Data align: %I64d\n", cie.data_align_factor);
|
dumpf(" Data align: %I64d\n", cie.data_align_factor);
|
||||||
dumpf(" Return addr reg: %u\n", cie.ret_addr_reg);
|
dumpf(" Return addr reg: %u\n", cie.ret_addr_reg);
|
||||||
if (cie.version > DW_Version_3) {
|
if (cie.version > DW_Version_3) {
|
||||||
dumpf(" Address size: %u\n", cie.address_size);
|
dumpf(" Address size: %u\n", cie.address_size);
|
||||||
dumpf(" Segment selector size: %u\n", cie.segment_selector_size);
|
dumpf(" Segment selector size: %u\n", cie.segment_selector_size);
|
||||||
}
|
|
||||||
dumpf(" Initial Insturction:\n");
|
|
||||||
dumpf(" {\n");
|
|
||||||
for EachNode(n, String8Node, init_insts_str_list.first) { dumpf(" %S\n", n->string); }
|
|
||||||
dumpf(" }\n");
|
|
||||||
dumpf("}\n");
|
|
||||||
} else {
|
|
||||||
dumpf("ERROR: unable to parse CIE @ %I64x\n", desc.entry_range.min);
|
|
||||||
}
|
}
|
||||||
} break;
|
dumpf(" Initial Insturction:\n");
|
||||||
case DW_DescriptorEntryType_FDE: {
|
dumpf(" {\n");
|
||||||
DW_DescriptorEntry cie_desc = {0};
|
for EachNode(n, String8Node, init_insts_str_list.first) { dumpf(" %S\n", n->string); }
|
||||||
U64 cie_desc_size = dw_parse_descriptor_entry_header(debug_frame, desc.cie_pointer, &cie_desc);
|
dumpf(" }\n");
|
||||||
String8 cie_data = str8_substr(debug_frame, cie_desc.entry_range);
|
dumpf("}\n");
|
||||||
DW_CIE cie = {0};
|
} else {
|
||||||
dw_parse_cie(cie_data, cie_desc.format, arch, &cie);
|
dumpf("ERROR: unable to parse CIE @ %I64x\n", desc.entry_range.min);
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case DW_DescriptorEntryType_FDE: {
|
||||||
|
DW_DescriptorEntry cie_desc = {0};
|
||||||
|
U64 cie_desc_size = dw_parse_descriptor_entry_header(debug_frame, desc.cie_pointer, &cie_desc);
|
||||||
|
String8 cie_data = str8_substr(debug_frame, cie_desc.entry_range);
|
||||||
|
DW_CIE cie = {0};
|
||||||
|
dw_parse_cie(cie_data, cie_desc.format, arch, &cie);
|
||||||
|
|
||||||
DW_FDE fde = {0};
|
DW_FDE fde = {0};
|
||||||
if (dw_parse_fde(raw_desc, desc.format, &cie, &fde)) {
|
if (dw_parse_fde(raw_desc, desc.format, &cie, &fde)) {
|
||||||
DW_Version version = DW_Version_5;
|
DW_Version version = DW_Version_5;
|
||||||
DW_Ext ext = DW_Ext_All;
|
DW_Ext ext = DW_Ext_All;
|
||||||
String8List insts_str_list = dw_string_list_from_cfi_program(scratch.arena, 0, arch, version, ext, fde.format, fde.pc_range.min, &cie, dw_decode_ptr_debug_frame, &cie, fde.insts);
|
String8List insts_str_list = dw_string_list_from_cfi_program(scratch.arena, 0, arch, version, ext, fde.format, fde.pc_range.min, &cie, dw_decode_ptr_debug_frame, &cie, fde.insts);
|
||||||
dumpf("FDE: // entry range: %r\n", desc.entry_range);
|
dumpf("FDE: // entry range: %r\n", desc.entry_range);
|
||||||
dumpf("{\n");
|
dumpf("{\n");
|
||||||
{
|
{
|
||||||
dumpf(" Format: %S\n", dw_string_from_format(fde.format));
|
dumpf(" Format: %S\n", dw_string_from_format(fde.format));
|
||||||
dumpf(" CIE pointer: 0x%I64x\n", fde.cie_pointer);
|
dumpf(" CIE pointer: 0x%I64x\n", fde.cie_pointer);
|
||||||
dumpf(" PC range: %r\n", fde.pc_range);
|
dumpf(" PC range: %r\n", fde.pc_range);
|
||||||
dumpf(" Instructions:\n");
|
dumpf(" Instructions:\n");
|
||||||
dumpf(" {\n");
|
|
||||||
for EachNode(n, String8Node, insts_str_list.first) { dumpf(" %S\n", n->string); }
|
|
||||||
dumpf(" }\n");
|
|
||||||
}
|
|
||||||
dumpf(" Unwind:\n");
|
|
||||||
dumpf(" {\n");
|
dumpf(" {\n");
|
||||||
DW_CFI_Unwind *cfi_unwind = dw_cfi_unwind_init(scratch.arena, arch, &cie, &fde, dw_decode_ptr_debug_frame, &cie);
|
for EachNode(n, String8Node, insts_str_list.first) { dumpf(" %S\n", n->string); }
|
||||||
do {
|
|
||||||
String8 cfa_str = dw_string_from_cfa(scratch.arena, arch, cie.address_size, version, ext, fde.format, cfi_unwind->row->cfa);
|
|
||||||
String8 cfi_regs_str = dw_string_from_cfi_row(scratch.arena, arch, cie.address_size, version, ext, fde.format, cfi_unwind->row);
|
|
||||||
dumpf(" { PC: 0x%I64x, CFA: %-7S, Rules: { %S }\n", cfi_unwind->pc, cfa_str, cfi_regs_str);
|
|
||||||
} while (dw_cfi_next_row(scratch.arena, cfi_unwind));
|
|
||||||
dumpf(" }\n");
|
dumpf(" }\n");
|
||||||
|
|
||||||
dumpf("}\n");
|
|
||||||
} else {
|
|
||||||
dumpf("ERROR: unable to parse FDE @ %I64x\n", desc.entry_range.min);
|
|
||||||
}
|
}
|
||||||
} break;
|
dumpf(" Unwind:\n");
|
||||||
|
dumpf(" {\n");
|
||||||
|
DW_CFI_Unwind *cfi_unwind = dw_cfi_unwind_init(scratch.arena, arch, &cie, &fde, dw_decode_ptr_debug_frame, &cie);
|
||||||
|
do {
|
||||||
|
String8 cfa_str = dw_string_from_cfa(scratch.arena, arch, cie.address_size, version, ext, fde.format, cfi_unwind->row->cfa);
|
||||||
|
String8 cfi_regs_str = dw_string_from_cfi_row(scratch.arena, arch, cie.address_size, version, ext, fde.format, cfi_unwind->row);
|
||||||
|
dumpf(" { PC: 0x%I64x, CFA: %-7S, Rules: { %S }\n", cfi_unwind->pc, cfa_str, cfi_regs_str);
|
||||||
|
} while (dw_cfi_next_row(scratch.arena, cfi_unwind));
|
||||||
|
dumpf(" }\n");
|
||||||
|
|
||||||
|
dumpf("}\n");
|
||||||
|
} else {
|
||||||
|
dumpf("ERROR: unable to parse FDE @ %I64x\n", desc.entry_range.min);
|
||||||
|
}
|
||||||
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-11
@@ -70,21 +70,21 @@ internal String8 dw_string_from_cfi_row(Arena *arena, Arch arch, U64 address_siz
|
|||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
internal void dw_print_eh_frame (Arena *arena, String8List *out, String8 indent, String8 raw_eh_frame, Arch arch, DW_Version ver, DW_Ext ext, EH_PtrCtx *ptr_ctx);
|
internal void dw_print_eh_frame (Arena *arena, String8List *out, String8 indent, String8 raw_eh_frame, Arch arch, DW_Version ver, DW_Ext ext, EH_PtrCtx *ptr_ctx);
|
||||||
internal void dw_print_debug_loc (Arena *arena, String8List *out, String8 indent, DW_Raw *input, Arch arch, ExecutableImageKind image_type, B32 relaxed);
|
internal void dw_print_debug_loc (Arena *arena, String8List *out, String8 indent, DW_Input *input, Arch arch, ExecutableImageKind image_type, B32 relaxed);
|
||||||
internal void dw_print_debug_ranges (Arena *arena, String8List *out, String8 indent, DW_Raw *input, Arch arch, ExecutableImageKind image_type, B32 relaxed);
|
internal void dw_print_debug_ranges (Arena *arena, String8List *out, String8 indent, DW_Input *input, Arch arch, ExecutableImageKind image_type, B32 relaxed);
|
||||||
internal void dw_print_debug_aranges (Arena *arena, String8List *out, String8 indent, DW_Raw *input);
|
internal void dw_print_debug_aranges (Arena *arena, String8List *out, String8 indent, DW_Input *input);
|
||||||
internal void dw_print_debug_addr (Arena *arena, String8List *out, String8 indent, DW_Raw *input);
|
internal void dw_print_debug_addr (Arena *arena, String8List *out, String8 indent, DW_Input *input);
|
||||||
internal void dw_print_debug_loclists (Arena *arena, String8List *out, String8 indent, DW_Raw *input, Rng1U64Array segment_vranges, Arch arch);
|
internal void dw_print_debug_loclists (Arena *arena, String8List *out, String8 indent, DW_Input *input, Rng1U64Array segment_vranges, Arch arch);
|
||||||
internal void dw_print_debug_rnglists (Arena *arena, String8List *out, String8 indent, DW_Raw *input, Rng1U64Array segment_vranges);
|
internal void dw_print_debug_rnglists (Arena *arena, String8List *out, String8 indent, DW_Input *input, Rng1U64Array segment_vranges);
|
||||||
internal void dw_print_debug_pubnames (Arena *arena, String8List *out, String8 indent, DW_Raw *input);
|
internal void dw_print_debug_pubnames (Arena *arena, String8List *out, String8 indent, DW_Input *input);
|
||||||
internal void dw_print_debug_pubtypes (Arena *arena, String8List *out, String8 indent, DW_Raw *input);
|
internal void dw_print_debug_pubtypes (Arena *arena, String8List *out, String8 indent, DW_Input *input);
|
||||||
internal void dw_print_debug_line_str (Arena *arena, String8List *out, String8 indent, DW_Raw *input);
|
internal void dw_print_debug_line_str (Arena *arena, String8List *out, String8 indent, DW_Input *input);
|
||||||
internal void dw_print_debug_str_offsets(Arena *arena, String8List *out, String8 indent, DW_Raw *input);
|
internal void dw_print_debug_str_offsets(Arena *arena, String8List *out, String8 indent, DW_Input *input);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Dump Entry Point
|
//~ rjf: Dump Entry Point
|
||||||
|
|
||||||
internal String8List dw_dump_list_from_sections(Arena *arena, DW_Raw *input, Arch arch, 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
|
#endif // DWARF_DUMP_H
|
||||||
|
|||||||
@@ -27,10 +27,10 @@ dw_is_dwarf_present_from_elf_bin(String8 data, ELF_Bin *bin)
|
|||||||
#define SINFL_IMPLEMENTATION
|
#define SINFL_IMPLEMENTATION
|
||||||
#include "third_party/sinfl/sinfl.h"
|
#include "third_party/sinfl/sinfl.h"
|
||||||
|
|
||||||
internal DW_Raw
|
internal DW_Input
|
||||||
dw_raw_from_elf_bin(Arena *arena, String8 data, ELF_Bin *bin)
|
dw_input_from_elf_bin(Arena *arena, String8 data, ELF_Bin *bin)
|
||||||
{
|
{
|
||||||
DW_Raw result = {0};
|
DW_Input result = {0};
|
||||||
B32 is_section_present[ArrayCount(result.sec)] = {0};
|
B32 is_section_present[ArrayCount(result.sec)] = {0};
|
||||||
for(U64 section_idx = 1; section_idx < bin->shdrs.count; section_idx += 1)
|
for(U64 section_idx = 1; section_idx < bin->shdrs.count; section_idx += 1)
|
||||||
{
|
{
|
||||||
@@ -106,6 +106,7 @@ dw_raw_from_elf_bin(Arena *arena, String8 data, ELF_Bin *bin)
|
|||||||
//- rjf: store
|
//- rjf: store
|
||||||
is_section_present[section_kind] = 1;
|
is_section_present[section_kind] = 1;
|
||||||
DW_Section *d = &result.sec[section_kind];
|
DW_Section *d = &result.sec[section_kind];
|
||||||
|
d->name = push_str8_copy(arena, section_name);
|
||||||
d->data = section_data__uncompressed;
|
d->data = section_data__uncompressed;
|
||||||
d->is_dwo = is_dwo;
|
d->is_dwo = is_dwo;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,6 @@
|
|||||||
#define DWARF_ELF_H
|
#define DWARF_ELF_H
|
||||||
|
|
||||||
internal B32 dw_is_dwarf_present_from_elf_bin(String8 raw_image, ELF_Bin *bin);
|
internal B32 dw_is_dwarf_present_from_elf_bin(String8 raw_image, ELF_Bin *bin);
|
||||||
internal DW_Raw dw_raw_from_elf_bin(Arena *arena, String8 raw_image, ELF_Bin *bin);
|
internal DW_Input dw_input_from_elf_bin(Arena *arena, String8 raw_image, ELF_Bin *bin);
|
||||||
|
|
||||||
#endif // DWARF_ELF_H
|
#endif // DWARF_ELF_H
|
||||||
|
|||||||
@@ -15,3 +15,4 @@ typedef struct DW_CallFrameInfo
|
|||||||
internal DW_CallFrameInfo dw_call_frame_info_from_data(Arena *arena, Arch arch, U64 rebase, String8 debug_frame);
|
internal DW_CallFrameInfo dw_call_frame_info_from_data(Arena *arena, Arch arch, U64 rebase, String8 debug_frame);
|
||||||
|
|
||||||
#endif // DWARF_HELP_H
|
#endif // DWARF_HELP_H
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
#include "dwarf/dwarf.c"
|
#include "dwarf/dwarf.c"
|
||||||
#include "dwarf/dwarf_expr.c"
|
#include "dwarf/dwarf_expr.c"
|
||||||
#include "dwarf/dwarf_parse.c"
|
#include "dwarf/dwarf_parse.c"
|
||||||
#include "dwarf/dwarf_parse_2.c"
|
|
||||||
#include "dwarf/dwarf_coff.c"
|
#include "dwarf/dwarf_coff.c"
|
||||||
#include "dwarf/dwarf_elf.c"
|
#include "dwarf/dwarf_elf.c"
|
||||||
#include "dwarf/dwarf_unwind.c"
|
#include "dwarf/dwarf_unwind.c"
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
#include "dwarf/dwarf.h"
|
#include "dwarf/dwarf.h"
|
||||||
#include "dwarf/dwarf_expr.h"
|
#include "dwarf/dwarf_expr.h"
|
||||||
#include "dwarf/dwarf_parse.h"
|
#include "dwarf/dwarf_parse.h"
|
||||||
#include "dwarf/dwarf_parse_2.h"
|
|
||||||
#include "dwarf/dwarf_coff.h"
|
#include "dwarf/dwarf_coff.h"
|
||||||
#include "dwarf/dwarf_elf.h"
|
#include "dwarf/dwarf_elf.h"
|
||||||
#include "dwarf/dwarf_unwind.h"
|
#include "dwarf/dwarf_unwind.h"
|
||||||
|
|||||||
+730
-597
File diff suppressed because it is too large
Load Diff
+131
-138
@@ -4,60 +4,54 @@
|
|||||||
#ifndef DWARF_PARSE_H
|
#ifndef DWARF_PARSE_H
|
||||||
#define DWARF_PARSE_H
|
#define DWARF_PARSE_H
|
||||||
|
|
||||||
////////////////////////////////
|
typedef struct DW_Section
|
||||||
//~ rjf: Raw DWARF Info Bundle
|
|
||||||
|
|
||||||
typedef struct DW_Section DW_Section;
|
|
||||||
struct DW_Section
|
|
||||||
{
|
{
|
||||||
|
String8 name;
|
||||||
String8 data;
|
String8 data;
|
||||||
B32 is_dwo;
|
B32 is_dwo;
|
||||||
};
|
} DW_Section;
|
||||||
|
|
||||||
typedef struct DW_Raw DW_Raw;
|
typedef struct DW_Input
|
||||||
struct DW_Raw
|
|
||||||
{
|
{
|
||||||
DW_Section sec[DW_Section_Count];
|
DW_Section sec[DW_Section_Count];
|
||||||
};
|
DW_Section sup[DW_Section_Count];
|
||||||
|
} DW_Input;
|
||||||
|
|
||||||
typedef struct DW_ListUnit DW_ListUnit;
|
typedef struct DW_ListUnit
|
||||||
struct DW_ListUnit
|
|
||||||
{
|
{
|
||||||
DW_Version version;
|
DW_Version version;
|
||||||
U64 address_size;
|
U64 address_size;
|
||||||
U64 segment_selector_size;
|
U64 segment_selector_size;
|
||||||
U64 entry_size;
|
U64 entry_size;
|
||||||
String8 entries;
|
String8 entries;
|
||||||
};
|
} DW_ListUnit;
|
||||||
|
|
||||||
typedef struct DW_ListUnitInput DW_ListUnitInput;
|
typedef struct DW_ListUnitInput
|
||||||
struct DW_ListUnitInput
|
|
||||||
{
|
{
|
||||||
U64 addr_count;
|
U64 addr_count;
|
||||||
U64 str_offset_count;
|
U64 str_offset_count;
|
||||||
U64 rnglist_count;
|
U64 rnglist_count;
|
||||||
U64 loclist_count;
|
U64 loclist_count;
|
||||||
Rng1U64Array addr_ranges;
|
Rng1U64Array addr_ranges;
|
||||||
Rng1U64Array str_offset_ranges;
|
Rng1U64Array str_offset_ranges;
|
||||||
Rng1U64Array rnglist_ranges;
|
Rng1U64Array rnglist_ranges;
|
||||||
Rng1U64Array loclist_ranges;
|
Rng1U64Array loclist_ranges;
|
||||||
DW_ListUnit *addrs;
|
DW_ListUnit *addrs;
|
||||||
DW_ListUnit *str_offsets;
|
DW_ListUnit *str_offsets;
|
||||||
DW_ListUnit *rnglists;
|
DW_ListUnit *rnglists;
|
||||||
DW_ListUnit *loclists;
|
DW_ListUnit *loclists;
|
||||||
};
|
} DW_ListUnitInput;
|
||||||
|
|
||||||
typedef struct DW_AbbrevTableEntry DW_AbbrevTableEntry;
|
typedef struct DW_AbbrevTableEntry
|
||||||
struct DW_AbbrevTableEntry
|
|
||||||
{
|
{
|
||||||
U64 id;
|
U64 id;
|
||||||
U64 off;
|
U64 off;
|
||||||
};
|
} DW_AbbrevTableEntry;
|
||||||
|
|
||||||
typedef struct DW_AbbrevTable DW_AbbrevTable;
|
typedef struct DW_AbbrevTable DW_AbbrevTable;
|
||||||
struct DW_AbbrevTable
|
struct DW_AbbrevTable
|
||||||
{
|
{
|
||||||
U64 count;
|
U64 count;
|
||||||
DW_AbbrevTableEntry *entries;
|
DW_AbbrevTableEntry *entries;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -69,8 +63,7 @@ typedef enum DW_AbbrevKind
|
|||||||
DW_Abbrev_AttribSequenceEnd,
|
DW_Abbrev_AttribSequenceEnd,
|
||||||
DW_Abbrev_DIEBegin,
|
DW_Abbrev_DIEBegin,
|
||||||
DW_Abbrev_DIEEnd,
|
DW_Abbrev_DIEEnd,
|
||||||
}
|
} DW_AbbrevKind;
|
||||||
DW_AbbrevKind;
|
|
||||||
|
|
||||||
typedef U32 DW_AbbrevFlags;
|
typedef U32 DW_AbbrevFlags;
|
||||||
enum
|
enum
|
||||||
@@ -79,15 +72,14 @@ enum
|
|||||||
DW_AbbrevFlag_HasChildren = (1 << 1),
|
DW_AbbrevFlag_HasChildren = (1 << 1),
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct DW_Abbrev DW_Abbrev;
|
typedef struct DW_Abbrev
|
||||||
struct DW_Abbrev
|
|
||||||
{
|
{
|
||||||
DW_AbbrevKind kind;
|
DW_AbbrevKind kind;
|
||||||
U64 sub_kind;
|
U64 sub_kind;
|
||||||
U64 id;
|
U64 id;
|
||||||
U64 const_value;
|
U64 const_value;
|
||||||
DW_AbbrevFlags flags;
|
DW_AbbrevFlags flags;
|
||||||
};
|
} DW_Abbrev;
|
||||||
|
|
||||||
typedef union DW_Form
|
typedef union DW_Form
|
||||||
{
|
{
|
||||||
@@ -108,78 +100,71 @@ typedef union DW_Form
|
|||||||
U64 rnglistx;
|
U64 rnglistx;
|
||||||
U64 ptr;
|
U64 ptr;
|
||||||
U64 implicit_const;
|
U64 implicit_const;
|
||||||
}
|
} DW_Form;
|
||||||
DW_Form;
|
|
||||||
|
|
||||||
typedef struct DW_Attrib DW_Attrib;
|
typedef struct DW_Attrib
|
||||||
struct DW_Attrib
|
|
||||||
{
|
{
|
||||||
U64 info_off;
|
U64 info_off;
|
||||||
DW_AttribKind attrib_kind;
|
U64 abbrev_off;
|
||||||
DW_FormKind form_kind;
|
U64 abbrev_id;
|
||||||
DW_Form form;
|
DW_AttribKind attrib_kind;
|
||||||
};
|
DW_FormKind form_kind;
|
||||||
|
DW_Form form;
|
||||||
|
} DW_Attrib;
|
||||||
|
|
||||||
typedef struct DW_AttribNode DW_AttribNode;
|
typedef struct DW_AttribNode
|
||||||
struct DW_AttribNode
|
|
||||||
{
|
{
|
||||||
DW_AttribNode *next;
|
struct DW_AttribNode *next;
|
||||||
DW_Attrib v;
|
DW_Attrib v;
|
||||||
};
|
} DW_AttribNode;
|
||||||
|
|
||||||
typedef struct DW_AttribList DW_AttribList;
|
typedef struct DW_AttribList
|
||||||
struct DW_AttribList
|
|
||||||
{
|
{
|
||||||
DW_AttribNode *first;
|
DW_AttribNode *first;
|
||||||
DW_AttribNode *last;
|
DW_AttribNode *last;
|
||||||
U64 count;
|
U64 count;
|
||||||
};
|
} DW_AttribList;
|
||||||
|
|
||||||
typedef struct DW_Tag DW_Tag;
|
typedef struct DW_Tag
|
||||||
struct DW_Tag
|
|
||||||
{
|
{
|
||||||
B32 has_children;
|
B32 has_children;
|
||||||
U64 abbrev_id;
|
U64 abbrev_id;
|
||||||
DW_TagKind kind;
|
DW_TagKind kind;
|
||||||
DW_AttribList attribs;
|
DW_AttribList attribs;
|
||||||
U64 info_off;
|
U64 info_off;
|
||||||
U8 v[1];
|
U8 v[1];
|
||||||
};
|
} DW_Tag;
|
||||||
|
|
||||||
typedef struct DW_TagNode DW_TagNode;
|
typedef struct DW_TagNode
|
||||||
struct DW_TagNode
|
|
||||||
{
|
{
|
||||||
DW_Tag tag;
|
DW_Tag tag;
|
||||||
DW_TagNode *sibling;
|
struct DW_TagNode *sibling;
|
||||||
DW_TagNode *first_child;
|
struct DW_TagNode *first_child;
|
||||||
DW_TagNode *last_child;
|
struct DW_TagNode *last_child;
|
||||||
};
|
} DW_TagNode;
|
||||||
|
|
||||||
typedef struct DW_Loc DW_Loc;
|
typedef struct DW_Loc
|
||||||
struct DW_Loc
|
|
||||||
{
|
{
|
||||||
Rng1U64 range;
|
Rng1U64 range;
|
||||||
String8 expr;
|
String8 expr;
|
||||||
};
|
} DW_Loc;
|
||||||
|
|
||||||
typedef struct DW_LocNode DW_LocNode;
|
typedef struct DW_LocNode
|
||||||
struct DW_LocNode
|
|
||||||
{
|
{
|
||||||
DW_LocNode *next;
|
DW_Loc v;
|
||||||
DW_Loc v;
|
struct DW_LocNode *next;
|
||||||
};
|
} DW_LocNode;
|
||||||
|
|
||||||
typedef struct DW_LocList DW_LocList;
|
typedef struct DW_LocList
|
||||||
struct DW_LocList
|
|
||||||
{
|
{
|
||||||
|
U64 count;
|
||||||
DW_LocNode *first;
|
DW_LocNode *first;
|
||||||
DW_LocNode *last;
|
DW_LocNode *last;
|
||||||
U64 count;
|
} DW_LocList;
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct DW_CompUnit DW_CompUnit;
|
typedef struct DW_CompUnit
|
||||||
struct DW_CompUnit
|
|
||||||
{
|
{
|
||||||
|
B32 relaxed;
|
||||||
DW_Ext ext;
|
DW_Ext ext;
|
||||||
DW_CompUnitKind kind;
|
DW_CompUnitKind kind;
|
||||||
DW_Version version;
|
DW_Version version;
|
||||||
@@ -198,7 +183,7 @@ struct DW_CompUnit
|
|||||||
U64 dwo_id;
|
U64 dwo_id;
|
||||||
DW_Tag tag;
|
DW_Tag tag;
|
||||||
HashTable *tag_ht;
|
HashTable *tag_ht;
|
||||||
};
|
} DW_CompUnit;
|
||||||
|
|
||||||
typedef struct DW_TagTree
|
typedef struct DW_TagTree
|
||||||
{
|
{
|
||||||
@@ -446,10 +431,18 @@ typedef struct DW_CFA_InstList
|
|||||||
#define DW_DECODE_PTR(name) U64 name(String8 data, void *ud, U64 *ptr_out)
|
#define DW_DECODE_PTR(name) U64 name(String8 data, void *ud, U64 *ptr_out)
|
||||||
typedef DW_DECODE_PTR(DW_DecodePtr);
|
typedef DW_DECODE_PTR(DW_DecodePtr);
|
||||||
|
|
||||||
|
// hasher
|
||||||
|
|
||||||
|
internal U64 dw_hash_from_string(String8 string);
|
||||||
|
|
||||||
// deserial helpers
|
// deserial helpers
|
||||||
|
|
||||||
internal U64 dw_str8_deserial_read_packed_size(String8 string, U64 off, U64 *size_out);
|
internal U64 str8_deserial_read_dwarf_packed_size(String8 string, U64 off, U64 *size_out);
|
||||||
internal U64 dw_str8_deserial_read_fmt_uint(String8 string, U64 off, DW_Format format, U64 *uint_out);
|
internal U64 str8_deserial_read_dwarf_uint (String8 string, U64 off, DW_Format format, U64 *uint_out);
|
||||||
|
internal U64 str8_deserial_read_uleb128 (String8 string, U64 off, U64 *value_out);
|
||||||
|
internal U64 str8_deserial_read_sleb128 (String8 string, U64 off, S64 *value_out);
|
||||||
|
internal U64 str8_deserial_read_uleb128_array(Arena *arena, String8 string, U64 off, U64 count, U64 **arr_out);
|
||||||
|
internal U64 str8_deserial_read_sleb128_array(Arena *arena, String8 string, U64 off, U64 count, S64 **arr_out);
|
||||||
|
|
||||||
internal Rng1U64List dw_unit_ranges_from_data(Arena *arena, String8 data);
|
internal Rng1U64List dw_unit_ranges_from_data(Arena *arena, String8 data);
|
||||||
|
|
||||||
@@ -459,7 +452,7 @@ internal U64 dw_read_list_unit_header_addr (String8 unit_data, DW_ListUnit
|
|||||||
internal U64 dw_read_list_unit_header_str_offsets(String8 unit_data, DW_ListUnit *lu_out);
|
internal U64 dw_read_list_unit_header_str_offsets(String8 unit_data, DW_ListUnit *lu_out);
|
||||||
internal U64 dw_read_list_unit_header_list (String8 unit_data, DW_ListUnit *lu_out);
|
internal U64 dw_read_list_unit_header_list (String8 unit_data, DW_ListUnit *lu_out);
|
||||||
|
|
||||||
internal DW_ListUnitInput dw_list_unit_input_from_raw(Arena *arena, DW_Raw *input);
|
internal DW_ListUnitInput dw_list_unit_input_from_input(Arena *arena, DW_Input *input);
|
||||||
|
|
||||||
internal U64 dw_offset_from_list_unit(DW_ListUnit *lu, U64 index);
|
internal U64 dw_offset_from_list_unit(DW_ListUnit *lu, U64 index);
|
||||||
internal U64 dw_addr_from_list_unit (DW_ListUnit *lu, U64 index);
|
internal U64 dw_addr_from_list_unit (DW_ListUnit *lu, U64 index);
|
||||||
@@ -475,7 +468,7 @@ internal U64 dw_abbrev_offset_from_abbrev_id(DW_AbbrevTable table, U6
|
|||||||
|
|
||||||
internal U64 dw_read_form(String8 data, U64 off, DW_Version version, DW_Format unit_format, U64 address_size, DW_FormKind form_kind, U64 implicit_const, DW_Form *form_out);
|
internal U64 dw_read_form(String8 data, U64 off, DW_Version version, DW_Format unit_format, U64 address_size, DW_FormKind form_kind, U64 implicit_const, DW_Form *form_out);
|
||||||
internal U64 dw_read_tag (Arena *arena, String8 tag_data, U64 tag_off, U64 tag_base, DW_AbbrevTable abbrev_table, String8 abbrev_data, DW_Version version, DW_Format unit_format, U64 address_size, DW_Tag *tag_out);
|
internal U64 dw_read_tag (Arena *arena, String8 tag_data, U64 tag_off, U64 tag_base, DW_AbbrevTable abbrev_table, String8 abbrev_data, DW_Version version, DW_Format unit_format, U64 address_size, DW_Tag *tag_out);
|
||||||
internal U64 dw_read_tag_cu(Arena *arena, DW_Raw *input, DW_CompUnit *cu, U64 info_off, DW_Tag *tag_out);
|
internal U64 dw_read_tag_cu(Arena *arena, DW_Input *input, DW_CompUnit *cu, U64 info_off, DW_Tag *tag_out);
|
||||||
|
|
||||||
// attrib interp
|
// attrib interp
|
||||||
|
|
||||||
@@ -488,56 +481,56 @@ internal S64 dw_interp_const_s64 (DW_FormKind form_kind, DW_Form form)
|
|||||||
internal S32 dw_interp_const_s32 (DW_FormKind form_kind, DW_Form form);
|
internal S32 dw_interp_const_s32 (DW_FormKind form_kind, DW_Form form);
|
||||||
internal B32 dw_interp_flag (DW_FormKind form_kind, DW_Form form);
|
internal B32 dw_interp_flag (DW_FormKind form_kind, DW_Form form);
|
||||||
internal U64 dw_interp_address (U64 address_size, U64 base_addr, DW_ListUnit *addr_xlist, DW_FormKind form_kind, DW_Form form);
|
internal U64 dw_interp_address (U64 address_size, U64 base_addr, DW_ListUnit *addr_xlist, DW_FormKind form_kind, DW_Form form);
|
||||||
internal String8 dw_interp_block (DW_Raw *input, DW_CompUnit *cu, DW_FormKind form_kind, DW_Form form);
|
internal String8 dw_interp_block (DW_Input *input, DW_CompUnit *cu, DW_FormKind form_kind, DW_Form form);
|
||||||
internal String8 dw_interp_string (DW_Raw *input, DW_Format unit_format, DW_ListUnit *str_offsets, DW_FormKind form_kind, DW_Form form);
|
internal String8 dw_interp_string (DW_Input *input, DW_Format unit_format, DW_ListUnit *str_offsets, DW_FormKind form_kind, DW_Form form);
|
||||||
internal String8 dw_interp_line_ptr (DW_Raw *input, DW_FormKind form_kind, DW_Form form);
|
internal String8 dw_interp_line_ptr (DW_Input *input, DW_FormKind form_kind, DW_Form form);
|
||||||
internal DW_LineFile * dw_interp_file (DW_LineVMHeader *line_vm, DW_FormKind form_kind, DW_Form form);
|
internal DW_LineFile * dw_interp_file (DW_LineVMHeader *line_vm, DW_FormKind form_kind, DW_Form form);
|
||||||
internal DW_Reference dw_interp_ref (DW_Raw *input, DW_CompUnit *cu, DW_FormKind form_kind, DW_Form form);
|
internal DW_Reference dw_interp_ref (DW_Input *input, DW_CompUnit *cu, DW_FormKind form_kind, DW_Form form);
|
||||||
internal DW_LocList dw_interp_loclist (Arena *arena, DW_Raw *input, DW_CompUnit *cu, DW_FormKind form_kind, DW_Form form);
|
internal DW_LocList dw_interp_loclist (Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_FormKind form_kind, DW_Form form);
|
||||||
internal Rng1U64List dw_interp_rnglist (Arena *arena, DW_Raw *input, DW_CompUnit *cu, DW_FormKind form_kind, DW_Form form);
|
internal Rng1U64List dw_interp_rnglist (Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_FormKind form_kind, DW_Form form);
|
||||||
|
|
||||||
internal String8 dw_exprloc_from_attrib (DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib);
|
internal String8 dw_exprloc_from_attrib (DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib);
|
||||||
internal U128 dw_const_u128_from_attrib(DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib);
|
internal U128 dw_const_u128_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib);
|
||||||
internal U64 dw_const_u64_from_attrib (DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib);
|
internal U64 dw_const_u64_from_attrib (DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib);
|
||||||
internal U32 dw_const_u32_from_attrib (DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib);
|
internal U32 dw_const_u32_from_attrib (DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib);
|
||||||
internal S64 dw_const_s64_from_attrib (DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib);
|
internal S64 dw_const_s64_from_attrib (DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib);
|
||||||
internal S32 dw_const_s32_from_attrib (DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib);
|
internal S32 dw_const_s32_from_attrib (DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib);
|
||||||
internal B32 dw_flag_from_attrib (DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib);
|
internal B32 dw_flag_from_attrib (DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib);
|
||||||
internal U64 dw_address_from_attrib (DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib);
|
internal U64 dw_address_from_attrib (DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib);
|
||||||
internal String8 dw_block_from_attrib (DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib);
|
internal String8 dw_block_from_attrib (DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib);
|
||||||
internal String8 dw_string_from_attrib (DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib);
|
internal String8 dw_string_from_attrib (DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib);
|
||||||
internal String8 dw_line_ptr_from_attrib (DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib);
|
internal String8 dw_line_ptr_from_attrib (DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib);
|
||||||
internal DW_LineFile * dw_file_from_attrib (DW_CompUnit *cu, DW_LineVMHeader *line_vm, DW_Attrib *attrib);
|
internal DW_LineFile * dw_file_from_attrib (DW_CompUnit *cu, DW_LineVMHeader *line_vm, DW_Attrib *attrib);
|
||||||
internal DW_Reference dw_ref_from_attrib (DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib);
|
internal DW_Reference dw_ref_from_attrib (DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib);
|
||||||
internal DW_LocList dw_loclist_from_attrib (Arena *arena, DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib);
|
internal DW_LocList dw_loclist_from_attrib (Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib);
|
||||||
internal Rng1U64List dw_rnglist_from_attrib (Arena *arena, DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib);
|
internal Rng1U64List dw_rnglist_from_attrib (Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib);
|
||||||
|
|
||||||
internal String8 dw_exprloc_from_tag_attrib_kind (DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
|
internal String8 dw_exprloc_from_tag_attrib_kind (DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
|
||||||
internal U128 dw_const_u128_from_tag_attrib_kind(DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
|
internal U128 dw_const_u128_from_tag_attrib_kind(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
|
||||||
internal U64 dw_const_u64_from_tag_attrib_kind (DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
|
internal U64 dw_const_u64_from_tag_attrib_kind (DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
|
||||||
internal U32 dw_const_u32_from_tag_attrib_kind (DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
|
internal U32 dw_const_u32_from_tag_attrib_kind (DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
|
||||||
internal B32 dw_flag_from_tag_attrib_kind (DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
|
internal B32 dw_flag_from_tag_attrib_kind (DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
|
||||||
internal U64 dw_address_from_tag_attrib_kind (DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
|
internal U64 dw_address_from_tag_attrib_kind (DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
|
||||||
internal String8 dw_block_from_tag_attrib_kind (DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
|
internal String8 dw_block_from_tag_attrib_kind (DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
|
||||||
internal String8 dw_string_from_tag_attrib_kind (DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
|
internal String8 dw_string_from_tag_attrib_kind (DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
|
||||||
internal String8 dw_line_ptr_from_tag_attrib_kind (DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
|
internal String8 dw_line_ptr_from_tag_attrib_kind (DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
|
||||||
internal String8 dw_line_ptr_from_tag_attrib_kind (DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
|
internal String8 dw_line_ptr_from_tag_attrib_kind (DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
|
||||||
internal DW_LineFile * dw_file_from_tag_attrib_kind (DW_Raw *input, DW_CompUnit *cu, DW_LineVMHeader *line_vm, DW_Tag tag, DW_AttribKind kind);
|
internal DW_LineFile * dw_file_from_tag_attrib_kind (DW_Input *input, DW_CompUnit *cu, DW_LineVMHeader *line_vm, DW_Tag tag, DW_AttribKind kind);
|
||||||
internal DW_Reference dw_ref_from_tag_attrib_kind (DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
|
internal DW_Reference dw_ref_from_tag_attrib_kind (DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
|
||||||
internal DW_LocList dw_loclist_from_tag_attrib_kind (Arena *arena, DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
|
internal DW_LocList dw_loclist_from_tag_attrib_kind (Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
|
||||||
internal Rng1U64List dw_rnglist_from_tag_attrib_kind (Arena *arena, DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
|
internal Rng1U64List dw_rnglist_from_tag_attrib_kind (Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
|
||||||
|
|
||||||
// compile unit
|
// compile unit
|
||||||
|
|
||||||
internal DW_CompUnit dw_cu_from_info_off(Arena *arena, DW_Raw *input, DW_ListUnitInput lu_input, U64 offset);
|
internal DW_CompUnit dw_cu_from_info_off(Arena *arena, DW_Input *input, DW_ListUnitInput lu_input, U64 offset, B32 relaxed);
|
||||||
internal DW_TagTree dw_tag_tree_from_cu(Arena *arena, DW_Raw *input, DW_CompUnit *cu);
|
internal DW_TagTree dw_tag_tree_from_cu(Arena *arena, DW_Input *input, DW_CompUnit *cu);
|
||||||
internal HashTable * dw_make_tag_hash_table(Arena *arena, DW_TagTree tag_tree);
|
internal HashTable * dw_make_tag_hash_table(Arena *arena, DW_TagTree tag_tree);
|
||||||
internal DW_TagNode * dw_tag_node_from_info_off(DW_CompUnit *cu, U64 info_off);
|
internal DW_TagNode * dw_tag_node_from_info_off(DW_CompUnit *cu, U64 info_off);
|
||||||
|
|
||||||
// line info
|
// line info
|
||||||
|
|
||||||
internal U64 dw_read_line_file(String8 line_data, U64 line_off, DW_Raw *input, DW_Version unit_version, DW_Format unit_format, DW_Ext ext, U64 address_size, DW_ListUnit *str_offsets, U64 enc_count, U64 *enc_arr, DW_LineFile *line_file_out);
|
internal U64 dw_read_line_file(String8 line_data, U64 line_off, DW_Input *input, DW_Version unit_version, DW_Format unit_format, DW_Ext ext, U64 address_size, DW_ListUnit *str_offsets, U64 enc_count, U64 *enc_arr, DW_LineFile *line_file_out);
|
||||||
internal U64 dw_read_line_vm_header(Arena *arena, String8 line_data, U64 line_off, DW_Raw *input, String8 cu_dir, String8 cu_name, U8 cu_address_size, DW_ListUnit *cu_str_offsets, DW_LineVMHeader *header_out);
|
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);
|
||||||
internal void dw_line_vm_reset(DW_LineVMState *state, B32 default_is_stmt);
|
internal void dw_line_vm_reset(DW_LineVMState *state, B32 default_is_stmt);
|
||||||
internal void dw_line_vm_advance(DW_LineVMState *state, U64 advance, U64 min_inst_len, U64 max_ops_for_inst);
|
internal void dw_line_vm_advance(DW_LineVMState *state, U64 advance, U64 min_inst_len, U64 max_ops_for_inst);
|
||||||
internal DW_LineSeqNode * dw_push_line_seq(Arena* arena, DW_LineTableParseResult *parsed_tbl);
|
internal DW_LineSeqNode * dw_push_line_seq(Arena* arena, DW_LineTableParseResult *parsed_tbl);
|
||||||
@@ -545,11 +538,11 @@ internal DW_LineNode * dw_push_line(Arena *arena, DW_LineTableParseResult *tb
|
|||||||
internal String8 dw_path_from_file(Arena *arena, DW_LineVMHeader *vm, DW_LineFile *file);
|
internal String8 dw_path_from_file(Arena *arena, DW_LineVMHeader *vm, DW_LineFile *file);
|
||||||
internal String8 dw_path_from_file_idx(Arena *arena, DW_LineVMHeader *vm, U64 file_idx);
|
internal String8 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_Raw *input, String8 cu_dir, String8 cu_name, U8 cu_address_size, DW_ListUnit *cu_str_offsets);
|
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);
|
||||||
|
|
||||||
// helper for .debug_pubtypes and .debug_pubnames
|
// helper for .debug_pubtypes and .debug_pubnames
|
||||||
|
|
||||||
internal DW_PubStringsTable dw_v4_pub_strings_table_from_section_kind(Arena *arena, DW_Raw *input, DW_SectionKind section_kind);
|
internal DW_PubStringsTable dw_v4_pub_strings_table_from_section_kind(Arena *arena, DW_Input *input, DW_SectionKind section_kind);
|
||||||
|
|
||||||
// expression
|
// expression
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -8,8 +8,8 @@
|
|||||||
//~ Dump Subset Types
|
//~ Dump Subset Types
|
||||||
|
|
||||||
#define EH_DumpSubset_XList \
|
#define EH_DumpSubset_XList \
|
||||||
X(EhFrameHdr, eh_frame_hdr, ".eh_frame_hdr") \
|
X(EhFrameHdr, eh_frame_hdr, ".eh_frame_hdr") \
|
||||||
X(EhFrame, eh_frame, ".eh_frame")
|
X(EhFrame, eh_frame, ".eh_frame")
|
||||||
|
|
||||||
typedef enum EH_DumpSubset {
|
typedef enum EH_DumpSubset {
|
||||||
#define X(name, name_lower, title) EH_DumpSubset_##name,
|
#define X(name, name_lower, title) EH_DumpSubset_##name,
|
||||||
@@ -45,3 +45,4 @@ read_only global String8 eh_name_title_from_dump_subset_table[] =
|
|||||||
internal String8List eh_dump_list_from_data(Arena *arena, Arch arch, U64 eh_frame_hdr_vaddr, U64 eh_frame_vaddr, String8 eh_frame_hdr, String8 eh_frame, EH_DumpSubsetFlags subset_flags);
|
internal String8List eh_dump_list_from_data(Arena *arena, Arch arch, U64 eh_frame_hdr_vaddr, U64 eh_frame_vaddr, String8 eh_frame_hdr, String8 eh_frame, EH_DumpSubsetFlags subset_flags);
|
||||||
|
|
||||||
#endif // EH_FRAME_DUMP_H
|
#endif // EH_FRAME_DUMP_H
|
||||||
|
|
||||||
|
|||||||
+82
-82
@@ -21,46 +21,46 @@ eh_parse_ptr(String8 frame_base, U64 off, U64 pc, EH_PtrCtx *ptr_ctx, EH_PtrEnc
|
|||||||
U64 raw_ptr_size = 0;
|
U64 raw_ptr_size = 0;
|
||||||
U64 raw_ptr = 0;
|
U64 raw_ptr = 0;
|
||||||
switch (encoding & EH_PtrEnc_TypeMask) {
|
switch (encoding & EH_PtrEnc_TypeMask) {
|
||||||
default: { InvalidPath; } break;
|
default: { InvalidPath; } break;
|
||||||
|
|
||||||
case EH_PtrEnc_Ptr : { raw_ptr_size = 8; } goto ufixed;
|
case EH_PtrEnc_Ptr : { raw_ptr_size = 8; } goto ufixed;
|
||||||
case EH_PtrEnc_UData2: { raw_ptr_size = 2; } goto ufixed;
|
case EH_PtrEnc_UData2: { raw_ptr_size = 2; } goto ufixed;
|
||||||
case EH_PtrEnc_UData4: { raw_ptr_size = 4; } goto ufixed;
|
case EH_PtrEnc_UData4: { raw_ptr_size = 4; } goto ufixed;
|
||||||
case EH_PtrEnc_UData8: { raw_ptr_size = 8; } goto ufixed;
|
case EH_PtrEnc_UData8: { raw_ptr_size = 8; } goto ufixed;
|
||||||
ufixed: {
|
ufixed: {
|
||||||
decode_size += str8_deserial_read(frame_base, ptr_off, &raw_ptr, raw_ptr_size, raw_ptr_size);
|
decode_size += str8_deserial_read(frame_base, ptr_off, &raw_ptr, raw_ptr_size, raw_ptr_size);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
// TODO: Signed is actually just a flag that indicates this int is negavite.
|
// TODO: Signed is actually just a flag that indicates this int is negavite.
|
||||||
// There shouldn't be a read for Signed.
|
// There shouldn't be a read for Signed.
|
||||||
// For instance, (EH_PtrEnc_UData2 | EH_PtrEnc_Signed) == EH_PtrEnc_SData etc.
|
// For instance, (EH_PtrEnc_UData2 | EH_PtrEnc_Signed) == EH_PtrEnc_SData etc.
|
||||||
case EH_PtrEnc_Signed: { raw_ptr_size = 8; } goto sfixed;
|
case EH_PtrEnc_Signed: { raw_ptr_size = 8; } goto sfixed;
|
||||||
|
|
||||||
case EH_PtrEnc_SData2: { raw_ptr_size = 2; } goto sfixed;
|
case EH_PtrEnc_SData2: { raw_ptr_size = 2; } goto sfixed;
|
||||||
case EH_PtrEnc_SData4: { raw_ptr_size = 4; } goto sfixed;
|
case EH_PtrEnc_SData4: { raw_ptr_size = 4; } goto sfixed;
|
||||||
case EH_PtrEnc_SData8: { raw_ptr_size = 8; } goto sfixed;
|
case EH_PtrEnc_SData8: { raw_ptr_size = 8; } goto sfixed;
|
||||||
sfixed: {
|
sfixed: {
|
||||||
decode_size += str8_deserial_read(frame_base, ptr_off, &raw_ptr, raw_ptr_size, raw_ptr_size);
|
decode_size += str8_deserial_read(frame_base, ptr_off, &raw_ptr, raw_ptr_size, raw_ptr_size);
|
||||||
raw_ptr = extend_sign64(raw_ptr, raw_ptr_size);
|
raw_ptr = extend_sign64(raw_ptr, raw_ptr_size);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case EH_PtrEnc_ULEB128: { decode_size += str8_deserial_read_uleb128(frame_base, ptr_off, &raw_ptr); } break;
|
case EH_PtrEnc_ULEB128: { decode_size += str8_deserial_read_uleb128(frame_base, ptr_off, &raw_ptr); } break;
|
||||||
case EH_PtrEnc_SLEB128: { decode_size += str8_deserial_read_sleb128(frame_base, ptr_off, (S64*)&raw_ptr); } break;
|
case EH_PtrEnc_SLEB128: { decode_size += str8_deserial_read_sleb128(frame_base, ptr_off, (S64*)&raw_ptr); } break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// apply relative bases
|
// apply relative bases
|
||||||
if (decode_size > 0) {
|
if (decode_size > 0) {
|
||||||
U64 ptr = raw_ptr;
|
U64 ptr = raw_ptr;
|
||||||
switch (encoding & EH_PtrEnc_ModifierMask) {
|
switch (encoding & EH_PtrEnc_ModifierMask) {
|
||||||
case 0: break;
|
case 0: break;
|
||||||
case EH_PtrEnc_PcRel: { ptr = pc + raw_ptr; } break;
|
case EH_PtrEnc_PcRel: { ptr = pc + raw_ptr; } break;
|
||||||
case EH_PtrEnc_TextRel: { ptr = ptr_ctx->text_vaddr + raw_ptr; } break;
|
case EH_PtrEnc_TextRel: { ptr = ptr_ctx->text_vaddr + raw_ptr; } break;
|
||||||
case EH_PtrEnc_DataRel: { ptr = ptr_ctx->data_vaddr + raw_ptr; } break;
|
case EH_PtrEnc_DataRel: { ptr = ptr_ctx->data_vaddr + raw_ptr; } break;
|
||||||
case EH_PtrEnc_FuncRel: {
|
case EH_PtrEnc_FuncRel: {
|
||||||
Assert(!"TODO: need a sample to verify implementation");
|
Assert(!"TODO: need a sample to verify implementation");
|
||||||
ptr = ptr_ctx->func_vaddr + raw_ptr;
|
ptr = ptr_ctx->func_vaddr + raw_ptr;
|
||||||
} break;
|
} break;
|
||||||
default: { InvalidPath; } break;
|
default: { InvalidPath; } break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ptr_out) {
|
if (ptr_out) {
|
||||||
@@ -98,17 +98,17 @@ eh_parse_frame_hdr(String8 data, U64 address_size, EH_PtrCtx *ptr_ctx)
|
|||||||
cursor += eh_parse_ptr(data, cursor, cursor, ptr_ctx, header.fde_count_enc, &header.fde_count);
|
cursor += eh_parse_ptr(data, cursor, cursor, ptr_ctx, header.fde_count_enc, &header.fde_count);
|
||||||
|
|
||||||
switch (header.table_enc & EH_PtrEnc_TypeMask) {
|
switch (header.table_enc & EH_PtrEnc_TypeMask) {
|
||||||
case EH_PtrEnc_Ptr: { header.field_byte_size = address_size; } break;
|
case EH_PtrEnc_Ptr: { header.field_byte_size = address_size; } break;
|
||||||
case EH_PtrEnc_ULEB128: { InvalidPath; } break; // TODO: when loading module convert these to UData8
|
case EH_PtrEnc_ULEB128: { InvalidPath; } break; // TODO: when loading module convert these to UData8
|
||||||
case EH_PtrEnc_UData2: { header.field_byte_size = 2; } break;
|
case EH_PtrEnc_UData2: { header.field_byte_size = 2; } break;
|
||||||
case EH_PtrEnc_UData4: { header.field_byte_size = 4; } break;
|
case EH_PtrEnc_UData4: { header.field_byte_size = 4; } break;
|
||||||
case EH_PtrEnc_UData8: { header.field_byte_size = 8; } break;
|
case EH_PtrEnc_UData8: { header.field_byte_size = 8; } break;
|
||||||
case EH_PtrEnc_Signed: { header.field_byte_size = address_size; } break;
|
case EH_PtrEnc_Signed: { header.field_byte_size = address_size; } break;
|
||||||
case EH_PtrEnc_SLEB128: { InvalidPath; } break; // TODO: when loading module convert these to UData8
|
case EH_PtrEnc_SLEB128: { InvalidPath; } break; // TODO: when loading module convert these to UData8
|
||||||
case EH_PtrEnc_SData2: { header.field_byte_size = 2; } break;
|
case EH_PtrEnc_SData2: { header.field_byte_size = 2; } break;
|
||||||
case EH_PtrEnc_SData4: { header.field_byte_size = 4; } break;
|
case EH_PtrEnc_SData4: { header.field_byte_size = 4; } break;
|
||||||
case EH_PtrEnc_SData8: { header.field_byte_size = 8; } break;
|
case EH_PtrEnc_SData8: { header.field_byte_size = 8; } break;
|
||||||
default: { InvalidPath; } break;
|
default: { InvalidPath; } break;
|
||||||
}
|
}
|
||||||
header.entry_byte_size = header.field_byte_size * 2;
|
header.entry_byte_size = header.field_byte_size * 2;
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ eh_parse_frame_hdr(String8 data, U64 address_size, EH_PtrCtx *ptr_ctx)
|
|||||||
Assert(0 && "unknown version");
|
Assert(0 && "unknown version");
|
||||||
}
|
}
|
||||||
|
|
||||||
exit:;
|
exit:;
|
||||||
return header;
|
return header;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,23 +144,23 @@ eh_parse_aug_data(String8 aug_string, String8 aug_data, U64 pc, EH_PtrCtx *ptr_c
|
|||||||
|
|
||||||
for (U8 *ptr = aug_string.str+1; ptr < (aug_string.str+aug_string.size); ptr += 1) {
|
for (U8 *ptr = aug_string.str+1; ptr < (aug_string.str+aug_string.size); ptr += 1) {
|
||||||
switch (*ptr) {
|
switch (*ptr) {
|
||||||
case 'L': {
|
case 'L': {
|
||||||
cursor += str8_deserial_read_struct(aug_data, cursor, &lsda_encoding);
|
cursor += str8_deserial_read_struct(aug_data, cursor, &lsda_encoding);
|
||||||
aug_flags |= EH_AugFlag_HasLSDA;
|
aug_flags |= EH_AugFlag_HasLSDA;
|
||||||
} break;
|
} break;
|
||||||
case 'P': {
|
case 'P': {
|
||||||
cursor += str8_deserial_read_struct(aug_data, cursor, &handler_encoding);
|
cursor += str8_deserial_read_struct(aug_data, cursor, &handler_encoding);
|
||||||
cursor += eh_parse_ptr(aug_data, cursor, pc + cursor, ptr_ctx, handler_encoding, &handler_ip);
|
cursor += eh_parse_ptr(aug_data, cursor, pc + cursor, ptr_ctx, handler_encoding, &handler_ip);
|
||||||
aug_flags |= EH_AugFlag_HasHandler;
|
aug_flags |= EH_AugFlag_HasHandler;
|
||||||
} break;
|
} break;
|
||||||
case 'R': {
|
case 'R': {
|
||||||
cursor += str8_deserial_read_struct(aug_data, cursor, &addr_encoding);
|
cursor += str8_deserial_read_struct(aug_data, cursor, &addr_encoding);
|
||||||
aug_flags |= EH_AugFlag_HasAddrEnc;
|
aug_flags |= EH_AugFlag_HasAddrEnc;
|
||||||
} break;
|
} break;
|
||||||
case 'S': {
|
case 'S': {
|
||||||
aug_flags |= EH_AugFlag_SignalFrame;
|
aug_flags |= EH_AugFlag_SignalFrame;
|
||||||
} break;
|
} break;
|
||||||
default: { Assert(!"failed to parse augmentation string"); goto exit; } break;
|
default: { Assert(!"failed to parse augmentation string"); goto exit; } break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -174,7 +174,7 @@ eh_parse_aug_data(String8 aug_string, String8 aug_data, U64 pc, EH_PtrCtx *ptr_c
|
|||||||
aug_out->size = aug_data_size;
|
aug_out->size = aug_data_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
exit:;
|
exit:;
|
||||||
U64 parse_size = cursor;
|
U64 parse_size = cursor;
|
||||||
return parse_size;
|
return parse_size;
|
||||||
}
|
}
|
||||||
@@ -187,13 +187,13 @@ eh_parse_descriptor_entry_header(String8 data, U64 off, DW_DescriptorEntry *desc
|
|||||||
DW_Format format = first_four_bytes == max_U32 ? DW_Format_64Bit : DW_Format_32Bit;
|
DW_Format format = first_four_bytes == max_U32 ? DW_Format_64Bit : DW_Format_32Bit;
|
||||||
|
|
||||||
U64 length = 0;
|
U64 length = 0;
|
||||||
U64 length_size = dw_str8_deserial_read_packed_size(data, off, &length);
|
U64 length_size = str8_deserial_read_dwarf_packed_size(data, off, &length);
|
||||||
if (length_size == 0) { goto exit; }
|
if (length_size == 0) { goto exit; }
|
||||||
|
|
||||||
Rng1U64 entry_range = rng_1u64(off, off + length_size + length);
|
Rng1U64 entry_range = rng_1u64(off, off + length_size + length);
|
||||||
String8 entry_data = str8_substr(data, entry_range);
|
String8 entry_data = str8_substr(data, entry_range);
|
||||||
U64 id = 0;
|
U64 id = 0;
|
||||||
U64 id_size = dw_str8_deserial_read_fmt_uint(entry_data, length_size, format, &id);
|
U64 id_size = str8_deserial_read_dwarf_uint(entry_data, length_size, format, &id);
|
||||||
if (id_size == 0) { goto exit; }
|
if (id_size == 0) { goto exit; }
|
||||||
|
|
||||||
desc_out->format = format;
|
desc_out->format = format;
|
||||||
@@ -202,7 +202,7 @@ eh_parse_descriptor_entry_header(String8 data, U64 off, DW_DescriptorEntry *desc
|
|||||||
desc_out->cie_pointer = id;
|
desc_out->cie_pointer = id;
|
||||||
desc_out->cie_pointer_off = off + length_size;
|
desc_out->cie_pointer_off = off + length_size;
|
||||||
|
|
||||||
exit:;
|
exit:;
|
||||||
return length + length_size;
|
return length + length_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,7 +213,7 @@ eh_parse_cie(String8 data, DW_Format format, Arch arch, U64 pc, EH_PtrCtx *ptr_c
|
|||||||
U64 cursor = format == DW_Format_32Bit ? 4 : 12;
|
U64 cursor = format == DW_Format_32Bit ? 4 : 12;
|
||||||
|
|
||||||
U64 cie_id = 0;
|
U64 cie_id = 0;
|
||||||
U64 cie_id_size = dw_str8_deserial_read_fmt_uint(data, cursor, format, &cie_id);
|
U64 cie_id_size = str8_deserial_read_dwarf_uint(data, cursor, format, &cie_id);
|
||||||
if (cie_id_size == 0) { goto exit; }
|
if (cie_id_size == 0) { goto exit; }
|
||||||
cursor += cie_id_size;
|
cursor += cie_id_size;
|
||||||
|
|
||||||
@@ -286,7 +286,7 @@ eh_parse_cie(String8 data, DW_Format format, Arch arch, U64 pc, EH_PtrCtx *ptr_c
|
|||||||
}
|
}
|
||||||
|
|
||||||
is_parsed = 1;
|
is_parsed = 1;
|
||||||
exit:;
|
exit:;
|
||||||
return is_parsed;
|
return is_parsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -317,7 +317,7 @@ eh_parse_fde(String8 data, DW_Format format, U64 pc, DW_CIE *cie, EH_PtrCtx *ptr
|
|||||||
fde_out->insts = str8_skip(data, cursor);
|
fde_out->insts = str8_skip(data, cursor);
|
||||||
|
|
||||||
is_parsed = 1;
|
is_parsed = 1;
|
||||||
exit:;
|
exit:;
|
||||||
return is_parsed;
|
return is_parsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -371,7 +371,7 @@ eh_find_nearest_fde(EH_FrameHdr header, EH_PtrCtx *ptr_ctx, U64 pc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exit:;
|
exit:;
|
||||||
if (fde_idx < header.fde_count) {
|
if (fde_idx < header.fde_count) {
|
||||||
U64 fde_addr_off = (fde_idx * header.entry_byte_size) + header.field_byte_size;
|
U64 fde_addr_off = (fde_idx * header.entry_byte_size) + header.field_byte_size;
|
||||||
U64 fde_addr_size = eh_parse_ptr(header.table, fde_addr_off, ptr_ctx->pc_vaddr + fde_addr_off, ptr_ctx, header.table_enc, &fde_addr);
|
U64 fde_addr_size = eh_parse_ptr(header.table, fde_addr_off, ptr_ctx->pc_vaddr + fde_addr_off, ptr_ctx, header.table_enc, &fde_addr);
|
||||||
@@ -432,16 +432,16 @@ internal String8
|
|||||||
eh_string_from_ptr_enc_type(EH_PtrEnc type)
|
eh_string_from_ptr_enc_type(EH_PtrEnc type)
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case EH_PtrEnc_Ptr: return str8_lit("Ptr");
|
case EH_PtrEnc_Ptr: return str8_lit("Ptr");
|
||||||
case EH_PtrEnc_ULEB128: return str8_lit("ULEB128");
|
case EH_PtrEnc_ULEB128: return str8_lit("ULEB128");
|
||||||
case EH_PtrEnc_UData2: return str8_lit("UData2");
|
case EH_PtrEnc_UData2: return str8_lit("UData2");
|
||||||
case EH_PtrEnc_UData4: return str8_lit("UData4");
|
case EH_PtrEnc_UData4: return str8_lit("UData4");
|
||||||
case EH_PtrEnc_UData8: return str8_lit("UData8");
|
case EH_PtrEnc_UData8: return str8_lit("UData8");
|
||||||
case EH_PtrEnc_Signed: return str8_lit("Signed");
|
case EH_PtrEnc_Signed: return str8_lit("Signed");
|
||||||
case EH_PtrEnc_SLEB128: return str8_lit("SLEB128");
|
case EH_PtrEnc_SLEB128: return str8_lit("SLEB128");
|
||||||
case EH_PtrEnc_SData2: return str8_lit("SData2");
|
case EH_PtrEnc_SData2: return str8_lit("SData2");
|
||||||
case EH_PtrEnc_SData4: return str8_lit("SData4");
|
case EH_PtrEnc_SData4: return str8_lit("SData4");
|
||||||
case EH_PtrEnc_SData8: return str8_lit("SData8");
|
case EH_PtrEnc_SData8: return str8_lit("SData8");
|
||||||
}
|
}
|
||||||
return str8_zero();
|
return str8_zero();
|
||||||
}
|
}
|
||||||
@@ -450,11 +450,11 @@ internal String8
|
|||||||
eh_string_from_ptr_enc_modifier(EH_PtrEnc modifier)
|
eh_string_from_ptr_enc_modifier(EH_PtrEnc modifier)
|
||||||
{
|
{
|
||||||
switch (modifier) {
|
switch (modifier) {
|
||||||
case EH_PtrEnc_PcRel: return str8_lit("PcRel");
|
case EH_PtrEnc_PcRel: return str8_lit("PcRel");
|
||||||
case EH_PtrEnc_TextRel: return str8_lit("TextRel");
|
case EH_PtrEnc_TextRel: return str8_lit("TextRel");
|
||||||
case EH_PtrEnc_DataRel: return str8_lit("DataRel");
|
case EH_PtrEnc_DataRel: return str8_lit("DataRel");
|
||||||
case EH_PtrEnc_FuncRel: return str8_lit("FuncRel");
|
case EH_PtrEnc_FuncRel: return str8_lit("FuncRel");
|
||||||
case EH_PtrEnc_Aligned: return str8_lit("Aligned");
|
case EH_PtrEnc_Aligned: return str8_lit("Aligned");
|
||||||
}
|
}
|
||||||
return str8_zero();
|
return str8_zero();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,3 +123,4 @@ internal String8 eh_string_from_ptr_enc_modifier(EH_PtrEnc modifier);
|
|||||||
internal String8 eh_string_from_ptr_enc(Arena *arena, EH_PtrEnc enc);
|
internal String8 eh_string_from_ptr_enc(Arena *arena, EH_PtrEnc enc);
|
||||||
|
|
||||||
#endif // EH_FRAME_H
|
#endif // EH_FRAME_H
|
||||||
|
|
||||||
|
|||||||
+30
-127
@@ -613,10 +613,12 @@ rb_thread_entry_point(void *p)
|
|||||||
}break;
|
}break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- rjf: convert DWARF in inputs to RDI info
|
//- rjf: convert inputs to RDI info
|
||||||
B32 convert_done = 0;
|
B32 convert_done = 0;
|
||||||
|
RDIM_BakeParams pdb_bake_params = {0};
|
||||||
RDIM_BakeParams dwarf_bake_params = {0};
|
RDIM_BakeParams dwarf_bake_params = {0};
|
||||||
{
|
{
|
||||||
|
//- rjf: PE inputs w/ DWARF, or ELF inputs => DWARF -> RDI conversion
|
||||||
B32 pe_w_dwarf = (input_files_from_format_table[RB_FileFormat_PE].count != 0 &&
|
B32 pe_w_dwarf = (input_files_from_format_table[RB_FileFormat_PE].count != 0 &&
|
||||||
input_files_from_format_table[RB_FileFormat_PE].first->v->format_flags & RB_FileFormatFlag_HasDWARF);
|
input_files_from_format_table[RB_FileFormat_PE].first->v->format_flags & RB_FileFormatFlag_HasDWARF);
|
||||||
B32 elf_w_dwarf = (input_files_from_format_table[RB_FileFormat_ELF32].count != 0 ||
|
B32 elf_w_dwarf = (input_files_from_format_table[RB_FileFormat_ELF32].count != 0 ||
|
||||||
@@ -628,103 +630,7 @@ rb_thread_entry_point(void *p)
|
|||||||
else if(pe_w_dwarf) { log_infof("PEs w/ DWARF specified; converting DWARF data to RDI\n"); }
|
else if(pe_w_dwarf) { log_infof("PEs w/ DWARF specified; converting DWARF data to RDI\n"); }
|
||||||
else if(elf_w_dwarf) { log_infof("ELFs specified; converting DWARF data to RDI\n"); }
|
else if(elf_w_dwarf) { log_infof("ELFs specified; converting DWARF data to RDI\n"); }
|
||||||
|
|
||||||
// rjf: input files -> exe, exe metadata, & raw dwarf
|
|
||||||
RB_File *exe_file = &rb_file_nil;
|
|
||||||
Arch arch = Arch_Null;
|
|
||||||
U64 base_vaddr = 0;
|
|
||||||
RDIM_BinarySectionList binary_sections = {0};
|
|
||||||
DW_Raw raw = {0};
|
|
||||||
B32 got_dwarf = 0;
|
|
||||||
{
|
|
||||||
for(RB_FileNode *n = input_files.first; n != 0; n = n->next)
|
|
||||||
{
|
|
||||||
// rjf: the first PE w/ DWARF, *or* the first ELF => pick as our exectable
|
|
||||||
if(exe_file == &rb_file_nil &&
|
|
||||||
((n->v->format == RB_FileFormat_PE && n->v->format_flags & RB_FileFormatFlag_HasDWARF) ||
|
|
||||||
n->v->format == RB_FileFormat_ELF64 ||
|
|
||||||
n->v->format == RB_FileFormat_ELF32))
|
|
||||||
{
|
|
||||||
exe_file = n->v;
|
|
||||||
}
|
|
||||||
|
|
||||||
// rjf: PE => get PE info
|
|
||||||
PE_BinInfo pe = {0};
|
|
||||||
if(n->v->format == RB_FileFormat_PE)
|
|
||||||
{
|
|
||||||
pe = pe_bin_info_from_data(arena, n->v->data);
|
|
||||||
if(arch == Arch_Null)
|
|
||||||
{
|
|
||||||
arch = pe.arch;
|
|
||||||
}
|
|
||||||
if(base_vaddr == 0)
|
|
||||||
{
|
|
||||||
base_vaddr = pe.image_base;
|
|
||||||
}
|
|
||||||
if(binary_sections.count == 0)
|
|
||||||
{
|
|
||||||
String8 raw_sections = str8_substr(n->v->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(n->v->data, pe.string_table_range);
|
|
||||||
binary_sections = c2r_rdi_binary_sections_from_coff_sections(arena, n->v->data, string_table, pe.section_count, section_table);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// rjf: ELF => get ELF info
|
|
||||||
ELF_Bin elf = {0};
|
|
||||||
if(n->v->format == RB_FileFormat_ELF32 ||
|
|
||||||
n->v->format == RB_FileFormat_ELF64)
|
|
||||||
{
|
|
||||||
elf = elf_bin_from_data(arena, n->v->data);
|
|
||||||
if(arch == Arch_Null)
|
|
||||||
{
|
|
||||||
arch = arch_from_elf_machine(elf.hdr.e_machine);
|
|
||||||
}
|
|
||||||
if(base_vaddr == 0)
|
|
||||||
{
|
|
||||||
base_vaddr = elf_base_addr_from_bin(&elf);
|
|
||||||
}
|
|
||||||
if(binary_sections.count == 0)
|
|
||||||
{
|
|
||||||
binary_sections = e2r_rdi_binary_sections_from_elf_section_table(arena, n->v->data, &elf, elf.shdrs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// rjf: PE w/ DWARF => gather DWARF sections
|
|
||||||
if(!got_dwarf && n->v->format == RB_FileFormat_PE && n->v->format_flags & RB_FileFormatFlag_HasDWARF)
|
|
||||||
{
|
|
||||||
String8 raw_sections = str8_substr(n->v->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(n->v->data, pe.string_table_range);
|
|
||||||
raw = dw_raw_from_coff_section_table(arena, n->v->data, string_table, pe.section_count, section_table);
|
|
||||||
got_dwarf = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// rjf: ELF w/ DWARF => gather DWARF sections
|
|
||||||
if(!got_dwarf && (n->v->format == RB_FileFormat_ELF32 || n->v->format == RB_FileFormat_ELF64) && n->v->format_flags & RB_FileFormatFlag_HasDWARF)
|
|
||||||
{
|
|
||||||
raw = dw_raw_from_elf_bin(arena, n->v->data, &elf);
|
|
||||||
got_dwarf = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// rjf: convert (NEW)
|
|
||||||
#if 0
|
|
||||||
D2R2_ConvertParams convert_params = {0};
|
|
||||||
{
|
|
||||||
convert_params.exe_name = exe_file->path;
|
|
||||||
convert_params.exe_data = exe_file->data;
|
|
||||||
convert_params.arch = arch;
|
|
||||||
convert_params.base_vaddr = base_vaddr;
|
|
||||||
convert_params.binary_sections = binary_sections;
|
|
||||||
convert_params.raw = raw;
|
|
||||||
convert_params.subset_flags = subset_flags;
|
|
||||||
convert_params.deterministic = cmd_line_has_flag(cmdline, str8_lit("deterministic"));
|
|
||||||
}
|
|
||||||
ProfScope("convert") dwarf_bake_params = d2r2_convert(arena, &convert_params);
|
|
||||||
|
|
||||||
// rjf: convert
|
// rjf: convert
|
||||||
#else
|
|
||||||
D2R_ConvertParams convert_params = {0};
|
D2R_ConvertParams convert_params = {0};
|
||||||
{
|
{
|
||||||
B32 got_exe = 0;
|
B32 got_exe = 0;
|
||||||
@@ -804,37 +710,34 @@ rb_thread_entry_point(void *p)
|
|||||||
convert_params.deterministic = cmd_line_has_flag(cmdline, str8_lit("deterministic"));
|
convert_params.deterministic = cmd_line_has_flag(cmdline, str8_lit("deterministic"));
|
||||||
}
|
}
|
||||||
ProfScope("convert") dwarf_bake_params = d2r_convert(arena, &convert_params);
|
ProfScope("convert") dwarf_bake_params = d2r_convert(arena, &convert_params);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
lane_sync();
|
|
||||||
|
|
||||||
//- rjf: convert PDB in inputs to RDI info
|
//- rjf: PDB inputs => PDB -> RDI conversion
|
||||||
RDIM_BakeParams pdb_bake_params = {0};
|
if(input_files_from_format_table[RB_FileFormat_PDB].count != 0)
|
||||||
if(input_files_from_format_table[RB_FileFormat_PDB].count != 0)
|
|
||||||
{
|
|
||||||
convert_done = 1;
|
|
||||||
log_infof("PDBs specified; converting PDB data to RDI\n");
|
|
||||||
|
|
||||||
// rjf: get EXE/PDB file data
|
|
||||||
RB_File *exe_file = rb_file_list_first(&input_files_from_format_table[RB_FileFormat_PE]);
|
|
||||||
RB_File *pdb_file = rb_file_list_first(&input_files_from_format_table[RB_FileFormat_PDB]);
|
|
||||||
String8 exe_path = exe_file->path;
|
|
||||||
String8 pdb_path = pdb_file->path;
|
|
||||||
String8 exe_data = exe_file->data;
|
|
||||||
String8 pdb_data = pdb_file->data;
|
|
||||||
|
|
||||||
// rjf: convert
|
|
||||||
P2R_ConvertParams convert_params = {0};
|
|
||||||
{
|
{
|
||||||
convert_params.input_pdb_name = pdb_path;
|
convert_done = 1;
|
||||||
convert_params.input_exe_name = exe_path;
|
log_infof("PDBs specified; converting PDB data to RDI\n");
|
||||||
convert_params.input_pdb_data = pdb_data;
|
|
||||||
convert_params.input_exe_data = exe_data;
|
// rjf: get EXE/PDB file data
|
||||||
convert_params.subset_flags = subset_flags;
|
RB_File *exe_file = rb_file_list_first(&input_files_from_format_table[RB_FileFormat_PE]);
|
||||||
convert_params.deterministic = cmd_line_has_flag(cmdline, str8_lit("deterministic"));
|
RB_File *pdb_file = rb_file_list_first(&input_files_from_format_table[RB_FileFormat_PDB]);
|
||||||
|
String8 exe_path = exe_file->path;
|
||||||
|
String8 pdb_path = pdb_file->path;
|
||||||
|
String8 exe_data = exe_file->data;
|
||||||
|
String8 pdb_data = pdb_file->data;
|
||||||
|
|
||||||
|
// rjf: convert
|
||||||
|
P2R_ConvertParams convert_params = {0};
|
||||||
|
{
|
||||||
|
convert_params.input_pdb_name = pdb_path;
|
||||||
|
convert_params.input_exe_name = exe_path;
|
||||||
|
convert_params.input_pdb_data = pdb_data;
|
||||||
|
convert_params.input_exe_data = exe_data;
|
||||||
|
convert_params.subset_flags = subset_flags;
|
||||||
|
convert_params.deterministic = cmd_line_has_flag(cmdline, str8_lit("deterministic"));
|
||||||
|
}
|
||||||
|
ProfScope("convert") pdb_bake_params = p2r_convert(arena, &convert_params);
|
||||||
}
|
}
|
||||||
ProfScope("convert") pdb_bake_params = p2r_convert(arena, &convert_params);
|
|
||||||
}
|
}
|
||||||
lane_sync();
|
lane_sync();
|
||||||
|
|
||||||
@@ -1196,7 +1099,7 @@ rb_thread_entry_point(void *p)
|
|||||||
Arch arch = Arch_Null;
|
Arch arch = Arch_Null;
|
||||||
PE_BinInfo pe = {0};
|
PE_BinInfo pe = {0};
|
||||||
ELF_Bin elf = {0};
|
ELF_Bin elf = {0};
|
||||||
DW_Raw dw = {0};
|
DW_Input dw = {0};
|
||||||
U64 eh_frame_hdr_vaddr = 0;
|
U64 eh_frame_hdr_vaddr = 0;
|
||||||
U64 eh_frame_vaddr = 0;
|
U64 eh_frame_vaddr = 0;
|
||||||
String8 eh_frame_hdr = {0};
|
String8 eh_frame_hdr = {0};
|
||||||
@@ -1238,12 +1141,12 @@ rb_thread_entry_point(void *p)
|
|||||||
U64 section_count = raw_sections.size / sizeof(COFF_SectionHeader);
|
U64 section_count = raw_sections.size / sizeof(COFF_SectionHeader);
|
||||||
COFF_SectionHeader *section_table = (COFF_SectionHeader *)raw_sections.str;
|
COFF_SectionHeader *section_table = (COFF_SectionHeader *)raw_sections.str;
|
||||||
String8 string_table = str8_substr(f->data, pe.string_table_range);
|
String8 string_table = str8_substr(f->data, pe.string_table_range);
|
||||||
dw = dw_raw_from_coff_section_table(arena, f->data, string_table, section_count, section_table);
|
dw = dw_input_from_coff_section_table(arena, f->data, string_table, section_count, section_table);
|
||||||
}
|
}
|
||||||
else if(f->format == RB_FileFormat_ELF32 ||
|
else if(f->format == RB_FileFormat_ELF32 ||
|
||||||
f->format == RB_FileFormat_ELF64)
|
f->format == RB_FileFormat_ELF64)
|
||||||
{
|
{
|
||||||
dw = dw_raw_from_elf_bin(arena, f->data, &elf);
|
dw = dw_input_from_elf_bin(arena, f->data, &elf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,6 @@
|
|||||||
#include "rdi_from_elf/rdi_from_elf.h"
|
#include "rdi_from_elf/rdi_from_elf.h"
|
||||||
#include "rdi_from_pdb/rdi_from_pdb.h"
|
#include "rdi_from_pdb/rdi_from_pdb.h"
|
||||||
#include "rdi_from_dwarf/rdi_from_dwarf.h"
|
#include "rdi_from_dwarf/rdi_from_dwarf.h"
|
||||||
#include "rdi_from_dwarf/rdi_from_dwarf_2.h"
|
|
||||||
#include "radbin/radbin.h"
|
#include "radbin/radbin.h"
|
||||||
|
|
||||||
//- rjf: [c]
|
//- rjf: [c]
|
||||||
@@ -61,7 +60,6 @@
|
|||||||
#include "rdi_from_elf/rdi_from_elf.c"
|
#include "rdi_from_elf/rdi_from_elf.c"
|
||||||
#include "rdi_from_pdb/rdi_from_pdb.c"
|
#include "rdi_from_pdb/rdi_from_pdb.c"
|
||||||
#include "rdi_from_dwarf/rdi_from_dwarf.c"
|
#include "rdi_from_dwarf/rdi_from_dwarf.c"
|
||||||
#include "rdi_from_dwarf/rdi_from_dwarf_2.c"
|
|
||||||
#include "radbin/radbin.c"
|
#include "radbin/radbin.c"
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|||||||
+578
-731
File diff suppressed because it is too large
Load Diff
@@ -1,11 +1,7 @@
|
|||||||
// Copyright (c) Epic Games Tools
|
// Copyright (c) Epic Games Tools
|
||||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||||
|
|
||||||
#ifndef RDI_FROM_DWARF_H
|
#pragma once
|
||||||
#define RDI_FROM_DWARF_H
|
|
||||||
|
|
||||||
////////////////////////////////
|
|
||||||
//~ rjf: Conversion Stage Inputs
|
|
||||||
|
|
||||||
typedef struct D2R_ConvertParams D2R_ConvertParams;
|
typedef struct D2R_ConvertParams D2R_ConvertParams;
|
||||||
struct D2R_ConvertParams
|
struct D2R_ConvertParams
|
||||||
@@ -19,43 +15,35 @@ struct D2R_ConvertParams
|
|||||||
B32 deterministic;
|
B32 deterministic;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
typedef struct D2R_TypeTable
|
||||||
//~ rjf: Conversion Helper Types
|
|
||||||
|
|
||||||
typedef struct D2R_TypeTable D2R_TypeTable;
|
|
||||||
struct D2R_TypeTable
|
|
||||||
{
|
{
|
||||||
HashTable *ht;
|
HashTable *ht;
|
||||||
RDIM_TypeChunkList *types;
|
RDIM_TypeChunkList *types;
|
||||||
U64 type_chunk_cap;
|
U64 type_chunk_cap;
|
||||||
RDIM_Type **builtin_types;
|
RDIM_Type **builtin_types;
|
||||||
};
|
} D2R_TypeTable;
|
||||||
|
|
||||||
typedef struct D2R_TagFrame D2R_TagFrame;
|
typedef struct D2R_TagFrame
|
||||||
struct D2R_TagFrame
|
|
||||||
{
|
{
|
||||||
DW_TagNode *node;
|
DW_TagNode *node;
|
||||||
RDIM_Scope *scope;
|
RDIM_Scope *scope;
|
||||||
struct D2R_TagFrame *next;
|
struct D2R_TagFrame *next;
|
||||||
};
|
} D2R_TagFrame;
|
||||||
|
|
||||||
typedef struct D2R_TagIter D2R_TagIter;
|
typedef struct D2R_TagIterator
|
||||||
struct D2R_TagIter
|
|
||||||
{
|
{
|
||||||
D2R_TagFrame *free_list;
|
D2R_TagFrame *free_list;
|
||||||
D2R_TagFrame *stack;
|
D2R_TagFrame *stack;
|
||||||
DW_TagNode *tag_node;
|
DW_TagNode *tag_node;
|
||||||
DW_TagNode *root;
|
B32 visit_children;
|
||||||
B32 visit_children;
|
} D2R_TagIterator;
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct D2R_CompUnitContribMap D2R_CompUnitContribMap;
|
typedef struct D2R_CompUnitContribMap
|
||||||
struct D2R_CompUnitContribMap
|
|
||||||
{
|
{
|
||||||
U64 count;
|
U64 count;
|
||||||
U64 *info_off_arr;
|
U64 *info_off_arr;
|
||||||
RDIM_Rng1U64ChunkList *voff_range_arr;
|
RDIM_Rng1U64ChunkList *voff_range_arr;
|
||||||
};
|
} D2R_CompUnitContribMap;
|
||||||
|
|
||||||
#define D2R_ValueType_IsSigned(x) ((x) == D2R_ValueType_S8 || (x) == D2R_ValueType_S16 || (x) == D2R_ValueType_S32 || (x) == D2R_ValueType_S64 || (x) == D2R_ValueType_S128 || (x) == D2R_ValueType_S256 || (x) == D2R_ValueType_S512)
|
#define D2R_ValueType_IsSigned(x) ((x) == D2R_ValueType_S8 || (x) == D2R_ValueType_S16 || (x) == D2R_ValueType_S32 || (x) == D2R_ValueType_S64 || (x) == D2R_ValueType_S128 || (x) == D2R_ValueType_S256 || (x) == D2R_ValueType_S512)
|
||||||
#define D2R_ValueType_IsUnsigned(x) ((x) == D2R_ValueType_U8 || (x) == D2R_ValueType_U16 || (x) == D2R_ValueType_U32 || (x) == D2R_ValueType_U64 || (x) == D2R_ValueType_U128 || (x) == D2R_ValueType_U256 || (x) == D2R_ValueType_U512)
|
#define D2R_ValueType_IsUnsigned(x) ((x) == D2R_ValueType_U8 || (x) == D2R_ValueType_U16 || (x) == D2R_ValueType_U32 || (x) == D2R_ValueType_U64 || (x) == D2R_ValueType_U128 || (x) == D2R_ValueType_U256 || (x) == D2R_ValueType_U512)
|
||||||
@@ -113,9 +101,12 @@ internal RDI_RegCode d2r_rdi_reg_code_from_dw_reg(Arch arch, DW_Reg v);
|
|||||||
internal RDIM_Type * d2r_create_type(Arena *arena, D2R_TypeTable *type_table);
|
internal RDIM_Type * d2r_create_type(Arena *arena, D2R_TypeTable *type_table);
|
||||||
internal RDIM_Type * d2r_create_type_from_offset(Arena *arena, D2R_TypeTable *type_table, U64 info_off);
|
internal RDIM_Type * d2r_create_type_from_offset(Arena *arena, D2R_TypeTable *type_table, U64 info_off);
|
||||||
internal RDIM_Type * d2r_type_from_offset(D2R_TypeTable *type_table, U64 info_off);
|
internal RDIM_Type * d2r_type_from_offset(D2R_TypeTable *type_table, U64 info_off);
|
||||||
internal RDIM_Type * d2r_type_from_attrib(D2R_TypeTable *type_table, DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
|
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_Raw *input, DW_CompUnit *cu, U64 image_base, DW_Tag tag);
|
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_Raw *input, DW_CompUnit *cu, DW_TagNode *cur_node, U64 *param_count_out);
|
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
|
//~ RDIM Bytecode Helpers
|
||||||
@@ -141,25 +132,26 @@ internal D2R_ValueType d2r_apply_usual_arithmetic_conversions(Arena *arena, D2R_
|
|||||||
internal void d2r_push_arithmetic_op(Arena *arena, D2R_ValueTypeStack *stack, RDIM_EvalBytecode *bc, RDI_EvalOp op);
|
internal void d2r_push_arithmetic_op(Arena *arena, D2R_ValueTypeStack *stack, RDIM_EvalBytecode *bc, RDI_EvalOp op);
|
||||||
internal void d2r_push_relational_op(Arena *arena, D2R_ValueTypeStack *stack, RDIM_EvalBytecode *bc, RDI_EvalOp op);
|
internal void d2r_push_relational_op(Arena *arena, D2R_ValueTypeStack *stack, RDIM_EvalBytecode *bc, RDI_EvalOp op);
|
||||||
|
|
||||||
internal RDIM_EvalBytecode d2r_bytecode_from_expression(Arena *arena, DW_Raw *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_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_Raw *input, U64 image_base, U64 address_size, Arch arch, DW_ListUnit *addr_lu, DW_CompUnit *cu, String8 expr);
|
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_LocationCaseList d2r_locset_from_attrib(Arena *arena, RDIM_ScopeChunkList *scopes, RDIM_Scope *curr_scope, RDIM_LocationChunkList *locations, DW_Raw *input, DW_CompUnit *cu, U64 image_base, Arch arch, DW_Tag tag, DW_AttribKind kind);
|
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_var_locset_from_tag(Arena *arena, RDIM_ScopeChunkList *scopes, RDIM_Scope *curr_scope, RDIM_LocationChunkList *locations, DW_Raw *input, DW_CompUnit *cu, U64 image_base, Arch arch, DW_Tag tag);
|
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
|
//~ rjf: Compilation Unit / Scope Conversion Helpers
|
||||||
|
|
||||||
internal RDIM_Rng1U64ChunkList d2r_voff_ranges_from_cu_info_off(D2R_CompUnitContribMap map, U64 info_off);
|
internal D2R_CompUnitContribMap d2r_cu_contrib_map_from_aranges(Arena *arena, DW_Input *input, U64 image_base);
|
||||||
internal RDIM_Scope *d2r_push_scope(Arena *arena, RDIM_ScopeChunkList *scopes, U64 scope_chunk_cap, D2R_TagFrame *tag_stack, Rng1U64List ranges);
|
internal RDIM_Rng1U64ChunkList d2r_voff_ranges_from_cu_info_off(D2R_CompUnitContribMap map, U64 info_off);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ Tag Iterator
|
//~ Tag Iterator
|
||||||
|
|
||||||
internal D2R_TagIter *d2r_tag_iter_init(Arena *arena, DW_TagNode *root);
|
internal D2R_TagIterator * d2r_tag_iterator_init(Arena *arena, DW_TagNode *root);
|
||||||
internal void d2r_tag_iter_next(Arena *arena, D2R_TagIter *iter);
|
internal void d2r_tag_iterator_next(Arena *arena, D2R_TagIterator *iter);
|
||||||
internal void d2r_tag_iter_skip_children(D2R_TagIter *iter);
|
internal void d2r_tag_iterator_skip_children(D2R_TagIterator *iter);
|
||||||
internal DW_TagNode * d2r_tag_iter_parent_tag_node(D2R_TagIter *iter);
|
internal DW_TagNode * d2r_tag_iterator_parent_tag_node(D2R_TagIterator *iter);
|
||||||
internal DW_Tag d2r_tag_iter_parent_tag(D2R_TagIter *iter);
|
internal DW_Tag d2r_tag_iterator_parent_tag(D2R_TagIterator *iter);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ Type/UDT/Symbol Conversion
|
//~ Type/UDT/Symbol Conversion
|
||||||
@@ -167,15 +159,11 @@ internal DW_Tag d2r_tag_iter_parent_tag(D2R_TagIter *iter);
|
|||||||
internal void d2r_flag_converted_tag(DW_TagNode *tag_node);
|
internal void d2r_flag_converted_tag(DW_TagNode *tag_node);
|
||||||
internal B8 d2r_is_tag_converted(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_Raw *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_types(Arena *arena, D2R_TypeTable *type_table, DW_Raw *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);
|
||||||
internal void d2r_convert_udts(Arena *arena, D2R_TypeTable *type_table, DW_Raw *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, DW_Raw *input, DW_CompUnit *cu, DW_Language cu_lang, U64 arch_addr_size, U64 image_base, Arch arch, DW_TagNode *root);
|
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Main Conversion Entry Point
|
//~ rjf: Main Conversion Entry Point
|
||||||
|
|
||||||
internal RDIM_BakeParams d2r_convert(Arena *arena, D2R_ConvertParams *params);
|
internal RDIM_BakeParams d2r_convert(Arena *arena, D2R_ConvertParams *params);
|
||||||
|
|
||||||
#endif // RDI_FROM_DWARF_H
|
|
||||||
|
|||||||
@@ -1,36 +1,9 @@
|
|||||||
// Copyright (c) Epic Games Tools
|
// Copyright (c) Epic Games Tools
|
||||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||||
|
|
||||||
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
|
internal RDIM_BinarySectionList
|
||||||
e2r_rdi_binary_sections_from_elf_section_table(Arena *arena, String8 data, ELF_Bin *bin, ELF_Shdr64Array shdrs)
|
e2r_rdi_binary_sections_from_elf_section_table(Arena *arena, ELF_Shdr64Array shdrs)
|
||||||
{
|
{
|
||||||
RDIM_BinarySectionList result = {0};
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
#ifndef RDI_FROM_ELF_H
|
#ifndef RDI_FROM_ELF_H
|
||||||
#define RDI_FROM_ELF_H
|
#define RDI_FROM_ELF_H
|
||||||
|
|
||||||
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, ELF_Shdr64Array shdrs);
|
||||||
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
|
#endif // RDI_FROM_ELF_H
|
||||||
|
|||||||
@@ -17,6 +17,35 @@ rdim_data_model_from_os_arch(OperatingSystem os, RDI_Arch arch)
|
|||||||
return data_model;
|
return data_model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal RDIM_TopLevelInfo
|
||||||
|
rdim_make_top_level_info(String8 image_name, Arch arch, U64 exe_hash, RDIM_BinarySectionList sections)
|
||||||
|
{
|
||||||
|
// convert arch
|
||||||
|
RDI_Arch arch_rdi = RDI_Arch_NULL;
|
||||||
|
switch(arch)
|
||||||
|
{
|
||||||
|
default:{}break;
|
||||||
|
case Arch_x64:{arch_rdi = RDI_Arch_X64;}break;
|
||||||
|
case Arch_x86:{arch_rdi = RDI_Arch_X86;}break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// find max VOFF
|
||||||
|
U64 exe_voff_max = 0;
|
||||||
|
for EachNode(sect_n, RDIM_BinarySectionNode, sections.first)
|
||||||
|
{
|
||||||
|
exe_voff_max = Max(exe_voff_max, sect_n->v.voff_opl);
|
||||||
|
}
|
||||||
|
|
||||||
|
// fill out top level info
|
||||||
|
RDIM_TopLevelInfo top_level_info = {0};
|
||||||
|
top_level_info.arch = arch_rdi;
|
||||||
|
top_level_info.exe_hash = exe_hash;
|
||||||
|
top_level_info.voff_max = exe_voff_max;
|
||||||
|
top_level_info.producer_name = str8_lit(BUILD_TITLE_STRING_LITERAL);
|
||||||
|
|
||||||
|
return top_level_info;
|
||||||
|
}
|
||||||
|
|
||||||
internal RDIM_BakeResults
|
internal RDIM_BakeResults
|
||||||
rdim_bake(Arena *arena, RDIM_BakeParams *params)
|
rdim_bake(Arena *arena, RDIM_BakeParams *params)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -161,6 +161,7 @@ struct RDIM_Shared
|
|||||||
global RDIM_Shared *rdim_shared = 0;
|
global RDIM_Shared *rdim_shared = 0;
|
||||||
|
|
||||||
internal RDIM_DataModel rdim_data_model_from_os_arch(OperatingSystem os, RDI_Arch arch);
|
internal RDIM_DataModel rdim_data_model_from_os_arch(OperatingSystem os, RDI_Arch arch);
|
||||||
|
internal RDIM_TopLevelInfo rdim_make_top_level_info(String8 image_name, Arch arch, U64 exe_hash, RDIM_BinarySectionList sections);
|
||||||
internal RDIM_BakeResults rdim_bake(Arena *arena, RDIM_BakeParams *params);
|
internal RDIM_BakeResults rdim_bake(Arena *arena, RDIM_BakeParams *params);
|
||||||
internal RDIM_SerializedSectionBundle rdim_compress(Arena *arena, RDIM_SerializedSectionBundle *in);
|
internal RDIM_SerializedSectionBundle rdim_compress(Arena *arena, RDIM_SerializedSectionBundle *in);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user