blob: 95d5e676a6e883e994ae38eb97d18c622e4bf31c [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001From 38bf606653ee08b10db6bb298e369cb3a9cdcda9 Mon Sep 17 00:00:00 2001
2From: Jerome Forissier <jerome.forissier@linaro.org>
3Date: Tue, 23 Aug 2022 12:31:46 +0000
4Subject: [PATCH] arm32: libutils, libutee, ta: add .note.GNU-stack section to
5
6 .S files
7
8When building for arm32 with GNU binutils 2.39, the linker outputs
9warnings when linking Trusted Applications:
10
11 arm-unknown-linux-uclibcgnueabihf-ld.bfd: warning: utee_syscalls_a32.o: missing .note.GNU-stack section implies executable stack
12 arm-unknown-linux-uclibcgnueabihf-ld.bfd: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
13
14We could silence the warning by adding the '-z execstack' option to the
15TA link flags, like we did in the parent commit for the TEE core and
16ldelf. Indeed, ldelf always allocates a non-executable piece of memory
17for the TA to use as a stack.
18
19However it seems preferable to comply with the common ELF practices in
20this case. A better fix is therefore to add the missing .note.GNU-stack
21sections in the assembler files.
22
23Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
24
25Signed-off-by: Anton Antonov <Anton.Antonov@arm.com>
26Upstream-Status: Backport [https://github.com/OP-TEE/optee_os/pull/5499]
27
28---
29 lib/libutee/arch/arm/utee_syscalls_a32.S | 2 ++
30 lib/libutils/ext/arch/arm/atomic_a32.S | 2 ++
31 lib/libutils/ext/arch/arm/mcount_a32.S | 2 ++
32 lib/libutils/isoc/arch/arm/arm32_aeabi_divmod_a32.S | 2 ++
33 lib/libutils/isoc/arch/arm/arm32_aeabi_ldivmod_a32.S | 2 ++
34 lib/libutils/isoc/arch/arm/setjmp_a32.S | 2 ++
35 ta/arch/arm/ta_entry_a32.S | 2 ++
36 7 files changed, 14 insertions(+)
37
38diff --git a/lib/libutee/arch/arm/utee_syscalls_a32.S b/lib/libutee/arch/arm/utee_syscalls_a32.S
39index 6e621ca6..af405f62 100644
40--- a/lib/libutee/arch/arm/utee_syscalls_a32.S
41+++ b/lib/libutee/arch/arm/utee_syscalls_a32.S
42@@ -7,6 +7,8 @@
43 #include <tee_syscall_numbers.h>
44 #include <asm.S>
45
46+ .section .note.GNU-stack,"",%progbits
47+
48 .section .text
49 .balign 4
50 .code 32
51diff --git a/lib/libutils/ext/arch/arm/atomic_a32.S b/lib/libutils/ext/arch/arm/atomic_a32.S
52index eaef6914..2be73ffa 100644
53--- a/lib/libutils/ext/arch/arm/atomic_a32.S
54+++ b/lib/libutils/ext/arch/arm/atomic_a32.S
55@@ -5,6 +5,8 @@
56
57 #include <asm.S>
58
59+ .section .note.GNU-stack,"",%progbits
60+
61 /* uint32_t atomic_inc32(uint32_t *v); */
62 FUNC atomic_inc32 , :
63 ldrex r1, [r0]
64diff --git a/lib/libutils/ext/arch/arm/mcount_a32.S b/lib/libutils/ext/arch/arm/mcount_a32.S
65index 51439a23..54dc3c02 100644
66--- a/lib/libutils/ext/arch/arm/mcount_a32.S
67+++ b/lib/libutils/ext/arch/arm/mcount_a32.S
68@@ -7,6 +7,8 @@
69
70 #if defined(CFG_TA_GPROF_SUPPORT) || defined(CFG_FTRACE_SUPPORT)
71
72+ .section .note.GNU-stack,"",%progbits
73+
74 /*
75 * Convert return address to call site address by subtracting the size of the
76 * mcount call instruction (blx __gnu_mcount_nc).
77diff --git a/lib/libutils/isoc/arch/arm/arm32_aeabi_divmod_a32.S b/lib/libutils/isoc/arch/arm/arm32_aeabi_divmod_a32.S
78index a600c879..37ae9ec6 100644
79--- a/lib/libutils/isoc/arch/arm/arm32_aeabi_divmod_a32.S
80+++ b/lib/libutils/isoc/arch/arm/arm32_aeabi_divmod_a32.S
81@@ -5,6 +5,8 @@
82
83 #include <asm.S>
84
85+ .section .note.GNU-stack,"",%progbits
86+
87 /*
88 * signed ret_idivmod_values(signed quot, signed rem);
89 * return quotient and remaining the EABI way (regs r0,r1)
90diff --git a/lib/libutils/isoc/arch/arm/arm32_aeabi_ldivmod_a32.S b/lib/libutils/isoc/arch/arm/arm32_aeabi_ldivmod_a32.S
91index 2dc50bc9..5c3353e2 100644
92--- a/lib/libutils/isoc/arch/arm/arm32_aeabi_ldivmod_a32.S
93+++ b/lib/libutils/isoc/arch/arm/arm32_aeabi_ldivmod_a32.S
94@@ -5,6 +5,8 @@
95
96 #include <asm.S>
97
98+ .section .note.GNU-stack,"",%progbits
99+
100 /*
101 * __value_in_regs lldiv_t __aeabi_ldivmod( long long n, long long d)
102 */
103diff --git a/lib/libutils/isoc/arch/arm/setjmp_a32.S b/lib/libutils/isoc/arch/arm/setjmp_a32.S
104index 43ea5937..f8a0b70d 100644
105--- a/lib/libutils/isoc/arch/arm/setjmp_a32.S
106+++ b/lib/libutils/isoc/arch/arm/setjmp_a32.S
107@@ -51,6 +51,8 @@
108 #define SIZE(x)
109 #endif
110
111+ .section .note.GNU-stack,"",%progbits
112+
113 /* Arm/Thumb interworking support:
114
115 The interworking scheme expects functions to use a BX instruction
116diff --git a/ta/arch/arm/ta_entry_a32.S b/ta/arch/arm/ta_entry_a32.S
117index d2f8a69d..cd9a12f9 100644
118--- a/ta/arch/arm/ta_entry_a32.S
119+++ b/ta/arch/arm/ta_entry_a32.S
120@@ -5,6 +5,8 @@
121
122 #include <asm.S>
123
124+ .section .note.GNU-stack,"",%progbits
125+
126 /*
127 * This function is the bottom of the user call stack. Mark it as such so that
128 * the unwinding code won't try to go further down.