[PATCH 2/2] aarch64: Set the syscall register right before doing the syscall.

Joe Simmons-Talbott josimmon@redhat.com
Tue Apr 11 13:30:04 GMT 2023


To make identifying syscalls easier during call tree analysis load the
syscall number just before performing the syscall.
---
 sysdeps/unix/sysv/linux/aarch64/sysdep.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/sysdeps/unix/sysv/linux/aarch64/sysdep.h b/sysdeps/unix/sysv/linux/aarch64/sysdep.h
index e94d1703ad..42a70feac2 100644
--- a/sysdeps/unix/sysv/linux/aarch64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/aarch64/sysdep.h
@@ -167,12 +167,18 @@
 
 # define HAVE_CLONE3_WRAPPER		1
 
+# define MSTR_HELPER(x) # x
+# define MSTR(x) MSTR_HELPER(x)
+
 # undef INTERNAL_SYSCALL_RAW
 # define INTERNAL_SYSCALL_RAW(name, nr, args...)		\
   ({ long _sys_result;						\
      {								\
        LOAD_ARGS_##nr (args)					\
        register long _x8 asm ("x8") = (name);			\
+       if (__builtin_constant_p(name))				\
+         asm volatile ("mov	x8, " MSTR(name) ";"		\
+                       : /* no output */ : "i" (name) : "x8");	\
        asm volatile ("svc	0	// syscall " # name     \
 		     : "=r" (_x0) : "r"(_x8) ASM_ARGS_##nr : "memory");	\
        _sys_result = _x0;					\
-- 
2.39.2



More information about the Libc-alpha mailing list