macOS: Fix Apple hardened runtime support and put behind build option.

Reported by vanc. #1334
This commit is contained in:
Mike Pall 2025-03-10 02:53:20 +01:00
parent e3c70a7d81
commit 4f2bb199fe
2 changed files with 4 additions and 2 deletions

View File

@ -263,7 +263,7 @@ static void *callback_mcode_init(global_State *g, uint32_t *page)
#endif #endif
/* Check for macOS hardened runtime. */ /* Check for macOS hardened runtime. */
#if LUAJIT_SECURITY_MCODE != 0 && defined(MAP_JIT) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 110000 #if defined(LUAJIT_ENABLE_OSX_HRT) && LUAJIT_SECURITY_MCODE != 0 && defined(MAP_JIT) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 110000
#include <pthread.h> #include <pthread.h>
#define CCMAP_CREATE MAP_JIT #define CCMAP_CREATE MAP_JIT
#else #else

View File

@ -99,7 +99,7 @@ static int mcode_setprot(void *p, size_t sz, DWORD prot)
#endif #endif
/* Check for macOS hardened runtime. */ /* Check for macOS hardened runtime. */
#if LUAJIT_SECURITY_MCODE != 0 && defined(MAP_JIT) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 110000 #if defined(LUAJIT_ENABLE_OSX_HRT) && LUAJIT_SECURITY_MCODE != 0 && defined(MAP_JIT) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 110000
#include <pthread.h> #include <pthread.h>
#define MCMAP_CREATE MAP_JIT #define MCMAP_CREATE MAP_JIT
#else #else
@ -111,6 +111,8 @@ static int mcode_setprot(void *p, size_t sz, DWORD prot)
#define MCPROT_RWX (PROT_READ|PROT_WRITE|PROT_EXEC) #define MCPROT_RWX (PROT_READ|PROT_WRITE|PROT_EXEC)
#ifdef PROT_MPROTECT #ifdef PROT_MPROTECT
#define MCPROT_CREATE (PROT_MPROTECT(MCPROT_RWX)) #define MCPROT_CREATE (PROT_MPROTECT(MCPROT_RWX))
#elif MCMAP_CREATE
#define MCPROT_CREATE PROT_EXEC
#else #else
#define MCPROT_CREATE 0 #define MCPROT_CREATE 0
#endif #endif