mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-18 06:51:47 +00:00
not all systems (eg, QNX) that have mprotect have getpagesize
This commit is contained in:
parent
37f660801b
commit
b36bd6a98c
2 changed files with 8 additions and 7 deletions
|
@ -425,7 +425,7 @@ AC_CHECK_FUNCS(
|
||||||
access _access gethostname gethostbyname connect gettimeofday getwd \
|
access _access gethostname gethostbyname connect gettimeofday getwd \
|
||||||
mkdir _mkdir ftime _ftime fcntl stat putenv select socket strerror \
|
mkdir _mkdir ftime _ftime fcntl stat putenv select socket strerror \
|
||||||
strcasestr strnlen strstr snprintf _snprintf vsnprintf _vsnprintf \
|
strcasestr strnlen strstr snprintf _snprintf vsnprintf _vsnprintf \
|
||||||
strsep dlopen getaddrinfo getnameinfo mprotect
|
strsep dlopen getaddrinfo getnameinfo mprotect getpagesize
|
||||||
)
|
)
|
||||||
|
|
||||||
DL_LIBS=""
|
DL_LIBS=""
|
||||||
|
|
|
@ -338,15 +338,16 @@ Sys_MakeCodeWriteable (unsigned long startaddr, unsigned long length)
|
||||||
#else
|
#else
|
||||||
# ifdef HAVE_MPROTECT
|
# ifdef HAVE_MPROTECT
|
||||||
int r;
|
int r;
|
||||||
unsigned long addr;
|
unsigned long endaddr = startaddr + length;
|
||||||
|
|
||||||
|
# ifdef HAVE_GETPAGESIZE
|
||||||
int psize = getpagesize ();
|
int psize = getpagesize ();
|
||||||
|
|
||||||
addr = (startaddr & ~(psize - 1)) - psize;
|
startaddr &= ~(psize - 1);
|
||||||
|
endaddr = (endaddr + psize - 1) & ~(psize - 1);
|
||||||
|
# endif
|
||||||
|
|
||||||
// fprintf(stderr, "writable code %lx(%lx)-%lx, length=%lx\n", startaddr,
|
r = mprotect ((char *) startaddr, endaddr - startaddr, 7);
|
||||||
// addr, startaddr+length, length);
|
|
||||||
|
|
||||||
r = mprotect ((char *) addr, length + startaddr - addr + psize, 7);
|
|
||||||
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
Sys_Error ("Protection change failed");
|
Sys_Error ("Protection change failed");
|
||||||
|
|
Loading…
Reference in a new issue