linux加载模块时出现:Invalid module format

lza705 2014-11-01 05:48:09
我有一个非开源的模块,module.ko,加载到我linux中的时候显示:
insmod: error inserting 'module.ko': -1 Invalid module format。
查看错误信息如下:
localhost:~# dmesg | grep module
[ 154.768599] module: version magic '2.6.33.7-Kernel SMP preempt mod_unload ATOM ' should be '2.6.26-1-486 mod_unload modversions 486 '
查看module模块的信息如下:
localhost:~# modinfo module.ko
filename: module.ko
license: Dual BSD/GPL
author: Nielsen
depends:
vermagic: 2.6.33.7-Kernel SMP preempt mod_unload ATOM
parm: net_device_name:charp
parm: buffersize:int
parm: ur_major:int
parm: ur_minor:int
我的系统里面的模块信息如下:
localhost:/lib/modules/2.6.26-1-486/kernel/drivers/i2c# modinfo i2c-dev.ko
filename: i2c-dev.ko
license: GPL
description: I2C /dev entries driver
author: Frodo Looijaard <frodol@dds.nl> and Simon G. Vogl <simon@tk.uni-linz.ac.at>
depends: i2c-core
vermagic: 2.6.26-1-486 mod_unload modversions 486

经过分析是由于版本不同,为了加载上模块,下载了一个linux内核,版本为:2.6.33.7,然后修改了/include/linux/vermagic.h 下的VERMAGIC_STRING,如下:

#include <linux/module.h>

/* Simply sanity version stamp for modules. */
#ifdef CONFIG_SMP
#define MODULE_VERMAGIC_SMP "SMP "
#else
#define MODULE_VERMAGIC_SMP ""
#endif
#ifdef CONFIG_PREEMPT
#define MODULE_VERMAGIC_PREEMPT "preempt "
#else
#define MODULE_VERMAGIC_PREEMPT ""
#endif
#ifdef CONFIG_MODULE_UNLOAD
#define MODULE_VERMAGIC_MODULE_UNLOAD "mod_unload "
#else
#define MODULE_VERMAGIC_MODULE_UNLOAD ""
#endif
#ifdef CONFIG_MODVERSIONS
#define MODULE_VERMAGIC_MODVERSIONS "modversions "
#else
#define MODULE_VERMAGIC_MODVERSIONS ""
#endif
#ifndef MODULE_ARCH_VERMAGIC
#define MODULE_ARCH_VERMAGIC ""
#endif

#define VERMAGIC_STRING \
UTS_RELEASE "2.6.33.7-Kernel SMP preempt mod_unload ATOM "

编译内核,把新编译成的内核替代了当前的内核,重启再加载模块,出现下面错误,怎么办:
localhost:~# insmod module.ko
已杀死
localhost:~#
Message from syslogd@localhost at Nov 1 17:25:38 ...
kernel:[ 90.233858] Oops: 0000 [#1] SMP

Message from syslogd@localhost at Nov 1 17:25:38 ...
kernel:[ 90.233971] Process insmod (pid: 3749, ti=f6efe000 task=f79167b0 task.ti=f6efe000)

Message from syslogd@localhost at Nov 1 17:25:38 ...
kernel:[ 90.233974] Stack:

Message from syslogd@localhost at Nov 1 17:25:38 ...
kernel:[ 90.234062] EIP: [<c1059fc9>] sys_init_module+0x88/0x1d7 SS:ESP 0068:f6efffa8

Message from syslogd@localhost at Nov 1 17:25:38 ...
kernel:[ 90.234070] CR2: 0000000000020074

Message from syslogd@localhost at Nov 1 17:25:38 ...
kernel:[ 90.234002] Call Trace:

Message from syslogd@localhost at Nov 1 17:25:38 ...
kernel:[ 90.234014] Code: 00 e9 6f 01 00 00 b8 74 45 32 c1 31 f6 e8 de 1b 1e 00 89 d9 ba 01 00 00 00 b8 94 45 32 c1 e8 c8 01 ff ff eb 0a 8b 83 58 01 00 00 <ff> 14 b0 46 3b b3 5c 01 00 00 72 ee 8b 83 d4 00 00 00 85 c0 0f

Message from syslogd@localhost at Nov 1 17:25:38 ...
kernel:[ 90.233862] last sysfs file: /sys/class/power_supply/ACAD/online
...全文
5630 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
this module was not built for your kernel. you either install the same kernel or find the source of this module and build it against your current kernel...
rambowng 2014-11-30
  • 打赏
  • 举报
回复
是不是编译驱动的内核版本和你板子烧写的版本不一样啊?版本识别不了
konglele 2014-11-30
  • 打赏
  • 举报
回复
版本不匹配,模块编译时需要内核源码,其版本必需和所要安装到的系统内核版本一致 你模块没有源码,那就只能把你系统内核换一下了
91program 2014-11-02
  • 打赏
  • 举报
回复
LZ,发错板块了

23,125

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧