From 7b6e92664130232b245a980b6869c4fcae934fad Mon Sep 17 00:00:00 2001 From: Eugene Syromyatnikov Date: Wed, 31 Jan 2018 20:28:56 +0100 Subject: [PATCH] Handle very special __ARM_NR_-prefixed syscalls * 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 | 3 +++ linux/aarch64/nr_prefix.c | 1 + linux/arm/nr_prefix.c | 12 ++++++++++++ linux/nr_prefix.c | 11 +++++++++++ printsiginfo.c | 5 ++++- 5 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 linux/aarch64/nr_prefix.c create mode 100644 linux/arm/nr_prefix.c create mode 100644 linux/nr_prefix.c diff --git a/Makefile.am b/Makefile.am index 137063d6..5cf2c9bf 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 index 00000000..49fe77ae --- /dev/null +++ b/linux/aarch64/nr_prefix.c @@ -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 index 00000000..99f571ff --- /dev/null +++ b/linux/arm/nr_prefix.c @@ -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 index 00000000..f22814f4 --- /dev/null +++ b/linux/nr_prefix.c @@ -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_"; +} diff --git a/printsiginfo.c b/printsiginfo.c index c1f826c9..d5ff8757 100644 --- a/printsiginfo.c +++ b/printsiginfo.c @@ -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="); -- 2.40.0