简体   繁体   English

在insmod之后不同意符号symbol_name的版本

[英]Disagrees about version of symbol symbol_name after insmod

I am new in kernel programming. 我是内核编程的新手。

For implementing my project work, I have downloaded the latest stable kernel (v4.3) from kernel.org . 为了实现我的项目工作,我从kernel.org下载了最新的稳定内核(v4.3)

Just for checking I have copied a few files from the kernel directories into my project directory. 只是为了检查我已经将内核目录中的一些文件复制到我的项目目录中。 Made changes to it and inserted a few more code to it. 对其进行了更改并向其中插入了更多代码。

Then I compiled on SLES11 Linux kernel using 然后我在SLES11 Linux内核上编译使用

make -C /lib/modules/$(uname -r)/build M=$PWD modules

I have used the below makefile 我使用了下面的makefile

obj-m := my_module.o
my_module-objs := module_main.0 other_module1.o other_module2.o other_module3.o

It compiled successfully. 它编译成功。 But when I tried to insert into the kernel using 但是当我尝试使用时插入内核

insmod my_sample.ko

It showed the following 它显示了以下内容

disagrees about version of symbol symbol_name 不同意符号symbol_name的版本

在此输入图像描述

You need to build your kernel module against the same version kernel you are going to run. 您需要针对要运行的相同版本内核构建内核模块。 Thus if you have kernel 4.3 sources that you have downloaded you need to compile that version of the kernel and boot with that running before trying to load your kernel. 因此,如果你有内核4.3源已下载你需要编译的内核版本,并启动与运行的尝试加载内核前。

You have two solutions then: 那你有两个解决方案:

  1. Download the kernel sources for the kernel you are currently running (you can install those with zypper install kernel-source on SLES or an equivalent command on other distributions.) 下载当前运行的内核的内核源代码(可以在SLES上zypper install kernel-source或在其他发行版上zypper install kernel-source等效命令。)
  2. Compile and install the 4.3 kernel in to your operating system. 编译并将4.3内核安装到您的操作系统中。 If you need help with this then ask a separate question (and it probably belongs on superuser not here). 如果你需要帮助,那就问一个单独的问题(它可能属于超级用户而不是这里)。 Note that if kernel and glibc are tightly coupled, and it is possible that you can't run a new kernel if you have a very old C library. 请注意,如果内核和glibc紧密耦合,并且如果您有一个非常旧的C库,则可能无法运行新内核。

make -C /lib/modules/$(uname -r)/build M=$PWD modules, "$(uname -r)" shows that you are compiling against the kernel version you are running now so you should be able to insmod the module in the current kernel if you haven't changed the headers. make -C / lib / modules / $(uname -r)/ build M = $ PWD modules,“$(uname -r)”表示你正在编译你正在运行的内核版本,所以你应该能够insmod如果你没有更改标题,那么当前内核中的模块。

From your text, "Just for checking I have copied a few files from the kernel directories into my project directory. Made changes to it and inserted a few more code to it." 从您的文本,“只是为了检查我已经从内核目录中复制了一些文件到我的项目目录。对其进行了更改并向其中插入了更多代码。”

If you have made modifications to the kernel source then you may need to recompile the new kernel and boot with the new updated kernel. 如果您已对内核源进行了修改,那么您可能需要重新编译新内核并使用新的更新内核进行引导。 Then you should be able to compile your kernel module with the modified headers. 然后,您应该能够使用修改后的头文件编译内核模块。

The problem here is that your Kernel module is using the exported symbols of other kernel modules which in this case appears to be the linux InfiniBand RDMA stack's exported methods or symbols. 这里的问题是您的内核模块正在使用其他内核模块的导出符号,在这种情况下,这些符号似乎是linux InfiniBand RDMA堆栈的导出方法或符号。

To solve the symbol version problems, copy the Module.symvers file from the 要解决符号版本问题,请Module.symvers复制Module.symvers文件

/usr/src/ofa-kernel

directory and paste it to your current working directory. 目录并将其粘贴到您当前的工作目录中。 Then you make your modules again. 然后再次制作模块。 Now the insmod should work perfectly fine. 现在insmod应该可以正常工作。

NOTE: The Module.symvers file contains information of all the kernel module exported symbol. 注意:Module.symvers文件包含所有内核模块导出符号的信息。 So by copying it to your working directory, you are helping kbuild to know more about the used exported symbols. 因此,通过将其复制到您的工作目录,您正在帮助kbuild了解有关已使用的导出符号的更多信息。

And if you don't find Module.symvers or it is empty, then create one using create_Module.symvers.sh 如果您没有找到Module.symvers或它是空的,那么使用create_Module.symvers.sh创建一个

Looks like you built agAinst right kernel.something to do with how your kernel is compiled. 看起来你构建了agAinst right kernel.something来处理内核的编译方式。 (See Config_conversions). (请参阅Config_conversions)。 Try --force 试试--force

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM