Fix broken implementation of NOEXECSTACK flag for MIPS architectures for gcc-linaro-4.8
[openwrt/svn-archive/archive.git] / toolchain / gcc / patches / 4.8-linaro / 930-fix-mips-noexecstack.patch
1 From da45b3fde60095756f5f6030f6012c23a3d34429 Mon Sep 17 00:00:00 2001
2 From: Andrew McDonnell <bugs@andrewmcdonnell.net>
3 Date: Fri, 3 Oct 2014 19:09:00 +0930
4 Subject: Add .note.GNU-stack section
5
6 See http://lists.busybox.net/pipermail/uclibc/2014-October/048671.html
7 Below copied from https://gcc.gnu.org/ml/gcc-patches/2014-09/msg02430.html
8
9 Re: [Patch, MIPS] Add .note.GNU-stack section
10
11 From: Steve Ellcey <sellcey at mips dot com>
12
13 On Wed, 2014-09-10 at 10:15 -0700, Eric Christopher wrote:
14 >
15 >
16 > On Wed, Sep 10, 2014 at 9:27 AM, <pinskia@gmail.com> wrote:
17
18 > This works except you did not update the assembly files in
19 > libgcc or glibc. We (Cavium) have the same patch in our tree
20 > for a few released versions.
21
22 > Mind just checking yours in then Andrew?
23
24 > Thanks!
25 > -eric
26
27 I talked to Andrew about what files he changed in GCC and created and
28 tested this new patch. Andrew also mentioned changing some assembly
29 files in glibc but I don't see any use of '.section .note.GNU-stack' in
30 any assembly files in glibc (for any platform) so I wasn't planning on
31 creating a glibc to add them to mips glibc assembly language files.
32
33 OK to check in this patch?
34
35 Steve Ellcey
36 sellcey@mips.com
37
38
39
40 2014-09-26 Steve Ellcey <sellcey@mips.com>
41 ---
42 gcc/config/mips/mips.c | 3 +++
43 libgcc/config/mips/crti.S | 4 ++++
44 libgcc/config/mips/crtn.S | 3 +++
45 libgcc/config/mips/mips16.S | 4 ++++
46 libgcc/config/mips/vr4120-div.S | 4 ++++
47 5 files changed, 18 insertions(+)
48
49 diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
50 index 41c5d6b..33d9793 100644
51 --- a/gcc/config/mips/mips.c
52 +++ b/gcc/config/mips/mips.c
53 @@ -18223,6 +18223,9 @@ mips_expand_vec_minmax (rtx target, rtx op0, rtx op1,
54 #undef TARGET_VECTORIZE_VEC_PERM_CONST_OK
55 #define TARGET_VECTORIZE_VEC_PERM_CONST_OK mips_vectorize_vec_perm_const_ok
56
57 +#undef TARGET_ASM_FILE_END
58 +#define TARGET_ASM_FILE_END file_end_indicate_exec_stack
59 +
60 struct gcc_target targetm = TARGET_INITIALIZER;
61 \f
62 #include "gt-mips.h"
63 diff --git a/libgcc/config/mips/crti.S b/libgcc/config/mips/crti.S
64 index c7418db..e5f2762 100644
65 --- a/libgcc/config/mips/crti.S
66 +++ b/libgcc/config/mips/crti.S
67 @@ -21,6 +21,10 @@ a copy of the GCC Runtime Library Exception along with this program;
68 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
69 <http://www.gnu.org/licenses/>. */
70
71 +
72 +/* An executable stack is *not* required for these functions. */
73 + .section .note.GNU-stack,"",%progbits
74 +
75 /* 4 slots for argument spill area. 1 for cpreturn, 1 for stack.
76 Return spill offset of 40 and 20. Aligned to 16 bytes for n32. */
77
78 diff --git a/libgcc/config/mips/crtn.S b/libgcc/config/mips/crtn.S
79 index 59d1a90..5cc03bf 100644
80 --- a/libgcc/config/mips/crtn.S
81 +++ b/libgcc/config/mips/crtn.S
82 @@ -21,6 +21,9 @@ a copy of the GCC Runtime Library Exception along with this program;
83 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
84 <http://www.gnu.org/licenses/>. */
85
86 +/* An executable stack is *not* required for these functions. */
87 + .section .note.GNU-stack,"",%progbits
88 +
89 /* 4 slots for argument spill area. 1 for cpreturn, 1 for stack.
90 Return spill offset of 40 and 20. Aligned to 16 bytes for n32. */
91
92 diff --git a/libgcc/config/mips/mips16.S b/libgcc/config/mips/mips16.S
93 index ab3a794..4ded5da 100644
94 --- a/libgcc/config/mips/mips16.S
95 +++ b/libgcc/config/mips/mips16.S
96 @@ -27,6 +27,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
97 values using the soft-float calling convention, but do the actual
98 operation using the hard floating point instructions. */
99
100 +/* An executable stack is *not* required for these functions. */
101 + .section .note.GNU-stack,"",%progbits
102 + .previous
103 +
104 #if defined _MIPS_SIM && (_MIPS_SIM == _ABIO32 || _MIPS_SIM == _ABIO64)
105
106 /* This file contains 32-bit assembly code. */
107 diff --git a/libgcc/config/mips/vr4120-div.S b/libgcc/config/mips/vr4120-div.S
108 index 6e9242a..1e260cd 100644
109 --- a/libgcc/config/mips/vr4120-div.S
110 +++ b/libgcc/config/mips/vr4120-div.S
111 @@ -26,6 +26,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
112 -mfix-vr4120. div and ddiv do not give the correct result when one
113 of the operands is negative. */
114
115 +/* An executable stack is *not* required for these functions. */
116 + .section .note.GNU-stack,"",%progbits
117 + .previous
118 +
119 .set nomips16
120
121 #define DIV \
122 --
123 1.9.1
124