diff --git a/runtime/vm/ffi_callback_metadata.cc b/runtime/vm/ffi_callback_metadata.cc index 94ba8726444..c8d5f3c816f 100644 --- a/runtime/vm/ffi_callback_metadata.cc +++ b/runtime/vm/ffi_callback_metadata.cc @@ -97,8 +97,19 @@ VirtualMemory* FfiCallbackMetadata::AllocateTrampolinePage() { UNREACHABLE(); return nullptr; #else + +#if defined(DART_HOST_OS_MACOS) && !defined(DART_PRECOMPILED_RUNTIME) + // If we are not going to use vm_remap then we need to pass + // is_executable=true so that pages get allocated with MAP_JIT flag if + // necessary. Otherwise OS will kill us with a codesigning violation if + // hardened runtime is enabled. + const bool is_executable = true; +#else + const bool is_executable = false; +#endif + VirtualMemory* new_page = VirtualMemory::AllocateAligned( - MappingSize(), MappingAlignment(), /*is_executable=*/false, + MappingSize(), MappingAlignment(), is_executable, /*is_compressed=*/false, "FfiCallbackMetadata::TrampolinePage"); if (new_page == nullptr) { return nullptr; diff --git a/runtime/vm/virtual_memory.cc b/runtime/vm/virtual_memory.cc index b6a54951aff..0220cd7f1fb 100644 --- a/runtime/vm/virtual_memory.cc +++ b/runtime/vm/virtual_memory.cc @@ -54,8 +54,7 @@ bool VirtualMemory::DuplicateRX(VirtualMemory* target) { const intptr_t aligned_size = Utils::RoundUp(size(), PageSize()); ASSERT_LESS_OR_EQUAL(aligned_size, target->size()); -#if defined(DART_HOST_OS_MACOS) && \ - (defined(DART_PRECOMPILED_RUNTIME) || defined(DART_PRECOMPILER)) +#if defined(DART_HOST_OS_MACOS) && defined(DART_PRECOMPILED_RUNTIME) // Mac is special cased because iOS doesn't allow allocating new executable // memory, so the default approach would fail. We are allowed to make new // mappings of existing executable memory using vm_remap though, which is