Linux模块版本错误 "Invalid module format"

标签 linux module kernel insmod

我制作了 Linux 外部模块,因为我的模块需要 Linux 内核符号,

我设置了 Modversion 配置并制作它。(也制作了 modules_install)

我的模块完全在 lib/modules/(my linux)/extra/中制作

但是当我插入我的模块时,shell 打印错误信息

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

这是dmesg的内容

[  341.458351] oxen_aggregator_module: version magic '3.17.8-gentoo-r1 SMP mod_unload modversions ' should be '3.17.8-gentoo-r1 SMP mod_unload '

但我需要 modversions 标志,因为如果我没有设置该标志,Module.symvers 将只有 0x00000000 个地址。

你能帮帮我吗?我该如何解决?

我的制作文件

SRCS    = oxen_aggregator_module.c
OBJS    = $(SRCS:.c=.o)

obj-m += $(OBJS)

KBUILD_EXTRA_SYMBOLS={/usr/src/linux-$(shell unamr -r)/Module.symvers}
all:
    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules_install
clean:
    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
    $(RM) Module.markers modules.order

最佳答案

您试图将模块加载到内核中,但它(模块)尚未构建。或者您为一个内核构建模块,但使用 KBUILD_EXTRA_SYMBOLS 和为另一个内核创建的 Module.symvers 文件。

如果您需要将 KBUILD_EXTRA_SYMBOLS 与内核 Module.symvers 文件 一起使用,那么它肯定会在某处与不同的内核混淆。

关于Linux模块版本错误 "Invalid module format",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30341496/

相关文章:

c - 调整 argVector

javascript - 如何减少 JavaScript 中内部函数变量的范围?

android - Qt Android 附加安装

c++ - FindResource 的内核模式版本

c - 为什么 tasklist_lock 使用 write_lock_irq 而不是 write_lock?

linux - 在远程机器上执行多个命令

c++ - 进入系统,Linux下的CRTL功能与Eclipse

swift - 下划线 "_"在 Swift 中是什么意思?

c++ - 跨网络发送数据最快的 C/C++ 技术?

linux - 如何为 "git last"设置接受数字作为参数的别名?