"模块中的未知符号"在EXPORT_SYMBOL上插入模块

时间:2015-09-04 07:37:22

标签: linux linux-kernel linux-device-driver

我正在尝试编译并插入r8169 realtek以太网驱动程序。我的内核版本是

ebin@sony:~$ uname -r
4.2.0-rc3-custom

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

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

当我浏览源代码时,我找到了

EXPORT_SYMBOL(mii_ethtool_gset);

已导出mii.c。所以我想这不是未出口符号的问题。如果我必须提供任何其他信息,请告诉我。请帮忙。

1 个答案:

答案 0 :(得分:2)

正如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.symvers上创建了make modules。我错过了那个文件。当我在模块构建目录中放置适当的Module.symvers时,模块按预期工作,没有任何错误。