免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 1583 | 回复: 15
打印 上一主题 下一主题

模块运行错误! [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-07-06 11:14 |只看该作者 |倒序浏览
我的Linux Kernel版本是2.4.20-8
gcc版本是3.2.2

模块为:
#define MODULE
#include
int init_module(void){printk("<1>;Hello,world!\n"; return 0;}
void cleanup_module(void) {printk("<1>;Goodbye cruel world\n";}

在root权限下编译成功后,运行该模块,出错信息如下:
[root@localhost /]#insmod ./hello.o
./hello.o: kernel-module version mismatch
         ./hello.o was compiled for kernel version 2.4.20
          while this kernel is version 2.4.20-8

请教各位大侠是怎么回事?不胜感激

论坛徽章:
5
2 [报告]
发表于 2005-07-06 12:57 |只看该作者

模块运行错误!

不是提示你了?版本号不匹配。
先修改kernel source code目录下的Makefile文件,里面有版本号。改为当前运行的kernel版本号 (多数情况下是相同的,无须修改)。然后build kernel,再build module。就行了

论坛徽章:
0
3 [报告]
发表于 2005-07-07 14:22 |只看该作者

模块运行错误!

奇怪了,我安转的是RedHat9.0,对其Kernel和GCC没有做任何的升级,结果在编译和加载一个Demo的模块时,就出现了这样的问题。

另外,我按照楼上说的修改版本号之后重新编译Kernel,又出现了新的编译错误,不知道什么原因,其错误提示如下:
tools/build bootsect setup compressed/vmlinux.out CURRENT >; zImage
Root device is (3, 2)
Boot sector 512 bytes.
Setup is 4914 bytes.
System is 1084 kB
System is too big. Try using bzImage or modules.
make[1]: *** [zImage] Error 1
make[1]: Leaving directory `/usr/src/linux-2.4.20-8/arch/i386/boot'
make: *** [zImage] Error 2

论坛徽章:
5
4 [报告]
发表于 2005-07-07 16:35 |只看该作者

模块运行错误!

做出来的内核文件太大,裁剪一些

论坛徽章:
0
5 [报告]
发表于 2005-07-08 08:27 |只看该作者

模块运行错误!

[quote]原帖由 "dream_money"]alhost / 发表:
#insmod ./hello.o
./hello.o: kernel-module version mismatch
         ./hello.o was compiled for kernel version 2.4.20
          while this kernel is version 2.4.20-8

请教各位大侠是怎么

论坛徽章:
0
6 [报告]
发表于 2005-07-08 08:30 |只看该作者

模块运行错误!

[quote]原帖由 "yidou"]做出来的内核文件太大,裁剪一些[/quote 发表:

他用的是 zImage,不是 bzImage

论坛徽章:
0
7 [报告]
发表于 2005-07-11 12:59 |只看该作者

模块运行错误!

我用gcc ... -I/usr/src/linux2.4.20-8/include ...选项进行编译,insmod之后没有出现版本匹配的问题,但是也没有打印出提示来,倒是有一个告警信息(和不用上面的选项,而直接用insmod -f产生的告警信息一样的)
Warning: loading ./hello.o will taint the kernel: no license
     See http://www.tux.org/lkml/#export-tainted for information about tainted modules
Module hello loaded, with warings

论坛徽章:
0
8 [报告]
发表于 2005-07-11 13:03 |只看该作者

模块运行错误!

to yidou:
    内核文件太大会有问题吗?我觉得最多会多占用一些系统资源而已,应该没有关系啊。另外,裁减是通过Make menuconfig来实现的,是吗?


to platinum:
    zImage和bzImage有什么区别,是不是后者是经过压缩之后的内核文件?

论坛徽章:
0
9 [报告]
发表于 2005-07-11 13:11 |只看该作者

模块运行错误!

2dream_money:
    内核太大不会有影响
    后者压缩度更高一些

论坛徽章:
0
10 [报告]
发表于 2005-07-11 13:31 |只看该作者

模块运行错误!

那就奇怪,不知道为什么在insmod的时候不会打印出提示信息。照理说,在insmod的时候,kernel会调用init_module函数的,从而打印出提示信息的。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP