Chinaunix

标题: MODULE_FIRMWARE 宏如何运作? [打印本页]

作者: palm008    时间: 2014-03-27 10:08
标题: MODULE_FIRMWARE 宏如何运作?
内核代码中的宏 MODULE_FIRMWARE 是干什么的呢?是如何工作的呢?
作者: palm008    时间: 2014-03-27 10:55
这个问题,我问的比较含糊,我想知道的是:
内核中每个模块都有诸如(MODULE_AUTHOR、MODULE_LICENSE、MODULE_DESCRIPTION)此类的宏 。而工具modinfo 可以读出模块代码中的宏信息。
modinfo是如何内读出这些信息的呢?
作者: kkddkkdd11    时间: 2014-03-27 11:33
本帖最后由 kkddkkdd11 于 2014-03-27 11:34 编辑
palm008 发表于 2014-03-27 10:55
这个问题,我问的比较含糊,我想知道的是:
内核中每个模块都有诸如(MODULE_AUTHOR、MODULE_LICENSE、MOD ...


一般这种得elf格式支持的:)
readelf -l 看看是否有这类信息?
作者: firkraag    时间: 2014-03-27 11:49
By reading '.modinfo' section of the ko file.
作者: palm008    时间: 2014-03-27 13:52
firkraag 发表于 2014-03-27 11:49
By reading '.modinfo' section of the ko file.

我如何能把 这类(MODULE_AUTHOR、MODULE_LICENSE、MODULE_DESCRIPTION)信息写到 '.modinfo' section 里呢? 代码依靠什么控制呢?
作者: kkddkkdd11    时间: 2014-03-27 14:27
palm008 发表于 2014-03-27 13:52
我如何能把 这类(MODULE_AUTHOR、MODULE_LICENSE、MODULE_DESCRIPTION)信息写到 '.modinfo' section 里呢 ...


编译器支持特定变量存储在特定的elf的section中的 :)
作者: palm008    时间: 2014-03-27 15:11
thanks,i have find the way to put the string to the section of .modinfo
the way an follow
static const char __module_cat(name,__LINE__)[]                                  \
  __used __attribute__((section(".modinfo"), unused, aligned(1)))          \
  = __stringify(tag) "=" info
作者: humjb_1983    时间: 2014-03-28 08:38
palm008 发表于 2014-03-27 15:11
thanks,i have find the way to put the string to the section of .modinfo
the way an follow
static  ...

呵呵,哪位专家能帮忙详细解释下这句话的意思?
作者: palm008    时间: 2014-03-28 10:19
看英文,用英文 感觉总是很牛逼的样子。推荐链接
作者: palm008    时间: 2014-03-28 10:21
http://gcc.gnu.org/onlinedocs/gc ... Variable-Attributes




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2