sketch out first part of new unified symbol table baking pass, sketch out new simplified sections

This commit is contained in:
Ryan Fleury
2026-04-20 09:57:29 -07:00
parent 270d73220f
commit eff693244b
7 changed files with 385 additions and 212 deletions
+10 -5
View File
@@ -10,7 +10,7 @@
#ifndef RDI_C #ifndef RDI_C
#define RDI_C #define RDI_C
RDI_U16 rdi_section_element_size_table[53] = RDI_U16 rdi_section_element_size_table[58] =
{ {
sizeof(RDI_U8), sizeof(RDI_U8),
sizeof(RDI_TopLevelInfo), sizeof(RDI_TopLevelInfo),
@@ -36,20 +36,25 @@ sizeof(RDI_UDT),
sizeof(RDI_Member), sizeof(RDI_Member),
sizeof(RDI_EnumMember), sizeof(RDI_EnumMember),
sizeof(RDI_GlobalVariable), sizeof(RDI_GlobalVariable),
sizeof(RDI_VMapEntry),
sizeof(RDI_ThreadVariable), sizeof(RDI_ThreadVariable),
sizeof(RDI_Constant), sizeof(RDI_Constant),
sizeof(RDI_Procedure), sizeof(RDI_Procedure),
sizeof(RDI_Local),
sizeof(RDI_VMapEntry),
sizeof(RDI_Scope), sizeof(RDI_Scope),
sizeof(RDI_U64), sizeof(RDI_U64),
sizeof(RDI_VMapEntry), sizeof(RDI_VMapEntry),
sizeof(RDI_InlineSite), sizeof(RDI_InlineSite),
sizeof(RDI_Local),
sizeof(RDI_LocationBlock), sizeof(RDI_LocationBlock),
sizeof(RDI_U8), sizeof(RDI_U8),
sizeof(RDI_Symbol),
sizeof(RDI_Symbol),
sizeof(RDI_Symbol),
sizeof(RDI_Symbol),
sizeof(RDI_Symbol),
sizeof(RDI_U8), sizeof(RDI_U8),
sizeof(RDI_LocationRegPlusU16), sizeof(RDI_RegAndOffsetU16),
sizeof(RDI_LocationReg), sizeof(RDI_RegCode),
sizeof(RDI_U64), sizeof(RDI_U64),
sizeof(RDI_U32), sizeof(RDI_U32),
sizeof(RDI_U64), sizeof(RDI_U64),
+82 -38
View File
@@ -99,35 +99,40 @@ RDI_SectionKind_UDTs = 0x0014,
RDI_SectionKind_Members = 0x0015, RDI_SectionKind_Members = 0x0015,
RDI_SectionKind_EnumMembers = 0x0016, RDI_SectionKind_EnumMembers = 0x0016,
RDI_SectionKind_GlobalVariables = 0x0017, RDI_SectionKind_GlobalVariables = 0x0017,
RDI_SectionKind_GlobalVMap = 0x0018, RDI_SectionKind_ThreadVariables = 0x0018,
RDI_SectionKind_ThreadVariables = 0x0019, RDI_SectionKind_Constants = 0x0019,
RDI_SectionKind_Constants = 0x001A, RDI_SectionKind_Procedures = 0x001A,
RDI_SectionKind_Procedures = 0x001B, RDI_SectionKind_Locals = 0x001B,
RDI_SectionKind_Scopes = 0x001C, RDI_SectionKind_GlobalVMap = 0x001C,
RDI_SectionKind_ScopeVOffData = 0x001D, RDI_SectionKind_Scopes = 0x001D,
RDI_SectionKind_ScopeVMap = 0x001E, RDI_SectionKind_ScopeVOffData = 0x001E,
RDI_SectionKind_InlineSites = 0x001F, RDI_SectionKind_ScopeVMap = 0x001F,
RDI_SectionKind_Locals = 0x0020, RDI_SectionKind_InlineSites = 0x0020,
RDI_SectionKind_LocationBlocks = 0x0021, RDI_SectionKind_LocationBlocks = 0x0021,
RDI_SectionKind_LocationData = 0x0022, RDI_SectionKind_LocationData = 0x0022,
RDI_SectionKind_LocationsBytecodeData = 0x0023, RDI_SectionKind_GlobalVariableSymbols = 0x0023,
RDI_SectionKind_LocationsRegPlusU16 = 0x0024, RDI_SectionKind_ThreadVariableSymbols = 0x0024,
RDI_SectionKind_LocationsReg = 0x0025, RDI_SectionKind_ConstantSymbols = 0x0025,
RDI_SectionKind_LocationsModuleOff = 0x0026, RDI_SectionKind_ProcedureSymbols = 0x0026,
RDI_SectionKind_LocationsTLSOff = 0x0027, RDI_SectionKind_LocalSymbols = 0x0027,
RDI_SectionKind_LocationsConstantDataOff = 0x0028, RDI_SectionKind_LocationsBytecodeData = 0x0028,
RDI_SectionKind_LocationsSet = 0x0029, RDI_SectionKind_LocationsRegPlusU16 = 0x0029,
RDI_SectionKind_LocationsSetElements = 0x002A, RDI_SectionKind_LocationsReg = 0x002A,
RDI_SectionKind_ConstantValueData = 0x002B, RDI_SectionKind_LocationsModuleOff = 0x002B,
RDI_SectionKind_ConstantValueTable = 0x002C, RDI_SectionKind_LocationsTLSOff = 0x002C,
RDI_SectionKind_MD5Checksums = 0x002D, RDI_SectionKind_LocationsConstantDataOff = 0x002D,
RDI_SectionKind_SHA1Checksums = 0x002E, RDI_SectionKind_LocationsSet = 0x002E,
RDI_SectionKind_SHA256Checksums = 0x002F, RDI_SectionKind_LocationsSetElements = 0x002F,
RDI_SectionKind_Timestamps = 0x0030, RDI_SectionKind_ConstantValueData = 0x0030,
RDI_SectionKind_NameMaps = 0x0031, RDI_SectionKind_ConstantValueTable = 0x0031,
RDI_SectionKind_NameMapBuckets = 0x0032, RDI_SectionKind_MD5Checksums = 0x0032,
RDI_SectionKind_NameMapNodes = 0x0033, RDI_SectionKind_SHA1Checksums = 0x0033,
RDI_SectionKind_COUNT = 0x0034, RDI_SectionKind_SHA256Checksums = 0x0034,
RDI_SectionKind_Timestamps = 0x0035,
RDI_SectionKind_NameMaps = 0x0036,
RDI_SectionKind_NameMapBuckets = 0x0037,
RDI_SectionKind_NameMapNodes = 0x0038,
RDI_SectionKind_COUNT = 0x0039,
} RDI_SectionKindEnum; } RDI_SectionKindEnum;
typedef RDI_U32 RDI_SectionEncoding; typedef RDI_U32 RDI_SectionEncoding;
@@ -564,20 +569,25 @@ X(UDTs, udts, RDI_UDT)\
X(Members, members, RDI_Member)\ X(Members, members, RDI_Member)\
X(EnumMembers, enum_members, RDI_EnumMember)\ X(EnumMembers, enum_members, RDI_EnumMember)\
X(GlobalVariables, global_variables, RDI_GlobalVariable)\ X(GlobalVariables, global_variables, RDI_GlobalVariable)\
X(GlobalVMap, global_vmap, RDI_VMapEntry)\
X(ThreadVariables, thread_variables, RDI_ThreadVariable)\ X(ThreadVariables, thread_variables, RDI_ThreadVariable)\
X(Constants, constants, RDI_Constant)\ X(Constants, constants, RDI_Constant)\
X(Procedures, procedures, RDI_Procedure)\ X(Procedures, procedures, RDI_Procedure)\
X(Locals, locals, RDI_Local)\
X(GlobalVMap, global_vmap, RDI_VMapEntry)\
X(Scopes, scopes, RDI_Scope)\ X(Scopes, scopes, RDI_Scope)\
X(ScopeVOffData, scope_voff_data, RDI_U64)\ X(ScopeVOffData, scope_voff_data, RDI_U64)\
X(ScopeVMap, scope_vmap, RDI_VMapEntry)\ X(ScopeVMap, scope_vmap, RDI_VMapEntry)\
X(InlineSites, inline_sites, RDI_InlineSite)\ X(InlineSites, inline_sites, RDI_InlineSite)\
X(Locals, locals, RDI_Local)\
X(LocationBlocks, location_blocks, RDI_LocationBlock)\ X(LocationBlocks, location_blocks, RDI_LocationBlock)\
X(LocationData, location_data, RDI_U8)\ X(LocationData, location_data, RDI_U8)\
X(GlobalVariableSymbols, global_variable_symbols, RDI_Symbol)\
X(ThreadVariableSymbols, thread_variable_symbols, RDI_Symbol)\
X(ConstantSymbols, constant_symbols, RDI_Symbol)\
X(ProcedureSymbols, procedure_symbols, RDI_Symbol)\
X(LocalSymbols, local_symbols, RDI_Symbol)\
X(LocationsBytecodeData, locations_bytecode_data, RDI_U8)\ X(LocationsBytecodeData, locations_bytecode_data, RDI_U8)\
X(LocationsRegPlusU16, locations_reg_plus_u16, RDI_LocationRegPlusU16)\ X(LocationsRegPlusU16, locations_reg_plus_u16, RDI_RegAndOffsetU16)\
X(LocationsReg, locations_reg, RDI_LocationReg)\ X(LocationsReg, locations_reg, RDI_RegCode)\
X(LocationsModuleOff, locations_module_off, RDI_U64)\ X(LocationsModuleOff, locations_module_off, RDI_U64)\
X(LocationsTLSOff, locations_tls_off, RDI_U32)\ X(LocationsTLSOff, locations_tls_off, RDI_U32)\
X(LocationsConstantDataOff, locations_constant_data_off, RDI_U64)\ X(LocationsConstantDataOff, locations_constant_data_off, RDI_U64)\
@@ -1006,13 +1016,21 @@ X(RDI_U16, offset)\
X(RDI_LocationKind, kind)\ X(RDI_LocationKind, kind)\
X(RDI_RegCode, reg_code)\ X(RDI_RegCode, reg_code)\
#define RDI_RegAndOffsetU16_XList \
X(RDI_RegCode, reg_code)\
X(RDI_U16, offset)\
#define RDI_LocationSet_XList \ #define RDI_LocationSet_XList \
X(RDI_U32, set_element_idx_first)\ X(RDI_U32, set_element_idx_first)\
X(RDI_U32, set_element_idx_opl)\ X(RDI_U32, set_element_idx_opl)\
#define RDI_LocationSetElement_XList \ #define RDI_LocationSetElement_XList \
X(RDI_LocationKind, kind)\ X(RDI_LocationKind, kind)\
X(RDI_U8, reserved_0)\
X(RDI_U16, reserved_1)\
X(RDI_U32, idx)\ X(RDI_U32, idx)\
X(RDI_U32, scope_off_first)\
X(RDI_U32, scope_off_opl)\
#define RDI_EvalOp_XList \ #define RDI_EvalOp_XList \
X(Stop)\ X(Stop)\
@@ -1134,12 +1152,17 @@ typedef struct RDI_U32_GlobalVariables { RDI_U32 v; } RDI_U32_Global
typedef struct RDI_U32_ThreadVariables { RDI_U32 v; } RDI_U32_ThreadVariables; typedef struct RDI_U32_ThreadVariables { RDI_U32 v; } RDI_U32_ThreadVariables;
typedef struct RDI_U32_Constants { RDI_U32 v; } RDI_U32_Constants; typedef struct RDI_U32_Constants { RDI_U32 v; } RDI_U32_Constants;
typedef struct RDI_U32_Procedures { RDI_U32 v; } RDI_U32_Procedures; typedef struct RDI_U32_Procedures { RDI_U32 v; } RDI_U32_Procedures;
typedef struct RDI_U32_Locals { RDI_U32 v; } RDI_U32_Locals;
typedef struct RDI_U32_Scopes { RDI_U32 v; } RDI_U32_Scopes; typedef struct RDI_U32_Scopes { RDI_U32 v; } RDI_U32_Scopes;
typedef struct RDI_U32_ScopeVOffData { RDI_U32 v; } RDI_U32_ScopeVOffData; typedef struct RDI_U32_ScopeVOffData { RDI_U32 v; } RDI_U32_ScopeVOffData;
typedef struct RDI_U32_InlineSites { RDI_U32 v; } RDI_U32_InlineSites; typedef struct RDI_U32_InlineSites { RDI_U32 v; } RDI_U32_InlineSites;
typedef struct RDI_U32_Locals { RDI_U32 v; } RDI_U32_Locals;
typedef struct RDI_U32_LocationBlocks { RDI_U32 v; } RDI_U32_LocationBlocks; typedef struct RDI_U32_LocationBlocks { RDI_U32 v; } RDI_U32_LocationBlocks;
typedef struct RDI_U32_LocationData { RDI_U32 v; } RDI_U32_LocationData; typedef struct RDI_U32_LocationData { RDI_U32 v; } RDI_U32_LocationData;
typedef struct RDI_U32_GlobalVariableSymbols { RDI_U32 v; } RDI_U32_GlobalVariableSymbols;
typedef struct RDI_U32_ThreadVariableSymbols { RDI_U32 v; } RDI_U32_ThreadVariableSymbols;
typedef struct RDI_U32_ConstantSymbols { RDI_U32 v; } RDI_U32_ConstantSymbols;
typedef struct RDI_U32_ProcedureSymbols { RDI_U32 v; } RDI_U32_ProcedureSymbols;
typedef struct RDI_U32_LocalSymbols { RDI_U32 v; } RDI_U32_LocalSymbols;
typedef struct RDI_U32_LocationsBytecodeData { RDI_U32 v; } RDI_U32_LocationsBytecodeData; typedef struct RDI_U32_LocationsBytecodeData { RDI_U32 v; } RDI_U32_LocationsBytecodeData;
typedef struct RDI_U32_LocationsRegPlusU16 { RDI_U32 v; } RDI_U32_LocationsRegPlusU16; typedef struct RDI_U32_LocationsRegPlusU16 { RDI_U32 v; } RDI_U32_LocationsRegPlusU16;
typedef struct RDI_U32_LocationsReg { RDI_U32 v; } RDI_U32_LocationsReg; typedef struct RDI_U32_LocationsReg { RDI_U32 v; } RDI_U32_LocationsReg;
@@ -1183,12 +1206,17 @@ typedef RDI_U32_Table RDI_U32_GlobalVariables;
typedef RDI_U32_Table RDI_U32_ThreadVariables; typedef RDI_U32_Table RDI_U32_ThreadVariables;
typedef RDI_U32_Table RDI_U32_Constants; typedef RDI_U32_Table RDI_U32_Constants;
typedef RDI_U32_Table RDI_U32_Procedures; typedef RDI_U32_Table RDI_U32_Procedures;
typedef RDI_U32_Table RDI_U32_Locals;
typedef RDI_U32_Table RDI_U32_Scopes; typedef RDI_U32_Table RDI_U32_Scopes;
typedef RDI_U32_Table RDI_U32_ScopeVOffData; typedef RDI_U32_Table RDI_U32_ScopeVOffData;
typedef RDI_U32_Table RDI_U32_InlineSites; typedef RDI_U32_Table RDI_U32_InlineSites;
typedef RDI_U32_Table RDI_U32_Locals;
typedef RDI_U32_Table RDI_U32_LocationBlocks; typedef RDI_U32_Table RDI_U32_LocationBlocks;
typedef RDI_U32_Table RDI_U32_LocationData; typedef RDI_U32_Table RDI_U32_LocationData;
typedef RDI_U32_Table RDI_U32_GlobalVariableSymbols;
typedef RDI_U32_Table RDI_U32_ThreadVariableSymbols;
typedef RDI_U32_Table RDI_U32_ConstantSymbols;
typedef RDI_U32_Table RDI_U32_ProcedureSymbols;
typedef RDI_U32_Table RDI_U32_LocalSymbols;
typedef RDI_U32_Table RDI_U32_LocationsBytecodeData; typedef RDI_U32_Table RDI_U32_LocationsBytecodeData;
typedef RDI_U32_Table RDI_U32_LocationsRegPlusU16; typedef RDI_U32_Table RDI_U32_LocationsRegPlusU16;
typedef RDI_U32_Table RDI_U32_LocationsReg; typedef RDI_U32_Table RDI_U32_LocationsReg;
@@ -1538,6 +1566,13 @@ RDI_LocationKind kind;
RDI_RegCode reg_code; RDI_RegCode reg_code;
}; };
typedef struct RDI_RegAndOffsetU16 RDI_RegAndOffsetU16;
struct RDI_RegAndOffsetU16
{
RDI_RegCode reg_code;
RDI_U16 offset;
};
typedef struct RDI_LocationSet RDI_LocationSet; typedef struct RDI_LocationSet RDI_LocationSet;
struct RDI_LocationSet struct RDI_LocationSet
{ {
@@ -1549,7 +1584,11 @@ typedef struct RDI_LocationSetElement RDI_LocationSetElement;
struct RDI_LocationSetElement struct RDI_LocationSetElement
{ {
RDI_LocationKind kind; RDI_LocationKind kind;
RDI_U8 reserved_0;
RDI_U16 reserved_1;
RDI_U32 idx; RDI_U32 idx;
RDI_U32 scope_off_first;
RDI_U32 scope_off_opl;
}; };
typedef struct RDI_NameMap RDI_NameMap; typedef struct RDI_NameMap RDI_NameMap;
@@ -1599,20 +1638,25 @@ typedef RDI_UDT RDI_SectionElementType_UDTs;
typedef RDI_Member RDI_SectionElementType_Members; typedef RDI_Member RDI_SectionElementType_Members;
typedef RDI_EnumMember RDI_SectionElementType_EnumMembers; typedef RDI_EnumMember RDI_SectionElementType_EnumMembers;
typedef RDI_GlobalVariable RDI_SectionElementType_GlobalVariables; typedef RDI_GlobalVariable RDI_SectionElementType_GlobalVariables;
typedef RDI_VMapEntry RDI_SectionElementType_GlobalVMap;
typedef RDI_ThreadVariable RDI_SectionElementType_ThreadVariables; typedef RDI_ThreadVariable RDI_SectionElementType_ThreadVariables;
typedef RDI_Constant RDI_SectionElementType_Constants; typedef RDI_Constant RDI_SectionElementType_Constants;
typedef RDI_Procedure RDI_SectionElementType_Procedures; typedef RDI_Procedure RDI_SectionElementType_Procedures;
typedef RDI_Local RDI_SectionElementType_Locals;
typedef RDI_VMapEntry RDI_SectionElementType_GlobalVMap;
typedef RDI_Scope RDI_SectionElementType_Scopes; typedef RDI_Scope RDI_SectionElementType_Scopes;
typedef RDI_U64 RDI_SectionElementType_ScopeVOffData; typedef RDI_U64 RDI_SectionElementType_ScopeVOffData;
typedef RDI_VMapEntry RDI_SectionElementType_ScopeVMap; typedef RDI_VMapEntry RDI_SectionElementType_ScopeVMap;
typedef RDI_InlineSite RDI_SectionElementType_InlineSites; typedef RDI_InlineSite RDI_SectionElementType_InlineSites;
typedef RDI_Local RDI_SectionElementType_Locals;
typedef RDI_LocationBlock RDI_SectionElementType_LocationBlocks; typedef RDI_LocationBlock RDI_SectionElementType_LocationBlocks;
typedef RDI_U8 RDI_SectionElementType_LocationData; typedef RDI_U8 RDI_SectionElementType_LocationData;
typedef RDI_Symbol RDI_SectionElementType_GlobalVariableSymbols;
typedef RDI_Symbol RDI_SectionElementType_ThreadVariableSymbols;
typedef RDI_Symbol RDI_SectionElementType_ConstantSymbols;
typedef RDI_Symbol RDI_SectionElementType_ProcedureSymbols;
typedef RDI_Symbol RDI_SectionElementType_LocalSymbols;
typedef RDI_U8 RDI_SectionElementType_LocationsBytecodeData; typedef RDI_U8 RDI_SectionElementType_LocationsBytecodeData;
typedef RDI_LocationRegPlusU16 RDI_SectionElementType_LocationsRegPlusU16; typedef RDI_RegAndOffsetU16 RDI_SectionElementType_LocationsRegPlusU16;
typedef RDI_LocationReg RDI_SectionElementType_LocationsReg; typedef RDI_RegCode RDI_SectionElementType_LocationsReg;
typedef RDI_U64 RDI_SectionElementType_LocationsModuleOff; typedef RDI_U64 RDI_SectionElementType_LocationsModuleOff;
typedef RDI_U32 RDI_SectionElementType_LocationsTLSOff; typedef RDI_U32 RDI_SectionElementType_LocationsTLSOff;
typedef RDI_U64 RDI_SectionElementType_LocationsConstantDataOff; typedef RDI_U64 RDI_SectionElementType_LocationsConstantDataOff;
@@ -1636,7 +1680,7 @@ RDI_PROC RDI_EvalConversionKind rdi_eval_conversion_kind_from_typegroups(RDI_Eva
RDI_PROC RDI_S32 rdi_eval_op_typegroup_are_compatible(RDI_EvalOp op, RDI_EvalTypeGroup group); RDI_PROC RDI_S32 rdi_eval_op_typegroup_are_compatible(RDI_EvalOp op, RDI_EvalTypeGroup group);
RDI_PROC RDI_U8 *rdi_explanation_string_from_eval_conversion_kind(RDI_EvalConversionKind kind, RDI_U64 *size_out); RDI_PROC RDI_U8 *rdi_explanation_string_from_eval_conversion_kind(RDI_EvalConversionKind kind, RDI_U64 *size_out);
extern RDI_U16 rdi_section_element_size_table[53]; extern RDI_U16 rdi_section_element_size_table[58];
extern RDI_U16 rdi_eval_op_ctrlbits_table[54]; extern RDI_U16 rdi_eval_op_ctrlbits_table[54];
#endif // RDI_H #endif // RDI_H
+2 -2
View File
@@ -737,9 +737,9 @@ struct RDIM_TypeNode
typedef struct RDIM_TypeList RDIM_TypeList; typedef struct RDIM_TypeList RDIM_TypeList;
struct RDIM_TypeList struct RDIM_TypeList
{ {
U64 count;
RDIM_TypeNode *first; RDIM_TypeNode *first;
RDIM_TypeNode *last; RDIM_TypeNode *last;
U64 count;
}; };
typedef struct RDIM_TypeChunkNode RDIM_TypeChunkNode; typedef struct RDIM_TypeChunkNode RDIM_TypeChunkNode;
@@ -919,7 +919,7 @@ struct RDIM_Symbol
RDIM_String8 link_name; RDIM_String8 link_name;
RDIM_Type *type; RDIM_Type *type;
RDI_U64 offset; RDI_U64 offset;
RDIM_Symbol *container_symbol; struct RDIM_Scope *container_scope;
RDIM_Type *container_type; RDIM_Type *container_type;
struct RDIM_Scope *root_scope; struct RDIM_Scope *root_scope;
RDIM_LocationCaseList location_cases; RDIM_LocationCaseList location_cases;
+87 -29
View File
@@ -136,62 +136,99 @@ RDI_HeaderMemberTable:
RDI_SectionTable: RDI_SectionTable:
{ {
{NULL null RDI_U8 0x0000 - ""} {NULL null RDI_U8 0x0000 - ""}
//- rjf: top-level-info
{TopLevelInfo top_level_info RDI_TopLevelInfo 0x0001 - ""} {TopLevelInfo top_level_info RDI_TopLevelInfo 0x0001 - ""}
//- rjf: strings
{StringData string_data RDI_U8 0x0002 - ""} {StringData string_data RDI_U8 0x0002 - ""}
{StringTable string_table RDI_U32 0x0003 U32 ""} {StringTable string_table RDI_U32 0x0003 U32 ""}
//- rjf: index runs
{IndexRuns index_runs RDI_U32 0x0004 U32 ""} {IndexRuns index_runs RDI_U32 0x0004 U32 ""}
//- rjf: binary sections
{BinarySections binary_sections RDI_BinarySection 0x0005 U32 ""} {BinarySections binary_sections RDI_BinarySection 0x0005 U32 ""}
//- rjf: filesystem / source files
{FilePathNodes file_path_nodes RDI_FilePathNode 0x0006 U32 ""} {FilePathNodes file_path_nodes RDI_FilePathNode 0x0006 U32 ""}
{SourceFiles source_files RDI_SourceFile 0x0007 U32 ""} {SourceFiles source_files RDI_SourceFile 0x0007 U32 ""}
//- rjf: voff -> line info
{LineTables line_tables RDI_LineTable 0x0008 U32 ""} {LineTables line_tables RDI_LineTable 0x0008 U32 ""}
{LineInfoVOffs line_info_voffs RDI_U64 0x0009 U32 ""} {LineInfoVOffs line_info_voffs RDI_U64 0x0009 U32 ""}
{LineInfoLines line_info_lines RDI_Line 0x000A U32 ""} {LineInfoLines line_info_lines RDI_Line 0x000A U32 ""}
{LineInfoColumns line_info_columns RDI_Column 0x000B U32 ""} {LineInfoColumns line_info_columns RDI_Column 0x000B U32 ""}
//- rjf: line -> voff info
{SourceLineMaps source_line_maps RDI_SourceLineMap 0x000C U32 ""} {SourceLineMaps source_line_maps RDI_SourceLineMap 0x000C U32 ""}
{SourceLineMapNumbers source_line_map_numbers RDI_U32 0x000D U32 ""} {SourceLineMapNumbers source_line_map_numbers RDI_U32 0x000D U32 ""}
{SourceLineMapRanges source_line_map_ranges RDI_U32 0x000E U32 ""} {SourceLineMapRanges source_line_map_ranges RDI_U32 0x000E U32 ""}
{SourceLineMapVOffs source_line_map_voffs RDI_U64 0x000F U32 ""} {SourceLineMapVOffs source_line_map_voffs RDI_U64 0x000F U32 ""}
//- rjf: units
{Units units RDI_Unit 0x0010 U32 ""} {Units units RDI_Unit 0x0010 U32 ""}
{UnitVMap unit_vmap RDI_VMapEntry 0x0011 - ""} {UnitVMap unit_vmap RDI_VMapEntry 0x0011 - ""}
//- rjf: namespaces
{Namespaces namespaces RDI_Namespace 0x0012 U32 ""} {Namespaces namespaces RDI_Namespace 0x0012 U32 ""}
//- rjf: type info
{TypeNodes type_nodes RDI_TypeNode 0x0013 U32 ""} {TypeNodes type_nodes RDI_TypeNode 0x0013 U32 ""}
{UDTs udts RDI_UDT 0x0014 U32 ""} {UDTs udts RDI_UDT 0x0014 U32 ""}
{Members members RDI_Member 0x0015 U32 ""} {Members members RDI_Member 0x0015 U32 ""}
{EnumMembers enum_members RDI_EnumMember 0x0016 U32 ""} {EnumMembers enum_members RDI_EnumMember 0x0016 U32 ""}
//- TODO(rjf): vvv old story for symbols
{GlobalVariables global_variables RDI_GlobalVariable 0x0017 U32 ""} {GlobalVariables global_variables RDI_GlobalVariable 0x0017 U32 ""}
{GlobalVMap global_vmap RDI_VMapEntry 0x0018 - ""} {ThreadVariables thread_variables RDI_ThreadVariable 0x0018 U32 ""}
{ThreadVariables thread_variables RDI_ThreadVariable 0x0019 U32 ""} {Constants constants RDI_Constant 0x0019 U32 ""}
{Constants constants RDI_Constant 0x001A U32 ""} {Procedures procedures RDI_Procedure 0x001A U32 ""}
{Procedures procedures RDI_Procedure 0x001B U32 ""} {Locals locals RDI_Local 0x001B U32 ""}
{Scopes scopes RDI_Scope 0x001C U32 ""} {GlobalVMap global_vmap RDI_VMapEntry 0x001C - ""}
{ScopeVOffData scope_voff_data RDI_U64 0x001D U32 ""}
{ScopeVMap scope_vmap RDI_VMapEntry 0x001E - ""} //- rjf: scope info
{InlineSites inline_sites RDI_InlineSite 0x001F U32 ""} {Scopes scopes RDI_Scope 0x001D U32 ""}
{Locals locals RDI_Local 0x0020 U32 ""} {ScopeVOffData scope_voff_data RDI_U64 0x001E U32 ""}
{ScopeVMap scope_vmap RDI_VMapEntry 0x001F - ""}
{InlineSites inline_sites RDI_InlineSite 0x0020 U32 ""}
//- TODO(rjf): vvv old story for locations
{LocationBlocks location_blocks RDI_LocationBlock 0x0021 U32 ""} {LocationBlocks location_blocks RDI_LocationBlock 0x0021 U32 ""}
{LocationData location_data RDI_U8 0x0022 U32 ""} {LocationData location_data RDI_U8 0x0022 U32 ""}
//- NOTE(rjf): vvv new story for locations //- NOTE(rjf): vvv new story for symbols
{LocationsBytecodeData locations_bytecode_data RDI_U8 0x0023 U32 ""} {GlobalVariableSymbols global_variable_symbols RDI_Symbol 0x0023 U32 ""}
{LocationsRegPlusU16 locations_reg_plus_u16 RDI_LocationRegPlusU16 0x0024 U32 ""} {ThreadVariableSymbols thread_variable_symbols RDI_Symbol 0x0024 U32 ""}
{LocationsReg locations_reg RDI_LocationReg 0x0025 U32 ""} {ConstantSymbols constant_symbols RDI_Symbol 0x0025 U32 ""}
{LocationsModuleOff locations_module_off RDI_U64 0x0026 U32 ""} {ProcedureSymbols procedure_symbols RDI_Symbol 0x0026 U32 ""}
{LocationsTLSOff locations_tls_off RDI_U32 0x0027 U32 ""} {LocalSymbols local_symbols RDI_Symbol 0x0027 U32 ""}
{LocationsConstantDataOff locations_constant_data_off RDI_U64 0x0028 U32 ""}
{LocationsSet locations_set RDI_LocationSet 0x0029 U32 ""}
{LocationsSetElements locations_set_elements RDI_LocationSetElement 0x002A U32 ""}
//- NOTE(rjf): ^^^
{ConstantValueData constant_value_data RDI_U8 0x002B U32 ""} //- NOTE(rjf): vvv new story for locations
{ConstantValueTable constant_value_table RDI_U32 0x002C U32 ""} {LocationsBytecodeData locations_bytecode_data RDI_U8 0x0028 U32 ""}
{MD5Checksums md5_checksums RDI_MD5 0x002D U32 ""} {LocationsRegPlusU16 locations_reg_plus_u16 RDI_RegAndOffsetU16 0x0029 U32 ""}
{SHA1Checksums sha1_checksums RDI_SHA1 0x002E U32 ""} {LocationsReg locations_reg RDI_RegCode 0x002A U32 ""}
{SHA256Checksums sha256_checksums RDI_SHA256 0x002F U32 ""} {LocationsModuleOff locations_module_off RDI_U64 0x002B U32 ""}
{Timestamps timestamps RDI_U64 0x0030 U32 ""} {LocationsTLSOff locations_tls_off RDI_U32 0x002C U32 ""}
{NameMaps name_maps RDI_NameMap 0x0031 U32 ""} {LocationsConstantDataOff locations_constant_data_off RDI_U64 0x002D U32 ""}
{NameMapBuckets name_map_buckets RDI_NameMapBucket 0x0032 U32 ""} {LocationsSet locations_set RDI_LocationSet 0x002E U32 ""}
{NameMapNodes name_map_nodes RDI_NameMapNode 0x0033 U32 ""} {LocationsSetElements locations_set_elements RDI_LocationSetElement 0x002F U32 ""}
{COUNT count RDI_U8 0x0034 - ""}
//- TODO(rjf): vvv old story for locations (constants)
{ConstantValueData constant_value_data RDI_U8 0x0030 U32 ""}
{ConstantValueTable constant_value_table RDI_U32 0x0031 U32 ""}
//- rjf: checksums / timestamps
{MD5Checksums md5_checksums RDI_MD5 0x0032 U32 ""}
{SHA1Checksums sha1_checksums RDI_SHA1 0x0033 U32 ""}
{SHA256Checksums sha256_checksums RDI_SHA256 0x0034 U32 ""}
{Timestamps timestamps RDI_U64 0x0035 U32 ""}
//- rjf: name maps
{NameMaps name_maps RDI_NameMap 0x0036 U32 ""}
{NameMapBuckets name_map_buckets RDI_NameMapBucket 0x0037 U32 ""}
{NameMapNodes name_map_nodes RDI_NameMapNode 0x0038 U32 ""}
{COUNT count RDI_U8 0x0039 - ""}
} }
@table(name value) @table(name value)
@@ -1137,6 +1174,13 @@ RDI_LocationRegMemberTable:
{reg_code RDI_RegCode } {reg_code RDI_RegCode }
} }
@table(name type desc)
RDI_RegAndOffsetU16MemberTable:
{
{reg_code RDI_RegCode }
{offset RDI_U16 }
}
@table(name type desc) @table(name type desc)
RDI_LocationSetMemberTable: RDI_LocationSetMemberTable:
{ {
@@ -1148,7 +1192,11 @@ RDI_LocationSetMemberTable:
RDI_LocationSetElementMemberTable: RDI_LocationSetElementMemberTable:
{ {
{kind RDI_LocationKind ""} {kind RDI_LocationKind ""}
{reserved_0 RDI_U8 ""}
{reserved_1 RDI_U16 ""}
{idx RDI_U32 ""} {idx RDI_U32 ""}
{scope_off_first RDI_U32 ""}
{scope_off_opl RDI_U32 ""}
} }
//- rjf: enums //- rjf: enums
@@ -1260,6 +1308,11 @@ RDI_LocationSetElementMemberTable:
@expand(RDI_LocationRegMemberTable a) `$(a.type), $(a.name)` @expand(RDI_LocationRegMemberTable a) `$(a.type), $(a.name)`
} }
@xlist RDI_RegAndOffsetU16_XList:
{
@expand(RDI_RegAndOffsetU16MemberTable a) `$(a.type), $(a.name)`
}
@xlist RDI_LocationSet_XList: @xlist RDI_LocationSet_XList:
{ {
@expand(RDI_LocationSetMemberTable a) `$(a.type), $(a.name)` @expand(RDI_LocationSetMemberTable a) `$(a.type), $(a.name)`
@@ -1337,6 +1390,11 @@ RDI_LocationSetElementMemberTable:
@expand(RDI_LocationRegMemberTable a) `$(a.type) $(a.name)` @expand(RDI_LocationRegMemberTable a) `$(a.type) $(a.name)`
} }
@struct RDI_RegAndOffsetU16:
{
@expand(RDI_RegAndOffsetU16MemberTable a) `$(a.type) $(a.name)`
}
@struct RDI_LocationSet: @struct RDI_LocationSet:
{ {
@expand(RDI_LocationSetMemberTable a) `$(a.type) $(a.name)` @expand(RDI_LocationSetMemberTable a) `$(a.type) $(a.name)`
+6 -6
View File
@@ -395,7 +395,7 @@ rdim_static_eval_bytecode_to_voff(RDIM_EvalBytecode bc, U64 image_base, U64 *vof
} }
is_ok = 1; is_ok = 1;
exit:; exit:;
scratch_end(scratch); scratch_end(scratch);
return is_ok; return is_ok;
} }
@@ -1302,7 +1302,7 @@ d2r_bytecode_from_expression(Arena *arena,
} }
is_ok = 1; is_ok = 1;
exit:; exit:;
if (!is_ok) { if (!is_ok) {
MemoryZeroStruct(&bc); MemoryZeroStruct(&bc);
temp_end(temp); temp_end(temp);
@@ -1759,7 +1759,7 @@ d2r_convert_types(Arena *arena,
// convert base type encoding to RDI version // convert base type encoding to RDI version
RDI_TypeKind kind = RDI_TypeKind_NULL; RDI_TypeKind kind = RDI_TypeKind_NULL;
#define X(t,g,s) case s: kind = RDI_TypeKind_##t; break; #define X(t,g,s) case s: kind = RDI_TypeKind_##t; break;
switch (encoding) { switch (encoding) {
case DW_ATE_Null: kind = RDI_TypeKind_NULL; break; case DW_ATE_Null: kind = RDI_TypeKind_NULL; break;
case DW_ATE_Address: kind = RDI_TypeKind_Void; break; case DW_ATE_Address: kind = RDI_TypeKind_Void; break;
@@ -1860,7 +1860,7 @@ d2r_convert_types(Arena *arena,
} break; } break;
default: log_user_errorf("unexpected base type encoding"); break; default: log_user_errorf("unexpected base type encoding"); break;
} }
#undef X #undef X
RDIM_Type *type = d2r_create_type_from_offset(arena, type_table, tag.info_off); RDIM_Type *type = d2r_create_type_from_offset(arena, type_table, tag.info_off);
type->kind = RDI_TypeKind_Alias; type->kind = RDI_TypeKind_Alias;
@@ -2392,7 +2392,7 @@ d2r_convert_symbols(Arena *arena,
proc->name = dw_string_from_tag_attrib_kind(input, cu, tag, DW_AttribKind_Name); proc->name = dw_string_from_tag_attrib_kind(input, cu, tag, DW_AttribKind_Name);
proc->link_name = dw_string_from_tag_attrib_kind(input, cu, tag, DW_AttribKind_LinkageName); proc->link_name = dw_string_from_tag_attrib_kind(input, cu, tag, DW_AttribKind_LinkageName);
proc->type = proc_type; proc->type = proc_type;
proc->container_symbol = 0; proc->container_scope = 0;
proc->container_type = container_type; proc->container_type = container_type;
proc->root_scope = root_scope; proc->root_scope = root_scope;
proc->location_cases = d2r_locset_from_attrib(arena, &g_d2r_shared.scopes, root_scope, &g_d2r_shared.locations, input, cu, image_base, arch, tag, DW_AttribKind_FrameBase); proc->location_cases = d2r_locset_from_attrib(arena, &g_d2r_shared.scopes, root_scope, &g_d2r_shared.locations, input, cu, image_base, arch, tag, DW_AttribKind_FrameBase);
@@ -2529,7 +2529,7 @@ d2r_convert_symbols(Arena *arena,
var->link_name = dw_string_from_tag_attrib_kind(input, cu, tag, DW_AttribKind_LinkageName); var->link_name = dw_string_from_tag_attrib_kind(input, cu, tag, DW_AttribKind_LinkageName);
var->type = type; var->type = type;
var->offset = voff; var->offset = voff;
var->container_symbol = 0; var->container_scope = 0;
} }
} break; } break;
case DW_TagKind_FormalParameter: { case DW_TagKind_FormalParameter: {
+11 -11
View File
@@ -3460,11 +3460,11 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
container_type = p2r_type_ptr_from_itype(cv_type_id); container_type = p2r_type_ptr_from_itype(cv_type_id);
} }
// rjf: unpack global's container symbol // rjf: unpack global's container scope
RDIM_Symbol *container_symbol = 0; RDIM_Scope *container_scope = 0;
if(container_type == 0 && top_scope_node != 0) if(container_type == 0 && top_scope_node != 0)
{ {
container_symbol = top_scope_node->scope->symbol; container_scope = top_scope_node->scope;
} }
// rjf: build symbol // rjf: build symbol
@@ -3473,7 +3473,7 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
symbol->name = name; symbol->name = name;
symbol->type = type; symbol->type = type;
symbol->offset = voff; symbol->offset = voff;
symbol->container_symbol = container_symbol; symbol->container_scope = container_scope;
symbol->container_type = container_type; symbol->container_type = container_type;
} }
}break; }break;
@@ -3516,11 +3516,11 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
container_type = p2r_type_ptr_from_itype(cv_type_id); container_type = p2r_type_ptr_from_itype(cv_type_id);
} }
// rjf: unpack proc's container symbol // rjf: unpack proc's container scope
RDIM_Symbol *container_symbol = 0; RDIM_Scope *container_scope = 0;
if(container_type == 0 && top_scope_node != 0) if(container_type == 0 && top_scope_node != 0)
{ {
container_symbol = top_scope_node->scope->symbol; container_scope = top_scope_node->scope;
} }
// rjf: build procedure's root scope // rjf: build procedure's root scope
@@ -3571,7 +3571,7 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
curr_proc_symbol->name = name; curr_proc_symbol->name = name;
curr_proc_symbol->link_name = link_name; curr_proc_symbol->link_name = link_name;
curr_proc_symbol->type = type; curr_proc_symbol->type = type;
curr_proc_symbol->container_symbol = container_symbol; curr_proc_symbol->container_scope = container_scope;
curr_proc_symbol->container_type = container_type; curr_proc_symbol->container_type = container_type;
curr_proc_symbol->root_scope = procedure_root_scope; curr_proc_symbol->root_scope = procedure_root_scope;
if(procedure_root_scope != 0) if(procedure_root_scope != 0)
@@ -3716,10 +3716,10 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
} }
// rjf: unpack thread variable's container symbol // rjf: unpack thread variable's container symbol
RDIM_Symbol *container_symbol = 0; RDIM_Scope *container_scope = 0;
if(container_type == 0 && top_scope_node != 0) if(container_type == 0 && top_scope_node != 0)
{ {
container_symbol = top_scope_node->scope->symbol; container_scope = top_scope_node->scope;
} }
// rjf: build symbol // rjf: build symbol
@@ -3729,7 +3729,7 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
tvar->is_extern = (iter.kind == CV_SymKind_GTHREAD32); tvar->is_extern = (iter.kind == CV_SymKind_GTHREAD32);
tvar->offset = tls_off; tvar->offset = tls_off;
tvar->container_type = container_type; tvar->container_type = container_type;
tvar->container_symbol = container_symbol; tvar->container_scope = container_scope;
}break; }break;
//- rjf: LOCAL //- rjf: LOCAL
+72 -6
View File
@@ -2999,10 +2999,10 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
dst->link_flags |= RDI_LinkFlag_TypeScoped; dst->link_flags |= RDI_LinkFlag_TypeScoped;
dst->container_idx = src->container_type ? (RDI_U32)rdim_idx_from_udt(src->container_type->udt) : 0; // TODO(rjf): @u64_to_u32 dst->container_idx = src->container_type ? (RDI_U32)rdim_idx_from_udt(src->container_type->udt) : 0; // TODO(rjf): @u64_to_u32
} }
else if(src->container_symbol != 0) else if(src->container_scope != 0)
{ {
dst->link_flags |= RDI_LinkFlag_ProcScoped; dst->link_flags |= RDI_LinkFlag_ProcScoped;
dst->container_idx = (RDI_U32)rdim_idx_from_symbol(src->container_symbol); // TODO(rjf): @u64_to_u32 dst->container_idx = (RDI_U32)rdim_idx_from_symbol(src->container_scope->symbol); // TODO(rjf): @u64_to_u32
} }
dst->type_idx = (RDI_U32)rdim_idx_from_type(src->type); // TODO(rjf): @u64_to_u32 dst->type_idx = (RDI_U32)rdim_idx_from_type(src->type); // TODO(rjf): @u64_to_u32
dst->root_scope_idx = (RDI_U32)rdim_idx_from_scope(src->root_scope); // TODO(rjf): @u64_to_u32 dst->root_scope_idx = (RDI_U32)rdim_idx_from_scope(src->root_scope); // TODO(rjf): @u64_to_u32
@@ -3294,10 +3294,10 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
dst->link_flags |= RDI_LinkFlag_TypeScoped; dst->link_flags |= RDI_LinkFlag_TypeScoped;
dst->container_idx = src->container_type ? (RDI_U32)rdim_idx_from_udt(src->container_type->udt) : 0; // TODO(rjf): @u64_to_u32 dst->container_idx = src->container_type ? (RDI_U32)rdim_idx_from_udt(src->container_type->udt) : 0; // TODO(rjf): @u64_to_u32
} }
else if(src->container_symbol != 0) else if(src->container_scope != 0)
{ {
dst->link_flags |= RDI_LinkFlag_ProcScoped; dst->link_flags |= RDI_LinkFlag_ProcScoped;
dst->container_idx = (RDI_U32)rdim_idx_from_symbol(src->container_symbol); // TODO(rjf): @u64_to_u32 dst->container_idx = (RDI_U32)rdim_idx_from_symbol(src->container_scope->symbol); // TODO(rjf): @u64_to_u32
} }
} }
} }
@@ -3325,10 +3325,10 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
dst->link_flags |= RDI_LinkFlag_TypeScoped; dst->link_flags |= RDI_LinkFlag_TypeScoped;
dst->container_idx = src->container_type ? (RDI_U32)rdim_idx_from_udt(src->container_type->udt) : 0; // TODO(rjf): @u64_to_u32 dst->container_idx = src->container_type ? (RDI_U32)rdim_idx_from_udt(src->container_type->udt) : 0; // TODO(rjf): @u64_to_u32
} }
else if(src->container_symbol != 0) else if(src->container_scope != 0)
{ {
dst->link_flags |= RDI_LinkFlag_ProcScoped; dst->link_flags |= RDI_LinkFlag_ProcScoped;
dst->container_idx = (RDI_U32)rdim_idx_from_symbol(src->container_symbol); // TODO(rjf): @u64_to_u32 dst->container_idx = (RDI_U32)rdim_idx_from_symbol(src->container_scope->symbol); // TODO(rjf): @u64_to_u32
} }
} }
} }
@@ -3354,6 +3354,72 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
} }
lane_sync(); lane_sync();
//////////////////////////////////////////////////////////////
//- rjf: @rdim_bake_stage bake symbols (NEW)
//
ProfScope("bake symbols")
{
////////////////////////////
//- rjf: set up all symbol table baking tasks
//
struct
{
RDIM_SymbolChunkList *symbols;
}
tasks[] =
{
{&params->global_variables},
{&params->thread_variables},
};
////////////////////////////
//- rjf: bake flat symbol tables
//
for EachElement(task_idx, tasks)
{
RDIM_SymbolChunkList *src_symbols = tasks[task_idx].symbols;
U64 dst_symbols_count = src_symbols->total_count + 1;
RDI_Symbol *dst_symbols = 0;
if(lane_idx() == 0)
{
dst_symbols = push_array(arena, RDI_Symbol, dst_symbols_count);
}
lane_sync_u64(&dst_symbols, 0);
for EachNode(n, RDIM_SymbolChunkNode, src_symbols->first)
{
Rng1U64 range = lane_range(n->count);
for EachInRange(n_idx, range)
{
RDIM_Symbol *src = &n->v[n_idx];
RDI_Symbol *dst = &dst_symbols[n->base_idx + n_idx + 1];
// rjf: fill basics
dst->name_string_idx = rdim_bake_idx_from_string(bake_strings, src->name);
dst->type_idx = (RDI_U32)rdim_idx_from_type(src->type); // TODO(rjf): @u64_to_u32
dst->root_scope_idx = (RDI_U32)rdim_idx_from_scope(src->root_scope); // TODO(rjf): @u64_to_u32
dst->link_name_string_idx = rdim_bake_idx_from_string(bake_strings, src->link_name);
// rjf: fill container info
if(src->is_extern)
{
dst->container_flags |= RDI_ContainerFlag_External;
}
if(src->container_scope != 0)
{
dst->container_flags |= RDI_ContainerKind_Scope;
dst->container_idx = rdim_idx_from_scope(src->container_scope);
}
else if(src->container_type != 0)
{
dst->container_flags |= RDI_ContainerKind_Type;
dst->container_idx = rdim_idx_from_udt(src->container_type->udt);
}
}
}
}
}
lane_sync();
////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////
//- rjf: @rdim_bake_stage bake file paths //- rjf: @rdim_bake_stage bake file paths
// //