diff --git a/src/eval/eval_core.h b/src/eval/eval_core.h index ddddebe1..87638a63 100644 --- a/src/eval/eval_core.h +++ b/src/eval/eval_core.h @@ -1278,7 +1278,7 @@ internal E_DbgInfo *e_dbg_info_from_type_key(E_TypeKey type_key); // // key // ________________________________________________ -// / / | \ +// _/ / | \_ // text -> expression -> ir tree and type -> interpretation result // // Each one of these calls refers to one stage in this pipeline. The cache will diff --git a/src/linux/base/linux_base.h b/src/linux/base/linux_base.h index b5cce089..b35c175a 100644 --- a/src/linux/base/linux_base.h +++ b/src/linux/base/linux_base.h @@ -37,9 +37,9 @@ // NOTE(rjf): this is required because we need to use architecture-specific code for "base" // OS functionality - we may want to reevaluate if such things should be in base - but for -// now just pulling in the whole x64 layer, just for linux. +// now just pulling in this portion ox 64, just for linux. #if ARCH_X64 || ARCH_X86 -# include "x64/x64.h" +# include "x64/x64_exceptions.h" #endif pid_t gettid(void); diff --git a/src/radbin/radbin_main.c b/src/radbin/radbin_main.c index 3c1fb526..8999d8f1 100644 --- a/src/radbin/radbin_main.c +++ b/src/radbin/radbin_main.c @@ -12,7 +12,7 @@ //- rjf: [h] #include "base/base_inc.h" -#include "x64/x64.h" +#include "x64/x64_inc.h" #include "linker/hash_table.h" #include "linker/base_ext/base_bit_array.h" #include "rdi/rdi_local.h" @@ -47,7 +47,7 @@ //- rjf: [c] #include "base/base_inc.c" -#include "x64/x64.c" +#include "x64/x64_inc.c" #include "linker/hash_table.c" #include "linker/base_ext/base_bit_array.c" #include "rdi/rdi_local.c" diff --git a/src/raddbg/raddbg_main.c b/src/raddbg/raddbg_main.c index abe98430..46536a93 100644 --- a/src/raddbg/raddbg_main.c +++ b/src/raddbg/raddbg_main.c @@ -376,7 +376,7 @@ //- rjf: [h] #include "base/base_inc.h" -#include "x64/x64.h" +#include "x64/x64_inc.h" #include "win32/win32_inc.h" #include "linker/base_ext/base_bit_array.h" #include "artifact_cache/artifact_cache.h" diff --git a/src/torture/torture_main.c b/src/torture/torture_main.c index 1b3a6915..71cb36bb 100644 --- a/src/torture/torture_main.c +++ b/src/torture/torture_main.c @@ -20,7 +20,7 @@ //////////////////////////////// #include "base/base_inc.h" -#include "x64/x64.h" +#include "x64/x64_inc.h" #include "linker/hash_table.h" #include "linker/lf_hash_table.h" #include "linker/base_ext/base_bit_array.h" diff --git a/src/x64/x64.h b/src/x64/x64.h index 2ee37845..459ea5c0 100644 --- a/src/x64/x64.h +++ b/src/x64/x64.h @@ -37,18 +37,18 @@ enum typedef struct X64_FXSave X64_FXSave; struct AlignType(16) X64_FXSave { - U16 fcw; - U16 fsw; - U8 ftw; - U8 reserved1; - U16 fop; - U64 fip; - U64 fdp; - U32 mxcsr; - U32 mxcsr_mask; + U16 fcw; + U16 fsw; + U8 ftw; + U8 reserved1; + U16 fop; + U64 fip; + U64 fdp; + U32 mxcsr; + U32 mxcsr_mask; U128 st_space[8]; U128 xmm_space[16]; - U8 padding[96]; + U8 padding[96]; }; StaticAssert(sizeof(X64_FXSave) == 512, g_x64_xsave_legacy_size_check); @@ -57,14 +57,14 @@ struct X64_XSaveHeader { U64 xstate_bv; U64 xcomp_bv; - U8 reserved[48]; + U8 reserved[48]; }; StaticAssert(sizeof(X64_XSaveHeader) == 64, g_x64_xsave_header_size_check); typedef struct X64_XSave X64_XSave; struct AlignType(64) X64_XSave { - X64_FXSave fxsave; + X64_FXSave fxsave; X64_XSaveHeader header; // U8 ext_area[0]; }; @@ -209,54 +209,6 @@ typedef enum X64_DebugControlFlags } X64_DebugControlFlags; -//////////////////////////////// -//~ Exception Codes - -typedef enum X64_ExceptionCode -{ - X64_ExceptionCode_DE = 0, // Divide error: division by zero or quotient overflow - X64_ExceptionCode_DB = 1, // Debug exception (single stepping, hardware breakpoint) - X64_ExceptionCode_NMI = 2, // Non-maskable interrupt - X64_ExceptionCode_BP = 3, // Breakpoint (int3) - X64_ExceptionCode_OF = 4, // Overflow - X64_ExceptionCode_BR = 5, // Bound range exceeded - X64_ExceptionCode_UD = 6, // Invalid opcode - X64_ExceptionCode_NM = 7, // Device not available - X64_ExceptionCode_DF = 8, // Double fault - X64_ExceptionCode_9 = 9, // Coprocessor segment overrun (obsolete) - X64_ExceptionCode_TS = 10, // Invalid task-state segment - X64_ExceptionCode_NP = 11, // Segment not present - X64_ExceptionCode_SS = 12, // Stack-segment fault - X64_ExceptionCode_GP = 13, // General-protection fault - X64_ExceptionCode_PF = 14, // Page fault - X64_ExceptionCode_15 = 15, // Reserved; Linux names it X86_TRAP_SPURIOUS - X64_ExceptionCode_MF = 16, // x87 floating-point exception - X64_ExceptionCode_AC = 17, // Alignment check - X64_ExceptionCode_MC = 18, // Machine check - X64_ExceptionCode_XF = 19, // SIMD floating-point exception - X64_ExceptionCode_VE = 20, // Virtualization exception - X64_ExceptionCode_CP = 21, // Control-protection exception - X64_ExceptionCode_Amd_HV = 28, // Hypervisor injection exception - X64_ExceptionCode_Amd_VC = 29, // VMM communication exception - X64_ExceptionCode_Amd_SX = 30, // Security exception -} -X64_ExceptionCode; - -//////////////////////////////// -//~ Page Fault Flags - -typedef enum X64_PageFaultError -{ - X64_PageFaultError_Protection = (1u << 0), - X64_PageFaultError_Write = (1u << 1), - X64_PageFaultError_User = (1u << 2), - X64_PageFaultError_ReservedBit = (1u << 3), - X64_PageFaultError_InstructionFetch = (1u << 4), - X64_PageFaultError_ProtectionKey = (1u << 5), - X64_PageFaultError_ShadowStack = (1u << 6), -} -X64_PageFaultError; - //////////////////////////////// //~ rjf: Generated diff --git a/src/x64/x64_exceptions.h b/src/x64/x64_exceptions.h new file mode 100644 index 00000000..e7df87d5 --- /dev/null +++ b/src/x64/x64_exceptions.h @@ -0,0 +1,55 @@ +// Copyright (c) Epic Games Tools +// Licensed under the MIT license (https://opensource.org/license/mit/) + +#ifndef X64_EXCEPTIONS_H +#define X64_EXCEPTIONS_H + +//////////////////////////////// +//~ Exception Codes + +typedef enum X64_ExceptionCode +{ + X64_ExceptionCode_DE = 0, // Divide error: division by zero or quotient overflow + X64_ExceptionCode_DB = 1, // Debug exception (single stepping, hardware breakpoint) + X64_ExceptionCode_NMI = 2, // Non-maskable interrupt + X64_ExceptionCode_BP = 3, // Breakpoint (int3) + X64_ExceptionCode_OF = 4, // Overflow + X64_ExceptionCode_BR = 5, // Bound range exceeded + X64_ExceptionCode_UD = 6, // Invalid opcode + X64_ExceptionCode_NM = 7, // Device not available + X64_ExceptionCode_DF = 8, // Double fault + X64_ExceptionCode_9 = 9, // Coprocessor segment overrun (obsolete) + X64_ExceptionCode_TS = 10, // Invalid task-state segment + X64_ExceptionCode_NP = 11, // Segment not present + X64_ExceptionCode_SS = 12, // Stack-segment fault + X64_ExceptionCode_GP = 13, // General-protection fault + X64_ExceptionCode_PF = 14, // Page fault + X64_ExceptionCode_15 = 15, // Reserved; Linux names it X86_TRAP_SPURIOUS + X64_ExceptionCode_MF = 16, // x87 floating-point exception + X64_ExceptionCode_AC = 17, // Alignment check + X64_ExceptionCode_MC = 18, // Machine check + X64_ExceptionCode_XF = 19, // SIMD floating-point exception + X64_ExceptionCode_VE = 20, // Virtualization exception + X64_ExceptionCode_CP = 21, // Control-protection exception + X64_ExceptionCode_Amd_HV = 28, // Hypervisor injection exception + X64_ExceptionCode_Amd_VC = 29, // VMM communication exception + X64_ExceptionCode_Amd_SX = 30, // Security exception +} +X64_ExceptionCode; + +//////////////////////////////// +//~ Page Fault Flags + +typedef enum X64_PageFaultError +{ + X64_PageFaultError_Protection = (1u << 0), + X64_PageFaultError_Write = (1u << 1), + X64_PageFaultError_User = (1u << 2), + X64_PageFaultError_ReservedBit = (1u << 3), + X64_PageFaultError_InstructionFetch = (1u << 4), + X64_PageFaultError_ProtectionKey = (1u << 5), + X64_PageFaultError_ShadowStack = (1u << 6), +} +X64_PageFaultError; + +#endif // X64_EXCEPTIONS_H diff --git a/src/x64/x64_inc.c b/src/x64/x64_inc.c new file mode 100644 index 00000000..2b64f3ff --- /dev/null +++ b/src/x64/x64_inc.c @@ -0,0 +1,4 @@ +// Copyright (c) Epic Games Tools +// Licensed under the MIT license (https://opensource.org/license/mit/) + +#include "x64.c" diff --git a/src/x64/x64_inc.h b/src/x64/x64_inc.h new file mode 100644 index 00000000..48cae4d3 --- /dev/null +++ b/src/x64/x64_inc.h @@ -0,0 +1,10 @@ +// Copyright (c) Epic Games Tools +// Licensed under the MIT license (https://opensource.org/license/mit/) + +#ifndef X64_INC_H +#define X64_INC_H + +#include "x64.h" +#include "x64_exceptions.h" + +#endif // X64_INC_H