From 542d168a06b8999e7c0409f5c41eb9a64eb9624c Mon Sep 17 00:00:00 2001 From: Manish Godse <61718172+mangod9@users.noreply.github.com> Date: Wed, 23 Feb 2022 10:54:04 -0800 Subject: [PATCH] Revert "[release/6.0] Fix ReadyToRun loading on Apple Silicon (#64104)" This reverts commit 8f7dff32974a6d387e3b99e95f522ee9377e6e15. --- src/coreclr/jit/importer.cpp | 4 ---- src/coreclr/pal/src/map/map.cpp | 4 ++-- src/coreclr/vm/jitinterface.cpp | 7 ------- src/coreclr/vm/peimagelayout.cpp | 4 ++-- 4 files changed, 4 insertions(+), 15 deletions(-) diff --git a/src/coreclr/jit/importer.cpp b/src/coreclr/jit/importer.cpp index 18208214d0b44..04e074cf44912 100644 --- a/src/coreclr/jit/importer.cpp +++ b/src/coreclr/jit/importer.cpp @@ -6960,9 +6960,7 @@ void Compiler::impImportNewObjArray(CORINFO_RESOLVED_TOKEN* pResolvedToken, CORI // CLANG_FORMAT_COMMENT_ANCHOR; -#ifndef OSX_ARM64_ABI if (!opts.IsReadyToRun() || IsTargetAbi(CORINFO_CORERT_ABI)) -#endif // !OSX_ARM64_ABI { // Reuse the temp used to pass the array dimensions to avoid bloating @@ -7019,7 +7017,6 @@ void Compiler::impImportNewObjArray(CORINFO_RESOLVED_TOKEN* pResolvedToken, CORI node = gtNewHelperCallNode(CORINFO_HELP_NEW_MDARR_NONVARARG, TYP_REF, args); } -#ifndef OSX_ARM64_ABI else { // @@ -7049,7 +7046,6 @@ void Compiler::impImportNewObjArray(CORINFO_RESOLVED_TOKEN* pResolvedToken, CORI } #endif } -#endif // !OSX_ARM64_ABI for (GenTreeCall::Use& use : node->AsCall()->Args()) { diff --git a/src/coreclr/pal/src/map/map.cpp b/src/coreclr/pal/src/map/map.cpp index 17ced208d6878..af97934f7ca84 100644 --- a/src/coreclr/pal/src/map/map.cpp +++ b/src/coreclr/pal/src/map/map.cpp @@ -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_WRITE) == -1) || + if ((mprotect(pvBaseAddress, len + adjust, prot | PROT_WRITE) == -1) || (pread(fd, pvBaseAddress, len + adjust, offset - adjust) == -1) || - (mprotect(pvBaseAddress, len + adjust, prot) == -1)) + (((prot & PROT_WRITE) == 0) && mprotect(pvBaseAddress, len + adjust, prot) == -1)) { palError = FILEGetLastErrorFromErrno(); } diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index 59fcb0c9f5ec9..75d3160dda7b1 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -14200,13 +14200,6 @@ BOOL LoadDynamicInfoEntry(Module *currentModule, CorInfoHelpFunc corInfoHelpFunc = MapReadyToRunHelper((ReadyToRunHelper)helperNum); if (corInfoHelpFunc != CORINFO_HELP_UNDEF) { -#ifdef OSX_ARM64_ABI - if (corInfoHelpFunc == CORINFO_HELP_NEW_MDARR) - { - STRESS_LOG(LF_ZAP, LL_WARNING, "CORINFO_HELP_NEW_MDARR is not supported on osx-arm64\n"); - return FALSE; - } -#endif // OSX_ARM64_ABI result = (size_t)CEEJitInfo::getHelperFtnStatic(corInfoHelpFunc); } else diff --git a/src/coreclr/vm/peimagelayout.cpp b/src/coreclr/vm/peimagelayout.cpp index 16f6dcb6dbf5e..76a4f52d6edd3 100644 --- a/src/coreclr/vm/peimagelayout.cpp +++ b/src/coreclr/vm/peimagelayout.cpp @@ -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) && !defined(__APPLE__) +#if defined(TARGET_UNIX) && !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 // TARGET_UNIX && !CROSSGEN_COMPILE && !__APPLE__ +#endif // TARGET_UNIX && !CROSSGEN_COMPILE if (!ClrVirtualProtect(pWriteableRegion, cbWriteableRegion, dwNewProtection, &dwOldProtection)) ThrowLastError();