Linux kernel Hello World内核模块格式无效
我目前正试图运行我的Hello World内核模块,但我有点挣扎,我不知道为什么 首先 uname-rLinux kernel Hello World内核模块格式无效,linux-kernel,kernel,Linux Kernel,Kernel,我目前正试图运行我的Hello World内核模块,但我有点挣扎,我不知道为什么 首先 uname-r 2.6.32-358.23.2.el6.x86_64 我的你好 #include <linux/module.h> /* Needed by all modules */ #include <linux/kernel.h> /* Needed for KERN_INFO */ #include <linux/init.h>
2.6.32-358.23.2.el6.x86_64
我的你好
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_INFO */
#include <linux/init.h> /* Needed for the macros */
static int __init hello_start(void)
{
printk(KERN_INFO "Loading hello module...\n");
printk(KERN_INFO "Hello world\n");
return 0;
}
static void __exit hello_end(void)
{
printk(KERN_INFO "Goodbye Mr.\n");
}
module_init(hello_start);
module_exit(hello_end);
MODULE_LICENSE("GPL");
运行时出现错误消息
$ sudo insmod ./hello.ko
insmod: error inserting './hello.ko': -1 Invalid module format
dmesg输出
hello: no symbol version for module_layout
文件夹中的文件
hello.c hello.ko hello.ko.unsigned hello.mod.c hello.mod.o hello.o include Makefile modules.order Module.symvers
插入此模块并完成我的进一步工作需要什么?我想您必须先在模块上签名。可能可以通过makemodules\u install来完成。您确定要将模块插入到一个内核中,该内核的版本与您所针对的头文件的版本相同吗?问题已解决。用于编译内核和模块的gcc版本不同。内核编译4.4.7,模块编译4.8.2
hello.c hello.ko hello.ko.unsigned hello.mod.c hello.mod.o hello.o include Makefile modules.order Module.symvers