Where is eax in the pt_regs struct? Only ax is present

余生颓废 提交于 2020-12-01 10:20:08

问题


I am trying to use the pt_regs struct to get and set registers such as eax, but compilation errors tell me that pt_regs has no such member eax.

However, I am able to get the ax register. Can anybody tell me what is happening?

I am using 32-bit Ubuntu linux with the 3.0.0 kernel. Thank you again.


回答1:


Take a look at the definition of struct pt_regs in arch/x86/include/asm/ptrace.h.

Notice #ifndef __KERNEL__ stuff there, it means that the definition of that structure is different for kernel-mode and user-mode code.

For the kernel code, pt_regs::ax is probably the value you need. It should contain the value of %eax on a 32-bit system and %rax on a 64-bit one.



来源:https://stackoverflow.com/questions/10070625/where-is-eax-in-the-pt-regs-struct-only-ax-is-present

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!