This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] Enable -zexecstack on Solaris
- From: David Bartley <dtbartle at csclub dot uwaterloo dot ca>
- To: binutils at sourceware dot org
- Date: Sat, 2 May 2009 16:11:28 -0700
- Subject: [PATCH] Enable -zexecstack on Solaris
Hi,
The attached patch enabled executable stacks on Solaris (via
-zexecstack). On Solaris, this is achieved by setting the final
PT_LOAD section to be executable.
-- David
diff -uraN binutils-2.19.51.orig/bfd/config.in binutils-2.19.51/bfd/config.in
--- binutils-2.19.51.orig/bfd/config.in 2008-11-06 09:10:45.000000000 -0500
+++ binutils-2.19.51/bfd/config.in 2009-05-02 18:55:34.000000000 -0400
@@ -234,6 +234,9 @@
*/
#undef LT_OBJDIR
+/* Enable -zexecstack on Solaris */
+#undef NEED_EXECLASTLOAD
+
/* Name of package */
#undef PACKAGE
diff -uraN binutils-2.19.51.orig/bfd/configure binutils-2.19.51/bfd/configure
--- binutils-2.19.51.orig/bfd/configure 2009-04-17 09:46:11.000000000 -0400
+++ binutils-2.19.51/bfd/configure 2009-05-02 18:53:51.000000000 -0400
@@ -20823,6 +20823,17 @@
+# Enable -zexecstack on Solaris
+case "${target}" in
+ *-*solaris2* | *-*kopensolaris*-gnu*)
+
+cat >>confdefs.h <<\_ACEOF
+#define NEED_EXECLASTLOAD 1
+_ACEOF
+
+ ;;
+esac
+
# target stuff:
# Canonicalize the secondary target names.
diff -uraN binutils-2.19.51.orig/bfd/configure.in binutils-2.19.51/bfd/configure.in
--- binutils-2.19.51.orig/bfd/configure.in 2009-04-17 09:46:16.000000000 -0400
+++ binutils-2.19.51/bfd/configure.in 2009-05-02 18:44:45.000000000 -0400
@@ -544,6 +544,14 @@
AC_SUBST(SHARED_LDFLAGS)
AC_SUBST(SHARED_LIBADD)
+# Enable -zexecstack on Solaris
+case "${target}" in
+ *-*solaris2* | *-*kopensolaris*-gnu*)
+ AC_DEFINE(NEED_EXECLASTLOAD, 1,
+ [Enable -zexecstack on Solaris])
+ ;;
+esac
+
# target stuff:
# Canonicalize the secondary target names.
diff -uraN binutils-2.19.51.orig/bfd/elf.c binutils-2.19.51/bfd/elf.c
--- binutils-2.19.51.orig/bfd/elf.c 2009-04-30 11:47:09.000000000 -0400
+++ binutils-2.19.51/bfd/elf.c 2009-05-02 18:44:45.000000000 -0400
@@ -3824,6 +3824,11 @@
if (m == NULL)
goto error_return;
+#ifdef NEED_EXECLASTLOAD
+ if (info->execstack)
+ m->p_flags = PF_X;
+#endif
+
*pm = m;
pm = &m->next;
}
diff -uraN binutils-2.19.51.orig/ChangeLog binutils-2.19.51/ChangeLog
--- binutils-2.19.51.orig/ChangeLog 2009-04-25 08:24:57.000000000 -0400
+++ binutils-2.19.51/ChangeLog 2009-05-02 18:56:42.000000000 -0400
@@ -1,3 +1,10 @@
+2009-05-02 David Bartley <dtbartle@csclub.uwaterloo.ca>
+
+ * bfd/elf.c: Enable -zexecstack on Solaris.
+ * bfd/configure.in: Likewise.
+ * bfd/configure: Regenerate.
+ * bfd/config.in: Likewise.
+
2009-04-25 Eric Botcazou <ebotcazou@adacore.com>
* Makefile.tpl (POSTSTAGE1_HOST_EXPORTS): Add GNATBIND.