mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
[SDK][XDK] Add more definitions for ARM64 and start fixing PE binaries (#4142)
- Add context structure and definitions, NEON128 structure, runtime function entry, dispatcher context, scope table All definitions are based on the latest SDK for arm64. [SDK] Use _TARGET_PE64 in the pefixup [GENINC] Add AA64 identifier for ARM64 PE binaries CORE-17518
This commit is contained in:
parent
6dfc13e411
commit
b1fca7ea55
3 changed files with 149 additions and 2 deletions
|
@ -2149,6 +2149,151 @@ typedef struct _DISPATCHER_CONTEXT
|
|||
DWORD Reserved;
|
||||
} DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT;
|
||||
|
||||
#elif defined(_ARM64_)
|
||||
|
||||
#define CONTEXT_ARM64 0x00400000L
|
||||
#define CONTEXT_CONTROL (CONTEXT_ARM64 | 0x1L)
|
||||
#define CONTEXT_INTEGER (CONTEXT_ARM64 | 0x2L)
|
||||
#define CONTEXT_FLOATING_POINT (CONTEXT_ARM64 | 0x4L)
|
||||
#define CONTEXT_DEBUG_REGISTERS (CONTEXT_ARM64 | 0x8L)
|
||||
#define CONTEXT_X18 (CONTEXT_ARM64 | 0x10L)
|
||||
#define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
|
||||
|
||||
|
||||
#define EXCEPTION_READ_FAULT 0
|
||||
#define EXCEPTION_WRITE_FAULT 1
|
||||
#define EXCEPTION_EXECUTE_FAULT 8
|
||||
|
||||
typedef union NEON128 {
|
||||
struct {
|
||||
ULONGLONG Low;
|
||||
LONGLONG High;
|
||||
} DUMMYSTRUCTNAME;
|
||||
double D[2];
|
||||
float S[4];
|
||||
WORD H[8];
|
||||
BYTE B[16];
|
||||
} NEON128, *PNEON128;
|
||||
|
||||
#define ARM64_MAX_BREAKPOINTS 8
|
||||
#define ARM64_MAX_WATCHPOINTS 2
|
||||
|
||||
typedef struct _CONTEXT {
|
||||
|
||||
//
|
||||
// Control flags.
|
||||
//
|
||||
|
||||
DWORD ContextFlags;
|
||||
|
||||
//
|
||||
// Integer registers
|
||||
//
|
||||
|
||||
DWORD Cpsr;
|
||||
union {
|
||||
struct {
|
||||
DWORD64 X0;
|
||||
DWORD64 X1;
|
||||
DWORD64 X2;
|
||||
DWORD64 X3;
|
||||
DWORD64 X4;
|
||||
DWORD64 X5;
|
||||
DWORD64 X6;
|
||||
DWORD64 X7;
|
||||
DWORD64 X8;
|
||||
DWORD64 X9;
|
||||
DWORD64 X10;
|
||||
DWORD64 X11;
|
||||
DWORD64 X12;
|
||||
DWORD64 X13;
|
||||
DWORD64 X14;
|
||||
DWORD64 X15;
|
||||
DWORD64 X16;
|
||||
DWORD64 X17;
|
||||
DWORD64 X18;
|
||||
DWORD64 X19;
|
||||
DWORD64 X20;
|
||||
DWORD64 X21;
|
||||
DWORD64 X22;
|
||||
DWORD64 X23;
|
||||
DWORD64 X24;
|
||||
DWORD64 X25;
|
||||
DWORD64 X26;
|
||||
DWORD64 X27;
|
||||
DWORD64 X28;
|
||||
DWORD64 Fp;
|
||||
DWORD64 Lr;
|
||||
} DUMMYSTRUCTNAME;
|
||||
DWORD64 X[31];
|
||||
} DUMMYUNIONNAME;
|
||||
|
||||
DWORD64 Sp;
|
||||
DWORD64 Pc;
|
||||
|
||||
//
|
||||
// Floating Point/NEON Registers
|
||||
//
|
||||
|
||||
NEON128 V[32];
|
||||
DWORD Fpcr;
|
||||
DWORD Fpsr;
|
||||
|
||||
//
|
||||
// Debug registers
|
||||
//
|
||||
|
||||
DWORD Bcr[ARM64_MAX_BREAKPOINTS];
|
||||
DWORD64 Bvr[ARM64_MAX_BREAKPOINTS];
|
||||
DWORD Wcr[ARM64_MAX_WATCHPOINTS];
|
||||
DWORD64 Wvr[ARM64_MAX_WATCHPOINTS];
|
||||
|
||||
} _CONTEXT, *P_CONTEXT;
|
||||
typedef _CONTEXT CONTEXT, *PCONTEXT;
|
||||
|
||||
typedef struct _IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY {
|
||||
DWORD BeginAddress;
|
||||
union {
|
||||
DWORD UnwindData;
|
||||
struct {
|
||||
DWORD Flag : 2;
|
||||
DWORD FunctionLength : 11;
|
||||
DWORD RegF : 3;
|
||||
DWORD RegI : 4;
|
||||
DWORD H : 1;
|
||||
DWORD CR : 2;
|
||||
DWORD FrameSize : 9;
|
||||
} DUMMYSTRUCTNAME;
|
||||
} DUMMYUNIONNAME;
|
||||
} IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY, * PIMAGE_ARM64_RUNTIME_FUNCTION_ENTRY;
|
||||
typedef struct _IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
|
||||
|
||||
typedef struct _SCOPE_TABLE_ARM64 {
|
||||
DWORD Count;
|
||||
struct
|
||||
{
|
||||
DWORD BeginAddress;
|
||||
DWORD EndAddress;
|
||||
DWORD HandlerAddress;
|
||||
DWORD JumpTarget;
|
||||
} ScopeRecord[1];
|
||||
} SCOPE_TABLE_ARM64, *PSCOPE_TABLE_ARM64;
|
||||
typedef SCOPE_TABLE_ARM64 SCOPE_TABLE, *PSCOPE_TABLE;
|
||||
|
||||
typedef struct _DISPATCHER_CONTEXT {
|
||||
ULONG_PTR ControlPc;
|
||||
ULONG_PTR ImageBase;
|
||||
PRUNTIME_FUNCTION FunctionEntry;
|
||||
ULONG_PTR EstablisherFrame;
|
||||
ULONG_PTR TargetPc;
|
||||
PCONTEXT ContextRecord;
|
||||
PEXCEPTION_ROUTINE LanguageHandler;
|
||||
PVOID HandlerData;
|
||||
struct _UNWIND_HISTORY_TABLE *HistoryTable;
|
||||
DWORD ScopeIndex;
|
||||
BOOLEAN ControlPcIsUnwound;
|
||||
PBYTE NonVolatileRegisters;
|
||||
} DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT;
|
||||
#else
|
||||
#error "undefined processor type"
|
||||
#endif
|
||||
|
|
|
@ -50,7 +50,7 @@ if(NOT MSVC)
|
|||
add_subdirectory(rsym)
|
||||
|
||||
add_host_tool(pefixup pefixup.c)
|
||||
if (ARCH STREQUAL "amd64")
|
||||
if (ARCH STREQUAL "amd64" OR ARCH STREQUAL "arm64")
|
||||
target_compile_definitions(pefixup PRIVATE _TARGET_PE64)
|
||||
endif()
|
||||
target_link_libraries(pefixup PRIVATE host_includes)
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#define IMAGE_FILE_MACHINE_I386 0x014c
|
||||
#define IMAGE_FILE_MACHINE_AMD64 0x8664
|
||||
#define IMAGE_FILE_MACHINE_ARMNT 0x01c4
|
||||
#define IMAGE_FILE_MACHINE_ARM64 0xaa64
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define PRIx64 "I64x"
|
||||
|
@ -117,7 +118,8 @@ int main(int argc, char* argv[])
|
|||
|
||||
if ((Machine != IMAGE_FILE_MACHINE_I386) &&
|
||||
(Machine != IMAGE_FILE_MACHINE_AMD64) &&
|
||||
(Machine != IMAGE_FILE_MACHINE_ARMNT))
|
||||
(Machine != IMAGE_FILE_MACHINE_ARMNT) &&
|
||||
(Machine != IMAGE_FILE_MACHINE_ARM64))
|
||||
{
|
||||
fprintf(stderr, "Invalid Machine: 0x%x.\n", Machine);
|
||||
goto quit;
|
||||
|
|
Loading…
Reference in a new issue