diff options
author | Vladimir Sadov <vsadov@microsoft.com> | 2021-06-18 23:48:22 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-18 23:48:22 +0300 |
commit | 97477e250c1448431d4070fb4b324ebd3d7f1a4c (patch) | |
tree | a25be1e02d46d920e98da92f0b8468c9b8b0c468 /src/coreclr/utilcode | |
parent | 6737dce33d35970fde2ca349cc1492da977b9699 (diff) |
Enable loading composite r2r images from a singlefile bundle (#53739)
* Enable loading composite r2r images from a singlefile bundle
Diffstat (limited to 'src/coreclr/utilcode')
-rw-r--r-- | src/coreclr/utilcode/pedecoder.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/coreclr/utilcode/pedecoder.cpp b/src/coreclr/utilcode/pedecoder.cpp index 3b46c56a415..639cb02099b 100644 --- a/src/coreclr/utilcode/pedecoder.cpp +++ b/src/coreclr/utilcode/pedecoder.cpp @@ -1034,14 +1034,29 @@ CHECK PEDecoder::CheckCorHeader() const IMAGE_COR20_HEADER *pCor = GetCorHeader(); + // Currently composite r2r images miss some information, for example the version is 0.0. + // We may want to change that to something more conforming and explicit. + // For now, for compatibility purposes, we will accept that as a valid format. + bool possiblyCompositeR2R = + pCor->MinorRuntimeVersion == 0 && + pCor->MajorRuntimeVersion == 0; + //CHECK(((ULONGLONG)pCor & 0x3)==0); // If the file is COM+ 1.0, which by definition has nothing the runtime can // use, or if the file requires a newer version of this engine than us, // it cannot be run by this engine. - CHECK(VAL16(pCor->MajorRuntimeVersion) > 1 && VAL16(pCor->MajorRuntimeVersion) <= COR_VERSION_MAJOR); + if (!possiblyCompositeR2R) + CHECK(VAL16(pCor->MajorRuntimeVersion) > 1 && VAL16(pCor->MajorRuntimeVersion) <= COR_VERSION_MAJOR); +#ifdef HOST_WINDOWS CHECK(CheckDirectory(&pCor->MetaData, IMAGE_SCN_MEM_WRITE, HasNativeHeader() ? NULL_OK : NULL_NOT_OK)); +#else + CHECK(CheckDirectory( + &pCor->MetaData, + possiblyCompositeR2R ? 0 : IMAGE_SCN_MEM_WRITE, + HasNativeHeader() ? NULL_OK : NULL_NOT_OK)); +#endif CHECK(CheckDirectory(&pCor->Resources, IMAGE_SCN_MEM_WRITE, NULL_OK)); CHECK(CheckDirectory(&pCor->StrongNameSignature, IMAGE_SCN_MEM_WRITE, NULL_OK)); CHECK(CheckDirectory(&pCor->CodeManagerTable, IMAGE_SCN_MEM_WRITE, NULL_OK)); @@ -1083,7 +1098,7 @@ CHECK PEDecoder::CheckCorHeader() const // IL library files (really a misnomer - these are native images or ReadyToRun images) // only they can have a native image header - if ((pCor->Flags&VAL32(COMIMAGE_FLAGS_IL_LIBRARY)) == 0) + if ((pCor->Flags&VAL32(COMIMAGE_FLAGS_IL_LIBRARY)) == 0 && !possiblyCompositeR2R) { CHECK(VAL32(pCor->ManagedNativeHeader.Size) == 0); } @@ -1769,7 +1784,7 @@ void PEDecoder::LayoutILOnly(void *base, bool enableExecution) const PAGE_READONLY, &oldProtection)) ThrowLastError(); - // Finally, apply proper protection to copied sections + // Finally, apply proper protection to copied sections for (section = sectionStart; section < sectionEnd; section++) { // Add appropriate page protection. |