Linux内核CONFIG_DEBUG_SECTION_MISMATCH出错 [英] Linux kernel CONFIG_DEBUG_SECTION_MISMATCH make errors

查看:573
本文介绍了Linux内核CONFIG_DEBUG_SECTION_MISMATCH出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在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'

我知道我可以做一个make CONFIG_DEBUG_SECTION_MISMATCH= y并继续进行,但是我想知道是否有更好的方法来处理这个问题.也许要向某人报告或我自己如何解决这些问题,等等.

解决方案

这只是警告.内核构建系统进行了完整性检查,发现可能存在错误.警告消息说,在内核代码中的某处存在可能执行不适当的横截面访问的代码.请注意,您的内核确实已构建!

要了解警告的含义,请考虑以下示例:

内核文本部分中的某些内核代码可能正在尝试调用标有__init数据宏的函数,链接器将其放置在内核 init 部分中,该宏在引导后被取消分配或模块加载.

这可能是运行时错误,因为如果初始化代码完成后 text 部分中的代码调用 init 部分中的代码,则基本上是在调用过时的指针.

话虽如此,该调用可能非常好-内核 text 部分中的调用可能有充分的理由知道它仅调用 init中的函数部分.

这当然只是一个例子.类似的其他情况也存在.

解决方案是使用CONFIG_DEBUG_SECTION_MISMATCH=y进行编译,这将为您提供试图访问哪些数据或函数以及它们属于哪个部分的函数的输出.然后,您可以尝试确定是否应该发出构建时间警告,并希望它可以解决.

初始化.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等可以修复有效"实例,因此它们存在的事实 可能不会激发信心.

During the "make" step of the Linux kernel compilation I get lots of these errors:

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.

解决方案

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 init section that gets de-allocated after boot or module loading.

This might be a run time error since if the code in the text section calls the code in the init section after the initialization code has finished, it is basically calling a stale pointer.

Having said that, that call may be perfectly fine - it is possible that the calls in the kernel text section has some good reason to know that it only calls the function in the init section when it is guaranteed to be there.

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.

The init.h macros __ref and __refdata can be used to allow such init references without warnings. For example,

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 may not inspire confidence.

这篇关于Linux内核CONFIG_DEBUG_SECTION_MISMATCH出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆