模块在编译的时候涉及到一个内核MAGIC_STRING的检查工作~(insmod会用检查模块的modinfo看看跟内核的是否一致)~
不光内核版本要一致,并且SMP, PREEMPT, MODULE_UNLOAD和MODVERSIONS再加上arch这几个都要一样!!!
详细请见/include/linux/vermagic.h,然后再到.config里面去改~
麻烦啊~必须要把内核和initrfd都换成目标系统的编译的模块才能这样吗?!——难道是必须的吗?!如果是必须的当我没说,以后就都这样做了~
回复 #11 lxyscls 的帖子
所以,为什么要交叉编译,就是这个原因。内核模块,不等于应用程序。 总算找到了Documentation/kbuild/modules.txt
442 === 7. Module versioning & Module.symvers
443
444 Module versioning is enabled by the CONFIG_MODVERSIONS tag.
445
446 Module versioning is used as a simple ABI consistency check. The Module
447 versioning creates a CRC value of the full prototype for an exported symbol and
448 when a module is loaded/used then the CRC values contained in the kernel are
449 compared with similar values in the module. If they are not equal, then the
450 kernel refuses to load the module.
451
452 Module.symvers contains a list of all exported symbols from a kernel build.
453
454 --- 7.1 Symbols from the kernel (vmlinux + modules)
455
456 During a kernel build, a file named Module.symvers will be generated.
457 Module.symvers contains all exported symbols from the kernel and
458 compiled modules. For each symbols, the corresponding CRC value
459 is stored too.
460
461 The syntax of the Module.symvers file is:
462 <CRC> <Symbol> <module>
463 Sample:
464 0x2d036834scsi_remove_host drivers/scsi/scsi_mod
465
466 For a kernel build without CONFIG_MODVERSIONS enabled, the crc
467 would read: 0x00000000
468
469 Module.symvers serves two purposes:
470 1) It lists all exported symbols both from vmlinux and all modules
471 2) It lists the CRC if CONFIG_MODVERSIONS is enabled
472
473 --- 7.2 Symbols and external modules
474
475 When building an external module, the build system needs access to
476 the symbols from the kernel to check if all external symbols are
477 defined. This is done in the MODPOST step and to obtain all
478 symbols, modpost reads Module.symvers from the kernel.
479 If a Module.symvers file is present in the directory where
480 the external module is being built, this file will be read too.
481 During the MODPOST step, a new Module.symvers file will be written
482 containing all exported symbols that were not defined in the kernel.
483
484 --- 7.3 Symbols from another external module
485
486 Sometimes, an external module uses exported symbols from another
487 external module. Kbuild needs to have full knowledge on all symbols
488 to avoid spitting out warnings about undefined symbols.
489 Three solutions exist to let kbuild know all symbols of more than
490 one external module.
491 The method with a top-level kbuild file is recommended but may be
492 impractical in certain situations.
493
494 Use a top-level Kbuild file
495 If you have two modules: 'foo' and 'bar', and 'foo' needs
496 symbols from 'bar', then one can use a common top-level kbuild
497 file so both modules are compiled in same build.
498
499 Consider following directory layout:
500 ./foo/ <= contains the foo module
501 ./bar/ <= contains the bar module
502 The top-level Kbuild file would then look like:
503
504 #./Kbuild: (this file may also be named Makefile)
505 obj-y := foo/ bar/
506
507 Executing:
508 make -C $KDIR M=`pwd`
509
510 will then do the expected and compile both modules with full
511 knowledge on symbols from both modules.
512
513 Use an extra Module.symvers file
514 When an external module is built, a Module.symvers file is
515 generated containing all exported symbols which are not
516 defined in the kernel.
517 To get access to symbols from module 'bar', one can copy the
518 Module.symvers file from the compilation of the 'bar' module
519 to the directory where the 'foo' module is built.
520 During the module build, kbuild will read the Module.symvers
521 file in the directory of the external module and when the
522 build is finished, a new Module.symvers file is created
523 containing the sum of all symbols defined and not part of the
524 kernel.
525
526 Use make variable KBUILD_EXTRA_SYMBOLS in the Makefile
527 If it is impractical to copy Module.symvers from another
528 module, you can assign a space separated list of files to
529 KBUILD_EXTRA_SYMBOLS in your Makfile. These files will be
530 loaded by modpost during the initialisation of its symbol
531 tables.
532
原帖由 lxyscls 于 2009-11-16 14:50 发表 http://linux.chinaunix.net/bbs/images/common/back.gif
是这样的,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这个内核来编译,然后加载到目标板上去。
页:
1
[2]