summary refs log tree commit diff
path: root/sysdeps
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-01-13 20:18:20 +0000
committerUlrich Drepper <drepper@redhat.com>2004-01-13 20:18:20 +0000
commit760bafc5aaf124e6eecc9ef0c10816b346270b7a (patch)
treeac7d8cb552074e4e4c2e3901a5356a0a0f7a17ac /sysdeps
parentd1fc817ea459ca28979948fbb23ff58a6f3f4a8c (diff)
downloadglibc-760bafc5aaf124e6eecc9ef0c10816b346270b7a.tar.gz
glibc-760bafc5aaf124e6eecc9ef0c10816b346270b7a.tar.xz
glibc-760bafc5aaf124e6eecc9ef0c10816b346270b7a.zip
(__libc_stack_end): Mark hidden. (_dl_make_stack_executable): Add one more __builtin_expect.
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/unix/sysv/linux/dl-execstack.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/sysdeps/unix/sysv/linux/dl-execstack.c b/sysdeps/unix/sysv/linux/dl-execstack.c
index d93dc8585f..e96197a22e 100644
--- a/sysdeps/unix/sysv/linux/dl-execstack.c
+++ b/sysdeps/unix/sysv/linux/dl-execstack.c
@@ -26,21 +26,21 @@
 #include "kernel-features.h"
 
 
-extern void *__libc_stack_end;
+extern void *__libc_stack_end attribute_hidden;
 
 int
 internal_function
 _dl_make_stack_executable (void **stack_endp)
 {
+  /* This gives us the highest/lowest page that needs to be changed.  */
+  uintptr_t page = (uintptr_t) __libc_stack_end & -(intptr_t) GL(dl_pagesize);
+
   /* Challenge the caller.  */
-  if (*stack_endp != __libc_stack_end)
+  if (__builtin_expect (*stack_endp != __libc_stack_end, 0))
     return EPERM;
   *stack_endp = NULL;
 
 #if _STACK_GROWS_DOWN
-  /* This gives us the highest page that needs to be changed.  */
-  uintptr_t page = (uintptr_t) __libc_stack_end & -(intptr_t) GL(dl_pagesize);
-
   /* Newer Linux kernels support a flag to make our job easy.  */
 # ifdef PROT_GROWSDOWN
 #  if __ASSUME_PROT_GROWSUPDOWN == 0
@@ -48,8 +48,9 @@ _dl_make_stack_executable (void **stack_endp)
   if (! no_growsdown)
 #  endif
     {
-      if (__mprotect ((void *) page, GL(dl_pagesize),
-		      PROT_READ|PROT_WRITE|PROT_EXEC|PROT_GROWSDOWN) == 0)
+      if (__builtin_expect (__mprotect ((void *) page, GL(dl_pagesize),
+					PROT_READ|PROT_WRITE|PROT_EXEC
+					|PROT_GROWSDOWN) == 0, 1))
 	goto return_success;
 #  if __ASSUME_PROT_GROWSUPDOWN == 0
       if (errno == EINVAL)
@@ -95,10 +96,6 @@ _dl_make_stack_executable (void **stack_endp)
 # endif
 
 #elif _STACK_GROWS_UP
-
-  /* This gives us the lowest page that needs to be changed.  */
-  uintptr_t page = (uintptr_t) __libc_stack_end & -(intptr_t) GL(dl_pagesize);
-
   /* Newer Linux kernels support a flag to make our job easy.  */
 # ifdef PROT_GROWSUP
 #  if __ASSUME_PROT_GROWSUPDOWN == 0