当前位置: 技术问答>linux和unix
start_kernel前面为什么有asmlinkage
来源: 互联网 发布时间:2016-08-14
本文导语: asmlinkage void __init start_kernel(void) 这是start_kernel的定义,asmlinkage,google了一下,是说用寄存器不是用栈传递参数。 但是我看到的start_kernel函数是没有参数的,那为什么前面还要加个asmlinkage?? 有知道的希望能告诉...
asmlinkage void __init start_kernel(void)
这是start_kernel的定义,asmlinkage,google了一下,是说用寄存器不是用栈传递参数。 但是我看到的start_kernel函数是没有参数的,那为什么前面还要加个asmlinkage?? 有知道的希望能告诉我,先谢过了
这是start_kernel的定义,asmlinkage,google了一下,是说用寄存器不是用栈传递参数。 但是我看到的start_kernel函数是没有参数的,那为什么前面还要加个asmlinkage?? 有知道的希望能告诉我,先谢过了
|
你理解错了
The asmlinkage tag is one other thing that we should observe about this simple function. 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. And, because you'll be seeing asmlinkage in front of many other functions, I thought you should know what it was about.
The asmlinkage tag is one other thing that we should observe about this simple function. 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. And, because you'll be seeing asmlinkage in front of many other functions, I thought you should know what it was about.
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。