pt_regs结构

来源:互联网 发布:赌神2016网络电影 编辑:程序博客网 时间:2024/06/08 00:32
struct pt_regs {
long ebx;                  //可执行文件路径的指针(regs.ebx中
long ecx;                  //命令行参数的指针(regs.ecx中)
long edx;                  //环境变量的指针(regs.edx中)。
long esi;
long edi;
long ebp;
long eax;
int xds;
int xes;
long orig_eax;
long eip;
int xcs;
long eflags;
long esp;
int xss;
};
该 参数描述了在执行该系统调用时,用户态下的CPU寄存器在核心态的栈中的保存情况。通过这个参数,sys_execve能获得保存在用户空间的以下信息: 可执行文件路径的指针(regs.ebx中)、命令行参数的指针(regs.ecx中)和环境变量的指针(regs.edx中)。

/* this struct defines the way the registers are stored on the 
24    stack during a system call. */
25 
26 struct pt_regs {
27         long ebx;
28         long ecx;
29         long edx;
30         long esi;
31         long edi;
32         long ebp;
33         long eax;
34         int  xds;
35         int  xes;
36         long orig_eax;
37         long eip;
38         int  xcs;
39         long eflags;
40         long esp;
41         int  xss;
42 };

《understanding the linux kernel》中说 struct pt_regs中前9个是存放通过SAVE_ALL压入的寄存器值。 orig_eax存放的是IRQ number. 后面的几个是处理器自动压入的寄存器值。

我不明白的是: xds xes xcs xss等是什么寄存器? 他们与edx ecs 等有什么区别? 而且类型还不一样。
哪位能解释一下。

答:是段寄存器,类型其实是一样的

保存断点现场:在内核栈中保存中断处理程序将要用到的所有cpu寄存器的内容叫保护断点现场。这时调用宏SAVE_ALL来完成的。

#define SAVE_ALL

 cld;

pushl %es;

pushl %ds;

pushl %eax;

pushl %ebp;

pushl %edi;

pushl %esi;

pushl %edx;

pushl %ecx;

pushl %ebx;

movl $(__KERNEL_DS),%edx;

movl %dx,%ds;

movl %dx,%es;

注意到这个宏没有保存EFLAGS,CS,EIP,SS和ESP寄存器,原因是这些寄存器在CPU响应中断是已被cpu自动保存了。在宏的最后,把内核数据段的选择符装入ds和es段寄存器

<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"16"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
阅读(220) | 评论(0) | 转发(0) |
0

上一篇:copy_to_user和copy_from_user两个函数的分析

下一篇:Linux VFS中write系统调用实现原理

相关热门文章
  • linux 常见服务端口
  • xmanager 2.0 for linux配置
  • 【ROOTFS搭建】busybox的httpd...
  • openwrt中luci学习笔记
  • Linux里如何查找文件内容...
给主人留下些什么吧!~~
原创粉丝点击