diff options
author | Mike Pall <mike> | 2025-03-10 02:53:20 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2025-03-10 02:53:20 +0100 |
commit | 4f2bb199fe7138247e0b075c886c9e9197cf0271 (patch) | |
tree | c24f4bef87ab4e6374c57b930ae076bd6318c3ad | |
parent | e3c70a7d813ec7e3226510acedd64fc96021d4b0 (diff) | |
download | luajit-4f2bb199fe7138247e0b075c886c9e9197cf0271.tar.gz luajit-4f2bb199fe7138247e0b075c886c9e9197cf0271.tar.bz2 luajit-4f2bb199fe7138247e0b075c886c9e9197cf0271.zip |
macOS: Fix Apple hardened runtime support and put behind build option.
Reported by vanc. #1334
-rw-r--r-- | src/lj_ccallback.c | 2 | ||||
-rw-r--r-- | src/lj_mcode.c | 4 |
2 files changed, 4 insertions, 2 deletions
diff --git a/src/lj_ccallback.c b/src/lj_ccallback.c index d93dbc64..7f08f0a8 100644 --- a/src/lj_ccallback.c +++ b/src/lj_ccallback.c | |||
@@ -263,7 +263,7 @@ static void *callback_mcode_init(global_State *g, uint32_t *page) | |||
263 | #endif | 263 | #endif |
264 | 264 | ||
265 | /* Check for macOS hardened runtime. */ | 265 | /* Check for macOS hardened runtime. */ |
266 | #if LUAJIT_SECURITY_MCODE != 0 && defined(MAP_JIT) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 110000 | 266 | #if defined(LUAJIT_ENABLE_OSX_HRT) && LUAJIT_SECURITY_MCODE != 0 && defined(MAP_JIT) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 110000 |
267 | #include <pthread.h> | 267 | #include <pthread.h> |
268 | #define CCMAP_CREATE MAP_JIT | 268 | #define CCMAP_CREATE MAP_JIT |
269 | #else | 269 | #else |
diff --git a/src/lj_mcode.c b/src/lj_mcode.c index d8fa165e..2b8ac2df 100644 --- a/src/lj_mcode.c +++ b/src/lj_mcode.c | |||
@@ -99,7 +99,7 @@ static int mcode_setprot(void *p, size_t sz, DWORD prot) | |||
99 | #endif | 99 | #endif |
100 | 100 | ||
101 | /* Check for macOS hardened runtime. */ | 101 | /* Check for macOS hardened runtime. */ |
102 | #if LUAJIT_SECURITY_MCODE != 0 && defined(MAP_JIT) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 110000 | 102 | #if defined(LUAJIT_ENABLE_OSX_HRT) && LUAJIT_SECURITY_MCODE != 0 && defined(MAP_JIT) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 110000 |
103 | #include <pthread.h> | 103 | #include <pthread.h> |
104 | #define MCMAP_CREATE MAP_JIT | 104 | #define MCMAP_CREATE MAP_JIT |
105 | #else | 105 | #else |
@@ -111,6 +111,8 @@ static int mcode_setprot(void *p, size_t sz, DWORD prot) | |||
111 | #define MCPROT_RWX (PROT_READ|PROT_WRITE|PROT_EXEC) | 111 | #define MCPROT_RWX (PROT_READ|PROT_WRITE|PROT_EXEC) |
112 | #ifdef PROT_MPROTECT | 112 | #ifdef PROT_MPROTECT |
113 | #define MCPROT_CREATE (PROT_MPROTECT(MCPROT_RWX)) | 113 | #define MCPROT_CREATE (PROT_MPROTECT(MCPROT_RWX)) |
114 | #elif MCMAP_CREATE | ||
115 | #define MCPROT_CREATE PROT_EXEC | ||
114 | #else | 116 | #else |
115 | #define MCPROT_CREATE 0 | 117 | #define MCPROT_CREATE 0 |
116 | #endif | 118 | #endif |