|
|
Message-ID: <20251208174940.949856-13-bill.roberts@arm.com>
Date: Mon, 8 Dec 2025 11:44:55 -0600
From: Bill Roberts <bill.roberts@....com>
To: musl@...ts.openwall.com
Cc: Bill Roberts <bill.roberts@....com>
Subject: [RFC 12/14] aarch64: rewrite dlsym routine in C using inline asm
Rewrite the AArch64 dlsym routine from assembly into
implementations using inline assembly.
This change eliminates the need for handwritten function prologues and
epilogues in dlsym.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/ldso/aarch64/dlsym.c | 11 +++++++++++
src/ldso/aarch64/dlsym.s | 6 ------
2 files changed, 11 insertions(+), 6 deletions(-)
create mode 100644 src/ldso/aarch64/dlsym.c
delete mode 100644 src/ldso/aarch64/dlsym.s
diff --git a/src/ldso/aarch64/dlsym.c b/src/ldso/aarch64/dlsym.c
new file mode 100644
index 00000000..eeab1691
--- /dev/null
+++ b/src/ldso/aarch64/dlsym.c
@@ -0,0 +1,11 @@
+void *dlsym(void *handle, const char *name)
+{
+ __asm__ volatile(
+ "mov x2, x30\n\t" // x0 = handle, x1 = name, x2 = caller (LR)
+ "b __dlsym\n\t" // tail-call into __dlsym, which will RET to the original caller
+ :
+ :
+ : "x2"
+ );
+ __builtin_unreachable();
+}
diff --git a/src/ldso/aarch64/dlsym.s b/src/ldso/aarch64/dlsym.s
deleted file mode 100644
index abaae4d5..00000000
--- a/src/ldso/aarch64/dlsym.s
+++ /dev/null
@@ -1,6 +0,0 @@
-.global dlsym
-.hidden __dlsym
-.type dlsym,%function
-dlsym:
- mov x2,x30
- b __dlsym
--
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.