美文网首页
Compiling and Loading Kernel Mod

Compiling and Loading Kernel Mod

作者: Programming | 来源:发表于2017-09-05 10:41 被阅读0次

after updating the kernel version to 4.12.0, it comes out the following error report when compiling the kernel modules:

[root@localhost BBU_coding]# make

#make -C /usr/src/kernels/4.12.9-200.fc25.x86_64/ M=/root/BBU_coding modules

make -C /usr/src/kernels/linux-4.12/ M=/root/BBU_coding modules

make[1]: Entering directory '/usr/src/kernels/linux-4.12'

make[2]: *** No rule to make target 'tools/objtool/objtool', needed by '/root/BBU_coding/hello.o'.  Stop.

Makefile:1512: recipe for target '_module_/root/BBU_coding' failed

make[1]: *** [_module_/root/BBU_coding] Error 2

make[1]: Leaving directory '/usr/src/kernels/linux-4.12'

Makefile:4: recipe for target 'all' failed

make: *** [all] Error 2

[root@localhost BBU_coding]#

2. I need to install the following packages:

dnf install kernel-headers kernel-devel -y

3. revise the Makefile

make -C /usr/src/kernels/4.12.9-200.fc25.x86_64/ M=$(PWD) modules

4. then when "insmod hello.ko"

[root@localhost BBU_coding]# insmod hello.ko

insmod: ERROR: could not insert module hello.ko: Invalid module format

[root@localhost BBU_coding]# dmesg

[ 2502.478285] hello: version magic '4.12.9-200.fc25.x86_64 SMP mod_unload ' should be '4.12.0 SMP mod_unload '.

5. revise the "hello.c" file by adding one more line:

MODULE_INFO(vermagic, "4.12.0 SMP mod_unload ");

6. OK, now.

or

dnf upgrade -y

相关文章

网友评论

      本文标题:Compiling and Loading Kernel Mod

      本文链接:https://www.haomeiwen.com/subject/nzhujxtx.html