[runtime] Allocate code memory using MAP_JIT on apple silicon, patching code randomly...
authormonojenkins <jo.shields+jenkins@xamarin.com>
Thu, 3 Sep 2020 21:56:36 +0000 (17:56 -0400)
committerGitHub <noreply@github.com>
Thu, 3 Sep 2020 21:56:36 +0000 (17:56 -0400)
Co-authored-by: vargaz <vargaz@users.noreply.github.com>
src/mono/mono/utils/mono-mmap.c

index 2dff889..fa4686f 100644 (file)
@@ -305,6 +305,9 @@ mono_valloc (void *addr, size_t length, int flags, MonoMemAccountType type)
                }
                if ((flags & MONO_MMAP_JIT) && (use_mmap_jit || is_hardened_runtime == 1))
                        mflags |= MAP_JIT;
+               /* Patching code on apple silicon seems to cause random crashes without this flag */
+               if (__builtin_available (macOS 11, *))
+                       mflags |= MAP_JIT;
        }
 #endif