diff --git a/src/coreclr/vm/arm/cgencpu.h b/src/coreclr/vm/arm/cgencpu.h index d31700e3477a4..6538cea705a56 100644 --- a/src/coreclr/vm/arm/cgencpu.h +++ b/src/coreclr/vm/arm/cgencpu.h @@ -996,7 +996,7 @@ inline BOOL ClrFlushInstructionCache(LPCVOID pCodeAddr, size_t sizeOfCode, bool // Precode to shuffle this and retbuf for closed delegates over static methods with return buffer struct ThisPtrRetBufPrecode { - static const int Type = 0x46; + static const int Type = 0x01; // mov r12, r0 // mov r0, r1 diff --git a/src/coreclr/vm/precode.h b/src/coreclr/vm/precode.h index 158c1ab08f554..3f6a2f532c4e6 100644 --- a/src/coreclr/vm/precode.h +++ b/src/coreclr/vm/precode.h @@ -36,8 +36,8 @@ EXTERN_C VOID STDCALL PrecodeRemotingThunk(); #elif defined(TARGET_ARM) -#define SIZEOF_PRECODE_BASE CODE_SIZE_ALIGN -#define OFFSETOF_PRECODE_TYPE 3 +#define SIZEOF_PRECODE_BASE CODE_SIZE_ALIGN * 2 +#define OFFSETOF_PRECODE_TYPE 7 #elif defined(TARGET_LOONGARCH64) @@ -100,7 +100,7 @@ struct StubPrecode static const int Type = 0x4A; static const SIZE_T CodeSize = 24; #elif defined(TARGET_ARM) - static const int Type = 0xCF; + static const int Type = 0xFF; static const SIZE_T CodeSize = 12; #elif defined(TARGET_LOONGARCH64) static const int Type = 0x4; @@ -189,7 +189,7 @@ typedef DPTR(StubPrecode) PTR_StubPrecode; // (This is fake precode. VTable slot does not point to it.) struct NDirectImportPrecode : StubPrecode { - static const int Type = 0x01; + static const int Type = 0x05; void Init(NDirectImportPrecode* pPrecodeRX, MethodDesc* pMD, LoaderAllocator *pLoaderAllocator); @@ -237,7 +237,7 @@ struct FixupPrecode static const SIZE_T CodeSize = 24; static const int FixupCodeOffset = 8; #elif defined(TARGET_ARM) - static const int Type = 0xFF; + static const int Type = 0xCF; static const SIZE_T CodeSize = 12; static const int FixupCodeOffset = 4 + THUMB_CODE; #elif defined(TARGET_LOONGARCH64) @@ -614,4 +614,8 @@ static_assert_no_msg(FixupPrecode::Type != NDirectImportPrecode::Type); static_assert_no_msg(FixupPrecode::Type != ThisPtrRetBufPrecode::Type); static_assert_no_msg(NDirectImportPrecode::Type != ThisPtrRetBufPrecode::Type); +// Verify that the base type for each precode fits into each specific precode type +static_assert_no_msg(sizeof(Precode) <= sizeof(NDirectImportPrecode)); +static_assert_no_msg(sizeof(Precode) <= sizeof(FixupPrecode)); +static_assert_no_msg(sizeof(Precode) <= sizeof(ThisPtrRetBufPrecode)); #endif // __PRECODE_H__