Skip to content

Commit e9f51b8

Browse files
mralephCommit Queue
authored andcommitted
[vm] Disable --write-protect-code on non-Mac OSes.
We still need to maintain W^X on iOS and Mac OS X. TEST=ci Change-Id: I78f005055d090d54f5da478164a73f18e11a32ac Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345303 Reviewed-by: Ryan Macnak <rmacnak@google.com> Commit-Queue: Slava Egorov <vegorov@google.com>
1 parent c338b85 commit e9f51b8

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

runtime/vm/code_patcher.cc

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,20 @@
1010

1111
namespace dart {
1212

13-
DEFINE_FLAG(bool, write_protect_code, true, "Write protect jitted code");
13+
#if defined(DART_HOST_OS_MACOS) || defined(DART_HOST_OS_MACOS_IOS)
14+
// On iOS even with debugger attached we must still guarantee that memory
15+
// is never executable and writable at the same time. On Mac OS X
16+
// com.apple.security.cs.allow-jit entitelement allows WX memory regions to be
17+
// created - but we should not rely on this entitelement to be present.
18+
static constexpr bool kShouldWriteProtectCodeByDefault = true;
19+
#else
20+
static constexpr bool kShouldWriteProtectCodeByDefault = false;
21+
#endif
22+
23+
DEFINE_FLAG(bool,
24+
write_protect_code,
25+
kShouldWriteProtectCodeByDefault,
26+
"Write protect jitted code");
1427

1528
#if defined(TARGET_ARCH_IA32)
1629
WritableInstructionsScope::WritableInstructionsScope(uword address,

0 commit comments

Comments
 (0)