From 4d8ef87936f90fdb45c0e052708f770083cdca7c Mon Sep 17 00:00:00 2001 From: Jethro Grassie Date: Sat, 13 Nov 2021 08:53:57 -0500 Subject: [PATCH] pageProtect when missing pthread_jit_write_protect_np --- src/virtual_memory.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/virtual_memory.cpp b/src/virtual_memory.cpp index af2b696..caf0292 100644 --- a/src/virtual_memory.cpp +++ b/src/virtual_memory.cpp @@ -142,6 +142,8 @@ void setPagesRW(void* ptr, std::size_t bytes) { && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_11_0 if (__builtin_available(macOS 11.0, *)) { pthread_jit_write_protect_np(false); + } else { + pageProtect(ptr, bytes, PAGE_READWRITE); } #else pageProtect(ptr, bytes, PAGE_READWRITE); @@ -153,6 +155,8 @@ void setPagesRX(void* ptr, std::size_t bytes) { && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_11_0 if (__builtin_available(macOS 11.0, *)) { pthread_jit_write_protect_np(true); + } else { + pageProtect(ptr, bytes, PAGE_EXECUTE_READ); } #else pageProtect(ptr, bytes, PAGE_EXECUTE_READ);