模块不能插入的问题解决 disagrees about version of symbol str

最近开发产品的时候发现个问题,以前没出现过,现在记录下来,算个积累吧。

编译了一个新的模块,在进行加载的时候出现了如下问题:

/opt/autorun # insmod board_config.koboard_config: disagrees about version of symbol __class_createboard_config: Unknown symbol __class_create (err -22)board_config: disagrees about version of symbol class_destroyboard_config: Unknown symbol class_destroy (err -22)board_config: disagrees about version of symbol device_createboard_config: Unknown symbol device_create (err -22)board_config: disagrees about version of symbol device_destroyboard_config: Unknown symbol device_destroy (err -22)insmod: can’t insert ‘board_config.ko’: invalid parameter

用modinfo命令查看:modinfo board_config.ko后如下所示:

filename: board_config.kolicense: GPLdepends: vermagic: 2.6.37 mod_unload modversions ARMv7 p2v8

wdove很好的解释了这个问题,在此感谢!原文

下面转载其解释:

最开始下载的内核源码和机子的kernel不匹配,参照:

检查/usr/src/linux/Makefile,确保下面这些特定的版本信息同你使用的内核完全一致:VERSION = 2PATCHLEVEL = 6SUBLEVEL = 5EXTRAVERSION = -1.358custom…不必完全编译一遍内核,只得到需要的文件即可:root@pcsenonsrv linux-2.6.x]# makeCHK include/linux/version.hUPD include/linux/version.hSYMLINK include/asm -> include/asm-i386SPLIT include/linux/autoconf.h -> include/config/*HOSTCCscrīpts/basic/fixdepHOSTCCscrīpts/basic/split-includeHOSTCCscrīpts/basic/docprocHOSTCCscrīpts/conmakehashHOSTCCscrīpts/kallsymsCC scrīpts/empty.o… 如果你不是确实想编译一个内核,你可以在SPLIT后通过按下CTRL-C中止编译过程。因为此时你需要的文件 已经就绪了。现在你可以返回你的模块目录然后编译加载它:此时模块将完全针对你的当前内核编译,加载时也不会由任何错误提示。

其中还提到:

我们可以借助选项–force-vermagic解决该问题,但这种方法有潜在的危险,所以在成熟的模块中也是不可接受的。首 先,准备同你目前的内核版本完全一致的内核代码树。然后,找到你的当前内核的编译配置文件。通常它可以在路径 /boot下找到,使用像config-2.6.x的文件名。你可以直接将它拷贝到内核代码树的路径下: cp /boot/config-`uname -r` /usr/src/linux-`uname -r`/.config。

不过用过了,不起作用。

最后:

自编module

$ modinfo memory.kofilename: memory.kolicense: Dual BSD/GPLsrcversion: BC5712DD3ED953ACB98BF49depends:vermagic:2.6.24-19-386 mod_unload modversions 486

内核

$ uname -aLinux shlx12 2.6.24-19-386 #1 Wed Jun 18 14:09:56 UTC 2008 i686 GNU/Linux

系统module

$ modinfo /lib/modules/2.6.24-19-386/kernel/sound/soundcore.kofilename: /lib/modules/2.6.24-19-386/kernel/sound/soundcore.koalias: char-major-14-*license: GPLauthor: Alan Coxdescription: Core sound modulesrcversion: 548AA54AF08207316C104F8depends:vermagic:2.6.24-19-386 mod_unload 486

因为kernel source是一个ubuntu修改版的内核,所有有 modversions的记号,,不知道去哪里除掉。最后查Makefile, .config发现了

x Symbol: MODVERSIONS [=n] x x Prompt: Module versioning support x x Defined at init/Kconfig:874 x x Depends on: MODULES x x Location: x x -> Enable loadable module support (MODULES [=y])

去掉该选项后,再用上面的步骤,可以编过module。

Rusty Russell提到modversions是为了不使一个没有版本的module插入一个修改版的内核

人,都有不能称心如意的时候,都有愿望落空的窘迫,

模块不能插入的问题解决 disagrees about version of symbol str

相关文章:

你感兴趣的文章:

标签云: