Hi,

On some systems executable stacks are denied. Since libunwind and the
tests don't actually need executable stacks this patch marks all
assembly files as not needing it.

The original patch comes from frysk:

2007-04-05  Jan Kratochvil  <[EMAIL PROTECTED]>
 
     * src/hppa/getcontext.S, src/hppa/setcontext.S, src/hppa/siglongjmp.S,
     src/ia64/Ginstall_cursor.S, src/ia64/Linstall_cursor.S,
     src/ia64/dyn_info_list.S, src/ia64/getcontext.S, src/ia64/longjmp.S,
     src/ia64/setjmp.S, src/ia64/siglongjmp.S, src/ia64/sigsetjmp.S,
     src/ppc64/longjmp.S, src/ppc64/siglongjmp.S, src/x86/longjmp.S,
     src/x86/siglongjmp.S, src/x86_64/longjmp.S, src/x86_64/setcontext.S,
     src/x86_64/siglongjmp.S: Stack should be non-executable, for SELinux.

I added a couple more markers for new files in current libunwind.

Before this patch you would get the following on selinux enabled systems
without allow_exec_stack: error while loading shared libraries:
libunwind.so.7: cannot enable executable stack as shared object
requires: Permission denied
After the patch that error disappears and all test results are similar
to the results on systems without executable stack protection.

Cheers,

Mark
diff -r 10a63888dd1b src/hppa/getcontext.S
--- a/src/hppa/getcontext.S	Sat Sep 22 13:06:24 2007 +0000
+++ b/src/hppa/getcontext.S	Mon Sep 24 12:50:18 2007 +0200
@@ -68,3 +68,7 @@ _Uhppa_getcontext:
 
 	bv,n	%r0(%rp)
 	.procend
+#ifdef __linux__
+	/* We do not need executable stack.  */
+	.section	.note.GNU-stack,"",@progbits
+#endif
diff -r 10a63888dd1b src/hppa/setcontext.S
--- a/src/hppa/setcontext.S	Sat Sep 22 13:06:24 2007 +0000
+++ b/src/hppa/setcontext.S	Mon Sep 24 12:50:18 2007 +0200
@@ -71,3 +71,7 @@ _Uhppa_setcontext:
 
 	bv,n	%r0(%rp)
 	.procend
+#ifdef __linux__
+	/* We do not need executable stack.  */
+	.section	.note.GNU-stack,"",@progbits
+#endif
diff -r 10a63888dd1b src/hppa/siglongjmp.S
--- a/src/hppa/siglongjmp.S	Sat Sep 22 13:06:24 2007 +0000
+++ b/src/hppa/siglongjmp.S	Mon Sep 24 12:50:18 2007 +0200
@@ -10,3 +10,7 @@ _UI_longjmp_cont:
 #warning fix me
 	bv	%r0(%rp)
 	.procend
+#ifdef __linux__
+	/* We do not need executable stack.  */
+	.section	.note.GNU-stack,"",@progbits
+#endif
diff -r 10a63888dd1b src/ia64/Ginstall_cursor.S
--- a/src/ia64/Ginstall_cursor.S	Sat Sep 22 13:06:24 2007 +0000
+++ b/src/ia64/Ginstall_cursor.S	Mon Sep 24 12:50:18 2007 +0200
@@ -342,3 +342,7 @@ ia64_install_cursor:
 	.endp ia64_install_cursor
 
 #endif /* !UNW_REMOTE_ONLY */
+#ifdef __linux__
+	/* We do not need executable stack.  */
+	.section	.note.GNU-stack,"",@progbits
+#endif
diff -r 10a63888dd1b src/ia64/Linstall_cursor.S
--- a/src/ia64/Linstall_cursor.S	Sat Sep 22 13:06:24 2007 +0000
+++ b/src/ia64/Linstall_cursor.S	Mon Sep 24 12:50:18 2007 +0200
@@ -1,2 +1,6 @@
 #define UNW_LOCAL_ONLY
 #include "Ginstall_cursor.S"
+#ifdef __linux__
+	/* We do not need executable stack.  */
+	.section	.note.GNU-stack,"",@progbits
+#endif
diff -r 10a63888dd1b src/ia64/dyn_info_list.S
--- a/src/ia64/dyn_info_list.S	Sat Sep 22 13:06:24 2007 +0000
+++ b/src/ia64/dyn_info_list.S	Mon Sep 24 12:50:18 2007 +0200
@@ -20,3 +20,7 @@
 	data8 0, 0, @segrel(.info)
 
 #endif
+#ifdef __linux__
+	/* We do not need executable stack.  */
+	.section	.note.GNU-stack,"",@progbits
+#endif
diff -r 10a63888dd1b src/ia64/getcontext.S
--- a/src/ia64/getcontext.S	Sat Sep 22 13:06:24 2007 +0000
+++ b/src/ia64/getcontext.S	Mon Sep 24 12:50:18 2007 +0200
@@ -171,3 +171,7 @@ _Uia64_getcontext:
 	mov r8 = 0
 	br.ret.sptk.many rp
 	.endp _Uia64_getcontext
+#ifdef __linux__
+	/* We do not need executable stack.  */
+	.section	.note.GNU-stack,"",@progbits
+#endif
diff -r 10a63888dd1b src/ia64/longjmp.S
--- a/src/ia64/longjmp.S	Sat Sep 22 13:06:24 2007 +0000
+++ b/src/ia64/longjmp.S	Mon Sep 24 12:50:18 2007 +0200
@@ -36,3 +36,7 @@ _UI_longjmp_cont:		// non-function label
 	mov r8 = r16
 	br.sptk.many rp
 	.endp longjmp_continuation
+#ifdef __linux__
+	/* We do not need executable stack.  */
+	.section	.note.GNU-stack,"",@progbits
+#endif
diff -r 10a63888dd1b src/ia64/setjmp.S
--- a/src/ia64/setjmp.S	Sat Sep 22 13:06:24 2007 +0000
+++ b/src/ia64/setjmp.S	Mon Sep 24 12:50:18 2007 +0200
@@ -45,3 +45,7 @@ _setjmp:
 	br.ret.sptk.many rp
 
 	.endp _setjmp
+#ifdef __linux__
+	/* We do not need executable stack.  */
+	.section	.note.GNU-stack,"",@progbits
+#endif
diff -r 10a63888dd1b src/ia64/siglongjmp.S
--- a/src/ia64/siglongjmp.S	Sat Sep 22 13:06:24 2007 +0000
+++ b/src/ia64/siglongjmp.S	Mon Sep 24 12:50:18 2007 +0200
@@ -63,3 +63,7 @@ _UI_siglongjmp_cont:		// non-function la
 	mov r8 = loc2
 	br.ret.sptk.many rp
 	.endp siglongjmp_continuation
+#ifdef __linux__
+	/* We do not need executable stack.  */
+	.section	.note.GNU-stack,"",@progbits
+#endif
diff -r 10a63888dd1b src/ia64/sigsetjmp.S
--- a/src/ia64/sigsetjmp.S	Sat Sep 22 13:06:24 2007 +0000
+++ b/src/ia64/sigsetjmp.S	Mon Sep 24 12:50:18 2007 +0200
@@ -63,3 +63,7 @@ __sigsetjmp:
 	br.ret.sptk.many rp
 
 	.endp __sigsetjmp
+#ifdef __linux__
+	/* We do not need executable stack.  */
+	.section	.note.GNU-stack,"",@progbits
+#endif
diff -r 10a63888dd1b src/ppc/longjmp.S
--- a/src/ppc/longjmp.S	Sat Sep 22 13:06:24 2007 +0000
+++ b/src/ppc/longjmp.S	Mon Sep 24 12:53:52 2007 +0200
@@ -29,3 +29,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DE
 	.type _UI_longjmp_cont, @function
 _UI_longjmp_cont:
 	.size _UI_longjmp_cont, .-_UI_longjmp_cont
+
+#ifdef __linux__
+        /* We do not need executable stack.  */
+        .section        .note.GNU-stack,"",@progbits
+#endif
diff -r 10a63888dd1b src/ppc/siglongjmp.S
--- a/src/ppc/siglongjmp.S	Sat Sep 22 13:06:24 2007 +0000
+++ b/src/ppc/siglongjmp.S	Mon Sep 24 12:53:40 2007 +0200
@@ -24,3 +24,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DE
 	.globl _UI_siglongjmp_cont
 
 	_UI_siglongjmp_cont:
+
+#ifdef __linux__
+        /* We do not need executable stack.  */
+        .section        .note.GNU-stack,"",@progbits
+#endif
diff -r 10a63888dd1b src/ppc32/setcontext.S
--- a/src/ppc32/setcontext.S	Sat Sep 22 13:06:24 2007 +0000
+++ b/src/ppc32/setcontext.S	Mon Sep 24 12:54:32 2007 +0200
@@ -2,3 +2,8 @@
 
 _UI_setcontext:
 	retq
+
+#ifdef __linux__
+        /* We do not need executable stack.  */
+        .section        .note.GNU-stack,"",@progbits
+#endif
diff -r 10a63888dd1b src/ppc64/setcontext.S
--- a/src/ppc64/setcontext.S	Sat Sep 22 13:06:24 2007 +0000
+++ b/src/ppc64/setcontext.S	Mon Sep 24 12:53:26 2007 +0200
@@ -2,3 +2,8 @@
 
 _UI_setcontext:
 	retq
+
+#ifdef __linux__
+        /* We do not need executable stack.  */
+        .section        .note.GNU-stack,"",@progbits
+#endif
diff -r 10a63888dd1b src/x86/longjmp.S
--- a/src/x86/longjmp.S	Sat Sep 22 13:06:24 2007 +0000
+++ b/src/x86/longjmp.S	Mon Sep 24 12:50:38 2007 +0200
@@ -35,3 +35,7 @@ _UI_longjmp_cont:
 	ret
 	.cfi_endproc
 	.size _UI_siglongjmp_cont, .-_UI_longjmp_cont
+#ifdef __linux__
+	/* We do not need executable stack.  */
+	.section	.note.GNU-stack,"",@progbits
+#endif
diff -r 10a63888dd1b src/x86/siglongjmp.S
--- a/src/x86/siglongjmp.S	Sat Sep 22 13:06:24 2007 +0000
+++ b/src/x86/siglongjmp.S	Mon Sep 24 12:50:38 2007 +0200
@@ -66,3 +66,7 @@ _UI_siglongjmp_cont:
 	jmp *%edx
 	.cfi_endproc
 	.size _UI_siglongjmp_cont, .-_UI_siglongjmp_cont
+#ifdef __linux__
+	/* We do not need executable stack.  */
+	.section	.note.GNU-stack,"",@progbits
+#endif
diff -r 10a63888dd1b src/x86_64/longjmp.S
--- a/src/x86_64/longjmp.S	Sat Sep 22 13:06:24 2007 +0000
+++ b/src/x86_64/longjmp.S	Mon Sep 24 12:50:38 2007 +0200
@@ -31,3 +31,7 @@ _UI_longjmp_cont:
 	mov %rdx, %rax		/* set up return-value */
 	retq
 	.size _UI_longjmp_cont, .-_UI_longjmp_cont
+#ifdef __linux__
+	/* We do not need executable stack.  */
+	.section	.note.GNU-stack,"",@progbits
+#endif
diff -r 10a63888dd1b src/x86_64/setcontext.S
--- a/src/x86_64/setcontext.S	Sat Sep 22 13:06:24 2007 +0000
+++ b/src/x86_64/setcontext.S	Mon Sep 24 12:51:36 2007 +0200
@@ -57,3 +57,7 @@ _x86_64_setcontext:
 	mov    REG_OFFSET_RDI(%rdi),%rdi
 	retq
 
+#ifdef __linux__
+      /* We do not need executable stack.  */
+      .section        .note.GNU-stack,"",@progbits
+#endif
diff -r 10a63888dd1b src/x86_64/siglongjmp.S
--- a/src/x86_64/siglongjmp.S	Sat Sep 22 13:06:24 2007 +0000
+++ b/src/x86_64/siglongjmp.S	Mon Sep 24 12:50:38 2007 +0200
@@ -27,3 +27,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DE
 
 _UI_siglongjmp_cont:
 	retq
+#ifdef __linux__
+	/* We do not need executable stack.  */
+	.section	.note.GNU-stack,"",@progbits
+#endif
diff -r 10a63888dd1b tests/flush-cache.S
--- a/tests/flush-cache.S	Sat Sep 22 13:06:24 2007 +0000
+++ b/tests/flush-cache.S	Mon Sep 24 12:55:11 2007 +0200
@@ -69,3 +69,8 @@ flush_cache:
 #else
 # error Need flush_cache code for this architecture.
 #endif
+
+#ifdef __linux__
+        /* We do not need executable stack.  */
+        .section        .note.GNU-stack,"",@progbits
+#endif
diff -r 10a63888dd1b tests/ia64-dyn-asm.S
--- a/tests/ia64-dyn-asm.S	Sat Sep 22 13:06:24 2007 +0000
+++ b/tests/ia64-dyn-asm.S	Mon Sep 24 12:55:58 2007 +0200
@@ -95,3 +95,8 @@ func_vframe:
 }
 func_vframe_end:
 	.endp func_vframe
+
+#ifdef __linux__
+        /* We do not need executable stack.  */
+        .section        .note.GNU-stack,"",@progbits
+#endif
diff -r 10a63888dd1b tests/ia64-test-nat-asm.S
--- a/tests/ia64-test-nat-asm.S	Sat Sep 22 13:06:24 2007 +0000
+++ b/tests/ia64-test-nat-asm.S	Mon Sep 24 12:54:57 2007 +0200
@@ -501,3 +501,8 @@ save_pr:
 	br.ret.sptk.many rp
 
 	.endp save_pr
+
+#ifdef __linux__
+        /* We do not need executable stack.  */
+        .section        .note.GNU-stack,"",@progbits
+#endif
diff -r 10a63888dd1b tests/ia64-test-rbs-asm.S
--- a/tests/ia64-test-rbs-asm.S	Sat Sep 22 13:06:24 2007 +0000
+++ b/tests/ia64-test-rbs-asm.S	Mon Sep 24 12:55:48 2007 +0200
@@ -268,3 +268,8 @@ resumption_point_label:
 	;;
 	br.cond.sptk.many b6
 	.endp resumption_point
+
+#ifdef __linux__
+        /* We do not need executable stack.  */
+        .section        .note.GNU-stack,"",@progbits
+#endif
diff -r 10a63888dd1b tests/ia64-test-readonly-asm.S
--- a/tests/ia64-test-readonly-asm.S	Sat Sep 22 13:06:24 2007 +0000
+++ b/tests/ia64-test-readonly-asm.S	Mon Sep 24 12:55:28 2007 +0200
@@ -48,3 +48,8 @@ test_func:
 	br.ret.sptk.many rp
 
 	.endp test_func
+
+#ifdef __linux__
+        /* We do not need executable stack.  */
+        .section        .note.GNU-stack,"",@progbits
+#endif
diff -r 10a63888dd1b tests/ia64-test-stack-asm.S
--- a/tests/ia64-test-stack-asm.S	Sat Sep 22 13:06:24 2007 +0000
+++ b/tests/ia64-test-stack-asm.S	Mon Sep 24 12:56:31 2007 +0200
@@ -176,3 +176,8 @@ touch_all:
 	mov ar.pfs = loc1
 	br.ret.sptk.many rp
 	.endp touch_all
+
+#ifdef __linux__
+        /* We do not need executable stack.  */
+        .section        .note.GNU-stack,"",@progbits
+#endif
_______________________________________________
Libunwind-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/libunwind-devel

Reply via email to