Index: contrib/gcc/config/sparc/freebsd.h =================================================================== RCS file: /home/ncvs/src/contrib/gcc/config/sparc/freebsd.h,v retrieving revision 1.2 diff -u -r1.2 freebsd.h --- contrib/gcc/config/sparc/freebsd.h 12 Sep 2002 17:19:09 -0000 1.2 +++ contrib/gcc/config/sparc/freebsd.h 29 Oct 2002 03:12:48 -0000 @@ -160,3 +160,34 @@ /* We use GNU ld so undefine this so that attribute((init_priority)) works. */ #undef CTORS_SECTION_ASM_OP #undef DTORS_SECTION_ASM_OP + +#define TRANSFER_FROM_TRAMPOLINE \ +static int need_enable_exec_stack; \ + \ +static void check_enabling(void) __attribute__ ((constructor)); \ +static void check_enabling(void) \ +{ \ + extern int sysctlbyname(const char *, void *, size_t *, void *, size_t);\ + size_t len; \ + int prot; \ + \ + prot = 0; \ + len = sizeof(prot); \ + sysctlbyname ("kern.stackprot", &prot, &len, NULL, 0); \ + if (prot != 7) \ + need_enable_exec_stack = 1; \ +} \ + \ +extern void __enable_execute_stack (void *); \ +void \ +__enable_execute_stack (addr) \ + void *addr; \ +{ \ + if (!need_enable_exec_stack) \ + return; \ + else { \ + /* 7 is PROT_READ | PROT_WRITE | PROT_EXEC */ \ + if (mprotect (addr, TRAMPOLINE_SIZE, 7) < 0) \ + perror ("mprotect of trampoline code"); \ + } \ +}