Compiling and Loading Kernel Modules

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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容