最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【未解决】WARNING: modpost: Found 1 section mismatch

工作和技术 crifan 3022浏览 0评论

【问题】

对于已经可以正常编译的内核linux-2.6.28.4,在加了自己写的一个rtc驱动后,再编译,出现warning:

make ARCH=arm; make ARCH=arm uImage

…….

WARNING: modpost: Found 1 section mismatch(es).
To see full details build your kernel with:
‘make CONFIG_DEBUG_SECTION_MISMATCH=y’

感觉有问题,但是实际测试结果,驱动也是可以正常工作的。

【解决过程】

1。至今未找到根本原因是啥。去掉那个rtc驱动,再编译,就是正常的,加上它,编译就出现上述警告。

2.这里:

http://www.loongson.cn/support/cgi-bin/gitweb/gitweb.cgi?p=linux-2.6.27;a=log;h=d3883ecebbf9e095b9e379dabbbe8b2c1ee7a41c

说,在make的时候,加上参数CONFIG_DEBUG_SECTION_MISMATCH=y’,然后应该可以看到具体错在哪里,是哪里mismatch了。

自己去试了下:

make ARCH=arm CONFIG_DEBUG_SECTION_MISMATCH=y

然后,导致整个kernel都要重新编译。。。漫长的等待啊。。。。

最后编译过程中,输出了对应的错误原因:

LD      drivers/rtc/built-in.o
WARNING: drivers/rtc/built-in.o(.data+0xe4): Section mismatch in reference from the variable as353x_rtc to the function .devexit.text:as353x_rtc_remove()
The variable as353x_rtc references
the function __devexit as353x_rtc_remove()
If the reference is valid then annotate the
variable with __exit* (see linux/init.h) or name the variable:
*driver, *_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console,

去看了下代码,具体涉及的代码为:

static int __devexit as353x_rtc_remove(struct platform_device *pdev)
{
。。。
}

static struct platform_driver as353x_rtc ={
.probe = as353x_rtc_probe,
.remove = __devexit_p(as353x_rtc_remove),
.driver = {
   .name ="as353x-rtc",
   .owner = THIS_MODULE,
},
};
意思就是,一个正常的变量as353x_rtc,去引用了as353x_rtc_remove函数,而这个函数是前面加了__devexit 修饰,即此驱动模块卸载的时候,就释放其内存占用,就不存在的函数,因此觉得mismatch,不匹配,其建议我们应该在这个变量as353x_rtc前面加上对应的修饰,比如__exit。

其说得,听起来,很在理,但是问题在于,我去搜索了一下内核的其他驱动模块,N多的驱动,都是这种做法,但是都是编译正常,没有警告的,为何只有我这个rtc驱动,对此提出了警告,说是mismatch了呢?很是不解。。。

转载请注明:在路上 » 【未解决】WARNING: modpost: Found 1 section mismatch

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
79 queries in 0.153 seconds, using 22.11MB memory