1
0
Fork 0

Added patch 1154355 from Thomas Weidner. Marks memory executable in the dynamic core under 64 bits linux

Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2277
This commit is contained in:
Peter Veenstra 2005-08-18 10:51:57 +00:00
parent 4fd29f7d49
commit 47cde6a97e
3 changed files with 27 additions and 0 deletions

View file

@ -244,6 +244,13 @@ else
AC_MSG_WARN([Can't find libSDL_sound, libSDL_sound support disabled])
fi
dnl Check for mprotect. Needed for 64 bits linux
AH_TEMPLATE(C_HAVE_MPROTECT,[Define to 1 if you have the mprotect function])
AC_CHECK_HEADER([sys/mman.h], [
AC_CHECK_FUNC([mprotect],[AC_DEFINE(C_HAVE_MPROTECT,1)])
])
dnl Setpriority
AH_TEMPLATE(C_SET_PRIORITY,[Define to 1 if you have setpriority support])
AC_MSG_CHECKING(for setpriority support)
AC_LINK_IFELSE([

View file

@ -26,6 +26,15 @@
#include <string.h>
#include <stddef.h>
#if (C_HAVE_MPROTECT)
#include <sys/mman.h>
#include <limits.h>
#ifndef PAGESIZE
#define PAGESIZE 4096
#endif
#endif /* C_HAVE_MPROTECT */
#include "callback.h"
#include "regs.h"
#include "mem.h"

View file

@ -42,10 +42,17 @@ static struct {
CodePageHandler * last_page;
} cache;
#if (C_HAVE_MPROTECT)
static Bit8u cache_code_link_blocks[2][16] GCC_ATTRIBUTE(aligned(PAGESIZE));
static Bit8u cache_code[CACHE_TOTAL+CACHE_MAXSIZE] GCC_ATTRIBUTE(aligned(PAGESIZE));
#else
static Bit8u cache_code_link_blocks[2][16];
static Bit8u cache_code[CACHE_TOTAL+CACHE_MAXSIZE];
#endif
static CacheBlock cache_blocks[CACHE_BLOCKS];
static CacheBlock link_blocks[2];
class CodePageHandler :public PageHandler {
public:
CodePageHandler() {}
@ -338,6 +345,10 @@ static void gen_return(BlockReturn retcode);
static void cache_init(void) {
Bits i;
memset(&cache_blocks,0,sizeof(cache_blocks));
#if (C_HAVE_MPROTECT)
mprotect(cache_code,sizeof(cache_code),PROT_WRITE|PROT_READ|PROT_EXEC);
mprotect(cache_code_link_blocks,sizeof(cache_code_link_blocks),PROT_WRITE|PROT_READ|PROT_EXEC);
#endif
cache.block.free=&cache_blocks[0];
for (i=0;i<CACHE_BLOCKS-1;i++) {
cache_blocks[i].link[0].to=(CacheBlock *)1;