Linux内核模块相关的理解?

标签 linux linux-kernel

要加载模块,内核必须包含模块中使用的所有内核符号。如果这些符号在编译时未包含在内核中,则由于缺少依赖项,模块将不会被加载。

这是否意味着内核模块应该使用完整的内核编译来编译以在 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 函数。因此,您需要在编译内核时做出合理的决定,以包含所有可能加载的模块确实可以加载的要素。

关于Linux内核模块相关的理解?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32716288/

相关文章:

python - 如何自动将 excel 文件的类型从 Tab 空格分隔的文本更改为 xls 文件?

linux - 不使用 ssh 在远程计算机上执行 postgresql 查询

c - PF_BRIDGE(NF_BR_PRE_ROUTING) Hook 未被调用

c - 绕过 softlockup_threshold

linux - Sonarqube在Centos7上加载css和js相关内容失败

linux - 使用 pcap 与原始套接字捕获性能

linux - 如何正确观看 psql 命令?

linux - UUID真的是唯一的吗?为什么我们可以将多个 UUID 分配给单个磁盘片

android - Android 中 eng 和 user-debug 构建的区别

c - printk 用法简单错误