aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Do Nascimento <Victor.DoNascimento@arm.com>2022-08-22 12:39:57 +0100
committerSzabolcs Nagy <szabolcs.nagy@arm.com>2022-08-22 12:39:57 +0100
commitffb6461143e29d34687aca489d9fd8d297dc9920 (patch)
tree09118f9a1cb1b8d38904d8289f412420c9e29b51
parent1d89678cd83c42953467c1405bf596362a7c96c0 (diff)
downloadarm-optimized-routines-ffb6461143e29d34687aca489d9fd8d297dc9920.tar.gz
string: arm: Prevent leaf function unwinding
As leaf functions cannot throw exceptions, with EHABI only supporting synchronous exceptions, add support for emitting a `.cantunwind' directive prior to `.fnend' in ARM_FNEND preprocessor macro. This ensures no personality routine or exception table data is generated. Existing `.save' directives used in leaf functions are also removed. Built w/ arm-none-linux-gnueabihf, ran make check-string w/ qemu-arm-static.
-rw-r--r--string/arm/memchr.S2
-rw-r--r--string/arm/strcmp.S7
-rw-r--r--string/arm/strlen-armv6t2.S7
-rw-r--r--string/asmdefs.h6
4 files changed, 17 insertions, 5 deletions
diff --git a/string/arm/memchr.S b/string/arm/memchr.S
index 77fe569..ddc808b 100644
--- a/string/arm/memchr.S
+++ b/string/arm/memchr.S
@@ -73,7 +73,6 @@ __memchr_arm:
10:
@ At this point, we are aligned, we know we have at least 8 bytes to work with
push {r4,r5,r6,r7}
- .save {r4-r7}
.cfi_adjust_cfa_offset 16
#if HAVE_PAC_LEAF
.cfi_offset 4, -20
@@ -169,6 +168,7 @@ __memchr_arm:
#endif /* HAVE_PAC_LEAF */
bx lr
.cfi_endproc
+ .cantunwind
.fnend
.size __memchr_arm, . - __memchr_arm
diff --git a/string/arm/strcmp.S b/string/arm/strcmp.S
index d891d33..2eb560f 100644
--- a/string/arm/strcmp.S
+++ b/string/arm/strcmp.S
@@ -27,6 +27,11 @@
#define STRCMP_NO_PRECHECK 0
+/* Ensure the .cantunwind directive is prepended to .fnend.
+ Leaf functions cannot throw exceptions - EHABI only supports
+ synchronous exceptions. */
+#define IS_LEAF
+
/* This version uses Thumb-2 code. */
.thumb
.syntax unified
@@ -152,7 +157,6 @@ __strcmp_arm:
bne L(fastpath_exit)
#endif
strd r4, r5, [sp, #-16]!
- .save {r4, r5}
.cfi_adjust_cfa_offset 16
#if HAVE_PAC_LEAF
.cfi_offset 4, -20
@@ -163,7 +167,6 @@ __strcmp_arm:
#endif /* HAVE_PAC_LEAF */
orr tmp1, src1, src2
strd r6, r7, [sp, #8]
- .save {r6, r7}
#if HAVE_PAC_LEAF
.cfi_offset 6, -12
.cfi_offset 7, -8
diff --git a/string/arm/strlen-armv6t2.S b/string/arm/strlen-armv6t2.S
index 2601d03..49ba928 100644
--- a/string/arm/strlen-armv6t2.S
+++ b/string/arm/strlen-armv6t2.S
@@ -24,6 +24,11 @@
#define S2HI lsl
#endif
+/* Ensure the .cantunwind directive is prepended to .fnend.
+ Leaf functions cannot throw exceptions - EHABI only supports
+ synchronous exceptions. */
+#define IS_LEAF
+
/* This code requires Thumb. */
.thumb
.syntax unified
@@ -52,7 +57,6 @@ ENTRY (__strlen_armv6t2)
#endif /* __ARM_FEATURE_BTI_DEFAULT */
.cfi_register 143, 12
push {r4, r5, ip}
- .save {r4, r5, ra_auth_code}
.cfi_def_cfa_offset 12
.cfi_offset 143, -4
.cfi_offset 5, -8
@@ -62,7 +66,6 @@ ENTRY (__strlen_armv6t2)
bti
#endif /* __ARM_FEATURE_BTI_DEFAULT */
push {r4, r5}
- .save {r4, r5}
.cfi_def_cfa_offset 8
.cfi_offset 4, -8
.cfi_offset 5, -4
diff --git a/string/asmdefs.h b/string/asmdefs.h
index d122b26..eb43836 100644
--- a/string/asmdefs.h
+++ b/string/asmdefs.h
@@ -10,7 +10,13 @@
#if defined (__arm__)
#define ARM_FNSTART .fnstart
+#if defined (IS_LEAF)
+#define ARM_FNEND \
+ .cantunwind \
+ .fnend
+#else
#define ARM_FNEND .fnend
+# endif
#else
#define ARM_FNSTART
#define ARM_FNEND