]> granicus.if.org Git - strace/commitdiff
arm: shorten syscall table for EABI - no point in storing NULL entries
authorDenys Vlasenko <vda.linux@googlemail.com>
Wed, 20 Feb 2013 17:08:25 +0000 (18:08 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Wed, 20 Feb 2013 17:08:25 +0000 (18:08 +0100)
Also, reformatted ARM code in get_scno(), mostly improved comments,
without code changes.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
linux/arm/signalent1.h
linux/arm/syscallent.h
syscall.c

index c927d7290e6c019c4ea74592c9d57d1fb2ebf0c1..130972be72d7a749aea11eca092a120fd9295cd0 100644 (file)
@@ -1,2 +1,2 @@
-/* i386 personality */
+/* "ARM specific syscall" personality */
 #include "../signalent.h"
index e3de1f5a4d6a736d8d3628c528b25d106ae311bc..53c01a86b93c64e3443d52e325babf8bba69b0bf 100644 (file)
        { 2,    TD,     sys_setns,              "setns"         }, /* 375 */
        { 6,    0,      sys_process_vm_readv,   "process_vm_readv"      }, /* 376 */
        { 6,    0,      sys_process_vm_writev,  "process_vm_writev"     }, /* 377 */
+
+#ifndef __ARM_EABI__
        { 5,    0,      NULL,                   NULL            }, /* 378 */
        { 5,    0,      NULL,                   NULL            }, /* 379 */
        { 5,    0,      NULL,                   NULL            }, /* 380 */
        { 5,    0,      NULL,                   NULL            }, /* 397 */
        { 5,    0,      NULL,                   NULL            }, /* 398 */
        { 5,    0,      NULL,                   NULL            }, /* 399 */
-
-#ifndef __ARM_EABI__
 #if SYS_socket_subcall != 400
  #error fix me
 #endif
index 158fe8968665501819d505f13afe40c3ec1553db..7e2d0e848c6613a21df19780c92e3418bc10a899 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -1215,59 +1215,43 @@ get_scno(struct tcb *tcp)
                        break;
        }
 #elif defined(ARM)
-       /*
-        * We only need to grab the syscall number on syscall entry.
-        */
-       if (arm_regs.ARM_ip == 0) {
-               /*
-                * Note: we only deal with 32-bit CPUs here
-                */
-               if (arm_regs.ARM_cpsr & 0x20) {
-                       /*
-                        * Get the Thumb-mode system call number
-                        */
-                       scno = arm_regs.ARM_r7;
+       if (arm_regs.ARM_ip != 0) {
+               /* It is not a syscall entry */
+               fprintf(stderr, "pid %d stray syscall exit\n", tcp->pid);
+               tcp->flags |= TCB_INSYSCALL;
+               return 0;
+       }
+       /* Note: we support only 32-bit CPUs, not 26-bit */
+
+       if (arm_regs.ARM_cpsr & 0x20) {
+               /* Thumb mode */
+               scno = arm_regs.ARM_r7;
+       } else {
+               /* ARM mode */
+               errno = 0;
+               scno = ptrace(PTRACE_PEEKTEXT, tcp->pid, (void *)(arm_regs.ARM_pc - 4), NULL);
+               if (errno)
+                       return -1;
+
+               /* EABI syscall convention? */
+               if (scno == 0xef000000) {
+                       scno = arm_regs.ARM_r7; /* yes */
                } else {
-                       /*
-                        * Get the ARM-mode system call number
-                        */
-                       errno = 0;
-                       scno = ptrace(PTRACE_PEEKTEXT, tcp->pid, (void *)(arm_regs.ARM_pc - 4), NULL);
-                       if (errno)
+                       if ((scno & 0x0ff00000) != 0x0f900000) {
+                               fprintf(stderr, "pid %d unknown syscall trap 0x%08lx\n",
+                                       tcp->pid, scno);
                                return -1;
-
-                       /* Handle the EABI syscall convention.  We do not
-                          bother converting structures between the two
-                          ABIs, but basic functionality should work even
-                          if strace and the traced program have different
-                          ABIs.  */
-                       if (scno == 0xef000000) {
-                               scno = arm_regs.ARM_r7;
-                       } else {
-                               if ((scno & 0x0ff00000) != 0x0f900000) {
-                                       fprintf(stderr, "syscall: unknown syscall trap 0x%08lx\n",
-                                               scno);
-                                       return -1;
-                               }
-
-                               /*
-                                * Fixup the syscall number
-                                */
-                               scno &= 0x000fffff;
                        }
+                       /* Fixup the syscall number */
+                       scno &= 0x000fffff;
                }
-               if (scno & 0x0f0000) {
-                       /*
-                        * Handle ARM specific syscall
-                        */
-                       update_personality(tcp, 1);
-                       scno &= 0x0000ffff;
-               } else
-                       update_personality(tcp, 0);
-
+       }
+       if (scno & 0x000f0000) {
+               /* ARM specific syscall. We handle it as a separate "personality" */
+               update_personality(tcp, 1);
+               scno &= 0x0000ffff;
        } else {
-               fprintf(stderr, "pid %d stray syscall entry\n", tcp->pid);
-               tcp->flags |= TCB_INSYSCALL;
+               update_personality(tcp, 0);
        }
 #elif defined(M68K)
        if (upeek(tcp, 4*PT_ORIG_D0, &scno) < 0)