no symbol version for xxx

本文探讨了Linux内核驱动模块加载时出现未知符号错误的问题,提供了从错误根源分析到解决方案的全过程。通过案例演示了如何正确配置模块依赖与符号版本,以确保模块间函数调用顺利进行。重点强调了内核版本2.6.26后存在的bug及其解决方法,包括将目标模块的Module.symvers文件放置在调用模块的当前路径下,或在调用模块的makefile中指定KBUILD_EXTRA_SYMBOLS变量。通过实践验证了此方法的有效性,并给出了完整的测试程序和步骤,旨在帮助开发者避免类似问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

最近在加载驱动时遇到这个问题,在网上搜了下,故转载下:http://blog.csdn.net/hshl1214/article/details/8769112


前几天一个同事问我:如果一个模块要调用另一个模块的函数,要不要做什么特别的处理?我当时只是知道需要将被调用的函数EXPORT_SYMBOL();。但是由于具体的模块实验自己还没有做过,我就立马做了一个给他看,自己也验证一下。这实验一做,问题就来了:虽然在编译通过了(有警告:

  1. WARNING: "exported_function_2" [/home/tekkaman/development/research/Linux_module/caller/caller.ko]undefined!
),但是当把导出函数的模块挂载后,再挂载调用模块的时候出了错误无法挂载:
  1. # insmod exporter_1.ko
  2. Hello, Tekkaman Ninja !
  3. exported_function_1 is online!
  4. # insmod exporter_2.ko
  5. Hello, Tekkaman Ninja !
  6. exported_function_2 is online!
  7. # insmod caller.ko
  8. caller: no symbol version for exported_function_2
  9. caller: Unknown symbol exported_function_2 (err -22)
  10. caller: no symbol version for exported_function_1
  11. caller: Unknown symbol exported_function_1 (err -22)
  12. insmod: error inserting 'caller.ko': -1 Invalid parameters
    这里先将我的测试用例分享如下,大家可以先看下代码:

   (请自行修改内核源码目录和交叉编译器的定义)
   
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
在出了问题之后,我到网上google了解决方法

   其中15楼daidaiangel 的解决办法是正解,转载如下:
  1. 这是linux kernel 2.6.26 之后版本的bug (详细描述, 请看http://bugzilla.kernel.org/show_bug.cgi%3Fid%3D12446)
  2. 并且这个bug不会被fix

  3. 解决办法是把mod_a的Module.symvers放到mod_b的当前路径,从而编译mod_b,符号信息会自动连接进去.
  4. 或者在mod_b的makefile中使用KBUILD_EXTRA_SYMBOLS指定mod_a的Module.symvers, 如:
  5. KBUILD_EXTRA_SYMBOLS=/mod_a/Module.symvers

  6. 编译mod_b时,搜索Module.symvers的路径是:
  7. 1, kernel source path, e.g. /usr/src/kernels/linux-2.6.28.10
  8. 2, makefile中M=所指定的路径, 它等效于变量KBUILD_EXTMOD的值
  9. 3, 变量KBUILD_EXTRA_SYMBOLS的值
    而16楼 littertiger  道出了问题的本质:
  1. 15楼分析透彻
  2. 简单说来,就是小b生成的时候不知道小a symbol的校验码,小b加载的时候自然check 校验码出错
    同时还有一篇网文作为参考,解决方法相同: Linux内核模块加载报错”no symbol version for struct_module”解决办法

    用这个方法的确可以解决问题,只要将上面的测试程序中的caller的makefile中加上“KBUILD_EXTRA_SYMBOLS”就好了(里面已经有了,去掉注释,路径改下,但必须是绝对路径哦!)。重新编译caller模块即可。

实验过程:

  1. root@dm816x-evm:/# insmod exporter_1.ko
  2. Hello, Tekkaman Ninja !
  3. exported_function_1 is online!
  4. root@dm816x-evm:/# insmod exporter_2.ko
  5. Hello, Tekkaman Ninja !
  6. exported_function_2 is online!
  7. root@dm816x-evm:/# insmod caller.ko
  8. Hello, Tekkaman Ninja !
  9. Now call exporters's function!
  10. I'm exported_function_1 !(in /home/tekkaman/development/research/Linux_module/exporter_1/exporter_1.c)
  11. I'm exported_function_2 !(in /home/tekkaman/development/research/Linux_module/exporter_2/exporter_2.c)

PS D:\vs code\资源_项目> & C:/Users/Lenovo/AppData/Local/Programs/Python/Python313/python.exe "d:/vs code/资源_项目/携程.py" DevTools listening on ws://127.0.0.1:57300/devtools/browser/6363486c-acb3-4c38-bf18-5da84280ebd0 Traceback (most recent call last): File "d:\vs code\资源_项目\携程.py", line 78, in <module> scrape_ctrip_reviews(hotel_url) ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^ File "d:\vs code\资源_项目\携程.py", line 47, in scrape_ctrip_reviews driver = stealth_driver() File "d:\vs code\资源_项目\携程.py", line 18, in stealth_driver driver = webdriver.Chrome(service=Service('chromedriver.exe'), options=chrome_options) File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python313\Lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 47, in __init__ super().__init__( ~~~~~~~~~~~~~~~~^ browser_name=DesiredCapabilities.CHROME["browserName"], ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...<3 lines>... keep_alive=keep_alive, ^^^^^^^^^^^^^^^^^^^^^^ ) ^ File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python313\Lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 69, in __init__ super().__init__(command_executor=executor, options=options) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python313\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 261, in __init__ self.start_session(capabilities) ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^ File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python313\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 362, in start_session response = self.execute(Command.NEW_SESSION, caps)["value"] ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python313\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 454, in execute self.error_handler.check_response(response) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^ File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python313\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 232, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 138 Current browser version is 123.0.6312.123 with binary path C:\Users\Lenovo\AppData\Local\Google\Chrome\Application\chrome.exe; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#sessionnotcreatedexception Stacktrace: GetHandleVerifier [0x0x7ff7d3244ef5+2841701] GetHandleVerifier [0x0x7ff7d2fa2640+78768] (No symbol) [0x0x7ff7d2d79bba] (No symbol) [0x0x7ff7d2dbddef] (No symbol) [0x0x7ff7d2dbce3b] (No symbol) [0x0x7ff7d2db680b] (No symbol) [0x0x7ff7d2db2716] (No symbol) [0x0x7ff7d2e0649e] (No symbol) [0x0x7ff7d2e05c30] (No symbol) [0x0x7ff7d2df8263] (No symbol) [0x0x7ff7d2dc1041] (No symbol) [0x0x7ff7d2dc1dd3] GetHandleVerifier [0x0x7ff7d326f65d+3015629] GetHandleVerifier [0x0x7ff7d3269c5d+2992589] GetHandleVerifier [0x0x7ff7d3287c4d+3115453] GetHandleVerifier [0x0x7ff7d2fbbe8e+183294] GetHandleVerifier [0x0x7ff7d2fc38ff+214639] GetHandleVerifier [0x0x7ff7d2faaad4+112708] GetHandleVerifier [0x0x7ff7d2faac89+113145] GetHandleVerifier [0x0x7ff7d2f91e68+11224] BaseThreadInitThunk [0x0x7fff1a72257d+29] RtlUserThreadStart [0x0x7fff1a94af28+40]
最新发布
07-26
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值