Linux 内核 CONFIG_DEBUG_SECTION_MISMATCH 出错
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6807766/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Linux kernel CONFIG_DEBUG_SECTION_MISMATCH make errors
提问by user361697
During the "make" step of the Linux kernel compilation I get lots of these errors:
在 Linux 内核编译的“make”步骤中,我收到了很多这样的错误:
Building modules, stage 2.
MODPOST 2283 modules
WARNING: modpost: Found 1 section mismatch(es).
To see full details build your kernel with:
'make CONFIG_DEBUG_SECTION_MISMATCH=y'
I know I can just do a make CONFIG_DEBUG_SECTION_MISMATCH=
y and go ahead with it, but I want to know if there is any better way to handle this. Maybe reporting to someone or how I fix these problems myself, etc.
我知道我可以做一个make CONFIG_DEBUG_SECTION_MISMATCH=
y 并继续它,但我想知道是否有更好的方法来处理这个问题。也许向某人报告或我如何自己解决这些问题等。
采纳答案by gby
This is just a warning. The kernel build systems did a sanity check and found out something that might be an error. The warning message says somewhere in kernel code there is code that might do inappropriate cross section access. Note that your kernel did build!
这只是一个警告。内核构建系统进行了健全性检查,发现了一些可能是错误的东西。警告消息表示内核代码中的某处存在可能执行不适当的横截面访问的代码。请注意,您的内核确实构建了!
To understand what the warning means, consider the following example:
要了解警告的含义,请考虑以下示例:
Some kernel code in the kernel text section might be trying to call a function marked with the __init
data macro, which the linker puts in the kernel initsection that gets de-allocated after boot or module loading.
内核文本部分中的某些内核代码可能试图调用标有__init
数据宏的函数,链接器将其放入内核初始化部分,该部分在启动或模块加载后解除分配。
This might be a run time error since if the code in the textsection calls the code in the initsection after the initialization code has finished, it is basically calling a stale pointer.
这可能是一个运行时错误,因为如果文本部分中的代码在初始化代码完成后调用init部分中的代码,它基本上是在调用一个陈旧的指针。
Having said that, that call may be perfectly fine - it is possible that the calls in the kernel textsection has some good reason to know that it only calls the function in the initsection when it is guaranteed to be there.
话虽如此,该调用可能完全没问题——内核文本部分中的调用可能有充分的理由知道它仅在保证存在的情况下才调用init部分中的函数。
This, of course, is just an example. Similar other scenarios also exists.
当然,这只是一个例子。类似的其他场景也存在。
The solution is to compile with CONFIG_DEBUG_SECTION_MISMATCH=y
which will give you output of what function is trying to access which data or function and which section they belong to. You can then try to figure out if the build time warning is warranted and if so hopefully fix.
解决方案是编译CONFIG_DEBUG_SECTION_MISMATCH=y
which 会给你什么函数试图访问哪个数据或函数以及它们属于哪个部分的输出。然后,您可以尝试确定构建时间警告是否有保证,如果有希望修复。
The init.hmacros __ref
and __refdata
can be used to allow such initreferences without warnings. For example,
该init.h中宏__ref
和__refdata
可用于允许这样的init没有出现警告的引用。例如,
char * __init_refok bar(void)
{
static int flag = 0;
static char* rval = NULL;
if(!flag) {
flag = 1;
rval = init_fn(); /* a function discarded after init */
}
return rval;
}
__init_refok
, etc can fix "valid" instances, so the fact they exist maynot inspire confidence.
__init_refok
等可以修复“有效”实例,因此它们存在的事实可能不会激发信心。