diff options
author | Vladimir Sadov <vsadov@microsoft.com> | 2021-04-15 05:00:31 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-15 05:00:31 +0300 |
commit | 711424876b78e2de44b6d7479fd750c4a60d7be7 (patch) | |
tree | 8c376f87f79449c00f0d719eceb71192df745674 /src/coreclr/utilcode | |
parent | 40a4cb663ee45d885bd5fa59d19d5d11750cf47f (diff) |
Singlefile: enabling compression for managed assemblies. (#50817)
* enable compression of assemblies
* fix Unix build
* map should use converted layout for compressed
* enable execution for R2R
* fixes for OSX
* PR feedback (comments)
* more PR feedback
* shorter include path to pal_zlib.h
* Apply suggestions from code review
Co-authored-by: Vitek Karas <vitek.karas@microsoft.com>
Co-authored-by: Vitek Karas <vitek.karas@microsoft.com>
Diffstat (limited to 'src/coreclr/utilcode')
-rw-r--r-- | src/coreclr/utilcode/pedecoder.cpp | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/coreclr/utilcode/pedecoder.cpp b/src/coreclr/utilcode/pedecoder.cpp index 91fde64d297..5ec34fa0700 100644 --- a/src/coreclr/utilcode/pedecoder.cpp +++ b/src/coreclr/utilcode/pedecoder.cpp @@ -1724,12 +1724,11 @@ CHECK PEDecoder::CheckILOnlyEntryPoint() const #ifndef DACCESS_COMPILE -void PEDecoder::LayoutILOnly(void *base, BOOL allowFullPE) const +void PEDecoder::LayoutILOnly(void *base, bool enableExecution) const { CONTRACT_VOID { INSTANCE_CHECK; - PRECONDITION(allowFullPE || CheckILOnlyFormat()); PRECONDITION(CheckZeroedMemory(base, VAL32(FindNTHeaders()->OptionalHeader.SizeOfImage))); // Ideally we would require the layout address to honor the section alignment constraints. // However, we do have 8K aligned IL only images which we load on 32 bit platforms. In this @@ -1774,18 +1773,22 @@ void PEDecoder::LayoutILOnly(void *base, BOOL allowFullPE) const for (section = sectionStart; section < sectionEnd; section++) { // Add appropriate page protection. -#if defined(CROSSGEN_COMPILE) || defined(TARGET_UNIX) - if (section->Characteristics & IMAGE_SCN_MEM_WRITE) - continue; + DWORD newProtection; + if (!enableExecution) + { + if (section->Characteristics & IMAGE_SCN_MEM_WRITE) + continue; - DWORD newProtection = PAGE_READONLY; -#else - DWORD newProtection = section->Characteristics & IMAGE_SCN_MEM_EXECUTE ? - PAGE_EXECUTE_READ : - section->Characteristics & IMAGE_SCN_MEM_WRITE ? - PAGE_READWRITE : - PAGE_READONLY; -#endif + newProtection = PAGE_READONLY; + } + else + { + newProtection = section->Characteristics & IMAGE_SCN_MEM_EXECUTE ? + PAGE_EXECUTE_READ : + section->Characteristics & IMAGE_SCN_MEM_WRITE ? + PAGE_READWRITE : + PAGE_READONLY; + } if (!ClrVirtualProtect((void*)((BYTE*)base + VAL32(section->VirtualAddress)), VAL32(section->Misc.VirtualSize), |