泪流满面,WARNING: modpost: Found 1 section mismatch(es).

看来编译时出现警告要非常重视,一定要对警告的意义非常清楚,这极可能是出现BUG的原因。

昨天调了一整个晚上,各种离奇的出错~~

其实编译内核模块时,已经提示我警告了,但我一直没注意:

  Building modules, stage 2.
  MODPOST 1 modules
WARNING: modpost: Found 1 section mismatch(es).
To see full details build your kernel with:
'make CONFIG_DEBUG_SECTION_MISMATCH=y'
  CC      /home/zausiu/linux-3.0.66/mm/sksm/sksm.mod.o
  LD [M]  /home/zausiu/linux-3.0.66/mm/sksm/sksm.ko

警告告诉我使用 'make CONFIG_DEBUG_SECTION_MISMATCH=y'

我以为要编译整棵kenel sourcecode tree时打开DEBUG_SECTION_MISMATCH编译选项,在我的虚机里编译一次要几个小时啊,果断拒绝了。其实在内核代码树外单独编译内核模块时也只用DEBUG_SECTION_MISMATCH=y这个选项。

# make DEBUG_SECTION_MISMATCH=y

  Building modules, stage 2.
  MODPOST 1 modules
WARNING: /home/zausiu/linux-3.0.66/mm/sksm/sksm.o(.init.text+0x193): Section mismatch in reference from the function init_module() to the function .exit.text:sksm_slab_free()
The function __init init_module() references
a function __exit sksm_slab_free().
This is often seen when error handling in the init function
uses functionality in the exit path.
The fix is often to remove the __exit annotation of
sksm_slab_free() so it may be used outside an exit section.

至此,真相大白于天下~~ .init段的函数内调用了 .exist段的函数,把被调用函数去掉__exit指示即可!

//////////

至此,当出现离奇错误时。要高度重视编译时的警告,另外一个就是极有可能是因为竞争条件,还有个是栈溢出。

Leave a Reply

Your email address will not be published. Required fields are marked *