我正在尝试加载准系统 Linux 设备驱动程序模块,但我在 dmesg 中不断遇到此问题:
module dummydriver: .gnu.linkonce.this_module section size must match the kernel's built struct module size at run time
当尝试加载模块时,我收到以下消息:
insmod: ERROR: could not insert module dummydriver.ko: Invalid module format
据我所知,我的内核版本与我用来构建模块的版本相匹配,我正在运行 Pop OS 22.04,如下所示uname -r
:
6.5.6-76060506-generic
- 驱动程序代码:
#include <linux/module.h> #include <linux/version.h> #include <linux/kernel.h> static int __init driver_init(void) { printk(KERN_INFO "bababooey :D"); return 0; } static void __exit driver_exit(void) { printk(KERN_INFO "bababooey :("); } module_init(driver_init); module_exit(driver_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("dude"); MODULE_DESCRIPTION("driver");
- 生成文件:
obj-m = dummydriver.o KVERSION = $(shell uname -r) all: make -C /lib/modules/$(KVERSION)/build M=$(shell pwd) modules clean: make -C /lib/modules/$(KVERSION)/build M=$(shell pwd) clean
- 进行输出:
make -C /lib/modules/6.5.6-76060506-generic/build M=/home/david/Programming/dummydriver modules make[1]: Entering directory '/usr/src/linux-headers-6.5.6-76060506-generic' CC [M] /home/david/Programming/dummydriver/dummydriver.o MODPOST /home/david/Programming/dummydriver/Module.symvers CC [M] /home/david/Programming/dummydriver/dummydriver.mod.o LD [M] /home/david/Programming/dummydriver/dummydriver.ko make[1]: Leaving directory '/usr/src/linux-headers-6.5.6-76060506-generic'
我已经签署了该模块,甚至尝试关闭安全启动,但我仍然在 dmesg 中收到初始错误。如果有人有建议,我将不胜感激。