尽管EXPORT_SYMBOL模块插入“模块中的未知符号”

问题描述:

我想编译并插入r8169 realtek ethernet驱动程序。我的内核版本是尽管EXPORT_SYMBOL模块插入“模块中的未知符号”

[email protected]:~$ uname -r 
4.2.0-rc3-custom 

我在我的本地磁盘中有相同的完整源代码,它用于安装当前内核。该模块编译成功,当我运行make -C /lib/modules/使用uname -r /build M= PWD modules
但是当我插入的模块,它显示

[email protected]:~/linux_testing/linux-stable/drivers/net/ethernet/realtek$ sudo insmod r8169.ko 
insmod: ERROR: could not insert module r8169.ko: Unknown symbol in module 
[email protected]:~/linux_testing/linux-stable/drivers/net/ethernet/realtek$ dmesg 
[16717.311216] r8169: Unknown symbol mii_ethtool_gset (err 0) 

当我通过源grepped,我发现

EXPORT_SYMBOL(mii_ethtool_gset); 

已经出口在mii.c。所以我想这不是未引用符号的问题。让我知道如果我必须提供任何其他信息。请帮忙。

+0

您是否将“Module.symvers”复制到构建目录中? – RedEyed

+0

@ebin:如果mii被编译为模块,在插入模块之前需要插入它('sudo modprobe mii')。与'modprobe'不同,'insmod'不会自动加载相关模块。 – Tsyvarev

+0

@Tsyvarev:我在加载mii模块后试过。现在,它显示了错误'错误:无法插入模块r8169.ko:无效parameters' dmesg的'[8157.140018] r8169:不同意关于符号mii_ethtool_gset版本 [8157.140027] r8169:未知符号mii_ethtool_gset(ERR -22) ' – ebin

正如Vadim Stupakov在评论中所说,将Module.symvers文件放入模块源目录中解决了我的问题。从这个documentation

Module versioning is enabled by the CONFIG_MODVERSIONS tag, and is used 
as a simple ABI consistency check. A CRC value of the full prototype 
for an exported symbol is created. When a module is loaded/used, the 
CRC values contained in the kernel are compared with similar values in 
the module. if they are not equal, the kernel refuses to load the 
module. 
Module.symvers contains a list of all exported symbols from a kernel 
build. 

按我的理解,Module.symversmake modules创建。我错过了那个文件。当我将合适的Module.symvers放入模块构建目录中时,该模块按我预期的方式工作,没有任何错误。