From 47781d53a00496fe2fb8affd73dd8b531cb033d0 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 29 Dec 2007 03:50:29 +0000 Subject: [PATCH] Fixed bug #528 OpenBSD (and possibly others) do not have executable memory by default, so use mprotect() to allow execution of dynamic assembly block. --HG-- branch : SDL-1.2 extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/branches/SDL-1.2%402662 --- src/video/SDL_stretch.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/video/SDL_stretch.c b/src/video/SDL_stretch.c index 2e08c10f3..fd3193963 100644 --- a/src/video/SDL_stretch.c +++ b/src/video/SDL_stretch.c @@ -42,6 +42,15 @@ #ifdef USE_ASM_STRETCH +/* OpenBSD has non-executable memory by default, so use mprotect() */ +#ifdef __OpenBSD__ +#define USE_MPROTECT +#endif +#ifdef USE_MPROTECT +#include +#include +#endif + #if defined(_M_IX86) || defined(i386) #define PREFIX16 0x66 #define STORE_BYTE 0xAA @@ -91,6 +100,9 @@ static int generate_rowbytes(int src_w, int dst_w, int bpp) SDL_SetError("ASM stretch of %d bytes isn't supported\n", bpp); return(-1); } +#ifdef USE_MPROTECT + mprotect(copy_row, sizeof(copy_row), PROT_READ|PROT_WRITE|PROT_EXEC); +#endif pos = 0x10000; inc = (src_w << 16) / dst_w; eip = copy_row;