mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-04 04:48:40 +00:00
prefix COFF machine enums with "Type"
This commit is contained in:
+17
-17
@@ -1283,7 +1283,7 @@ lnk_push_linker_symbols(LNK_SymbolTable *symtab, COFF_MachineType machine)
|
||||
LNK_Symbol *image_base = lnk_symbol_table_push_defined_chunk(symtab, str8_lit("__ImageBase"), LNK_DefinedSymbolVisibility_Extern, 0, g_null_chunk_ptr, 0, COFF_ComdatSelect_Any, 0);
|
||||
|
||||
{ // load config symbols
|
||||
if (machine == COFF_Machine_X86) {
|
||||
if (machine == COFF_MachineType_X86) {
|
||||
lnk_symbol_table_push_defined_chunk(symtab, str8_lit(LNK_SAFE_SE_HANDLER_TABLE_SYMBOL_NAME), LNK_DefinedSymbolVisibility_Extern, 0, g_null_chunk_ptr, 0, COFF_ComdatSelect_NoDuplicates, 0);
|
||||
lnk_symbol_table_push_defined_chunk(symtab, str8_lit(LNK_SAFE_SE_HANDLER_COUNT_SYMBOL_NAME), LNK_DefinedSymbolVisibility_Extern, 0, g_null_chunk_ptr, 0, COFF_ComdatSelect_NoDuplicates, 0);
|
||||
}
|
||||
@@ -1604,7 +1604,7 @@ lnk_build_guard_tables(TP_Context *tp,
|
||||
}
|
||||
|
||||
// TODO: emit table for SEH on X86
|
||||
if (machine == COFF_Machine_X86) {
|
||||
if (machine == COFF_MachineType_X86) {
|
||||
lnk_not_implemented("__safe_se_handler_table");
|
||||
lnk_not_implemented("__safe_se_handler_count");
|
||||
}
|
||||
@@ -2372,7 +2372,7 @@ lnk_build_win32_image_header(LNK_SymbolTable *symtab,
|
||||
lnk_build_pe_magic(symtab, header_sect, pe_magic_chunk);
|
||||
lnk_build_coff_file_header(symtab, header_sect, coff_file_header_chunk, config->machine, config->time_stamp, config->file_characteristics);
|
||||
switch (config->machine) {
|
||||
case COFF_Machine_X64: {
|
||||
case COFF_MachineType_X64: {
|
||||
lnk_build_pe_optional_header_x64(symtab,
|
||||
header_sect,
|
||||
pe_optional_chunk,
|
||||
@@ -3404,8 +3404,8 @@ lnk_run(int argc, char **argv)
|
||||
|
||||
String8 delay_helper_name = str8_zero();
|
||||
switch (config->machine) {
|
||||
case COFF_Machine_X86: delay_helper_name = str8_cstring(LNK_DELAY_LOAD_HELPER2_X86_SYMBOL_NAME); break;
|
||||
case COFF_Machine_X64: delay_helper_name = str8_cstring(LNK_DELAY_LOAD_HELPER2_SYMBOL_NAME); break;
|
||||
case COFF_MachineType_X86: delay_helper_name = str8_cstring(LNK_DELAY_LOAD_HELPER2_X86_SYMBOL_NAME); break;
|
||||
case COFF_MachineType_X64: delay_helper_name = str8_cstring(LNK_DELAY_LOAD_HELPER2_SYMBOL_NAME); break;
|
||||
default: NotImplemented;
|
||||
}
|
||||
|
||||
@@ -3464,7 +3464,7 @@ lnk_run(int argc, char **argv)
|
||||
|
||||
if (is_delayed) {
|
||||
if (!imptab_delayed) {
|
||||
Assert(config->machine != COFF_Machine_Unknown);
|
||||
Assert(config->machine != COFF_MachineType_Unknown);
|
||||
B32 is_unloadable = !!(config->flags & LNK_ConfigFlag_DelayUnload);
|
||||
B32 is_bindable = !!(config->flags & LNK_ConfigFlag_DelayBind);
|
||||
imptab_delayed = lnk_import_table_alloc_delayed(st, symtab, config->machine, is_unloadable, is_bindable);
|
||||
@@ -3479,7 +3479,7 @@ lnk_run(int argc, char **argv)
|
||||
}
|
||||
} else {
|
||||
if (!imptab_static) {
|
||||
Assert(config->machine != COFF_Machine_Unknown);
|
||||
Assert(config->machine != COFF_MachineType_Unknown);
|
||||
imptab_static = lnk_import_table_alloc_static(st, symtab, config->machine);
|
||||
}
|
||||
LNK_ImportDLL *dll = lnk_import_table_search_dll(imptab_static, import_header->dll_name);
|
||||
@@ -3561,14 +3561,14 @@ lnk_run(int argc, char **argv)
|
||||
LNK_Obj *obj = &obj_node_arr.v[obj_idx].data;
|
||||
|
||||
// derive machine from obj
|
||||
if (config->machine == COFF_Machine_Unknown) {
|
||||
if (config->machine == COFF_MachineType_Unknown) {
|
||||
config->machine = obj->machine;
|
||||
} else if (config->machine != COFF_Machine_X64) {
|
||||
} else if (config->machine != COFF_MachineType_X64) {
|
||||
lnk_error_with_loc(LNK_Error_UnsupportedMachine, obj->path, obj->lib_path, "%S machine is supported", coff_string_from_machine_type(obj->machine));
|
||||
} else {
|
||||
// is obj machine compatible?
|
||||
if (config->machine != obj->machine &&
|
||||
obj->machine != COFF_Machine_Unknown) { // obj with unknown machine type is compatible with any other machine type
|
||||
obj->machine != COFF_MachineType_Unknown) { // obj with unknown machine type is compatible with any other machine type
|
||||
lnk_error_obj(LNK_Error_IncompatibleObj, obj,
|
||||
"conflicting machine types expected %S but got %S",
|
||||
coff_string_from_machine_type(config->machine),
|
||||
@@ -3990,18 +3990,18 @@ lnk_run(int argc, char **argv)
|
||||
if (pdata_symbol) {
|
||||
String8 pdata = lnk_data_from_chunk_ref_no_pad(sect_id_map, image_data, pdata_symbol->u.defined.u.chunk->ref);
|
||||
switch (config->machine) {
|
||||
case COFF_Machine_X86:
|
||||
case COFF_Machine_X64: {
|
||||
case COFF_MachineType_X86:
|
||||
case COFF_MachineType_X64: {
|
||||
U64 count = pdata.size / sizeof(PE_IntelPdata);
|
||||
radsort((PE_IntelPdata *)pdata.str, count, lnk_pdata_is_before_x8664);
|
||||
} break;
|
||||
case COFF_Machine_Arm64:
|
||||
case COFF_Machine_Arm: {
|
||||
case COFF_MachineType_Arm64:
|
||||
case COFF_MachineType_Arm: {
|
||||
AssertAlways(!"TOOD: ARM");
|
||||
} break;
|
||||
case COFF_Machine_MipsFpu:
|
||||
case COFF_Machine_Mips16:
|
||||
case COFF_Machine_MipsFpu16: {
|
||||
case COFF_MachineType_MipsFpu:
|
||||
case COFF_MachineType_Mips16:
|
||||
case COFF_MachineType_MipsFpu16: {
|
||||
AssertAlways(!"TODO: MIPS");
|
||||
} break;
|
||||
}
|
||||
|
||||
+24
-24
@@ -355,11 +355,11 @@ lnk_get_default_function_pad_min(COFF_MachineType machine)
|
||||
{
|
||||
U64 function_pad_min = 0;
|
||||
switch (machine) {
|
||||
case COFF_Machine_Unknown: break;
|
||||
case COFF_Machine_X86: {
|
||||
case COFF_MachineType_Unknown: break;
|
||||
case COFF_MachineType_X86: {
|
||||
function_pad_min = 5;
|
||||
} break;
|
||||
case COFF_Machine_X64: {
|
||||
case COFF_MachineType_X64: {
|
||||
function_pad_min = 6;
|
||||
} break;
|
||||
default: {
|
||||
@@ -399,12 +399,12 @@ lnk_get_default_subsystem_version(PE_WindowsSubsystem subsystem, COFF_MachineTyp
|
||||
|
||||
case PE_WindowsSubsystem_WINDOWS_CUI: {
|
||||
switch (machine) {
|
||||
case COFF_Machine_X64:
|
||||
case COFF_Machine_X86: ver = make_version(6,0); break;
|
||||
case COFF_MachineType_X64:
|
||||
case COFF_MachineType_X86: ver = make_version(6,0); break;
|
||||
|
||||
case COFF_Machine_ArmNt:
|
||||
case COFF_Machine_Arm64:
|
||||
case COFF_Machine_Arm: ver = make_version(6,2); break;
|
||||
case COFF_MachineType_ArmNt:
|
||||
case COFF_MachineType_Arm64:
|
||||
case COFF_MachineType_Arm: ver = make_version(6,2); break;
|
||||
|
||||
default: lnk_not_implemented("define subsystem(%S) version for %S", pe_string_from_subsystem(subsystem), coff_string_from_machine_type(machine)); break;
|
||||
}
|
||||
@@ -412,12 +412,12 @@ lnk_get_default_subsystem_version(PE_WindowsSubsystem subsystem, COFF_MachineTyp
|
||||
|
||||
case PE_WindowsSubsystem_WINDOWS_GUI: {
|
||||
switch (machine) {
|
||||
case COFF_Machine_X64:
|
||||
case COFF_Machine_X86: ver = make_version(6,0); break;
|
||||
case COFF_MachineType_X64:
|
||||
case COFF_MachineType_X86: ver = make_version(6,0); break;
|
||||
|
||||
case COFF_Machine_ArmNt:
|
||||
case COFF_Machine_Arm64:
|
||||
case COFF_Machine_Arm: ver = make_version(6,2); break;
|
||||
case COFF_MachineType_ArmNt:
|
||||
case COFF_MachineType_Arm64:
|
||||
case COFF_MachineType_Arm: ver = make_version(6,2); break;
|
||||
|
||||
default: lnk_not_implemented("define subsystem(%S) version for %S", pe_string_from_subsystem(subsystem), coff_string_from_machine_type(machine)); break;
|
||||
}
|
||||
@@ -447,13 +447,13 @@ lnk_get_min_subsystem_version(PE_WindowsSubsystem subsystem, COFF_MachineType ma
|
||||
|
||||
case PE_WindowsSubsystem_WINDOWS_CUI: {
|
||||
switch (machine) {
|
||||
case COFF_Machine_X86: ver = make_version(5,1); break;
|
||||
case COFF_MachineType_X86: ver = make_version(5,1); break;
|
||||
|
||||
case COFF_Machine_X64: ver = make_version(5,2); break;
|
||||
case COFF_MachineType_X64: ver = make_version(5,2); break;
|
||||
|
||||
case COFF_Machine_ArmNt:
|
||||
case COFF_Machine_Arm64:
|
||||
case COFF_Machine_Arm: ver = make_version(6,2); break;
|
||||
case COFF_MachineType_ArmNt:
|
||||
case COFF_MachineType_Arm64:
|
||||
case COFF_MachineType_Arm: ver = make_version(6,2); break;
|
||||
|
||||
default: lnk_not_implemented("define min subsystem(%S) version for %S", pe_string_from_subsystem(subsystem), coff_string_from_machine_type(machine)); break;
|
||||
}
|
||||
@@ -461,13 +461,13 @@ lnk_get_min_subsystem_version(PE_WindowsSubsystem subsystem, COFF_MachineType ma
|
||||
|
||||
case PE_WindowsSubsystem_WINDOWS_GUI: {
|
||||
switch (machine) {
|
||||
case COFF_Machine_X86: ver = make_version(5,1); break;
|
||||
case COFF_MachineType_X86: ver = make_version(5,1); break;
|
||||
|
||||
case COFF_Machine_X64: ver = make_version(5,2); break;
|
||||
case COFF_MachineType_X64: ver = make_version(5,2); break;
|
||||
|
||||
case COFF_Machine_ArmNt:
|
||||
case COFF_Machine_Arm64:
|
||||
case COFF_Machine_Arm: ver = make_version(6,2); break;
|
||||
case COFF_MachineType_ArmNt:
|
||||
case COFF_MachineType_Arm64:
|
||||
case COFF_MachineType_Arm: ver = make_version(6,2); break;
|
||||
|
||||
default: lnk_not_implemented("define min subsystem(%S) version for %S", pe_string_from_subsystem(subsystem), coff_string_from_machine_type(machine)); break;
|
||||
}
|
||||
@@ -1213,7 +1213,7 @@ lnk_apply_cmd_option_to_config(Arena *arena, LNK_Config *config, String8 cmd_nam
|
||||
case LNK_CmdSwitch_Machine: {
|
||||
if (value_strings.node_count == 1) {
|
||||
COFF_MachineType machine = coff_machine_from_string(value_strings.first->string);
|
||||
if (machine != COFF_Machine_Unknown) {
|
||||
if (machine != COFF_MachineType_Unknown) {
|
||||
config->machine = machine;
|
||||
} else {
|
||||
lnk_error_cmd_switch(LNK_Error_Cmdl, obj_path, lib_path, cmd_switch, "unknown parameter \"%S\"", value_strings.first->string);
|
||||
|
||||
@@ -345,7 +345,7 @@ lnk_import_table_push_dll_delayed(LNK_ImportTable *imptab, LNK_SymbolTable *symt
|
||||
// emit tail merge
|
||||
LNK_Chunk *tail_merge_chunk = 0;
|
||||
switch (machine) {
|
||||
case COFF_Machine_X64: {
|
||||
case COFF_MachineType_X64: {
|
||||
LNK_Symbol *delay_load_helper_symbol = lnk_make_undefined_symbol(symtab->arena->v[0], str8_lit(LNK_DELAY_LOAD_HELPER2_SYMBOL_NAME), LNK_SymbolScopeFlag_Main);
|
||||
tail_merge_chunk = lnk_emit_tail_merge_thunk_x64(code_sect, code_chunk, imp_desc_symbol, delay_load_helper_symbol);
|
||||
} break;
|
||||
@@ -446,7 +446,7 @@ lnk_import_table_push_func_static(LNK_ImportTable *imptab, LNK_SymbolTable *symt
|
||||
LNK_Symbol *jmp_thunk_symbol = g_null_symbol_ptr;
|
||||
if (header->type == COFF_ImportHeader_Code) {
|
||||
switch (dll->machine) {
|
||||
case COFF_Machine_X64: {
|
||||
case COFF_MachineType_X64: {
|
||||
// generate jump thunk
|
||||
LNK_Chunk *jmp_thunk_chunk = lnk_emit_indirect_jump_thunk_x64(code_sect, code_table_chunk, iat_symbol);
|
||||
lnk_section_associate_chunks(data_sect, iat_chunk, jmp_thunk_chunk);
|
||||
@@ -507,7 +507,7 @@ lnk_import_table_push_func_delayed(LNK_ImportTable *imptab, LNK_SymbolTable *sym
|
||||
LNK_Chunk *load_thunk_chunk = 0;
|
||||
if (header->type == COFF_ImportHeader_Code) {
|
||||
switch (dll->machine) {
|
||||
case COFF_Machine_X64: {
|
||||
case COFF_MachineType_X64: {
|
||||
String8 iat_symbol_name = push_str8f(symtab->arena->v[0], "__imp_%S", header->func_name);
|
||||
LNK_Symbol *iat_symbol = lnk_make_undefined_symbol(symtab->arena->v[0], iat_symbol_name, LNK_SymbolScopeFlag_Main);
|
||||
|
||||
@@ -624,12 +624,12 @@ lnk_ordinal_data_from_hint(Arena *arena, COFF_MachineType machine, U16 hint)
|
||||
{
|
||||
String8 ordinal_data = str8_zero();
|
||||
switch (machine) {
|
||||
case COFF_Machine_X64: {
|
||||
case COFF_MachineType_X64: {
|
||||
U64 *ordinal = push_array(arena, U64, 1);
|
||||
*ordinal = coff_make_ordinal64(hint);
|
||||
ordinal_data = str8_struct(ordinal);
|
||||
} break;
|
||||
case COFF_Machine_X86: {
|
||||
case COFF_MachineType_X86: {
|
||||
U32 *ordinal = push_array(arena, U32, 1);
|
||||
*ordinal = coff_make_ordinal32(hint);
|
||||
ordinal_data = str8_struct(ordinal);
|
||||
|
||||
@@ -541,7 +541,7 @@ lnk_build_import_entry_obj(Arena *arena, String8 dll_name, COFF_MachineType mach
|
||||
{
|
||||
ProfBeginFunction();
|
||||
|
||||
Assert(machine == COFF_Machine_X64);
|
||||
Assert(machine == COFF_MachineType_X64);
|
||||
Assert(str8_match_lit("dll", str8_skip_last_dot(dll_name), StringMatchFlag_CaseInsensitive|StringMatchFlag_RightSideSloppy));
|
||||
|
||||
String8List list = {0};
|
||||
|
||||
@@ -117,8 +117,8 @@ lnk_ext_reloc_type_from_coff(COFF_MachineType machine, U32 type)
|
||||
{
|
||||
LNK_RelocType result = LNK_Reloc_NULL;
|
||||
switch (machine) {
|
||||
case COFF_Machine_Unknown: break;
|
||||
case COFF_Machine_X64: {
|
||||
case COFF_MachineType_Unknown: break;
|
||||
case COFF_MachineType_X64: {
|
||||
switch (type) {
|
||||
case COFF_Reloc_X64_Abs: result = LNK_Reloc_NULL; break;
|
||||
case COFF_Reloc_X64_Addr64: result = LNK_Reloc_ADDR_64; break;
|
||||
@@ -150,7 +150,7 @@ lnk_ext_reloc_type_to_coff(COFF_MachineType machine, LNK_RelocType type)
|
||||
{
|
||||
U32 result = 0;
|
||||
switch (machine) {
|
||||
case COFF_Machine_X64: {
|
||||
case COFF_MachineType_X64: {
|
||||
switch (type) {
|
||||
case LNK_Reloc_NULL: result = COFF_Reloc_X64_Abs; break;
|
||||
case LNK_Reloc_ADDR_64: result = COFF_Reloc_X64_Addr64; break;
|
||||
|
||||
@@ -236,8 +236,8 @@ lnk_code_align_byte_from_machine(COFF_MachineType machine)
|
||||
{
|
||||
U8 align_byte = 0;
|
||||
switch (machine) {
|
||||
case COFF_Machine_X64:
|
||||
case COFF_Machine_X86: {
|
||||
case COFF_MachineType_X64:
|
||||
case COFF_MachineType_X86: {
|
||||
align_byte = 0xCC;
|
||||
} break;
|
||||
default: {
|
||||
|
||||
+24
-24
@@ -5,31 +5,31 @@ internal RDI_Arch
|
||||
rdi_arch_from_coff_machine(COFF_MachineType machine)
|
||||
{
|
||||
switch (machine) {
|
||||
case COFF_Machine_X86: return RDI_Arch_X86;
|
||||
case COFF_Machine_X64: return RDI_Arch_X64;
|
||||
case COFF_MachineType_X86: return RDI_Arch_X86;
|
||||
case COFF_MachineType_X64: return RDI_Arch_X64;
|
||||
|
||||
case COFF_Machine_Unknown:
|
||||
case COFF_Machine_Am33:
|
||||
case COFF_Machine_Arm:
|
||||
case COFF_Machine_Arm64:
|
||||
case COFF_Machine_ArmNt:
|
||||
case COFF_Machine_Ebc:
|
||||
case COFF_Machine_Ia64:
|
||||
case COFF_Machine_M32R:
|
||||
case COFF_Machine_Mips16:
|
||||
case COFF_Machine_MipsFpu:
|
||||
case COFF_Machine_MipsFpu16:
|
||||
case COFF_Machine_PowerPc:
|
||||
case COFF_Machine_PowerPcFp:
|
||||
case COFF_Machine_R4000:
|
||||
case COFF_Machine_RiscV32:
|
||||
case COFF_Machine_RiscV64:
|
||||
case COFF_Machine_Sh3:
|
||||
case COFF_Machine_Sh3Dsp:
|
||||
case COFF_Machine_Sh4:
|
||||
case COFF_Machine_Sh5:
|
||||
case COFF_Machine_Thumb:
|
||||
case COFF_Machine_WceMipsV2:
|
||||
case COFF_MachineType_Unknown:
|
||||
case COFF_MachineType_Am33:
|
||||
case COFF_MachineType_Arm:
|
||||
case COFF_MachineType_Arm64:
|
||||
case COFF_MachineType_ArmNt:
|
||||
case COFF_MachineType_Ebc:
|
||||
case COFF_MachineType_Ia64:
|
||||
case COFF_MachineType_M32R:
|
||||
case COFF_MachineType_Mips16:
|
||||
case COFF_MachineType_MipsFpu:
|
||||
case COFF_MachineType_MipsFpu16:
|
||||
case COFF_MachineType_PowerPc:
|
||||
case COFF_MachineType_PowerPcFp:
|
||||
case COFF_MachineType_R4000:
|
||||
case COFF_MachineType_RiscV32:
|
||||
case COFF_MachineType_RiscV64:
|
||||
case COFF_MachineType_Sh3:
|
||||
case COFF_MachineType_Sh3Dsp:
|
||||
case COFF_MachineType_Sh4:
|
||||
case COFF_MachineType_Sh5:
|
||||
case COFF_MachineType_Thumb:
|
||||
case COFF_MachineType_WceMipsV2:
|
||||
NotImplemented;
|
||||
default:
|
||||
return RDI_Arch_NULL;
|
||||
|
||||
Reference in New Issue
Block a user