Linux 内核模块相关的理解?
Linux kernel module related understanding?
要加载模块,内核必须包含模块中使用的所有内核符号。如果这些符号在编译时未包含在内核中,则由于缺少依赖项,模块将不会被加载。
这是否意味着内核模块应该使用完整的内核编译来编译以在 vmlinux 中包含内核模块符号,如果我们单独编译模块那么我们将无法在 运行 时加载到内核中?
请指正我的理解即使我问错了问题也请指正。
如果我没记错的话,你指的是这篇文章:http://www.linuxjournal.com/content/kbuild-linux-kernel-build-system?page=0,0
Is this mean kernel module should be compiled with full kernel compilation to include kernel module symbols in vmlinux , If we compile module separately then we will not be able to load in kernel at run time ?
此声明指的是内核编译,而不是模块编译(而是加载)。
To load a module, the kernel must contain all the kernel symbols used in the module. If those symbols were not included in the kernel at compile time, the module will not be loaded due to missing dependencies.
这不完全正确。这是来自 The Linux Kernel Module Programming Guide
的示例
For example, msdos.ko requires the fat.ko module to be already loaded into the kernel. The requested module has a dependency on another module if the other module defines symbols (variables or functions) that the requested module uses.
因此,即使符号不是用内核编译的(但由不同的模块提供),您仍然可以加载模块
但是,想象一下您以某种方式在没有 printk
支持的情况下编译内核。现在,您尝试加载的每个模块都会尝试找到根本不存在的 printk
函数。因此,您需要在编译内核时做出合理的决定,以包含所有可能加载的模块确实可以加载的要素。
要加载模块,内核必须包含模块中使用的所有内核符号。如果这些符号在编译时未包含在内核中,则由于缺少依赖项,模块将不会被加载。
这是否意味着内核模块应该使用完整的内核编译来编译以在 vmlinux 中包含内核模块符号,如果我们单独编译模块那么我们将无法在 运行 时加载到内核中?
请指正我的理解即使我问错了问题也请指正。
如果我没记错的话,你指的是这篇文章:http://www.linuxjournal.com/content/kbuild-linux-kernel-build-system?page=0,0
Is this mean kernel module should be compiled with full kernel compilation to include kernel module symbols in vmlinux , If we compile module separately then we will not be able to load in kernel at run time ?
此声明指的是内核编译,而不是模块编译(而是加载)。
To load a module, the kernel must contain all the kernel symbols used in the module. If those symbols were not included in the kernel at compile time, the module will not be loaded due to missing dependencies.
这不完全正确。这是来自 The Linux Kernel Module Programming Guide
的示例For example, msdos.ko requires the fat.ko module to be already loaded into the kernel. The requested module has a dependency on another module if the other module defines symbols (variables or functions) that the requested module uses.
因此,即使符号不是用内核编译的(但由不同的模块提供),您仍然可以加载模块
但是,想象一下您以某种方式在没有 printk
支持的情况下编译内核。现在,您尝试加载的每个模块都会尝试找到根本不存在的 printk
函数。因此,您需要在编译内核时做出合理的决定,以包含所有可能加载的模块确实可以加载的要素。