问题描述
我已在基于 struct pt_regs
的 x86-64 系统调用上阅读了此 LWN article。
我不明白 struct pt_regs *
被解码成寄存器的方式。
确实,%rdi
保存了 struct pt_regs *
的地址,因此 (%rdi)
是内存中实际的 struct pt_regs
。
但是第一行mov 0x70(%rdi),%rdi
改变了%rdi
,那么我如何用来解码剩余的寄存器,%rsi
、%rdx
和%rcx
,在调用 SyS_recv
之前?
LWN 文章除外:
asmlinkage long sys_recv(struct pt_regs *regs)
{
return SyS_recv(regs->di,regs->si,regs->dx,regs->r10);
}
然后该函数的汇编变成,稍微重新排序 时尚:
<sys_recv>:
callq <__fentry__>
/* decode regs->di,->si,->dx and ->r10 */
mov 0x70(%rdi),%rdi
mov 0x68(%rdi),%rsi
mov 0x60(%rdi),%rdx
mov 0x38(%rdi),%rcx
/* [ SyS_recv() is inlined here by the compiler,as it is tiny ] */
/* clear %r9 and %r8,the 5th and 6th args */
xor %r9d,%r9d
xor %r8d,%r8d
/* do the actual work */
callq __sys_recvfrom
/* cleanup and return */
cltq
retq
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)