diff options
author | Mattias Andrée <maandree@kth.se> | 2023-06-24 17:15:21 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2023-06-24 17:15:21 +0200 |
commit | f61fda368da04a569e10c9928c01cfdca0faff7e (patch) | |
tree | c9789d794806a1d1468b7fae32134dcebb6ca67e | |
parent | Fix some illegal aliasing (diff) | |
download | sctrace-f61fda368da04a569e10c9928c01cfdca0faff7e.tar.gz sctrace-f61fda368da04a569e10c9928c01cfdca0faff7e.tar.bz2 sctrace-f61fda368da04a569e10c9928c01cfdca0faff7e.tar.xz |
Argument 3 and 4 are swapped on SPARC for PTRACE_GETREGS and PTRACE_SETREGS
Signed-off-by: Mattias Andrée <maandree@kth.se>
-rw-r--r-- | linux/os.h | 6 | ||||
-rw-r--r-- | sctrace.c | 6 |
2 files changed, 9 insertions, 3 deletions
@@ -30,3 +30,9 @@ #else # error "This program is only implemented for x86-64 on Linux" #endif + +#if defined(__sparc__) +# define REGARGS(a, b) b, a +#else +# define REGARGS(a, b) a, b +#endif @@ -22,7 +22,7 @@ handle_syscall(struct process *proc) switch ((int)proc->state) { default: /* Get system call arguments */ - if (ptrace(PTRACE_GETREGS, proc->pid, NULL, ®s)) + if (ptrace(PTRACE_GETREGS, proc->pid, REGARGS(NULL, ®s))) eprintf("ptrace PTRACE_GETREGS %ju NULL <buffer>:", (uintmax_t)proc->pid); proc->scall = regs.SYSCALL_NUM_REG; #ifdef CHECK_ARCHITECTURE @@ -45,7 +45,7 @@ handle_syscall(struct process *proc) case CloneParent: case ForkParent: /* Get system call result */ - if (ptrace(PTRACE_GETREGS, proc->pid, NULL, ®s)) + if (ptrace(PTRACE_GETREGS, proc->pid, REGARGS(NULL, ®s))) eprintf("ptrace PTRACE_GETREGS %ju NULL <buffer>:", (uintmax_t)proc->pid); /* Get or set return */ @@ -53,7 +53,7 @@ handle_syscall(struct process *proc) proc->ret = regs.SYSCALL_RET_REG; } else { regs.SYSCALL_RET_REG = proc->ret; - if (ptrace(PTRACE_SETREGS, proc->pid, NULL, ®s)) + if (ptrace(PTRACE_SETREGS, proc->pid, REGARGS(NULL, ®s))) eprintf("ptrace PTRACE_SETREGS %ju NULL <buffer>:", (uintmax_t)proc->pid); if (ptrace(PTRACE_SYSCALL, proc->pid, NULL, 0)) eprintf("ptrace PTRACE_SYSCALL %ju NULL 0:", (uintmax_t)proc->pid); |