]> granicus.if.org Git - strace/commitdiff
Handle very special __ARM_NR_-prefixed syscalls
authorEugene Syromyatnikov <evgsyr@gmail.com>
Wed, 31 Jan 2018 19:28:56 +0000 (20:28 +0100)
committerDmitry V. Levin <ldv@altlinux.org>
Sat, 10 Feb 2018 00:01:01 +0000 (00:01 +0000)
* linux/aarch64/nr_prefix.c: New file.
* linux/arm/nr_prefix.c: Likewise.
* linux/nr_prefix.c: Likewise.
* Makefile.am (EXTRA_DIST): Add them.
* printsiginfo.c: Include nr_prefix.c
(print_si_info): Use nr_prefix.

Makefile.am
linux/aarch64/nr_prefix.c [new file with mode: 0644]
linux/arm/nr_prefix.c [new file with mode: 0644]
linux/nr_prefix.c [new file with mode: 0644]
printsiginfo.c

index 137063d615e6dea5bcd764bc85653e5da4a4a3a1..5cf2c9bf1de91608982df1b679ee53693c29e89d 100644 (file)
@@ -404,6 +404,7 @@ EXTRA_DIST =                                \
        linux/aarch64/ioctls_arch1.h    \
        linux/aarch64/ioctls_inc0.h     \
        linux/aarch64/ioctls_inc1.h     \
+       linux/aarch64/nr_prefix.c       \
        linux/aarch64/set_error.c       \
        linux/aarch64/set_scno.c        \
        linux/aarch64/shuffle_scno.c    \
@@ -453,6 +454,7 @@ EXTRA_DIST =                                \
        linux/arm/get_syscall_args.c    \
        linux/arm/ioctls_arch0.h        \
        linux/arm/ioctls_inc0.h         \
+       linux/arm/nr_prefix.c           \
        linux/arm/set_error.c           \
        linux/arm/set_scno.c            \
        linux/arm/shuffle_scno.c        \
@@ -611,6 +613,7 @@ EXTRA_DIST =                                \
        linux/nios2/set_error.c         \
        linux/nios2/set_scno.c          \
        linux/nios2/syscallent.h        \
+       linux/nr_prefix.c               \
        linux/or1k/arch_regs.c          \
        linux/or1k/arch_regs.h          \
        linux/or1k/arch_rt_sigframe.c   \
diff --git a/linux/aarch64/nr_prefix.c b/linux/aarch64/nr_prefix.c
new file mode 100644 (file)
index 0000000..49fe77a
--- /dev/null
@@ -0,0 +1 @@
+#include "../arm/nr_prefix.c"
diff --git a/linux/arm/nr_prefix.c b/linux/arm/nr_prefix.c
new file mode 100644 (file)
index 0000000..99f571f
--- /dev/null
@@ -0,0 +1,12 @@
+static inline const char *
+nr_prefix(kernel_ulong_t scno)
+{
+       /*
+        * For now, the set of syscalls that are shuffled is equivalent to the
+        * set of syscalls that have __ARM_NR_ prefix.
+        */
+       if (shuffle_scno(scno) != scno)
+               return "__ARM_NR_";
+       else
+               return "__NR_";
+}
diff --git a/linux/nr_prefix.c b/linux/nr_prefix.c
new file mode 100644 (file)
index 0000000..f22814f
--- /dev/null
@@ -0,0 +1,11 @@
+/**
+ * Returns prefix for a syscall constant literal.  It is has to be that way
+ * thanks to ARM that decided to prefix their special system calls like sys32
+ * and sys26 with __ARM_NR_* prefix instead of __NR_*, so we can't simply print
+ * "__NR_".
+ */
+static inline const char *
+nr_prefix(kernel_ulong_t scno)
+{
+       return "__NR_";
+}
index c1f826c938f3c76ef4d836140e9f335bbcb51ba8..d5ff8757fdd155c412aedca12c8ed1f21f1ff063 100644 (file)
@@ -42,6 +42,8 @@
 
 #include MPERS_DEFS
 
+#include "nr_prefix.c"
+
 #ifndef IN_MPERS
 #include "printsiginfo.h"
 #endif
@@ -214,7 +216,8 @@ print_si_info(const siginfo_t *sip)
                        printaddr(ptr_to_kulong(sip->si_call_addr));
                        tprints(", si_syscall=");
                        if (scname)
-                               tprintf("__NR_%s", scname);
+                               tprintf("%s%s",
+                                       nr_prefix(sip->si_syscall), scname);
                        else
                                tprintf("%u", (unsigned) sip->si_syscall);
                        tprints(", si_arch=");