linux(4): fix ptrace(2) to properly handle orig_rax
This fixes strace(1) erroneously reporting return values as "Function not implemented", combined with reporting the binary ABI as X32. Very similar code in linux_ptrace_getregs() is left as it is - it's probably wrong too, but I don't have a way to test it. Sponsored By: EPSRC Differential Revision: https://reviews.freebsd.org/D29927
This commit is contained in:
parent
b59851e99c
commit
023bff7990
@ -505,21 +505,21 @@ linux_ptrace_getregset_prstatus(struct thread *td, pid_t pid, l_ulong data)
|
||||
return (error);
|
||||
}
|
||||
if (lwpinfo.pl_flags & PL_FLAG_SCE) {
|
||||
/*
|
||||
* The strace(1) utility depends on RAX being set to -ENOSYS
|
||||
* on syscall entry; otherwise it loops printing those:
|
||||
*
|
||||
* [ Process PID=928 runs in 64 bit mode. ]
|
||||
* [ Process PID=928 runs in x32 mode. ]
|
||||
*/
|
||||
l_regset.rax = -38; /* -ENOSYS */
|
||||
|
||||
/*
|
||||
* Undo the mangling done in exception.S:fast_syscall_common().
|
||||
*/
|
||||
l_regset.r10 = l_regset.rcx;
|
||||
}
|
||||
|
||||
if (lwpinfo.pl_flags & (PL_FLAG_SCE | PL_FLAG_SCX)) {
|
||||
/*
|
||||
* In Linux, the syscall number - passed to the syscall
|
||||
* as rax - is preserved in orig_rax; rax gets overwritten
|
||||
* with syscall return value.
|
||||
*/
|
||||
l_regset.orig_rax = lwpinfo.pl_syscall_code;
|
||||
}
|
||||
|
||||
len = MIN(iov.iov_len, sizeof(l_regset));
|
||||
error = copyout(&l_regset, (void *)iov.iov_base, len);
|
||||
if (error != 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user