diff options
-rw-r--r-- | src/vm/clsload.cpp | 5 | ||||
-rw-r--r-- | src/vm/pefile.cpp | 8 |
2 files changed, 10 insertions, 3 deletions
diff --git a/src/vm/clsload.cpp b/src/vm/clsload.cpp index f1fbe57ba7..5af8f19c28 100644 --- a/src/vm/clsload.cpp +++ b/src/vm/clsload.cpp @@ -100,8 +100,9 @@ PTR_Module ClassLoader::ComputeLoaderModuleWorker( #ifndef DACCESS_COMPILE #ifdef FEATURE_NATIVE_IMAGE_GENERATION - // Check we're NGEN'ing - if (IsCompilationProcess()) + // Check we're NGEN'ing. ComputeLoaderModuleForCompilation algorithm assumes that there is fragile + // NGen image for CoreLib that is not the case for ReadyToRun compilation. + if (IsCompilationProcess() && !IsReadyToRunCompilation()) { RETURN(ComputeLoaderModuleForCompilation(pDefinitionModule, token, classInst, methodInst)); } diff --git a/src/vm/pefile.cpp b/src/vm/pefile.cpp index deddc67408..440281e953 100644 --- a/src/vm/pefile.cpp +++ b/src/vm/pefile.cpp @@ -499,7 +499,7 @@ static void ValidatePEFileMachineType(PEFile *peFile) if (actualMachineType == IMAGE_FILE_MACHINE_I386 && ((peKind & (peILonly | pe32BitRequired)) == peILonly)) return; // Image is marked CPU-agnostic. - if (actualMachineType != IMAGE_FILE_MACHINE_NATIVE) + if (actualMachineType != IMAGE_FILE_MACHINE_NATIVE && actualMachineType != IMAGE_FILE_MACHINE_NATIVE_NI) { #ifdef _TARGET_AMD64_ // v4.0 64-bit compatibility workaround. The 64-bit v4.0 CLR's Reflection.Load(byte[]) api does not detect cpu-matches. We should consider fixing that in @@ -2334,6 +2334,12 @@ BOOL PEFile::ShouldTreatNIAsMSIL() { LIMITED_METHOD_CONTRACT; + // Never use fragile native image content during ReadyToRun compilation. It would + // produces non-version resilient images because of wrong cached values for + // MethodTable::IsLayoutFixedInCurrentVersionBubble, etc. + if (IsReadyToRunCompilation()) + return TRUE; + // Ask profiling API & config vars whether NGENd images should be avoided // completely. if (!NGENImagesAllowed()) |