Andrew Geissler | 23e0279 | 2023-07-21 09:06:10 -0500 | [diff] [blame] | 1 | From 1a991cbedf8647d5a1e7c312614f7867c3940968 Mon Sep 17 00:00:00 2001 |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 2 | From: Jerome Forissier <jerome.forissier@linaro.org> |
| 3 | Date: Tue, 23 Aug 2022 12:31:46 +0000 |
| 4 | Subject: [PATCH] arm32: libutils, libutee, ta: add .note.GNU-stack section to |
| 5 | |
| 6 | .S files |
| 7 | |
| 8 | When building for arm32 with GNU binutils 2.39, the linker outputs |
| 9 | warnings 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 | |
| 14 | We could silence the warning by adding the '-z execstack' option to the |
| 15 | TA link flags, like we did in the parent commit for the TEE core and |
| 16 | ldelf. Indeed, ldelf always allocates a non-executable piece of memory |
| 17 | for the TA to use as a stack. |
| 18 | |
| 19 | However it seems preferable to comply with the common ELF practices in |
| 20 | this case. A better fix is therefore to add the missing .note.GNU-stack |
| 21 | sections in the assembler files. |
| 22 | |
| 23 | Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> |
| 24 | |
| 25 | Signed-off-by: Anton Antonov <Anton.Antonov@arm.com> |
| 26 | Upstream-Status: Backport [https://github.com/OP-TEE/optee_os/pull/5499] |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 27 | --- |
| 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 | |
| 37 | diff --git a/lib/libutee/arch/arm/utee_syscalls_a32.S b/lib/libutee/arch/arm/utee_syscalls_a32.S |
Andrew Geissler | 23e0279 | 2023-07-21 09:06:10 -0500 | [diff] [blame] | 38 | index 6e621ca6e06d..af405f62723c 100644 |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 39 | --- 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 |
| 50 | diff --git a/lib/libutils/ext/arch/arm/atomic_a32.S b/lib/libutils/ext/arch/arm/atomic_a32.S |
Andrew Geissler | 23e0279 | 2023-07-21 09:06:10 -0500 | [diff] [blame] | 51 | index eaef6914734e..2be73ffadcc9 100644 |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 52 | --- 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] |
| 63 | diff --git a/lib/libutils/ext/arch/arm/mcount_a32.S b/lib/libutils/ext/arch/arm/mcount_a32.S |
Andrew Geissler | 23e0279 | 2023-07-21 09:06:10 -0500 | [diff] [blame] | 64 | index 51439a23014e..54dc3c02da66 100644 |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 65 | --- 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). |
| 76 | diff --git a/lib/libutils/isoc/arch/arm/arm32_aeabi_divmod_a32.S b/lib/libutils/isoc/arch/arm/arm32_aeabi_divmod_a32.S |
Andrew Geissler | 23e0279 | 2023-07-21 09:06:10 -0500 | [diff] [blame] | 77 | index a600c879668c..37ae9ec6f9f1 100644 |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 78 | --- 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) |
| 89 | diff --git a/lib/libutils/isoc/arch/arm/arm32_aeabi_ldivmod_a32.S b/lib/libutils/isoc/arch/arm/arm32_aeabi_ldivmod_a32.S |
Andrew Geissler | 23e0279 | 2023-07-21 09:06:10 -0500 | [diff] [blame] | 90 | index 2dc50bc98bbf..5c3353e2c1ba 100644 |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 91 | --- 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 | */ |
| 102 | diff --git a/lib/libutils/isoc/arch/arm/setjmp_a32.S b/lib/libutils/isoc/arch/arm/setjmp_a32.S |
Andrew Geissler | 23e0279 | 2023-07-21 09:06:10 -0500 | [diff] [blame] | 103 | index 43ea593758c9..f8a0b70df705 100644 |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 104 | --- 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 |
| 115 | diff --git a/ta/arch/arm/ta_entry_a32.S b/ta/arch/arm/ta_entry_a32.S |
Andrew Geissler | 23e0279 | 2023-07-21 09:06:10 -0500 | [diff] [blame] | 116 | index d2f8a69daa7f..cd9a12f9dbf9 100644 |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 117 | --- 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. |