NetBSD: Use PROT_MPROTECT() and disable getentropy().
Note: this is not an officially supported target. Contributed by David Carlier.
This commit is contained in:
@@ -97,10 +97,15 @@ static int mcode_setprot(void *p, size_t sz, DWORD prot)
|
||||
#define MCPROT_RW (PROT_READ|PROT_WRITE)
|
||||
#define MCPROT_RX (PROT_READ|PROT_EXEC)
|
||||
#define MCPROT_RWX (PROT_READ|PROT_WRITE|PROT_EXEC)
|
||||
#ifdef PROT_MPROTECT
|
||||
#define MCPROT_CREATE (PROT_MPROTECT(MCPROT_RWX))
|
||||
#else
|
||||
#define MCPROT_CREATE 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|MCPROT_CREATE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
|
||||
if (p == MAP_FAILED) {
|
||||
if (!hint) lj_trace_err(J, LJ_TRERR_MCODEAL);
|
||||
p = NULL;
|
||||
@@ -238,7 +243,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)) {
|
||||
|
||||
Reference in New Issue
Block a user