Fix handling of FCalls in ExternalMethodFixupWorker (#17252)
authorJan Vorlicek <janvorli@microsoft.com>
Tue, 27 Mar 2018 23:31:20 +0000 (01:31 +0200)
committerGitHub <noreply@github.com>
Tue, 27 Mar 2018 23:31:20 +0000 (01:31 +0200)
When running ready to run code on ARM, the ExternalMethodFixupWorker
doesn't handle the entrypoints of FCalls correctly. It tries to handle
them as compact entrypoints, but those use a different machine code
instructions and it results in an assert in debug / checked build.

This change detects the runtime supplied calls before trying to check
for the compact entrypoint.

src/vm/method.cpp

index 9b3080e..d323ef0 100644 (file)
@@ -4409,7 +4409,10 @@ BOOL MethodDescChunk::IsCompactEntryPointAtAddress(PCODE addr)
     if (fSpeculative INDEBUG(|| TRUE))
     {
 #ifdef _TARGET_ARM_
-        if (!IsCompactEntryPointAtAddress(addr))
+        TADDR instrCodeAddr = PCODEToPINSTR(addr);
+        if (!IsCompactEntryPointAtAddress(addr) ||
+            *PTR_BYTE(instrCodeAddr) != TEP_ENTRY_INSTR1_BYTE1 ||
+            *PTR_BYTE(instrCodeAddr+1) != TEP_ENTRY_INSTR1_BYTE2)
 #else // _TARGET_ARM_
         if ((addr & 3) != 1 ||
             *PTR_BYTE(addr) != X86_INSTR_MOV_AL ||