免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12
最近访问板块 发新帖
楼主: lxyscls
打印 上一主题 下一主题

invalid module format (-1):Exec format error [复制链接]

论坛徽章:
14
水瓶座
日期:2014-06-10 09:51:0215-16赛季CBA联赛之江苏
日期:2017-11-27 11:42:3515-16赛季CBA联赛之八一
日期:2017-04-12 14:26:2815-16赛季CBA联赛之吉林
日期:2016-08-20 10:43:1215-16赛季CBA联赛之广夏
日期:2016-06-23 09:53:58程序设计版块每日发帖之星
日期:2016-02-11 06:20:00程序设计版块每日发帖之星
日期:2016-02-09 06:20:0015-16赛季CBA联赛之上海
日期:2015-12-25 16:40:3515-16赛季CBA联赛之广夏
日期:2015-12-22 09:39:36程序设计版块每日发帖之星
日期:2015-08-24 06:20:002015亚冠之德黑兰石油
日期:2015-08-07 09:57:302015年辞旧岁徽章
日期:2015-03-03 16:54:15
11 [报告]
发表于 2009-11-17 13:43 |只看该作者
NND,确实是啊~

模块在编译的时候涉及到一个内核MAGIC_STRING的检查工作~(insmod会用检查模块的modinfo看看跟内核的是否一致)~

不光内核版本要一致,并且SMP, PREEMPT, MODULE_UNLOAD和MODVERSIONS再加上arch这几个都要一样!!!

详细请见/include/linux/vermagic.h,然后再到.config里面去改~

麻烦啊~必须要把内核和initrfd都换成目标系统的编译的模块才能这样吗?!——难道是必须的吗?!如果是必须的当我没说,以后就都这样做了~

论坛徽章:
3
金牛座
日期:2014-06-14 22:04:062015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:49:45
12 [报告]
发表于 2009-11-17 14:38 |只看该作者

回复 #11 lxyscls 的帖子

所以,为什么要交叉编译,就是这个原因。内核模块,不等于应用程序。

论坛徽章:
1
天蝎座
日期:2013-10-23 21:11:03
13 [报告]
发表于 2009-11-25 13:41 |只看该作者
总算找到了
Documentation/kbuild/modules.txt

  1. 442         === 7. Module versioning & Module.symvers
  2. 443        
  3. 444         Module versioning is enabled by the CONFIG_MODVERSIONS tag.
  4. 445        
  5. 446         Module versioning is used as a simple ABI consistency check. The Module
  6. 447         versioning creates a CRC value of the full prototype for an exported symbol and
  7. 448         when a module is loaded/used then the CRC values contained in the kernel are
  8. 449         compared with similar values in the module. If they are not equal, then the
  9. 450         kernel refuses to load the module.
  10. 451        
  11. 452         Module.symvers contains a list of all exported symbols from a kernel build.
  12. 453        
  13. 454         --- 7.1 Symbols from the kernel (vmlinux + modules)
  14. 455        
  15. 456                 During a kernel build, a file named Module.symvers will be generated.
  16. 457                 Module.symvers contains all exported symbols from the kernel and
  17. 458                 compiled modules. For each symbols, the corresponding CRC value
  18. 459                 is stored too.
  19. 460        
  20. 461                 The syntax of the Module.symvers file is:
  21. 462                         <CRC>       <Symbol>           <module>
  22. 463                 Sample:
  23. 464                         0x2d036834  scsi_remove_host   drivers/scsi/scsi_mod
  24. 465        
  25. 466                 For a kernel build without CONFIG_MODVERSIONS enabled, the crc
  26. 467                 would read: 0x00000000
  27. 468        
  28. 469                 Module.symvers serves two purposes:
  29. 470                 1) It lists all exported symbols both from vmlinux and all modules
  30. 471                 2) It lists the CRC if CONFIG_MODVERSIONS is enabled
  31. 472        
  32. 473         --- 7.2 Symbols and external modules
  33. 474        
  34. 475                 When building an external module, the build system needs access to
  35. 476                 the symbols from the kernel to check if all external symbols are
  36. 477                 defined. This is done in the MODPOST step and to obtain all
  37. 478                 symbols, modpost reads Module.symvers from the kernel.
  38. 479                 If a Module.symvers file is present in the directory where
  39. 480                 the external module is being built, this file will be read too.
  40. 481                 During the MODPOST step, a new Module.symvers file will be written
  41. 482                 containing all exported symbols that were not defined in the kernel.
  42. 483        
  43. 484         --- 7.3 Symbols from another external module
  44. 485        
  45. 486                 Sometimes, an external module uses exported symbols from another
  46. 487                 external module. Kbuild needs to have full knowledge on all symbols
  47. 488                 to avoid spitting out warnings about undefined symbols.
  48. 489                 Three solutions exist to let kbuild know all symbols of more than
  49. 490                 one external module.
  50. 491                 The method with a top-level kbuild file is recommended but may be
  51. 492                 impractical in certain situations.
  52. 493        
  53. 494                 Use a top-level Kbuild file
  54. 495                         If you have two modules: 'foo' and 'bar', and 'foo' needs
  55. 496                         symbols from 'bar', then one can use a common top-level kbuild
  56. 497                         file so both modules are compiled in same build.
  57. 498        
  58. 499                         Consider following directory layout:
  59. 500                         ./foo/ <= contains the foo module
  60. 501                         ./bar/ <= contains the bar module
  61. 502                         The top-level Kbuild file would then look like:
  62. 503        
  63. 504                         #./Kbuild: (this file may also be named Makefile)
  64. 505                                 obj-y := foo/ bar/
  65. 506        
  66. 507                         Executing:
  67. 508                                 make -C $KDIR M=`pwd`
  68. 509        
  69. 510                         will then do the expected and compile both modules with full
  70. 511                         knowledge on symbols from both modules.
  71. 512        
  72. 513                 Use an extra Module.symvers file
  73. 514                         When an external module is built, a Module.symvers file is
  74. 515                         generated containing all exported symbols which are not
  75. 516                         defined in the kernel.
  76. 517                         To get access to symbols from module 'bar', one can copy the
  77. 518                         Module.symvers file from the compilation of the 'bar' module
  78. 519                         to the directory where the 'foo' module is built.
  79. 520                         During the module build, kbuild will read the Module.symvers
  80. 521                         file in the directory of the external module and when the
  81. 522                         build is finished, a new Module.symvers file is created
  82. 523                         containing the sum of all symbols defined and not part of the
  83. 524                         kernel.
  84. 525        
  85. 526                 Use make variable KBUILD_EXTRA_SYMBOLS in the Makefile
  86. 527                         If it is impractical to copy Module.symvers from another
  87. 528                         module, you can assign a space separated list of files to
  88. 529                         KBUILD_EXTRA_SYMBOLS in your Makfile. These files will be
  89. 530                         loaded by modpost during the initialisation of its symbol
  90. 531                         tables.
  91. 532        
复制代码

论坛徽章:
3
金牛座
日期:2014-06-14 22:04:062015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:49:45
14 [报告]
发表于 2009-11-25 18:31 |只看该作者
原帖由 lxyscls 于 2009-11-16 14:50 发表
是这样的,ko是在开发环境ubuntu804上面make的,内核是2.6.24.16

目标环境内核版本是2.6.29.1,因此我在804建了对应的2.6.29.1的源码树,可惜还素不行!出现这个问题~

泪奔跪求!都是x86~


2.6.24和2.6.29两个版本的内核差异是相当的大啊。你在本机也最好是用2.6.29这个内核来编译,然后加载到目标板上去。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP