GoT*_*imw 30 linux kernel module linux-kernel
在编译内核模块时,我得到了一个WARNING,其中包含一个添加编译选项CONFIG_DEBUG_SECTION_MISMATCH = y的注释.它给了我更详细的问题信息:
WARNING: \**\*path to module\***(.text+0x8d2): Section mismatch in reference from the function Pch_Spi_Enable_Bios_Wr() to the variable .devinit.data:ich9_pci_tbl.22939
The function Pch_Spi_Enable_Bios_Wr() references
the variable __devinitdata ich9_pci_tbl.22939.
This is often because Pch_Spi_Enable_Bios_Wr lacks a __devinitdata
annotation or the annotation of ich9_pci_tbl.22939 is wrong.
Run Code Online (Sandbox Code Playgroud)
我无法找到究竟核心部分不匹配的内容,更不用说如何修复它了.
Mat*_*Mat 38
这意味着具有给定生存期的节中的函数引用具有不同生命期的节中的内容.
当链接内核二进制文件时,代码和数据的不同部分被分成不同的部分.其中一些部分一直保持加载状态,但是一些部分在不再需要时会被删除(例如,只有在启动时才需要的东西一旦启动就可以释放 - 这可以节省内存).
如果持久化部分中的某个函数引用其中一个可丢弃部分中的数据,则会出现问题 - 它可能会在已释放数据时尝试访问该数据,从而导致各种运行时问题.
除非您编写该代码或非常熟悉它,否则这不是您自己修复的警告.它通过正确地注释函数(或它引用的数据)来修复,以便它进入正确的部分.只有详细了解内核的那一部分才能确定正确的修复方法.
有关这些部分和注释的列表,请参阅include/linux/init.h内核源代码树中的标头:
/* These macros are used to mark some functions or
* initialized data (doesn't apply to uninitialized data)
* as `initialization' functions. The kernel can take this
* as hint that the function is used only during the initialization
* phase and free up used memory resources after
*
* Usage:
* For functions:
*
* You should add __init immediately before the function name, like:
*
* static void __init initme(int x, int y)
* {
* extern int z; z = x * y;
* }
*
* If the function has a prototype somewhere, you can also add
* __init between closing brace of the prototype and semicolon:
*
* extern int initialize_foobar_device(int, int, int) __init;
*
* For initialized data:
* You should insert __initdata between the variable name and equal
* sign followed by value, e.g.:
*
* static int init_variable __initdata = 0;
* static const char linux_logo[] __initconst = { 0x32, 0x36, ... };
*
* Don't forget to initialize data not at file scope, i.e. within a function,
* as gcc otherwise puts the data into the bss section and not into the init
* section.
*
* Also note, that this data cannot be "const".
*/
/* These are for everybody (although not all archs will actually
discard it in modules) */
#define __init __section(.init.text) __cold notrace
#define __initdata __section(.init.data)
#define __initconst __section(.init.rodata)
#define __exitdata __section(.exit.data)
#define __exit_call __used __section(.exitcall.exit)
Run Code Online (Sandbox Code Playgroud)
其他人跟随,更多的评论和解释.
另请参阅CONFIG_DEBUG_SECTION_MISMATCHKconfig符号的帮助文本:
部分不匹配分析检查
从一个部分到另一个部分是否存在非法引用.
Linux将在链接期间或在运行时删除某些部分,
并且以前在这些部分中使用代码/数据
很可能会导致oops.
在代码中,函数和变量用
__init,__ devinit等注释(参见include/linux/init.h中的完整列表)
,这导致代码/数据被放置在特定的部分中.
部分不匹配分析总是在完整
内核构建之后完成,但启用此选项还将
执行以下操作:
- 将选项-fno-inline-functions-called-once添加到gcc
当在非init
函数中内联函数注释__init时,我们将丢失节信息,因此
分析不会捕获非法引用.
此选项告诉gcc内联较少,但也会
导致更大的内核.- 对每个模块/内置
运行部分不匹配分析.当我们在vmlinux.o上运行部分不匹配分析时,我们
会丢失有关
引入不匹配的位置的有价值的信息.
对每个模块/ built-in.o文件运行分析
将告知不匹配发生在哪里更靠近
源.缺点是我们将报告相同的
不匹配至少两次.- 从modpost启用详细报告,以帮助解决
报告的部分不匹配问题.
| 归档时间: |
|
| 查看次数: |
17763 次 |
| 最近记录: |