Chinaunix首页 | 论坛 | 博客
  • 博客访问: 505674
  • 博文数量: 184
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1172
  • 用 户 组: 普通用户
  • 注册时间: 2016-06-21 13:40
个人简介

技术改变命运

文章分类

全部博文(184)

文章存档

2020年(16)

2017年(12)

2016年(156)

我的朋友

分类: LINUX

2016-07-27 15:46: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段寄存器

阅读(839) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~