diff options
author | Geoffrey Keating <geoffk@apple.com> | 2006-09-28 07:03:59 +0000 |
---|---|---|
committer | Geoffrey Keating <geoffk@gcc.gnu.org> | 2006-09-28 07:03:59 +0000 |
commit | c6c621d4153e799e4618023a7252244810e1fde7 (patch) | |
tree | 6ac634501bdaf2ff88e85b2b5941422ceb3a20fb | |
parent | f3ed85f6eb9a97b9c75d0f5dbc12e4c4eb2756c9 (diff) | |
download | gcc-c6c621d4153e799e4618023a7252244810e1fde7.zip gcc-c6c621d4153e799e4618023a7252244810e1fde7.tar.gz gcc-c6c621d4153e799e4618023a7252244810e1fde7.tar.bz2 |
darwin.h (ENABLE_EXECUTE_STACK): New, use getpagesize not __sysctl.
* config/darwin.h (ENABLE_EXECUTE_STACK): New, use getpagesize not
__sysctl.
* config/rs6000/darwin.h (ENABLE_EXECUTE_STACK): Remove.
* config/i386/darwin.h (ENABLE_EXECUTE_STACK): Remove.
From-SVN: r117274
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/config/darwin.h | 38 | ||||
-rw-r--r-- | gcc/config/i386/darwin.h | 47 | ||||
-rw-r--r-- | gcc/config/rs6000/darwin.h | 47 |
4 files changed, 45 insertions, 94 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 18fdc4d..9e95e5f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2006-09-27 Geoffrey Keating <geoffk@apple.com> + + * config/darwin.h (ENABLE_EXECUTE_STACK): New, use getpagesize not + __sysctl. + * config/rs6000/darwin.h (ENABLE_EXECUTE_STACK): Remove. + * config/i386/darwin.h (ENABLE_EXECUTE_STACK): Remove. + 2006-09-28 Kaz Kojima <kkojima@gcc.gnu.org> * config/sh/sh.md (divsi_inv_m0): Remove unused variable. diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h index 328754e..6817dc8 100644 --- a/gcc/config/darwin.h +++ b/gcc/config/darwin.h @@ -886,4 +886,42 @@ void add_framework_path (char *); #define TARGET_ASM_OUTPUT_ANCHOR NULL #endif +/* Attempt to turn on execute permission for the stack. This may be + used by INITIALIZE_TRAMPOLINE of the target needs it (that is, + if the target machine can change execute permissions on a page). + + There is no way to query the execute permission of the stack, so + we always issue the mprotect() call. + + Unfortunately it is not possible to make this namespace-clean. + + Also note that no errors should be emitted by this code; it is + considered dangerous for library calls to send messages to + stdout/stderr. */ + +#define ENABLE_EXECUTE_STACK \ +extern void __enable_execute_stack (void *); \ +void \ +__enable_execute_stack (void *addr) \ +{ \ + extern int mprotect (void *, size_t, int); \ + extern int getpagesize (void); \ + static int size; \ + static long mask; \ + \ + char *page, *end; \ + \ + if (size == 0) \ + { \ + size = getpagesize(); \ + mask = ~((long) size - 1); \ + } \ + \ + page = (char *) (((long) addr) & mask); \ + end = (char *) ((((long) (addr + (TARGET_64BIT ? 48 : 40))) & mask) + size); \ + \ + /* 7 == PROT_READ | PROT_WRITE | PROT_EXEC */ \ + (void) mprotect (page, end - page, 7); \ +} + #endif /* CONFIG_DARWIN_H */ diff --git a/gcc/config/i386/darwin.h b/gcc/config/i386/darwin.h index 51259db..61cdeb0 100644 --- a/gcc/config/i386/darwin.h +++ b/gcc/config/i386/darwin.h @@ -204,53 +204,6 @@ extern void darwin_x86_file_end (void); : (n) >= 11 && (n) <= 18 ? (n) + 1 \ : (n)) -/* Attempt to turn on execute permission for the stack. This may be - used by INITIALIZE_TRAMPOLINE of the target needs it (that is, - if the target machine can change execute permissions on a page). - - There is no way to query the execute permission of the stack, so - we always issue the mprotect() call. - - Note that we go out of our way to use namespace-non-invasive calls - here. Unfortunately, there is no libc-internal name for mprotect(). - - Also note that no errors should be emitted by this code; it is - considered dangerous for library calls to send messages to - stdout/stderr. */ - -#define ENABLE_EXECUTE_STACK \ -extern void __enable_execute_stack (void *); \ -void \ -__enable_execute_stack (void *addr) \ -{ \ - extern int mprotect (void *, size_t, int); \ - extern int __sysctl (int *, unsigned int, void *, size_t *, \ - void *, size_t); \ - \ - static int size; \ - static long mask; \ - \ - char *page, *end; \ - \ - if (size == 0) \ - { \ - int mib[2]; \ - size_t len; \ - \ - mib[0] = 6; /* CTL_HW */ \ - mib[1] = 7; /* HW_PAGESIZE */ \ - len = sizeof (size); \ - (void) __sysctl (mib, 2, &size, &len, NULL, 0); \ - mask = ~((long) size - 1); \ - } \ - \ - page = (char *) (((long) addr) & mask); \ - end = (char *) ((((long) (addr + TRAMPOLINE_SIZE)) & mask) + size); \ - \ - /* 7 == PROT_READ | PROT_WRITE | PROT_EXEC */ \ - (void) mprotect (page, end - page, 7); \ -} - #undef REGISTER_TARGET_PRAGMAS #define REGISTER_TARGET_PRAGMAS() DARWIN_REGISTER_TARGET_PRAGMAS() diff --git a/gcc/config/rs6000/darwin.h b/gcc/config/rs6000/darwin.h index 27b0bfb..6594c71 100644 --- a/gcc/config/rs6000/darwin.h +++ b/gcc/config/rs6000/darwin.h @@ -441,50 +441,3 @@ do { \ (TARGET_64BIT \ || (darwin_macosx_version_min \ && strverscmp (darwin_macosx_version_min, "10.3") >= 0)) - -/* Attempt to turn on execute permission for the stack. This may be - used by INITIALIZE_TRAMPOLINE of the target needs it (that is, - if the target machine can change execute permissions on a page). - - There is no way to query the execute permission of the stack, so - we always issue the mprotect() call. - - Note that we go out of our way to use namespace-non-invasive calls - here. Unfortunately, there is no libc-internal name for mprotect(). - - Also note that no errors should be emitted by this code; it is - considered dangerous for library calls to send messages to - stdout/stderr. */ - -#define ENABLE_EXECUTE_STACK \ -extern void __enable_execute_stack (void *); \ -void \ -__enable_execute_stack (void *addr) \ -{ \ - extern int mprotect (void *, size_t, int); \ - extern int __sysctl (int *, unsigned int, void *, size_t *, \ - void *, size_t); \ - \ - static int size; \ - static long mask; \ - \ - char *page, *end; \ - \ - if (size == 0) \ - { \ - int mib[2]; \ - size_t len; \ - \ - mib[0] = 6; /* CTL_HW */ \ - mib[1] = 7; /* HW_PAGESIZE */ \ - len = sizeof (size); \ - (void) __sysctl (mib, 2, &size, &len, NULL, 0); \ - mask = ~((long) size - 1); \ - } \ - \ - page = (char *) (((long) addr) & mask); \ - end = (char *) ((((long) (addr + (TARGET_64BIT ? 48 : 40))) & mask) + size); \ - \ - /* 7 == PROT_READ | PROT_WRITE | PROT_EXEC */ \ - (void) mprotect (page, end - page, 7); \ -} |