The Linux kernel boot module mainly contains a run-time linker. A .ko file is really an object file, like any other, and as such it comes with a character table. If you run nm on it ( nm <path/to/some_module.ko> ), you will see many characters with the inscription "U", that is, "undefined". This includes symbols for the core kernel functions used by the module, such as __kmalloc , kfree , kfree , etc., but in many cases also symbols implemented by other modules.
When the module is loaded, the kernel goes through the undefined module symbols and looks at them in the run-time symbol table, fixing the corresponding memory cells, like any other linker. If any undefined characters are not already in the character table, the download will fail (just for demonstration using insmod instead of modprobe , since it will not load dependencies). It also adds any characters exported by the module to the symbol table for use by other modules, tracking dependencies so that you cannot pull out the module used by others. Ilya Matveychikov contacted the corresponding code in the module loader in the comments, which will help if you want to know all the details of gory.
source share