Commit 10a9b180 authored by dons's avatar dons
Browse files

[project @ 2004-09-13 09:19:16 by dons]

malloc memory isn't executable by default on OpenBSD, so mprotect
pages in execPage for that platform. Enables the FFI.

Merge to stable
parent 4bd153f2
......@@ -46,6 +46,11 @@ Haskell side.
#include <windows.h>
#endif
#if defined(openbsd_TARGET_OS)
#include <unistd.h>
#include <sys/mman.h>
#endif
/* Heavily arch-specific, I'm afraid.. */
typedef enum {
......@@ -79,6 +84,15 @@ execPage (void* addr, pageMode mode)
barf("execPage: failed to protect 0x%p; error=%lu; old protection: %lu\n", addr, rc, dwOldProtect);
}
#else
#if defined(openbsd_TARGET_OS)
/* malloc memory isn't executable by default on OpenBSD */
unsigned long pagesize = sysconf(_SC_PAGESIZE);
unsigned long round = (unsigned long)addr & (pagesize - 1);
if (mprotect(addr - round, pagesize, PROT_EXEC|PROT_READ|PROT_WRITE) == -1)
barf("execPage: failed to protect 0x%p\n", addr);
#endif
(void)addr; (void)mode; /* keep gcc -Wall happy */
#endif
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment