+2010-08-14 Ivan Maidanski <ivmai@mail.ru>
+
+ * os_dep.c (os2_alloc): Don't set PAG_EXECUTE unless
+ pages_executable is on.
+ * os_dep.c (os2_alloc): Add FIXME (for recursion).
+ * os_dep.c (UNPROTECT): Abort with a more informative message if
+ pages_executable is on ("mprotect" case).
+ * os_dep.c (PROTECT, UNPROTECT): Set VM_PROT_EXEC if
+ pages_executable is on (Darwin case).
+ * pthread_support.c (GC_init_real_syms): Abort with an informative
+ message if libgc is linked after libpthread.
+
2010-08-14 Ivan Maidanski <ivmai@mail.ru>
* dyn_load.c (GC_register_dynlib_callback): Adjust "start" pointer
{
void * result;
- if (DosAllocMem(&result, bytes, PAG_EXECUTE | PAG_READ |
- PAG_WRITE | PAG_COMMIT)
+ if (DosAllocMem(&result, bytes, (PAG_READ | PAG_WRITE | PAG_COMMIT)
+ | (pages_executable ? PAG_EXECUTE : 0))
!= NO_ERROR) {
return(0);
}
+ /* FIXME: What's the purpose of this recursion? (Probably, if */
+ /* DosAllocMem returns memory at 0 address then just retry once.) */
if (result == 0) return(os2_alloc(bytes));
return(result);
}
if (mprotect((caddr_t)(addr), (size_t)(len), \
(PROT_READ | PROT_WRITE) \
| (pages_executable ? PROT_EXEC : 0)) < 0) { \
- ABORT("un-mprotect failed"); \
+ ABORT(pages_executable ? "un-mprotect executable page" \
+ " failed (probably disabled by OS)" : \
+ "un-mprotect failed"); \
}
# undef IGNORE_PAGES_EXECUTABLE
STATIC mach_port_t GC_task_self = 0;
# define PROTECT(addr,len) \
if(vm_protect(GC_task_self,(vm_address_t)(addr),(vm_size_t)(len), \
- FALSE,VM_PROT_READ) != KERN_SUCCESS) { \
+ FALSE, VM_PROT_READ \
+ | (pages_executable ? VM_PROT_EXEC : 0)) != KERN_SUCCESS) { \
ABORT("vm_protect (PROTECT) failed"); \
}
# define UNPROTECT(addr,len) \
if(vm_protect(GC_task_self,(vm_address_t)(addr),(vm_size_t)(len), \
- FALSE,VM_PROT_READ|VM_PROT_WRITE) != KERN_SUCCESS) { \
+ FALSE, (VM_PROT_READ | VM_PROT_WRITE) \
+ | (pages_executable ? VM_PROT_EXEC : 0)) != KERN_SUCCESS) { \
ABORT("vm_protect (UNPROTECT) failed"); \
}
# else
# endif
REAL_FUNC(pthread_create) = (GC_pthread_create_t)
dlsym(dl_handle, "pthread_create");
+# ifdef RTLD_NEXT
+ if (REAL_FUNC(pthread_create) == 0)
+ ABORT("pthread_create not found"
+ " (probably -lgc is specified after -lpthread)");
+# endif
REAL_FUNC(pthread_sigmask) = (GC_pthread_sigmask_t)
dlsym(dl_handle, "pthread_sigmask");
REAL_FUNC(pthread_join) = (GC_pthread_join_t)