blob: f9dcd651f9a4eb9a1718786a7758b8b69f595b00 [file] [log] [blame]
Dmitry V. Levind70d1c42015-03-22 22:13:55 +00001/* Note: we support only 32-bit CPUs, not 26-bit */
2
3#if !defined(__ARM_EABI__) || ENABLE_ARM_OABI
4if (arm_regs.ARM_cpsr & 0x20) {
5 /* Thumb mode */
6 goto scno_in_r7;
7}
8/* ARM mode */
9/* Check EABI/OABI by examining SVC insn's low 24 bits */
10errno = 0;
11scno = ptrace(PTRACE_PEEKTEXT, tcp->pid, (void *)(arm_regs.ARM_pc - 4), NULL);
12if (errno)
13 return -1;
14/* EABI syscall convention? */
15if ((unsigned long) scno != 0xef000000) {
16 /* No, it's OABI */
17 if ((scno & 0x0ff00000) != 0x0f900000) {
18 fprintf(stderr, "pid %d unknown syscall trap 0x%08lx\n",
19 tcp->pid, scno);
20 return -1;
21 }
22 /* Fixup the syscall number */
23 scno &= 0x000fffff;
24} else {
25scno_in_r7:
26 scno = arm_regs.ARM_r7;
27}
28#else /* __ARM_EABI__ || !ENABLE_ARM_OABI */
29
30scno = arm_regs.ARM_r7;
31
32#endif
33
34scno = shuffle_scno(scno);
Dmitry V. Levin9945ec92015-03-23 23:00:37 +000035
36/*
37 * Do some sanity checks to figure out
38 * whether it's really a syscall entry.
39 */
40if (arm_regs.ARM_ip && !SCNO_IN_RANGE(scno)) {
41 if (debug_flag)
42 fprintf(stderr,
43 "pid %d stray syscall exit: ARM_ip = %ld, scno = %ld\n",
44 tcp->pid, arm_regs.ARM_ip, shuffle_scno(scno));
45 return 0;
46}