Skip to content

Commit 4d6f6bc

Browse files
github-actions[bot]Mike McLaughlin
andauthored
Fix arm64/arm32 cross-DAC (#91438)
The precode code was incorrectly using the HOST_ARM64, HOST_ARM, etc. defines instead of the TARGET_ ones. This means the cross-DAC was using the wrong architectures *Precode::Type codes. Co-authored-by: Mike McLaughlin <[email protected]>
1 parent dc652c1 commit 4d6f6bc

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

src/coreclr/vm/precode.h

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111

1212
#define PRECODE_ALIGNMENT sizeof(void*)
1313

14-
#if defined(HOST_AMD64)
14+
#if defined(TARGET_AMD64)
1515

1616
#define OFFSETOF_PRECODE_TYPE 0
1717
#define OFFSETOF_PRECODE_TYPE_CALL_OR_JMP 5
1818
#define OFFSETOF_PRECODE_TYPE_MOV_R10 10
1919

2020
#define SIZEOF_PRECODE_BASE 16
2121

22-
#elif defined(HOST_X86)
22+
#elif defined(TARGET_X86)
2323

2424
EXTERN_C VOID STDCALL PrecodeRemotingThunk();
2525

@@ -29,27 +29,27 @@ EXTERN_C VOID STDCALL PrecodeRemotingThunk();
2929

3030
#define SIZEOF_PRECODE_BASE 8
3131

32-
#elif defined(HOST_ARM64)
32+
#elif defined(TARGET_ARM64)
3333

3434
#define SIZEOF_PRECODE_BASE CODE_SIZE_ALIGN
3535
#define OFFSETOF_PRECODE_TYPE 0
3636

37-
#elif defined(HOST_ARM)
37+
#elif defined(TARGET_ARM)
3838

3939
#define SIZEOF_PRECODE_BASE CODE_SIZE_ALIGN
4040
#define OFFSETOF_PRECODE_TYPE 3
4141

42-
#elif defined(HOST_LOONGARCH64)
42+
#elif defined(TARGET_LOONGARCH64)
4343

4444
#define SIZEOF_PRECODE_BASE CODE_SIZE_ALIGN
4545
#define OFFSETOF_PRECODE_TYPE 0
4646

47-
#elif defined(HOST_RISCV64)
47+
#elif defined(TARGET_RISCV64)
4848

4949
#define SIZEOF_PRECODE_BASE CODE_SIZE_ALIGN
5050
#define OFFSETOF_PRECODE_TYPE 0
5151

52-
#endif // HOST_AMD64
52+
#endif // TARGET_AMD64
5353

5454
#ifndef DACCESS_COMPILE
5555
// Given an address in a slot, figure out if the prestub will be called
@@ -61,14 +61,14 @@ BOOL DoesSlotCallPrestub(PCODE pCode);
6161
// Invalid precode type
6262
struct InvalidPrecode
6363
{
64-
#if defined(HOST_AMD64) || defined(HOST_X86)
64+
#if defined(TARGET_AMD64) || defined(TARGET_X86)
6565
// int3
6666
static const int Type = 0xCC;
67-
#elif defined(HOST_ARM64) || defined(HOST_ARM)
67+
#elif defined(TARGET_ARM64) || defined(TARGET_ARM)
6868
static const int Type = 0;
69-
#elif defined(HOST_LOONGARCH64)
69+
#elif defined(TARGET_LOONGARCH64)
7070
static const int Type = 0xff;
71-
#elif defined(HOST_RISCV64)
71+
#elif defined(TARGET_RISCV64)
7272
static const int Type = 0xff;
7373
#endif
7474
};
@@ -90,25 +90,25 @@ extern "C" void StubPrecodeCode_End();
9090
// Regular precode
9191
struct StubPrecode
9292
{
93-
#if defined(HOST_AMD64)
93+
#if defined(TARGET_AMD64)
9494
static const BYTE Type = 0x4C;
9595
static const SIZE_T CodeSize = 24;
96-
#elif defined(HOST_X86)
96+
#elif defined(TARGET_X86)
9797
static const BYTE Type = 0xA1;
9898
static const SIZE_T CodeSize = 24;
99-
#elif defined(HOST_ARM64)
99+
#elif defined(TARGET_ARM64)
100100
static const int Type = 0x4A;
101101
static const SIZE_T CodeSize = 24;
102-
#elif defined(HOST_ARM)
102+
#elif defined(TARGET_ARM)
103103
static const int Type = 0xCF;
104104
static const SIZE_T CodeSize = 12;
105-
#elif defined(HOST_LOONGARCH64)
105+
#elif defined(TARGET_LOONGARCH64)
106106
static const int Type = 0x4;
107107
static const SIZE_T CodeSize = 24;
108-
#elif defined(HOST_RISCV64)
108+
#elif defined(TARGET_RISCV64)
109109
static const int Type = 0x17;
110110
static const SIZE_T CodeSize = 24;
111-
#endif // HOST_AMD64
111+
#endif // TARGET_AMD64
112112

113113
BYTE m_code[CodeSize];
114114

@@ -224,31 +224,31 @@ extern "C" void FixupPrecodeCode_End();
224224
// The fixup precode is simple jump once patched. It does not have the two instruction overhead of regular precode.
225225
struct FixupPrecode
226226
{
227-
#if defined(HOST_AMD64)
227+
#if defined(TARGET_AMD64)
228228
static const int Type = 0xFF;
229229
static const SIZE_T CodeSize = 24;
230230
static const int FixupCodeOffset = 6;
231-
#elif defined(HOST_X86)
231+
#elif defined(TARGET_X86)
232232
static const int Type = 0xFF;
233233
static const SIZE_T CodeSize = 24;
234234
static const int FixupCodeOffset = 6;
235-
#elif defined(HOST_ARM64)
235+
#elif defined(TARGET_ARM64)
236236
static const int Type = 0x0B;
237237
static const SIZE_T CodeSize = 24;
238238
static const int FixupCodeOffset = 8;
239-
#elif defined(HOST_ARM)
239+
#elif defined(TARGET_ARM)
240240
static const int Type = 0xFF;
241241
static const SIZE_T CodeSize = 12;
242242
static const int FixupCodeOffset = 4 + THUMB_CODE;
243-
#elif defined(HOST_LOONGARCH64)
243+
#elif defined(TARGET_LOONGARCH64)
244244
static const int Type = 0x3;
245245
static const SIZE_T CodeSize = 32;
246246
static const int FixupCodeOffset = 12;
247-
#elif defined(HOST_RISCV64)
247+
#elif defined(TARGET_RISCV64)
248248
static const int Type = 0x97;
249249
static const SIZE_T CodeSize = 32;
250250
static const int FixupCodeOffset = 10;
251-
#endif // HOST_AMD64
251+
#endif // TARGET_AMD64
252252

253253
BYTE m_code[CodeSize];
254254

0 commit comments

Comments
 (0)