__atribute__使用:关于_attribute__ ((used,__section__(".xxxx")))的理解
来源:互联网 发布:轮毂数据计算器 编辑:程序博客网 时间:2024/05/18 00:56
从etherboot代码中发现有一个__attribute__的使用,#define __pci_driver __attribute__ ((used,__section__(".drivers.pci")))
/* Defined by the linker... */
extern const struct pci_driver pci_drivers[];
extern const struct pci_driver pci_drivers_end[];
这部分代码是etherboot搜索相应网卡驱动用到的。
for(driver = pci_drivers; driver < pci_drivers_end; driver++) {
/*scan driver*/
}
__section__是把相应的结构放到指定的段.drivers.pci中
在 src/arch/i386/core/etherboot.lds中有下面描述
SECTIONS {
......
.drivers.pci : {
pci_drivers = . ;
*(.drivers.pci);
pci_drivers_end = . ;
}
......
}
说明所有的驱动都放在pci_drivers 和pci_drivers_end两个地址之间,这样可以通过上面的for循环一次查找相应的驱动程序。
unused
属性 unused 用于函数和变量,表示该函数或变量可能不使用,这个属性可以避免
编译器产生警告信息。used反之 。
- __atribute__使用:关于_attribute__ ((used,__section__(".xxxx")))的理解
- __atribute__使用:关于_attribute__ ((used,__section__(".xxxx")))的理解
- Java泛型:<? extends XXXX> 中的? 和 extends 的理解和使用实例
- 20140627-IAR平台中Warning[Pe550]: variable "xxxx" was set but never used的问题
- __atribute__机制
- 关于undefined referenced xxxx的另一种原因
- _attribute__改变段的特性,即section选项
- 关于SearchView的使用理解
- DataBinder.Eval(Container.DataItem,"xxxx")的使用
- 关于VC的错误 error LNK2005:xxxx already defined in xxxx.lib
- 关于Nios II中Verify failed between address 0xxxx and 0xxxx错误的解决
- 关于strdup的使用与理解
- 关于使用函数feof的理解
- 关于状态模式的理解和使用
- 关于进度条的使用理解(待续)
- 关于android instrumentation的理解、使用
- 关于springMVC中使用session的理解
- 关于MyApplication的理解和使用
- SDE的连接方法
- Visual C++2005中开发自定义绘图控件之二
- 打开Windows组策略失败的原因分析
- Visual C++2005中开发自定义绘图控件之三
- 可口可乐公司的招聘题目——如果是你,你会怎么做?
- __atribute__使用:关于_attribute__ ((used,__section__(".xxxx")))的理解
- 一位软件设计师的6年总结
- COM ATL IDispatchEx InvokeEx 钩子
- how to use ocx control in console app.
- 四大关键词 解读08年韩国游戏企业
- 工作流模型设计 (引)
- ocx function and the order of BEGIN_DISPATCH_MAP
- c# regex深入正则表达式
- 模式总结——模板方法