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

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容