|
|
Message-ID: <20251208174940.949856-9-bill.roberts@arm.com>
Date: Mon, 8 Dec 2025 11:44:51 -0600
From: Bill Roberts <bill.roberts@....com>
To: musl@...ts.openwall.com
Cc: Bill Roberts <bill.roberts@....com>
Subject: [RFC 08/14] aarch64: rewrite __restore_rt routines in C using inline asm
Rewrite the AArch64 __restore_rt routine from assembly into
implementations using inline assembly.
This change eliminates the need for handwritten function prologues and
epilogues in restore.s, which simplifies maintenance and allows the compiler
to automatically insert architecture features such as BTI landing pads and
pointer authentication (PAC) sequences where applicable.
Moving to C also enables the compiler to manage register allocation,
stack usage, and ABI compliance automatically while keeping the low-level
behavior (bitmasks and register accesses) explicit and verifiable.
No functional changes intended.
Signed-off-by: Bill Roberts <bill.roberts@....com>
---
src/signal/aarch64/restore.c | 15 +++++++++++++++
src/signal/aarch64/restore.s | 10 ----------
2 files changed, 15 insertions(+), 10 deletions(-)
create mode 100644 src/signal/aarch64/restore.c
delete mode 100644 src/signal/aarch64/restore.s
diff --git a/src/signal/aarch64/restore.c b/src/signal/aarch64/restore.c
new file mode 100644
index 00000000..f20da148
--- /dev/null
+++ b/src/signal/aarch64/restore.c
@@ -0,0 +1,15 @@
+#include <stddef.h>
+
+__attribute__((visibility("hidden"), noreturn, alias("__restore_rt")))
+void __restore(void);
+
+/* rt_sigreturn on AArch64 = 139 */
+__attribute__((visibility("hidden"), noreturn))
+void __restore_rt(void)
+{
+ __asm__ __volatile__(
+ "mov x8, #139\n\t" /* SYS_rt_sigreturn */
+ "svc #0\n\t"
+ );
+ __builtin_unreachable();
+}
diff --git a/src/signal/aarch64/restore.s b/src/signal/aarch64/restore.s
deleted file mode 100644
index d4e5fcf1..00000000
--- a/src/signal/aarch64/restore.s
+++ /dev/null
@@ -1,10 +0,0 @@
-.global __restore
-.hidden __restore
-.type __restore,%function
-__restore:
-.global __restore_rt
-.hidden __restore_rt
-.type __restore_rt,%function
-__restore_rt:
- mov x8,#139 // SYS_rt_sigreturn
- svc 0
--
2.51.0
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.