From 9dbe48ac2d14742d2acefb9cb4138b810a1a128e Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Mon, 22 Mar 2010 12:42:48 -0700 Subject: [PATCH] Move non-executable stack assembly code to end of file The non-executable stack annotation used for Linux works by adding an additional section to the generated object. The annotation added in 9bfd03d723a9cf17673f40513a7adde1d503bcbc was added to the beginning of each assembly file. This caused build failures on Linux s390 because the remainder of the assembly code was then put in that section, which was discarded during linking. Add the annotation to the end of each assembly file instead, following the instructions at: http://www.gentoo.org/proj/en/hardened/gnu-stack.xml Change-Id: I5bd2d8d0ac31932b59757dcec0a942c459d61cac Reviewed-on: http://gerrit.openafs.org/1615 Tested-by: Russ Allbery Reviewed-by: Simon Wilkinson Reviewed-by: Derrick Brashear --- src/lwp/process.amd64.s | 7 +++---- src/lwp/process.i386.s | 6 +++--- src/lwp/process.s | 7 +++---- src/lwp/process.s390.s | 7 +++---- src/lwp/process.s390x.s | 7 +++---- src/sys/syscall.s | 7 +++---- 6 files changed, 18 insertions(+), 23 deletions(-) diff --git a/src/lwp/process.amd64.s b/src/lwp/process.amd64.s index 1d59cd4..c7e1f2a 100644 --- a/src/lwp/process.amd64.s +++ b/src/lwp/process.amd64.s @@ -47,10 +47,6 @@ #include -#if defined(__linux__) && defined(__ELF__) - .section .note.GNU-stack,"",%progbits -#endif - .file "process.s" .data .text @@ -163,3 +159,6 @@ ENTRY(returnto) pushq $1234 call _C_LABEL(abort) +#if defined(__linux__) && defined(__ELF__) + .section .note.GNU-stack,"",%progbits +#endif diff --git a/src/lwp/process.i386.s b/src/lwp/process.i386.s index f5b3bc4..15173aa 100644 --- a/src/lwp/process.i386.s +++ b/src/lwp/process.i386.s @@ -17,9 +17,6 @@ */ #include -#if defined(__linux__) && defined(__ELF__) - .section .note.GNU-stack,"",%progbits -#endif .file "process.s" @@ -82,3 +79,6 @@ ENTRY(returnto) popl %ebp ret +#if defined(__linux__) && defined(__ELF__) + .section .note.GNU-stack,"",%progbits +#endif diff --git a/src/lwp/process.s b/src/lwp/process.s index 4f81456..5d26c87 100644 --- a/src/lwp/process.s +++ b/src/lwp/process.s @@ -10,10 +10,6 @@ #define IGNORE_STDS_H 1 #include -#if defined(__linux__) && defined(__ELF__) - .section .note.GNU-stack,"",%progbits -#endif - #if defined(__arm32__) || defined(__arm__) /* register definitions */ fp .req r11 @@ -1291,3 +1287,6 @@ returnto: blr #endif +#if defined(__linux__) && defined(__ELF__) + .section .note.GNU-stack,"",%progbits +#endif diff --git a/src/lwp/process.s390.s b/src/lwp/process.s390.s index 585404f..bda4522 100644 --- a/src/lwp/process.s390.s +++ b/src/lwp/process.s390.s @@ -16,10 +16,6 @@ #define IGNORE_STDS_H 1 #include -#if defined(__linux__) && defined(__ELF__) - .section .note.GNU-stack,"",%progbits -#endif - .file "process.s" .globl savecontext @@ -100,3 +96,6 @@ returnto: .returnto_end: .size returnto,.returnto_end-returnto +#if defined(__linux__) && defined(__ELF__) + .section .note.GNU-stack,"",%progbits +#endif diff --git a/src/lwp/process.s390x.s b/src/lwp/process.s390x.s index f3087bf..f24afdc 100644 --- a/src/lwp/process.s390x.s +++ b/src/lwp/process.s390x.s @@ -17,10 +17,6 @@ #define IGNORE_STDS_H 1 #include -#if defined(__linux__) && defined(__ELF__) - .section .note.GNU-stack,"",%progbits -#endif - .file "process.s" .globl savecontext @@ -100,3 +96,6 @@ returnto: .returnto_end: .size returnto,.returnto_end-returnto +#if defined(__linux__) && defined(__ELF__) + .section .note.GNU-stack,"",%progbits +#endif diff --git a/src/sys/syscall.s b/src/sys/syscall.s index c42d578..f14651f 100644 --- a/src/sys/syscall.s +++ b/src/sys/syscall.s @@ -10,10 +10,6 @@ #define IGNORE_STDS_H #include -#if defined(__linux__) && defined(__ELF__) - .section .note.GNU-stack,"",%progbits -#endif - #if defined(AFS_AIX32_ENV) && defined(RIOS) /* * This is never be referenced, and is only here as placeholder; @@ -66,3 +62,6 @@ LEAF(afs_syscall) #endif /* AFS_SGI_ENV */ #endif +#if defined(__linux__) && defined(__ELF__) + .section .note.GNU-stack,"",%progbits +#endif -- 1.9.4