aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/kbuild/modules.txt
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation/kbuild/modules.txt')
-rw-r--r--Documentation/kbuild/modules.txt87
1 files changed, 80 insertions, 7 deletions
diff --git a/Documentation/kbuild/modules.txt b/Documentation/kbuild/modules.txt
index 87d858df4e34..fcccf2432f98 100644
--- a/Documentation/kbuild/modules.txt
+++ b/Documentation/kbuild/modules.txt
@@ -23,7 +23,10 @@ In this document you will find information about:
23 === 6. Module installation 23 === 6. Module installation
24 --- 6.1 INSTALL_MOD_PATH 24 --- 6.1 INSTALL_MOD_PATH
25 --- 6.2 INSTALL_MOD_DIR 25 --- 6.2 INSTALL_MOD_DIR
26 === 7. Module versioning 26 === 7. Module versioning & Module.symvers
27 --- 7.1 Symbols fron the kernel (vmlinux + modules)
28 --- 7.2 Symbols and external modules
29 --- 7.3 Symbols from another external module
27 === 8. Tips & Tricks 30 === 8. Tips & Tricks
28 --- 8.1 Testing for CONFIG_FOO_BAR 31 --- 8.1 Testing for CONFIG_FOO_BAR
29 32
@@ -89,7 +92,8 @@ when building an external module.
89 make -C $KDIR M=$PWD modules_install 92 make -C $KDIR M=$PWD modules_install
90 Install the external module(s). 93 Install the external module(s).
91 Installation default is in /lib/modules/<kernel-version>/extra, 94 Installation default is in /lib/modules/<kernel-version>/extra,
92 but may be prefixed with INSTALL_MOD_PATH - see separate chapter. 95 but may be prefixed with INSTALL_MOD_PATH - see separate
96 chapter.
93 97
94 make -C $KDIR M=$PWD clean 98 make -C $KDIR M=$PWD clean
95 Remove all generated files for the module - the kernel 99 Remove all generated files for the module - the kernel
@@ -433,7 +437,7 @@ External modules are installed in the directory:
433 => Install dir: /lib/modules/$(KERNELRELEASE)/gandalf 437 => Install dir: /lib/modules/$(KERNELRELEASE)/gandalf
434 438
435 439
436=== 7. Module versioning 440=== 7. Module versioning & Module.symvers
437 441
438Module versioning is enabled by the CONFIG_MODVERSIONS tag. 442Module versioning is enabled by the CONFIG_MODVERSIONS tag.
439 443
@@ -443,11 +447,80 @@ when a module is loaded/used then the CRC values contained in the kernel are
443compared with similar values in the module. If they are not equal then the 447compared with similar values in the module. If they are not equal then the
444kernel refuses to load the module. 448kernel refuses to load the module.
445 449
446During a kernel build a file named Module.symvers will be generated. This 450Module.symvers contains a list of all exported symbols from a kernel build.
447file includes the symbol version of all symbols within the kernel. If the
448Module.symvers file is saved from the last full kernel compile one does not
449have to do a full kernel compile to build a module version's compatible module.
450 451
452--- 7.1 Symbols fron the kernel (vmlinux + modules)
453
454 During a kernel build a file named Module.symvers will be generated.
455 Module.symvers contains all exported symbols from the kernel and
456 compiled modules. For each symbols the corresponding CRC value
457 is stored too.
458
459 The syntax of the Module.symvers file is:
460 <CRC> <Symbol> <module>
461 Sample:
462 0x2d036834 scsi_remove_host drivers/scsi/scsi_mod
463
464 For a kernel build without CONFIG_MODVERSIONING enabled the crc
465 would read: 0x00000000
466
467 Module.symvers serve two purposes.
468 1) It list all exported symbols both from vmlinux and all modules
469 2) It list CRC if CONFIG_MODVERSION is enabled
470
471--- 7.2 Symbols and external modules
472
473 When building an external module the build system needs access to
474 the symbols from the kernel to check if all external symbols are
475 defined. This is done in the MODPOST step and to obtain all
476 symbols modpost reads Module.symvers from the kernel.
477 If a Module.symvers file is present in the directory where
478 the external module is being build this file will be read too.
479 During the MODPOST step a new Module.symvers file will be written
480 containing all exported symbols that was not defined in the kernel.
481
482--- 7.3 Symbols from another external module
483
484 Sometimes one external module uses exported symbols from another
485 external module. Kbuild needs to have full knowledge on all symbols
486 to avoid spitting out warnings about undefined symbols.
487 Two solutions exist to let kbuild know all symbols of more than
488 one external module.
489 The method with a top-level kbuild file is recommended but may be
490 impractical in certain situations.
491
492 Use a top-level Kbuild file
493 If you have two modules: 'foo', 'bar' and 'foo' needs symbols
494 from 'bar' then one can use a common top-level kbuild file so
495 both modules are compiled in same build.
496
497 Consider following directory layout:
498 ./foo/ <= contains the foo module
499 ./bar/ <= contains the bar module
500 The top-level Kbuild file would then look like:
501
502 #./Kbuild: (this file may also be named Makefile)
503 obj-y := foo/ bar/
504
505 Executing:
506 make -C $KDIR M=`pwd`
507
508 will then do the expected and compile both modules with full
509 knowledge on symbols from both modules.
510
511 Use an extra Module.symvers file
512 When an external module is build a Module.symvers file is
513 generated containing all exported symbols which are not
514 defined in the kernel.
515 To get access to symbols from module 'bar' one can copy the
516 Module.symvers file from the compilation of the 'bar' module
517 to the directory where the 'foo' module is build.
518 During the module build kbuild will read the Module.symvers
519 file in the directory of the external module and when the
520 build is finished a new Module.symvers file is created
521 containing the sum of all symbols defined and not part of the
522 kernel.
523
451=== 8. Tips & Tricks 524=== 8. Tips & Tricks
452 525
453--- 8.1 Testing for CONFIG_FOO_BAR 526--- 8.1 Testing for CONFIG_FOO_BAR