mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-04-22 06:43:27 +00:00
Update NetBSD support.
no getentropy api support and enable JIT/W^X case explicitally on this platform.
This commit is contained in:
parent
9442226825
commit
6a6dcfdb46
@ -271,7 +271,12 @@ static void callback_mcode_new(CTState *cts)
|
||||
if (!p)
|
||||
lj_err_caller(cts->L, LJ_ERR_FFI_CBACKOV);
|
||||
#elif LJ_TARGET_POSIX
|
||||
p = mmap(NULL, sz, (PROT_READ|PROT_WRITE), MAP_PRIVATE|MAP_ANONYMOUS,
|
||||
#ifndef PROT_MPROTECT
|
||||
// On NetBSD we need to explicitally allow setting executable bit
|
||||
// via PROT_MPROTECT
|
||||
#define PROT_MPROTECT(flag) (0)
|
||||
#endif
|
||||
p = mmap(NULL, sz, (PROT_READ|PROT_WRITE|PROT_MPROTECT(PROT_EXEC)), MAP_PRIVATE|MAP_ANONYMOUS,
|
||||
-1, 0);
|
||||
if (p == MAP_FAILED)
|
||||
lj_err_caller(cts->L, LJ_ERR_FFI_CBACKOV);
|
||||
|
@ -98,9 +98,15 @@ static int mcode_setprot(void *p, size_t sz, DWORD prot)
|
||||
#define MCPROT_RX (PROT_READ|PROT_EXEC)
|
||||
#define MCPROT_RWX (PROT_READ|PROT_WRITE|PROT_EXEC)
|
||||
|
||||
#if !defined(PROT_MPROTECT)
|
||||
// On NetBSD we need this flag to allow mcode_protect
|
||||
// for RWX mode
|
||||
#define PROT_MPROTECT(flag) (0)
|
||||
#endif
|
||||
|
||||
static void *mcode_alloc_at(jit_State *J, uintptr_t hint, size_t sz, int prot)
|
||||
{
|
||||
void *p = mmap((void *)hint, sz, prot, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
|
||||
void *p = mmap((void *)hint, sz, prot|PROT_MPROTECT(MCPROT_RWX), MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
|
||||
if (p == MAP_FAILED) {
|
||||
if (!hint) lj_trace_err(J, LJ_TRERR_MCODEAL);
|
||||
p = NULL;
|
||||
@ -238,7 +244,7 @@ static void *mcode_alloc(jit_State *J, size_t sz)
|
||||
/* All memory addresses are reachable by relative jumps. */
|
||||
static void *mcode_alloc(jit_State *J, size_t sz)
|
||||
{
|
||||
#if defined(__OpenBSD__) || LJ_TARGET_UWP
|
||||
#if defined(__OpenBSD__) || defined(__NetBSD__) || LJ_TARGET_UWP
|
||||
/* Allow better executable memory allocation for OpenBSD W^X mode. */
|
||||
void *p = mcode_alloc_at(J, 0, sz, MCPROT_RUN);
|
||||
if (p && mcode_setprot(p, sz, MCPROT_GEN)) {
|
||||
|
@ -121,7 +121,7 @@ static PRGR libfunc_rgr;
|
||||
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
|
||||
#define LJ_TARGET_HAS_GETENTROPY 1
|
||||
#endif
|
||||
#elif LJ_TARGET_BSD || LJ_TARGET_SOLARIS || LJ_TARGET_CYGWIN
|
||||
#elif (LJ_TARGET_BSD && !defined(__NetBSD__)) || LJ_TARGET_SOLARIS || LJ_TARGET_CYGWIN
|
||||
#define LJ_TARGET_HAS_GETENTROPY 1
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user