Chinaunix首页 | 论坛 | 博客
  • 博客访问: 478497
  • 博文数量: 115
  • 博客积分: 5016
  • 博客等级: 大校
  • 技术积分: 1401
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-21 16:03
文章分类

全部博文(115)

文章存档

2013年(1)

2010年(17)

2009年(76)

2008年(21)

我的朋友

分类: LINUX

2009-05-05 15:32:43

它的定义如下:#define asmlinkage __attribute__((regparm(0)))
导致gcc对do_IRQ函数不作调用参数的优化工作,即不通过寄存器传递参数,所以在 do_IRQ的二进制代码中,将认为此时的“参数”都到栈中寻找。而进一步,在调用do_IRQ之前,SAVE_ALL推进栈中一些寄存器变量,这样,栈中的变量在do_IRQ的内部被认为是传递的参数。
CSDN中有人的解释:
asmlinkage是个宏,使用它是为了保持参数在stack中。因为从汇编语言到C语言代码参数的传递是通过stack的,它也可能从stack中得到一些不需要的参数。Asmlinkage将要解析那些参数。     
  This is a #define for some gcc magic that tells the compiler that the function  should not expect to find any of its arguments in registers(a common optimization), but only on the CPU's stack.Recall our earlier assertion that system_call consumes  its first argument, the system call number, and allows up to four more arguments that are passed along to the real system call. system_call achieves this feat simply by leaving its other arguments(which were passed to it in registers) on the stack. All system calls are marked with the asmlinkage tag, so they all look to the stack   for arguments. Of course, in sys_ni_syscall's case, this doesn't make any difference, because sys_ni_syscall doesn't take any arguments, but it's an issue for most other system calls.

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