Skip to content

Commit 1be2db9

Browse files
authored
Update the Windows ARM64 unwinder (#92604)
* Update the Windows ARM64 unwinder This change updates the Windows ARM64 unwinder to match the current state in Windows. It contains a fix for a bug that is needed as a basis for a .NET issue fix. * Reflect PR feedback
1 parent d283475 commit 1be2db9

File tree

3 files changed

+1800
-653
lines changed

3 files changed

+1800
-653
lines changed

src/coreclr/inc/crosscomp.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,8 @@ typedef struct DECLSPEC_ALIGN(16) _T_CONTEXT {
282282
} T_CONTEXT, *PT_CONTEXT;
283283

284284
// _IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY (see ExternalAPIs\Win9CoreSystem\inc\winnt.h)
285-
typedef struct _T_RUNTIME_FUNCTION {
285+
#ifdef HOST_UNIX
286+
typedef struct _IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY {
286287
DWORD BeginAddress;
287288
union {
288289
DWORD UnwindData;
@@ -294,12 +295,11 @@ typedef struct _T_RUNTIME_FUNCTION {
294295
DWORD H : 1;
295296
DWORD CR : 2;
296297
DWORD FrameSize : 9;
297-
} PackedUnwindData;
298+
};
298299
};
299-
} T_RUNTIME_FUNCTION, *PT_RUNTIME_FUNCTION;
300+
} IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY, * PIMAGE_ARM64_RUNTIME_FUNCTION_ENTRY;
300301

301302

302-
#ifdef HOST_UNIX
303303

304304
typedef
305305
EXCEPTION_DISPOSITION
@@ -310,6 +310,8 @@ EXCEPTION_DISPOSITION
310310
PVOID DispatcherContext
311311
);
312312
#endif
313+
314+
typedef IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY T_RUNTIME_FUNCTION, * PT_RUNTIME_FUNCTION;
313315
//
314316
// Define exception dispatch context structure.
315317
//

src/coreclr/pal/inc/pal.h

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2085,6 +2085,34 @@ typedef struct _KNONVOLATILE_CONTEXT_POINTERS {
20852085

20862086
} KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
20872087

2088+
typedef struct _IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY {
2089+
DWORD BeginAddress;
2090+
union {
2091+
DWORD UnwindData;
2092+
struct {
2093+
DWORD Flag : 2;
2094+
DWORD FunctionLength : 11;
2095+
DWORD RegF : 3;
2096+
DWORD RegI : 4;
2097+
DWORD H : 1;
2098+
DWORD CR : 2;
2099+
DWORD FrameSize : 9;
2100+
};
2101+
};
2102+
} IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY, * PIMAGE_ARM64_RUNTIME_FUNCTION_ENTRY;
2103+
2104+
typedef union IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY_XDATA {
2105+
ULONG HeaderData;
2106+
struct {
2107+
ULONG FunctionLength : 18; // in words (2 bytes)
2108+
ULONG Version : 2;
2109+
ULONG ExceptionDataPresent : 1;
2110+
ULONG EpilogInHeader : 1;
2111+
ULONG EpilogCount : 5; // number of epilogs or byte index of the first unwind code for the one only epilog
2112+
ULONG CodeWords : 5; // number of dwords with unwind codes
2113+
};
2114+
} IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY_XDATA;
2115+
20882116
#elif defined(HOST_LOONGARCH64)
20892117

20902118
// Please refer to src/coreclr/pal/src/arch/loongarch64/asmconstants.h
@@ -3139,13 +3167,17 @@ enum {
31393167
//
31403168
// A function table entry is generated for each frame function.
31413169
//
3170+
#if defined(HOST_ARM64)
3171+
typedef IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
3172+
#else // HOST_ARM64
31423173
typedef struct _RUNTIME_FUNCTION {
31433174
DWORD BeginAddress;
3144-
#ifdef TARGET_AMD64
3175+
#ifdef HOST_AMD64
31453176
DWORD EndAddress;
31463177
#endif
31473178
DWORD UnwindData;
31483179
} RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
3180+
#endif // HOST_ARM64
31493181

31503182
#define STANDARD_RIGHTS_REQUIRED (0x000F0000L)
31513183
#define SYNCHRONIZE (0x00100000L)

0 commit comments

Comments
 (0)