mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-04 21:08:40 +00:00
prefix COFF machine enums with "Type"
This commit is contained in:
+11
-11
@@ -174,8 +174,8 @@ internal U64
|
||||
coff_apply_size_from_reloc(COFF_MachineType machine, COFF_RelocType x)
|
||||
{
|
||||
switch (machine) {
|
||||
case COFF_Machine_X64: return coff_apply_size_from_reloc_x64(x);
|
||||
case COFF_Machine_X86: return coff_apply_size_from_reloc_x86(x);
|
||||
case COFF_MachineType_X64: return coff_apply_size_from_reloc_x64(x);
|
||||
case COFF_MachineType_X86: return coff_apply_size_from_reloc_x86(x);
|
||||
default: NotImplemented;
|
||||
}
|
||||
return 0;
|
||||
@@ -221,7 +221,7 @@ coff_make_import_header_by_name(Arena *arena,
|
||||
flags |= COFF_ImportBy_Name << COFF_ImportHeader_ImportByShift;
|
||||
|
||||
COFF_ImportHeader header = {0};
|
||||
header.sig1 = COFF_Machine_Unknown;
|
||||
header.sig1 = COFF_MachineType_Unknown;
|
||||
header.sig2 = max_U16;
|
||||
header.version = 0;
|
||||
header.machine = machine;
|
||||
@@ -264,7 +264,7 @@ coff_make_import_header_by_ordinal(Arena *arena,
|
||||
flags |= COFF_ImportBy_Ordinal << COFF_ImportHeader_ImportByShift;
|
||||
|
||||
COFF_ImportHeader header = {0};
|
||||
header.sig1 = COFF_Machine_Unknown;
|
||||
header.sig1 = COFF_MachineType_Unknown;
|
||||
header.sig2 = max_U16;
|
||||
header.version = 0;
|
||||
header.machine = machine;
|
||||
@@ -298,8 +298,8 @@ coff_word_size_from_machine(COFF_MachineType machine)
|
||||
{
|
||||
U64 result = 0;
|
||||
switch (machine) {
|
||||
case COFF_Machine_X64: result = 8; break;
|
||||
case COFF_Machine_X86: result = 4; break;
|
||||
case COFF_MachineType_X64: result = 8; break;
|
||||
case COFF_MachineType_X86: result = 4; break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -332,11 +332,11 @@ arch_from_coff_machine(COFF_MachineType machine)
|
||||
{
|
||||
Arch result = Arch_Null;
|
||||
switch (machine) {
|
||||
case COFF_Machine_Unknown: break;
|
||||
case COFF_Machine_X86: result = Arch_x86; break;
|
||||
case COFF_Machine_X64: result = Arch_x64; break;
|
||||
case COFF_Machine_Arm: result = Arch_arm32; break;
|
||||
case COFF_Machine_Arm64: result = Arch_arm64; break;
|
||||
case COFF_MachineType_Unknown: break;
|
||||
case COFF_MachineType_X86: result = Arch_x86; break;
|
||||
case COFF_MachineType_X64: result = Arch_x64; break;
|
||||
case COFF_MachineType_Arm: result = Arch_arm32; break;
|
||||
case COFF_MachineType_Arm64: result = Arch_arm64; break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
+27
-28
@@ -47,32 +47,31 @@ enum
|
||||
typedef U16 COFF_MachineType;
|
||||
enum
|
||||
{
|
||||
// TODO(rjf): COFF_Machine prefix -> COFF_MachineType prefix
|
||||
COFF_Machine_Unknown = 0x0,
|
||||
COFF_Machine_X86 = 0x14c,
|
||||
COFF_Machine_X64 = 0x8664,
|
||||
COFF_Machine_Am33 = 0x1d3,
|
||||
COFF_Machine_Arm = 0x1c0,
|
||||
COFF_Machine_Arm64 = 0xaa64,
|
||||
COFF_Machine_ArmNt = 0x1c4,
|
||||
COFF_Machine_Ebc = 0xebc,
|
||||
COFF_Machine_Ia64 = 0x200,
|
||||
COFF_Machine_M32R = 0x9041,
|
||||
COFF_Machine_Mips16 = 0x266,
|
||||
COFF_Machine_MipsFpu = 0x366,
|
||||
COFF_Machine_MipsFpu16 = 0x466,
|
||||
COFF_Machine_PowerPc = 0x1f0,
|
||||
COFF_Machine_PowerPcFp = 0x1f1,
|
||||
COFF_Machine_R4000 = 0x166,
|
||||
COFF_Machine_RiscV32 = 0x5032,
|
||||
COFF_Machine_RiscV64 = 0x5064,
|
||||
COFF_Machine_RiscV128 = 0x5128,
|
||||
COFF_Machine_Sh3 = 0x1a2,
|
||||
COFF_Machine_Sh3Dsp = 0x1a3,
|
||||
COFF_Machine_Sh4 = 0x1a6,
|
||||
COFF_Machine_Sh5 = 0x1a8,
|
||||
COFF_Machine_Thumb = 0x1c2,
|
||||
COFF_Machine_WceMipsV2 = 0x169
|
||||
COFF_MachineType_Unknown = 0x0,
|
||||
COFF_MachineType_X86 = 0x14c,
|
||||
COFF_MachineType_X64 = 0x8664,
|
||||
COFF_MachineType_Am33 = 0x1d3,
|
||||
COFF_MachineType_Arm = 0x1c0,
|
||||
COFF_MachineType_Arm64 = 0xaa64,
|
||||
COFF_MachineType_ArmNt = 0x1c4,
|
||||
COFF_MachineType_Ebc = 0xebc,
|
||||
COFF_MachineType_Ia64 = 0x200,
|
||||
COFF_MachineType_M32R = 0x9041,
|
||||
COFF_MachineType_Mips16 = 0x266,
|
||||
COFF_MachineType_MipsFpu = 0x366,
|
||||
COFF_MachineType_MipsFpu16 = 0x466,
|
||||
COFF_MachineType_PowerPc = 0x1f0,
|
||||
COFF_MachineType_PowerPcFp = 0x1f1,
|
||||
COFF_MachineType_R4000 = 0x166,
|
||||
COFF_MachineType_RiscV32 = 0x5032,
|
||||
COFF_MachineType_RiscV64 = 0x5064,
|
||||
COFF_MachineType_RiscV128 = 0x5128,
|
||||
COFF_MachineType_Sh3 = 0x1a2,
|
||||
COFF_MachineType_Sh3Dsp = 0x1a3,
|
||||
COFF_MachineType_Sh4 = 0x1a6,
|
||||
COFF_MachineType_Sh5 = 0x1a8,
|
||||
COFF_MachineType_Thumb = 0x1c2,
|
||||
COFF_MachineType_WceMipsV2 = 0x169
|
||||
};
|
||||
|
||||
typedef struct COFF_FileHeader
|
||||
@@ -88,7 +87,7 @@ typedef struct COFF_FileHeader
|
||||
|
||||
typedef struct COFF_BigObjHeader
|
||||
{
|
||||
U16 sig1; // COFF_Machine_Unknown
|
||||
U16 sig1; // COFF_MachineType_Unknown
|
||||
U16 sig2; // max_U16
|
||||
U16 version; // 2
|
||||
COFF_MachineType machine;
|
||||
@@ -548,7 +547,7 @@ enum
|
||||
|
||||
typedef struct COFF_ImportHeader
|
||||
{
|
||||
U16 sig1; // COFF_Machine_Unknown
|
||||
U16 sig1; // COFF_MachineType_Unknown
|
||||
U16 sig2; // max_U16
|
||||
U16 version; // 0
|
||||
COFF_MachineType machine;
|
||||
|
||||
+30
-30
@@ -21,31 +21,31 @@ read_only struct
|
||||
String8 string;
|
||||
COFF_MachineType machine;
|
||||
} g_coff_machine_map[] = {
|
||||
{ str8_lit_comp(""), COFF_Machine_Unknown },
|
||||
{ str8_lit_comp("X86"), COFF_Machine_X86 },
|
||||
{ str8_lit_comp("Amd64"), COFF_Machine_X64 },
|
||||
{ str8_lit_comp("X64"), COFF_Machine_X64 },
|
||||
{ str8_lit_comp("Am33"), COFF_Machine_Am33 },
|
||||
{ str8_lit_comp("Arm"), COFF_Machine_Arm },
|
||||
{ str8_lit_comp("Arm64"), COFF_Machine_Arm64 },
|
||||
{ str8_lit_comp("ArmNt"), COFF_Machine_ArmNt },
|
||||
{ str8_lit_comp("Ebc"), COFF_Machine_Ebc },
|
||||
{ str8_lit_comp("Ia64"), COFF_Machine_Ia64 },
|
||||
{ str8_lit_comp("M32r"), COFF_Machine_M32R },
|
||||
{ str8_lit_comp("Mips16"), COFF_Machine_Mips16 },
|
||||
{ str8_lit_comp("MipsFpu"), COFF_Machine_MipsFpu },
|
||||
{ str8_lit_comp("MipsFpu16"), COFF_Machine_MipsFpu16 },
|
||||
{ str8_lit_comp("PowerPc"), COFF_Machine_PowerPc },
|
||||
{ str8_lit_comp("PowerPcFp"), COFF_Machine_PowerPcFp },
|
||||
{ str8_lit_comp("R4000"), COFF_Machine_R4000 },
|
||||
{ str8_lit_comp("RiscV32"), COFF_Machine_RiscV32 },
|
||||
{ str8_lit_comp("RiscV64"), COFF_Machine_RiscV64 },
|
||||
{ str8_lit_comp("Sh3"), COFF_Machine_Sh3 },
|
||||
{ str8_lit_comp("Sh3Dsp"), COFF_Machine_Sh3Dsp },
|
||||
{ str8_lit_comp("Sh4"), COFF_Machine_Sh4 },
|
||||
{ str8_lit_comp("Sh5"), COFF_Machine_Sh5 },
|
||||
{ str8_lit_comp("Thumb"), COFF_Machine_Thumb },
|
||||
{ str8_lit_comp("WceMipsV2"), COFF_Machine_WceMipsV2 },
|
||||
{ str8_lit_comp(""), COFF_MachineType_Unknown },
|
||||
{ str8_lit_comp("X86"), COFF_MachineType_X86 },
|
||||
{ str8_lit_comp("Amd64"), COFF_MachineType_X64 },
|
||||
{ str8_lit_comp("X64"), COFF_MachineType_X64 },
|
||||
{ str8_lit_comp("Am33"), COFF_MachineType_Am33 },
|
||||
{ str8_lit_comp("Arm"), COFF_MachineType_Arm },
|
||||
{ str8_lit_comp("Arm64"), COFF_MachineType_Arm64 },
|
||||
{ str8_lit_comp("ArmNt"), COFF_MachineType_ArmNt },
|
||||
{ str8_lit_comp("Ebc"), COFF_MachineType_Ebc },
|
||||
{ str8_lit_comp("Ia64"), COFF_MachineType_Ia64 },
|
||||
{ str8_lit_comp("M32r"), COFF_MachineType_M32R },
|
||||
{ str8_lit_comp("Mips16"), COFF_MachineType_Mips16 },
|
||||
{ str8_lit_comp("MipsFpu"), COFF_MachineType_MipsFpu },
|
||||
{ str8_lit_comp("MipsFpu16"), COFF_MachineType_MipsFpu16 },
|
||||
{ str8_lit_comp("PowerPc"), COFF_MachineType_PowerPc },
|
||||
{ str8_lit_comp("PowerPcFp"), COFF_MachineType_PowerPcFp },
|
||||
{ str8_lit_comp("R4000"), COFF_MachineType_R4000 },
|
||||
{ str8_lit_comp("RiscV32"), COFF_MachineType_RiscV32 },
|
||||
{ str8_lit_comp("RiscV64"), COFF_MachineType_RiscV64 },
|
||||
{ str8_lit_comp("Sh3"), COFF_MachineType_Sh3 },
|
||||
{ str8_lit_comp("Sh3Dsp"), COFF_MachineType_Sh3Dsp },
|
||||
{ str8_lit_comp("Sh4"), COFF_MachineType_Sh4 },
|
||||
{ str8_lit_comp("Sh5"), COFF_MachineType_Sh5 },
|
||||
{ str8_lit_comp("Thumb"), COFF_MachineType_Thumb },
|
||||
{ str8_lit_comp("WceMipsV2"), COFF_MachineType_WceMipsV2 },
|
||||
};
|
||||
|
||||
read_only static struct {
|
||||
@@ -446,10 +446,10 @@ internal String8
|
||||
coff_string_from_reloc(COFF_MachineType machine, COFF_RelocType x)
|
||||
{
|
||||
switch (machine) {
|
||||
case COFF_Machine_X86: return coff_string_from_reloc_x86(x);
|
||||
case COFF_Machine_X64: return coff_string_from_reloc_x64(x);
|
||||
case COFF_Machine_Arm: return coff_string_from_reloc_arm(x);
|
||||
case COFF_Machine_Arm64: return coff_string_from_reloc_arm64(x);
|
||||
case COFF_MachineType_X86: return coff_string_from_reloc_x86(x);
|
||||
case COFF_MachineType_X64: return coff_string_from_reloc_x64(x);
|
||||
case COFF_MachineType_Arm: return coff_string_from_reloc_arm(x);
|
||||
case COFF_MachineType_Arm64: return coff_string_from_reloc_arm64(x);
|
||||
}
|
||||
return str8_zero();
|
||||
}
|
||||
@@ -462,7 +462,7 @@ coff_machine_from_string(String8 string)
|
||||
return g_coff_machine_map[i].machine;
|
||||
}
|
||||
}
|
||||
return COFF_Machine_Unknown;
|
||||
return COFF_MachineType_Unknown;
|
||||
}
|
||||
|
||||
internal COFF_ImportType
|
||||
|
||||
+15
-15
@@ -7,7 +7,7 @@ coff_is_big_obj(String8 raw_coff)
|
||||
B32 is_big_obj = 0;
|
||||
if (raw_coff.size >= sizeof(COFF_BigObjHeader)) {
|
||||
COFF_BigObjHeader *file_header32 = (COFF_BigObjHeader*)(raw_coff.str);
|
||||
is_big_obj = file_header32->sig1 == COFF_Machine_Unknown &&
|
||||
is_big_obj = file_header32->sig1 == COFF_MachineType_Unknown &&
|
||||
file_header32->sig2 == max_U16 &&
|
||||
file_header32->version >= 2 &&
|
||||
MemoryCompare(file_header32->magic, g_coff_big_header_magic, sizeof(file_header32->magic)) == 0;
|
||||
@@ -26,19 +26,19 @@ coff_is_obj(String8 raw_coff)
|
||||
// validate machine
|
||||
B32 is_machine_type_valid = 0;
|
||||
switch (header->machine) {
|
||||
case COFF_Machine_Unknown:
|
||||
case COFF_Machine_X86: case COFF_Machine_X64:
|
||||
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_RiscV128:
|
||||
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_X86: case COFF_MachineType_X64:
|
||||
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_RiscV128:
|
||||
case COFF_MachineType_Sh3: case COFF_MachineType_Sh3Dsp:
|
||||
case COFF_MachineType_Sh4: case COFF_MachineType_Sh5:
|
||||
case COFF_MachineType_Thumb: case COFF_MachineType_WceMipsV2:
|
||||
{
|
||||
is_machine_type_valid = 1;
|
||||
}break;
|
||||
@@ -499,7 +499,7 @@ coff_is_import(String8 raw_archive_member)
|
||||
if (raw_archive_member.size >= sizeof(U16)*2) {
|
||||
U16 *sig1 = (U16*)raw_archive_member.str;
|
||||
U16 *sig2 = sig1 + 1;
|
||||
is_import = *sig1 == COFF_Machine_Unknown && *sig2 == 0xffff;
|
||||
is_import = *sig1 == COFF_MachineType_Unknown && *sig2 == 0xffff;
|
||||
}
|
||||
return is_import;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user