免费注册 查看新帖 |

Chinaunix

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

模块加载错误 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-09-26 16:51 |只看该作者 |倒序浏览
模块加载错误
加载HelloWorld模块时,出现错误,请问如何修改?
【root@HelloWorld】# insmod hello.ko
Insmod: error inserting ‘hello.ko’: -1 Invalid module format
在/var/log/messages中查看错误:
[root@HelloWorld]# vi /var/log/messages
Sep 26 14:32:11 TOM kernel: hello: version magic ‘2.6.35.4 SMP mod_unlog 686 4 KSTACKS’ should be ‘2.6.25-14.fc9.i686 SMP mod_unload 686 4 KSTACKS’
附程序:
#include <linux/module.h>
#include <linux/init.h>
#include <linux/kernel.h>

MODULE_LICENSE("GPL");
MODULE_AUTHOR("David Xie");
MODULE_DESCRIPTION("Hello World Module");
MODULE_ALIAS("a simplest module");

static int hello_init()
{
    printk(KERN_EMERG"Hello World!\n");
    return 0;
}

static void hello_exit()
{
    printk("<6>hello exit\n");
}

module_init(hello_init);
module_exit(hello_exit);

Makefile程序:
ifneq ($(KERNELRELEASE),)

obj-m := hello.o

else
       
KDIR := /home/guoqian/4-1-1/linux-2.6.35.4
all:
        make -C $(KDIR) M=$(PWD) modules
clean:
        rm -f *.ko *.o *.mod.o *.mod.c *.symvers

endif

论坛徽章:
0
2 [报告]
发表于 2010-09-26 17:43 |只看该作者
本帖最后由 omycle 于 2010-09-26 17:46 编辑

由dmesg信息来看是你编译所用的版本,和内核版本不一致的原因。
参考:
http://forum.ubuntu.org.cn/weblog.php?w=37

论坛徽章:
0
3 [报告]
发表于 2010-09-27 12:26 |只看该作者
本帖最后由 omycle 于 2010-09-26 17:46 编辑



http://forum.ubuntu.org.cn/weblog.php?w=37
网页打不开!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP