From 3c8b6734088ceb54e17b03e11dbb07bc8294f9c5 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Thu, 1 Dec 2016 01:01:02 +0000 Subject: [PATCH] syscall_name: clear __X32_SYSCALL_BIT from syscall number on x32 * linux/x86_64/get_scno.c (X32_PERSONALITY_NUMBER): New macro. * syscall.c (syscall_name) [X32_PERSONALITY_NUMBER && __X32_SYSCALL_BIT]: Clear __X32_SYSCALL_BIT from scno on x32 personality. --- linux/x86_64/get_scno.c | 6 ++++++ syscall.c | 16 ++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/linux/x86_64/get_scno.c b/linux/x86_64/get_scno.c index af3329a1..a87987e1 100644 --- a/linux/x86_64/get_scno.c +++ b/linux/x86_64/get_scno.c @@ -30,6 +30,12 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifdef X86_64 +# define X32_PERSONALITY_NUMBER 2 +#else +# define X32_PERSONALITY_NUMBER 0 +#endif + /* Return codes: 1 - ok, 0 - ignore, other - error. */ static int arch_get_scno(struct tcb *tcp) diff --git a/syscall.c b/syscall.c index 36f32799..fed5d7cd 100644 --- a/syscall.c +++ b/syscall.c @@ -987,12 +987,6 @@ shuffle_scno(unsigned long scno) # define shuffle_scno(scno) ((long)(scno)) #endif -const char * -syscall_name(long scno) -{ - return SCNO_IS_VALID(scno) ? sysent[scno].sys_name: NULL; -} - const char * err_name(unsigned long err) { @@ -1740,3 +1734,13 @@ get_syscall_result(struct tcb *tcp) #ifdef HAVE_GETREGS_OLD # include "getregs_old.c" #endif + +const char * +syscall_name(long scno) +{ +#if defined X32_PERSONALITY_NUMBER && defined __X32_SYSCALL_BIT + if (current_personality == X32_PERSONALITY_NUMBER) + scno &= ~__X32_SYSCALL_BIT; +#endif + return SCNO_IS_VALID(scno) ? sysent[scno].sys_name: NULL; +} -- 2.40.0