__attribute__宏与link脚本的用法
2011-11-03 16:23
211 查看
__attribute__宏用于定义变量或函数的编译属性,编译器在链接时参考这些属性参数进行相应的链接操作.
比如format属性用于检查函数参数合法性,.section属性用于将变量或函数放入指定段内.
__attribute__宏通常与link脚本./arch/ia64/kernel/vmlinux.lds.S配合使用
例子:
vmlinux.lds.S会将如下函数放入.init.text段,初始化时被调用且只调用一次,然后改段所占用内存被释放.
# define __section(S) __attribute__ ((__section__(#S)))
#define __init __section(.init.text) __cold notrace
asmlinkage void __init start_kernel(void)
{
}
具体用法参考 GCC手册
变量属性:
http://gcc.gnu.org/onlinedocs/gcc-4.5.3/gcc/Variable-Attributes.html#Variable-Attributes
函数属性:
http://gcc.gnu.org/onlinedocs/gcc-4.5.3/gcc/Function-Attributes.html#Function-Attributes
类型定义属性:
http://gcc.gnu.org/onlinedocs/gcc-4.5.3/gcc/Type-Attributes.html#Type-Attributes
比如format属性用于检查函数参数合法性,.section属性用于将变量或函数放入指定段内.
__attribute__宏通常与link脚本./arch/ia64/kernel/vmlinux.lds.S配合使用
例子:
vmlinux.lds.S会将如下函数放入.init.text段,初始化时被调用且只调用一次,然后改段所占用内存被释放.
# define __section(S) __attribute__ ((__section__(#S)))
#define __init __section(.init.text) __cold notrace
asmlinkage void __init start_kernel(void)
{
}
具体用法参考 GCC手册
变量属性:
http://gcc.gnu.org/onlinedocs/gcc-4.5.3/gcc/Variable-Attributes.html#Variable-Attributes
函数属性:
http://gcc.gnu.org/onlinedocs/gcc-4.5.3/gcc/Function-Attributes.html#Function-Attributes
类型定义属性:
http://gcc.gnu.org/onlinedocs/gcc-4.5.3/gcc/Type-Attributes.html#Type-Attributes
相关文章推荐
- GCC __attribute__ 和 link 脚本控制 section 基地址
- [转]使用GCC __attribute__和link脚本来控制section基地址
- 使用 GCC __attribute__和 link 脚本来控制section基地址
- [转]使用GCC __attribute__和link脚本来控制section基地址
- 使用 GCC __attribute__和 link 脚本来控制section基地址
- xmlstarlet toolkit 脚本操作xml的好工具, 用法心得
- 不知道的shell用法和脚本
- link rel=canonical 用法
- 网络打印机安装脚本(rundll32 printui.dll,PrintUIEntry用法示例)
- linux脚本read的用法
- 20.1 shell脚本介绍 20.2 shell脚本结构和执行 20.3 date命令用法 20.4 shell脚本中的变量
- lua脚本中表的用法
- prop(Property)和attr(attribute)用法区别
- jmeter中Beanshell脚本的用法
- LUA脚本的loadstring的用法
- lvs+keepalived自定义健康检查脚本(MISC_CHECK用法)
- cl.exe link.exe用法详解
- shell用法和脚本,简单&强大
- Ajax.ActionLink 用法
- @ModelAttribute和@SessionAttributes的用法