From: dons Date: Mon, 13 Sep 2004 09:19:16 +0000 (+0000) Subject: [project @ 2004-09-13 09:19:16 by dons] X-Git-Tag: Initial_conversion_from_CVS_complete~1607 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=10a9b180ee41f88056b50327fb898dca93a1dbb1;hp=4bd153f2dd93745183584054e17c6ff169691a49;p=ghc-hetmet.git [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 --- diff --git a/ghc/rts/Adjustor.c b/ghc/rts/Adjustor.c index 3b93989..bf1002d 100644 --- a/ghc/rts/Adjustor.c +++ b/ghc/rts/Adjustor.c @@ -46,6 +46,11 @@ Haskell side. #include #endif +#if defined(openbsd_TARGET_OS) +#include +#include +#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 }