Linux 加载内核模块时出现未知符号

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7513184/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 06:18:57  来源:igfitidea点击:

Unknown symbol in while loading a kernel module

linuxlinux-kernelkernel-modulelinux-scst

提问by

I need help understanding why I get an error when I insert a module. I have tried thiswith no success.

我需要帮助理解为什么在插入模块时出现错误。我试过这个没有成功。

$ sudo modprobe lpfc_scst 
FATAL: Error inserting lpfc_scst (/lib/modules/2.6.32-33-generic/extra/lpfc_scst.ko): Unknown symbol in module, or unknown parameter (see dmesg)

$ dmesg | tail
[ 1201.262842] lpfc_scst: Unknown symbol scst_register_target
[ 1201.262949] lpfc_scst: Unknown symbol lpfc_tm_term
[ 1201.263161] lpfc_scst: no symbol version for scst_register_session
[ 1201.263164] lpfc_scst: Unknown symbol scst_register_session
[ 1201.263284] lpfc_scst: no symbol version for scst_rx_mgmt_fn
[ 1201.263286] lpfc_scst: Unknown symbol scst_rx_mgmt_fn
[ 1201.263395] lpfc_scst: no symbol version for scst_unregister_session
[ 1201.263398] lpfc_scst: Unknown symbol scst_unregister_session
[ 1201.263573] lpfc_scst: no symbol version for scst_rx_data
[ 1201.263575] lpfc_scst: Unknown symbol scst_rx_data

$ cat /proc/kallsyms | grep scst_register_target
dffd2a10 r __ksymtab_scst_register_target   [scst]
dffd302e r __kstrtab_scst_register_target   [scst]
dffd2b34 r __kcrctab_scst_register_target   [scst]
dffd2a20 r __ksymtab___scst_register_target_template_non_gpl    [scst]
dffd3063 r __kstrtab___scst_register_target_template_non_gpl    [scst]
dffd2b3c r __kcrctab___scst_register_target_template_non_gpl    [scst]
dffd2c10 r __ksymtab___scst_register_target_template    [scst]
dffd308b r __kstrtab___scst_register_target_template    [scst]
dffd2de8 r __kcrctab___scst_register_target_template    [scst]
dff913a0 t __scst_register_target_template  [scst]
dff90dd0 T scst_register_target [scst]
dff91840 T __scst_register_target_template_non_gpl  [scst]

$

Many thanks.

非常感谢。

采纳答案by Oleksandr Kravchuk

I have solved this problem as suggested on this forum:

我已经按照这个论坛上的建议解决了这个问题:

  1. Compiled scst.
  2. Appended the generated Module.symversto existent /lib/modules/<version>/build/Module.symvers(Hack. Do not know why the kernel did not see the exported symbols).
  3. Copied the scstto /lib/modules/<version>/extra.
  4. depmod -a.
  5. Compiled lpfc_scst.
  6. Inserted module lpfc_scstwith no problems.
  1. 编译scst
  2. 将生成的附加Module.symvers到现有/lib/modules/<version>/build/Module.symversHack。不知道为什么内核没有看到导出的符号)。
  3. 复制scst/lib/modules/<version>/extra.
  4. depmod -a.
  5. 编译lpfc_scst
  6. 插入模块lpfc_scst没有问题。

Have a nice day.

祝你今天过得愉快。

回答by gby

If you are trying to insmod a module that was build against a kernel source tree/headers that are not the actual source of the running kernel, the most likely cause is that some kernel configuration is different between the running kernel and the one you built the module against.

如果您尝试插入针对不是正在运行的内核的实际源的内核源代码树/头文件构建的模块,最可能的原因是正在运行的内核与您构建的内核之间的某些内核配置不同模块反对。

The linker inside the Linux kernel actually looks at a bunch of things besides the symbol name for matching symbols, including possibly a hash of the function parameter and return value, various config option (preempt / non preempt) when trying to match symbol names. I guess that in your case it does not find the right match due to different config options

Linux 内核中的链接器实际上除了匹配符号的符号名称外,还会查看一堆东西,可能包括函数参数和返回值的哈希值、尝试匹配符号名称时的各种配置选项(抢占/非抢占)。我猜在你的情况下,由于不同的配置选项,它没有找到正确的匹配

回答by Oleksandr Kravchuk

This means that the kernel isn't allowing modules to see that variable. It does look like you haven't added your variables to the list of symbols that the kernel exports:

这意味着内核不允许模块看到该变量。看起来您还没有将变量添加到内核导出的符号列表中:

EXPORT_SYMBOL_NOVERS(scst_register_target);