linux _setup()
来源:互联网 发布:暨南大学博士知乎 编辑:程序博客网 时间:2024/06/16 13:37
1. system.map分析
2.__setup(str, fn)
路径:linux-3.10.x\include\linux\init.h
源码如下
/* * Only for really core code. See moduleparam.h for the normal way. * * Force the alignment so the compiler doesn't space elements of the * obs_kernel_param "array" too far apart in .init.setup. */#define __setup_param(str, unique_id, fn, early)\static const char __setup_str_##unique_id[] __initconst\__aligned(1) = str; \static struct obs_kernel_param __setup_##unique_id\__used __section(.init.setup)\__attribute__((aligned((sizeof(long)))))\= { __setup_str_##unique_id, fn, early }#define __setup(str, fn)\__setup_param(str, fn, fn, 0)
其中obs_kernel_param如下:
struct obs_kernel_param {const char *str;int (*setup_func)(char *);int early;};
3.__setup("console=", console_setup)
路径:\linux-3.10.x\kernel\printk.c
展开如下:
#define __setup_param("console=", console_setup, console_setup, 0)\static const char __setup_str_##console_setup[] __initconst\__aligned(1) = "console="; \static struct obs_kernel_param __setup_##console_setup\__used __section(.init.setup)\//使用.init.setup保存相应的数据__attribute__((aligned((sizeof(long)))))\= { __setup_str_##console_setup, console_setup, 0 }#define __setup("console=", console_setup)\__setup_param("console=", console_setup, console_setup, 0)__setup("console=", console_setup)
所以struct obs_kernel_param为
struct obs_kernel_param {const char *str=“console”int (*setup_func)(char *)=console_setupint early=0};
所以最终会生成__setup_console_setup结构体地址,我们可以通过查看system.map表看到
c04373e0 T __setup_startc04373ec t __setup_init_setupc04373f8 t __setup_loglevelc0437404 t __setup_quiet_kernel......c0437560 t __setup_console_setup //注意这里......c0437788 T __setup_end
至此,__setup("console=", console_setup)关系已分析完!
阅读全文
0 0
- linux _setup()
- linux -- _setup宏介绍
- _setup()
- Tomcat用户指南_Setup
- Python_lesson 1_setup python
- makecab对_setup.xml文件进行打包
- python自动化测试_setUp and tearDown
- linux
- linux
- Linux
- Linux
- LINUX!
- Linux
- linux
- linux
- linux
- Linux
- linux
- mac更新系统后Git不能用,提示missing xcrun at
- 嵌入式软件工程师经典面试题
- 安卓 补间动画代码添加
- tomcat源码解读六 tomcat中的session生命历程
- PHP中使用CURL实现GET和POST请求
- linux _setup()
- Python 大文件读取
- C语言编程需要注意的64位和32机器的区别
- [leetcode]解决Climbing Stairs的一点小心得
- webrtc 码率设置
- Freemarker生成乱码解决
- localStorage
- 软件测试面试题
- CCF 201312-1 出现次数最多的数 C语言解法