summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Vorlicek <janvorli@microsoft.com>2017-09-14 16:43:13 +0200
committerGitHub <noreply@github.com>2017-09-14 16:43:13 +0200
commit3452efb58d2f3be867080f8627417b264fcbd73c (patch)
tree6b20e07a13ff43c13c37eacac5ccb44ee3ace954 /src
parent46fcf059d51766e36ab59cb95c53b435a6991603 (diff)
downloadcoreclr-3452efb58d2f3be867080f8627417b264fcbd73c.tar.gz
coreclr-3452efb58d2f3be867080f8627417b264fcbd73c.tar.bz2
coreclr-3452efb58d2f3be867080f8627417b264fcbd73c.zip
Fix crossgen memory mappings (#13972)
This change removes executable memory mappings from crossgen. Now it can be run on systems with PAX set to prevent executable mappings without any marking using the paxctl.
Diffstat (limited to 'src')
-rw-r--r--src/utilcode/loaderheap.cpp4
-rw-r--r--src/vm/peimagelayout.cpp12
-rw-r--r--src/vm/stublink.cpp2
3 files changed, 16 insertions, 2 deletions
diff --git a/src/utilcode/loaderheap.cpp b/src/utilcode/loaderheap.cpp
index 2603a8ec33..ca1ed666f4 100644
--- a/src/utilcode/loaderheap.cpp
+++ b/src/utilcode/loaderheap.cpp
@@ -944,8 +944,12 @@ UnlockedLoaderHeap::UnlockedLoaderHeap(DWORD dwReserveBlockSize,
m_pPrivatePerfCounter_LoaderBytes = pPrivatePerfCounter_LoaderBytes;
m_Options = 0;
+
+#ifndef CROSSGEN_COMPILE
if (fMakeExecutable)
m_Options |= LHF_EXECUTABLE;
+#endif // CROSSGEN_COMPILE
+
if (fZeroInit)
m_Options |= LHF_ZEROINIT;
diff --git a/src/vm/peimagelayout.cpp b/src/vm/peimagelayout.cpp
index 93ab77cc78..94810a0e61 100644
--- a/src/vm/peimagelayout.cpp
+++ b/src/vm/peimagelayout.cpp
@@ -195,14 +195,14 @@ void PEImageLayout::ApplyBaseRelocations()
if (((pSection->Characteristics & VAL32(IMAGE_SCN_MEM_WRITE)) == 0))
{
DWORD dwNewProtection = PAGE_READWRITE;
-#ifdef FEATURE_PAL
+#if defined(FEATURE_PAL) && !defined(CROSSGEN_COMPILE)
if (((pSection->Characteristics & VAL32(IMAGE_SCN_MEM_EXECUTE)) != 0))
{
// On SELinux, we cannot change protection that doesn't have execute access rights
// to one that has it, so we need to set the protection to RWX instead of RW
dwNewProtection = PAGE_EXECUTE_READWRITE;
}
-#endif // FEATURE_PAL
+#endif // FEATURE_PAL && !CROSSGEN_COMPILE
if (!ClrVirtualProtect(pWriteableRegion, cbWriteableRegion,
dwNewProtection, &dwOldProtection))
ThrowLastError();
@@ -243,6 +243,7 @@ void PEImageLayout::ApplyBaseRelocations()
}
_ASSERTE(dirSize == dirPos);
+#ifndef CROSSGEN_COMPILE
if (dwOldProtection != 0)
{
// Restore the protection
@@ -250,6 +251,7 @@ void PEImageLayout::ApplyBaseRelocations()
dwOldProtection, &dwOldProtection))
ThrowLastError();
}
+#endif // CROSSGEN_COMPILE
}
#endif // FEATURE_PREJIT
@@ -478,7 +480,9 @@ MappedImageLayout::MappedImageLayout(HANDLE hFile, PEImage* pOwner)
#else //!FEATURE_PAL
+#ifndef CROSSGEN_COMPILE
m_FileView = PAL_LOADLoadPEFile(hFile);
+
if (m_FileView == NULL)
{
// For CoreCLR, try to load all files via LoadLibrary first. If LoadLibrary did not work, retry using
@@ -507,6 +511,10 @@ MappedImageLayout::MappedImageLayout(HANDLE hFile, PEImage* pOwner)
SetRelocated();
}
+#else // !CROSSGEN_COMPILE
+ m_FileView = NULL;
+#endif // !CROSSGEN_COMPILE
+
#endif // !FEATURE_PAL
}
diff --git a/src/vm/stublink.cpp b/src/vm/stublink.cpp
index d1833260c5..631f51150b 100644
--- a/src/vm/stublink.cpp
+++ b/src/vm/stublink.cpp
@@ -888,7 +888,9 @@ Stub *StubLinker::Link(LoaderHeap *pHeap, DWORD flags)
int globalsize = 0;
int size = CalculateSize(&globalsize);
+#ifndef CROSSGEN_COMPILE
_ASSERTE(!pHeap || pHeap->IsExecutable());
+#endif
StubHolder<Stub> pStub;