Skip to content
Permalink
Browse files

Fixed bug #528

OpenBSD (and possibly others) do not have executable memory by default,
so use mprotect() to allow execution of dynamic assembly block.
  • Loading branch information
slouken committed Dec 29, 2007
1 parent 0cc7b28 commit 3702444f5883b4650dc89802b10389b9e46dc00d
Showing with 12 additions and 0 deletions.
  1. +12 −0 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 <sys/types.h>
#include <sys/mman.h>
#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;

0 comments on commit 3702444

Please sign in to comment.