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.txt98
1 files changed, 91 insertions, 7 deletions
diff --git a/Documentation/kbuild/modules.txt b/Documentation/kbuild/modules.txt
index 7e77f93634ea..fcccf2432f98 100644
--- a/Documentation/kbuild/modules.txt
+++ b/Documentation/kbuild/modules.txt
@@ -13,6 +13,7 @@ In this document you will find information about:
13 --- 2.2 Available targets 13 --- 2.2 Available targets
14 --- 2.3 Available options 14 --- 2.3 Available options
15 --- 2.4 Preparing the kernel tree for module build 15 --- 2.4 Preparing the kernel tree for module build
16 --- 2.5 Building separate files for a module
16 === 3. Example commands 17 === 3. Example commands
17 === 4. Creating a kbuild file for an external module 18 === 4. Creating a kbuild file for an external module
18 === 5. Include files 19 === 5. Include files
@@ -22,7 +23,10 @@ In this document you will find information about:
22 === 6. Module installation 23 === 6. Module installation
23 --- 6.1 INSTALL_MOD_PATH 24 --- 6.1 INSTALL_MOD_PATH
24 --- 6.2 INSTALL_MOD_DIR 25 --- 6.2 INSTALL_MOD_DIR
25 === 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
26 === 8. Tips & Tricks 30 === 8. Tips & Tricks
27 --- 8.1 Testing for CONFIG_FOO_BAR 31 --- 8.1 Testing for CONFIG_FOO_BAR
28 32
@@ -88,7 +92,8 @@ when building an external module.
88 make -C $KDIR M=$PWD modules_install 92 make -C $KDIR M=$PWD modules_install
89 Install the external module(s). 93 Install the external module(s).
90 Installation default is in /lib/modules/<kernel-version>/extra, 94 Installation default is in /lib/modules/<kernel-version>/extra,
91 but may be prefixed with INSTALL_MOD_PATH - see separate chapter. 95 but may be prefixed with INSTALL_MOD_PATH - see separate
96 chapter.
92 97
93 make -C $KDIR M=$PWD clean 98 make -C $KDIR M=$PWD clean
94 Remove all generated files for the module - the kernel 99 Remove all generated files for the module - the kernel
@@ -131,6 +136,16 @@ when building an external module.
131 Therefore a full kernel build needs to be executed to make 136 Therefore a full kernel build needs to be executed to make
132 module versioning work. 137 module versioning work.
133 138
139--- 2.5 Building separate files for a module
140 It is possible to build single files which is part of a module.
141 This works equal for the kernel, a module and even for external
142 modules.
143 Examples (module foo.ko, consist of bar.o, baz.o):
144 make -C $KDIR M=`pwd` bar.lst
145 make -C $KDIR M=`pwd` bar.o
146 make -C $KDIR M=`pwd` foo.ko
147 make -C $KDIR M=`pwd` /
148
134 149
135=== 3. Example commands 150=== 3. Example commands
136 151
@@ -422,7 +437,7 @@ External modules are installed in the directory:
422 => Install dir: /lib/modules/$(KERNELRELEASE)/gandalf 437 => Install dir: /lib/modules/$(KERNELRELEASE)/gandalf
423 438
424 439
425=== 7. Module versioning 440=== 7. Module versioning & Module.symvers
426 441
427Module versioning is enabled by the CONFIG_MODVERSIONS tag. 442Module versioning is enabled by the CONFIG_MODVERSIONS tag.
428 443
@@ -432,11 +447,80 @@ when a module is loaded/used then the CRC values contained in the kernel are
432compared 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
433kernel refuses to load the module. 448kernel refuses to load the module.
434 449
435During 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.
436file includes the symbol version of all symbols within the kernel. If the 451
437Module.symvers file is saved from the last full kernel compile one does not 452--- 7.1 Symbols fron the kernel (vmlinux + modules)
438have to do a full kernel compile to build a module version's compatible module. 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
439 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
440=== 8. Tips & Tricks 524=== 8. Tips & Tricks
441 525
442--- 8.1 Testing for CONFIG_FOO_BAR 526--- 8.1 Testing for CONFIG_FOO_BAR