blob: e82fdc7147e587edef72fdf4701896935525d601 [file] [log] [blame]
Andrew Geissler23e02792023-07-21 09:06:10 -05001From 1a991cbedf8647d5a1e7c312614f7867c3940968 Mon Sep 17 00:00:00 2001
Patrick Williams92b42cb2022-09-03 06:53:57 -05002From: 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]
Patrick Williams92b42cb2022-09-03 06:53:57 -050027---
28 lib/libutee/arch/arm/utee_syscalls_a32.S | 2 ++
29 lib/libutils/ext/arch/arm/atomic_a32.S | 2 ++
30 lib/libutils/ext/arch/arm/mcount_a32.S | 2 ++
31 lib/libutils/isoc/arch/arm/arm32_aeabi_divmod_a32.S | 2 ++
32 lib/libutils/isoc/arch/arm/arm32_aeabi_ldivmod_a32.S | 2 ++
33 lib/libutils/isoc/arch/arm/setjmp_a32.S | 2 ++
34 ta/arch/arm/ta_entry_a32.S | 2 ++
35 7 files changed, 14 insertions(+)
36
37diff --git a/lib/libutee/arch/arm/utee_syscalls_a32.S b/lib/libutee/arch/arm/utee_syscalls_a32.S
Andrew Geissler23e02792023-07-21 09:06:10 -050038index 6e621ca6e06d..af405f62723c 100644
Patrick Williams92b42cb2022-09-03 06:53:57 -050039--- a/lib/libutee/arch/arm/utee_syscalls_a32.S
40+++ b/lib/libutee/arch/arm/utee_syscalls_a32.S
41@@ -7,6 +7,8 @@
42 #include <tee_syscall_numbers.h>
43 #include <asm.S>
44
45+ .section .note.GNU-stack,"",%progbits
46+
47 .section .text
48 .balign 4
49 .code 32
50diff --git a/lib/libutils/ext/arch/arm/atomic_a32.S b/lib/libutils/ext/arch/arm/atomic_a32.S
Andrew Geissler23e02792023-07-21 09:06:10 -050051index eaef6914734e..2be73ffadcc9 100644
Patrick Williams92b42cb2022-09-03 06:53:57 -050052--- a/lib/libutils/ext/arch/arm/atomic_a32.S
53+++ b/lib/libutils/ext/arch/arm/atomic_a32.S
54@@ -5,6 +5,8 @@
55
56 #include <asm.S>
57
58+ .section .note.GNU-stack,"",%progbits
59+
60 /* uint32_t atomic_inc32(uint32_t *v); */
61 FUNC atomic_inc32 , :
62 ldrex r1, [r0]
63diff --git a/lib/libutils/ext/arch/arm/mcount_a32.S b/lib/libutils/ext/arch/arm/mcount_a32.S
Andrew Geissler23e02792023-07-21 09:06:10 -050064index 51439a23014e..54dc3c02da66 100644
Patrick Williams92b42cb2022-09-03 06:53:57 -050065--- a/lib/libutils/ext/arch/arm/mcount_a32.S
66+++ b/lib/libutils/ext/arch/arm/mcount_a32.S
67@@ -7,6 +7,8 @@
68
69 #if defined(CFG_TA_GPROF_SUPPORT) || defined(CFG_FTRACE_SUPPORT)
70
71+ .section .note.GNU-stack,"",%progbits
72+
73 /*
74 * Convert return address to call site address by subtracting the size of the
75 * mcount call instruction (blx __gnu_mcount_nc).
76diff --git a/lib/libutils/isoc/arch/arm/arm32_aeabi_divmod_a32.S b/lib/libutils/isoc/arch/arm/arm32_aeabi_divmod_a32.S
Andrew Geissler23e02792023-07-21 09:06:10 -050077index a600c879668c..37ae9ec6f9f1 100644
Patrick Williams92b42cb2022-09-03 06:53:57 -050078--- a/lib/libutils/isoc/arch/arm/arm32_aeabi_divmod_a32.S
79+++ b/lib/libutils/isoc/arch/arm/arm32_aeabi_divmod_a32.S
80@@ -5,6 +5,8 @@
81
82 #include <asm.S>
83
84+ .section .note.GNU-stack,"",%progbits
85+
86 /*
87 * signed ret_idivmod_values(signed quot, signed rem);
88 * return quotient and remaining the EABI way (regs r0,r1)
89diff --git a/lib/libutils/isoc/arch/arm/arm32_aeabi_ldivmod_a32.S b/lib/libutils/isoc/arch/arm/arm32_aeabi_ldivmod_a32.S
Andrew Geissler23e02792023-07-21 09:06:10 -050090index 2dc50bc98bbf..5c3353e2c1ba 100644
Patrick Williams92b42cb2022-09-03 06:53:57 -050091--- a/lib/libutils/isoc/arch/arm/arm32_aeabi_ldivmod_a32.S
92+++ b/lib/libutils/isoc/arch/arm/arm32_aeabi_ldivmod_a32.S
93@@ -5,6 +5,8 @@
94
95 #include <asm.S>
96
97+ .section .note.GNU-stack,"",%progbits
98+
99 /*
100 * __value_in_regs lldiv_t __aeabi_ldivmod( long long n, long long d)
101 */
102diff --git a/lib/libutils/isoc/arch/arm/setjmp_a32.S b/lib/libutils/isoc/arch/arm/setjmp_a32.S
Andrew Geissler23e02792023-07-21 09:06:10 -0500103index 43ea593758c9..f8a0b70df705 100644
Patrick Williams92b42cb2022-09-03 06:53:57 -0500104--- a/lib/libutils/isoc/arch/arm/setjmp_a32.S
105+++ b/lib/libutils/isoc/arch/arm/setjmp_a32.S
106@@ -51,6 +51,8 @@
107 #define SIZE(x)
108 #endif
109
110+ .section .note.GNU-stack,"",%progbits
111+
112 /* Arm/Thumb interworking support:
113
114 The interworking scheme expects functions to use a BX instruction
115diff --git a/ta/arch/arm/ta_entry_a32.S b/ta/arch/arm/ta_entry_a32.S
Andrew Geissler23e02792023-07-21 09:06:10 -0500116index d2f8a69daa7f..cd9a12f9dbf9 100644
Patrick Williams92b42cb2022-09-03 06:53:57 -0500117--- a/ta/arch/arm/ta_entry_a32.S
118+++ b/ta/arch/arm/ta_entry_a32.S
119@@ -5,6 +5,8 @@
120
121 #include <asm.S>
122
123+ .section .note.GNU-stack,"",%progbits
124+
125 /*
126 * This function is the bottom of the user call stack. Mark it as such so that
127 * the unwinding code won't try to go further down.