Skip to content

Commit 6e24b2d

Browse files
committed
Fix broken ReadyToRun loading on Apple Silicon
1 parent a193279 commit 6e24b2d

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/coreclr/pal/src/map/map.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2047,9 +2047,9 @@ MAPmmapAndRecord(
20472047

20482048
// Set the requested mapping with forced PROT_WRITE to ensure data from the file can be read there,
20492049
// read the data in and finally remove the forced PROT_WRITE
2050-
if ((mprotect(pvBaseAddress, len + adjust, prot | PROT_WRITE) == -1) ||
2050+
if ((mprotect(pvBaseAddress, len + adjust, PROT_WRITE) == -1) ||
20512051
(pread(fd, pvBaseAddress, len + adjust, offset - adjust) == -1) ||
2052-
(((prot & PROT_WRITE) == 0) && mprotect(pvBaseAddress, len + adjust, prot) == -1))
2052+
(mprotect(pvBaseAddress, len + adjust, prot) == -1))
20532053
{
20542054
palError = FILEGetLastErrorFromErrno();
20552055
}

src/coreclr/vm/peimagelayout.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,14 +235,14 @@ void PEImageLayout::ApplyBaseRelocations()
235235
if (((pSection->Characteristics & VAL32(IMAGE_SCN_MEM_WRITE)) == 0))
236236
{
237237
DWORD dwNewProtection = PAGE_READWRITE;
238-
#if defined(TARGET_UNIX) && !defined(CROSSGEN_COMPILE)
238+
#if defined(TARGET_UNIX) && !defined(CROSSGEN_COMPILE) && !defined(__APPLE__)
239239
if (((pSection->Characteristics & VAL32(IMAGE_SCN_MEM_EXECUTE)) != 0))
240240
{
241241
// On SELinux, we cannot change protection that doesn't have execute access rights
242242
// to one that has it, so we need to set the protection to RWX instead of RW
243243
dwNewProtection = PAGE_EXECUTE_READWRITE;
244244
}
245-
#endif // TARGET_UNIX && !CROSSGEN_COMPILE
245+
#endif // TARGET_UNIX && !CROSSGEN_COMPILE && !__APPLE__
246246
if (!ClrVirtualProtect(pWriteableRegion, cbWriteableRegion,
247247
dwNewProtection, &dwOldProtection))
248248
ThrowLastError();

0 commit comments

Comments
 (0)