[vm/ffi] Fix FFI callbacks on iOS 17

The new Secure Page Table Monitor in iOS on A15 and A16 does not allow
`vm_remap`ping memory pages that are manually created. It only allows
remapping pages which come directly from a signed binary.

Manually copying the pages is supported in JIT mode.

TEST=manually tested locally in a local-engine build

Bug: https://github.com/flutter/flutter/issues/136980
Change-Id: I94d87f753a50648486f46fe728dd8358038971fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332241
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
This commit is contained in:
Daco Harkes 2023-10-25 14:00:02 +00:00 committed by Commit Queue
parent 87f62aedad
commit bd57548de1

View file

@ -54,7 +54,8 @@ 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)
#if defined(DART_HOST_OS_MACOS) && \
(defined(DART_PRECOMPILED_RUNTIME) || defined(DART_PRECOMPILER))
// 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