Mercurial > pub > dyncall > dyncall
diff dyncallback/dyncall_alloc_wx_mmap.c @ 251:3f7c69fadfc3
- regression fix for changing writable to executable memory for platforms where
mmap has no MAP_ANON (usually older platforms, e.g. solaris 7)
author | Tassilo Philipp |
---|---|
date | Sun, 14 May 2017 02:26:21 +0200 |
parents | 030fbb70aa1b |
children | 047d2829bdf6 |
line wrap: on
line diff
--- a/dyncallback/dyncall_alloc_wx_mmap.c Sun May 14 00:19:15 2017 +0200 +++ b/dyncallback/dyncall_alloc_wx_mmap.c Sun May 14 02:26:21 2017 +0200 @@ -45,8 +45,8 @@ { void* p; #if !defined(MAP_ANON) && defined(DC_UNIX) - // Hack around not having POSIX' MAP_ANON by going through /dev/zero; store - // file descriptor to close on dcFreeWX at beginning of memory, as tiny hack + /* Hack around not having POSIX' MAP_ANON by going through /dev/zero; store + file descr to close on dcFreeWX at beginning of memory, as tiny hack */ int fd = open("/dev/zero", O_RDWR); if(fd == -1) return -1; @@ -69,13 +69,17 @@ DCerror dcInitExecWX(void* p, size_t size) { +#if !defined(MAP_ANON) && defined(DC_UNIX) + /* Fixup pointer for no-MAP_ANON workaround (see above) */ + p -= sizeof(int); +#endif return mprotect(p, size, PROT_READ|PROT_EXEC); } void dcFreeWX(void* p, size_t size) { #if !defined(MAP_ANON) && defined(DC_UNIX) - // Close file descriptor of no-MAP_ANON workaround (see above) + /* Close file descriptor for no-MAP_ANON workaround (see above) */ p -= sizeof(int); size += sizeof(int); close(*(int*)p);