Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix broken ReadyToRun loading on Apple Silicon
  • Loading branch information
jgiannuzzi committed Jan 19, 2022
commit 6e24b2dc1fd273a9c820162235fe4909fefa8778
4 changes: 2 additions & 2 deletions src/coreclr/pal/src/map/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2047,9 +2047,9 @@ MAPmmapAndRecord(

// Set the requested mapping with forced PROT_WRITE to ensure data from the file can be read there,
// read the data in and finally remove the forced PROT_WRITE
if ((mprotect(pvBaseAddress, len + adjust, prot | PROT_WRITE) == -1) ||
if ((mprotect(pvBaseAddress, len + adjust, PROT_WRITE) == -1) ||
(pread(fd, pvBaseAddress, len + adjust, offset - adjust) == -1) ||
(((prot & PROT_WRITE) == 0) && mprotect(pvBaseAddress, len + adjust, prot) == -1))
(mprotect(pvBaseAddress, len + adjust, prot) == -1))
{
palError = FILEGetLastErrorFromErrno();
}
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/vm/peimagelayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,14 @@ void PEImageLayout::ApplyBaseRelocations()
if (((pSection->Characteristics & VAL32(IMAGE_SCN_MEM_WRITE)) == 0))
{
DWORD dwNewProtection = PAGE_READWRITE;
#if defined(TARGET_UNIX) && !defined(CROSSGEN_COMPILE)
#if defined(TARGET_UNIX) && !defined(CROSSGEN_COMPILE) && !defined(__APPLE__)
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 // TARGET_UNIX && !CROSSGEN_COMPILE
#endif // TARGET_UNIX && !CROSSGEN_COMPILE && !__APPLE__
if (!ClrVirtualProtect(pWriteableRegion, cbWriteableRegion,
dwNewProtection, &dwOldProtection))
ThrowLastError();
Expand Down