Dmitry V. Levin | d70d1c4 | 2015-03-22 22:13:55 +0000 | [diff] [blame] | 1 | if (arm_regs.ARM_ip != 0) { |
| 2 | /* It is not a syscall entry */ |
| 3 | fprintf(stderr, "pid %d stray syscall exit\n", tcp->pid); |
| 4 | tcp->flags |= TCB_INSYSCALL; |
| 5 | return 0; |
| 6 | } |
| 7 | |
| 8 | /* Note: we support only 32-bit CPUs, not 26-bit */ |
| 9 | |
| 10 | #if !defined(__ARM_EABI__) || ENABLE_ARM_OABI |
| 11 | if (arm_regs.ARM_cpsr & 0x20) { |
| 12 | /* Thumb mode */ |
| 13 | goto scno_in_r7; |
| 14 | } |
| 15 | /* ARM mode */ |
| 16 | /* Check EABI/OABI by examining SVC insn's low 24 bits */ |
| 17 | errno = 0; |
| 18 | scno = ptrace(PTRACE_PEEKTEXT, tcp->pid, (void *)(arm_regs.ARM_pc - 4), NULL); |
| 19 | if (errno) |
| 20 | return -1; |
| 21 | /* EABI syscall convention? */ |
| 22 | if ((unsigned long) scno != 0xef000000) { |
| 23 | /* No, it's OABI */ |
| 24 | if ((scno & 0x0ff00000) != 0x0f900000) { |
| 25 | fprintf(stderr, "pid %d unknown syscall trap 0x%08lx\n", |
| 26 | tcp->pid, scno); |
| 27 | return -1; |
| 28 | } |
| 29 | /* Fixup the syscall number */ |
| 30 | scno &= 0x000fffff; |
| 31 | } else { |
| 32 | scno_in_r7: |
| 33 | scno = arm_regs.ARM_r7; |
| 34 | } |
| 35 | #else /* __ARM_EABI__ || !ENABLE_ARM_OABI */ |
| 36 | |
| 37 | scno = arm_regs.ARM_r7; |
| 38 | |
| 39 | #endif |
| 40 | |
| 41 | scno = shuffle_scno(scno); |