编译模块insmod时如果模块的vermagic和内核的vermagic不一致的话,将会导致insmod失败。
modinfo hello_world.ko
vermagic: 2.6.38-xxx+ mod_unload modversions 586
内核的vermagic信息是不能改的,除非make menuconfig然后重现编译内核。
模块的vermagic是怎么来的呢,由几个部分组成:
2.6.38:内核版本,在/lib/modules/`uname -r`/build/Makefile获取的。
-xxx+:内核本地版本,在/lib/modules/`uname -r`/build/include/generated/utsrelease.h获取的。
686:cpu芯片类型。在在/lib/modules/`uname -r`/build/include/generated/autoconf.h获取的。CONFIG_M686
具体的意义如下:
config M686
bool "Pentium-Pro"
depends on X86_32
---help---
Select this for Intel Pentium Pro chips. This enables the use of
Pentium Pro extended instructions, and disables the init-time guard
against the f00f bug found in earlier Pentiums.
另外还有SMP等组成部分,就不详细说了。这几个组成部分可以直接通过修改makefile或者头文件使编译后的模块的vermagic生效。当然最好的办法还是make menuconfig然后make,让内核的编译系统自动生成这些文件。