__versions部分包含在所有单独的* .mod.c文件中
CRC Symbol
{ 0xa6d8dcb5, "module_layout" },
{ 0x16c2b958, "register_netdevice" },
... ...
是一个符号列表及其相应的CRC.这有两个主要用途:
>所有导出符号的全局列表.
>加载ko模块时的模块版本检查.
模块版本控制背后的基本原理
Module versioning is enabled by the CONFIG_MODVERSIONS tag, and is
used as a simple ABI consistency check. A CRC value of the full
prototype for an exported symbol is created. When a module is
loaded/used, the CRC values contained in the kernel are compared with
similar values in the module; if they are not equal, the kernel
refuses to load the module as it indicates that the module is built with
reference to a different version of the Linux kernel source.
编译成功后,所有导出符号的所有CRC的全局列表都存储在Linux内核源目录的Module.symvers文件中.本质上,此检查确保从内核模块调用的任何导出符号都存在于模块所期望的相同位置(内核中的偏移量).
entire source code of the modpost tool在Linux内核源代码中可用. add_depends()是负责在每个* .mod.c文件中生成整个__versions部分的相关函数.