about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRyan Arnold <ryanarn@etna.rchland.ibm.com>2010-06-11 15:11:10 -0500
committerRyan Arnold <ryanarn@etna.rchland.ibm.com>2010-06-29 17:09:36 -0500
commit052b16c76579af4519983e47c8d1d1f05d9a81a8 (patch)
tree19144db266688a1b5b502e55d4c40dca9239f987
parent5af95888b07369ead5620d266bde16d79f8e2f95 (diff)
downloadglibc-052b16c76579af4519983e47c8d1d1f05d9a81a8.tar.gz
glibc-052b16c76579af4519983e47c8d1d1f05d9a81a8.tar.xz
glibc-052b16c76579af4519983e47c8d1d1f05d9a81a8.zip
Experimental patch to default PPC64 to no-execstack support. This will need
to be abstracted to remove the guards from common files and put the stack
initialization into a header file that can be overridden.

2010-06-11  Ryan S. Arnold  <rsa@us.ibm.com>

	* elf/dl-load.c (_dl_map_object_from_fd): Set default stack_flags to
	no-exec for ARCH_PPC64.
	* elf/dl-support.c [_dl_stack_flags]: Set default stack_flags to
	no-exec for ARCH_PPC64.
	* elf/rtld.c (_dl_starting_up): Set default stack_flags to no-exec for
	ARCH_PPC64.
-rw-r--r--ChangeLog9
-rw-r--r--elf/dl-load.c5
-rw-r--r--elf/dl-support.c7
-rw-r--r--elf/rtld.c5
4 files changed, 26 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 928c74aff4..1108ebc3c5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2010-06-11  Ryan S. Arnold  <rsa@us.ibm.com>
+
+	* elf/dl-load.c (_dl_map_object_from_fd): Set default stack_flags to
+	no-exec for ARCH_PPC64.
+	* elf/dl-support.c [_dl_stack_flags]: Set default stack_flags to
+	no-exec for ARCH_PPC64.
+	* elf/rtld.c (_dl_starting_up): Set default stack_flags to no-exec for
+	ARCH_PPC64.
+
 2009-09-04  H.J. Lu  <hongjiu.lu@intel.com>
 
 	* configure.in: Support binutils 2.20.
diff --git a/elf/dl-load.c b/elf/dl-load.c
index 94531b271f..ca7115ee1b 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -1000,8 +1000,13 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp,
 	}
     }
 
+#if (defined (_ARCH_PPC64) || defined (__powerpc64__))
+  /* Default to no-exec stack on PPC64.  */
+  uint_fast16_t stack_flags = PF_R|PF_W;
+#else
   /* Presumed absent PT_GNU_STACK.  */
   uint_fast16_t stack_flags = PF_R|PF_W|PF_X;
+#endif
 
   {
     /* Scan the program header table, collecting its load commands.  */
diff --git a/elf/dl-support.c b/elf/dl-support.c
index 2c11ac6881..582d3ed98d 100644
--- a/elf/dl-support.c
+++ b/elf/dl-support.c
@@ -122,8 +122,15 @@ ElfW(Phdr) *_dl_phdr;
 size_t _dl_phnum;
 uint64_t _dl_hwcap __attribute__ ((nocommon));
 
+
+#if (defined (_ARCH_PPC64) || defined (__powerpc64__))
+/* Default to no-exec stack on PPC64.  */
+/* Prevailing state of the stack, PF_X indicating it's executable.  */
+ElfW(Word) _dl_stack_flags = PF_R|PF_W;
+#else
 /* Prevailing state of the stack, PF_X indicating it's executable.  */
 ElfW(Word) _dl_stack_flags = PF_R|PF_W|PF_X;
+#endif
 
 /* If loading a shared object requires that we make the stack executable
    when it was not, we do it by calling this function.
diff --git a/elf/rtld.c b/elf/rtld.c
index 46bece7fa3..95ba8858e1 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -123,7 +123,12 @@ INTVARDEF(_dl_starting_up)
 struct rtld_global _rtld_global =
   {
     /* Default presumption without further information is executable stack.  */
+#if (defined (_ARCH_PPC64) || defined (__powerpc64__))
+    /* Default to no-exec stack on PPC64.  */
+    ._dl_stack_flags = PF_R|PF_W,
+#else
     ._dl_stack_flags = PF_R|PF_W|PF_X,
+#endif
 #ifdef _LIBC_REENTRANT
     ._dl_load_lock = _RTLD_LOCK_RECURSIVE_INITIALIZER
 #endif