module - Linux : order of statically linked module loading

标签 module linux-kernel

如果我有两个静态链接的模块。一个模块的 module_init 函数依赖于另一个模块的 module_init 函数已经运行。有没有办法强制一个模块先于另一个模块加载?

此外,第一个模块的 init 函数是否保证在调用第二个模块之前完成?

最后,如果上述答案是否定的,同步两个模块初始化调用以确保我不会遇到问题的推荐方法是什么?

最佳答案

Is there a way to force one module to load before the other?

答案非常简单,确保第一个模块在 Makefile 中位于第一个:

obj-y += mod1.o
obj-y += mod2.o

is the first module's init function guaranteed to finish before the second one is invoked?

是的,在您的情况下,initcalls(module_init hook)是被一一调用的。请参阅init/main.c, do_one_initcall() 调用者。

关于module - Linux : order of statically linked module loading,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5669647/

相关文章:

python - Python 模块和 Python 包有什么区别?

html - Joomla 模块 CSS 覆盖

c - 如何在 Linux 内核空间使用 ioctl()?

c - 在单核机器上,如果编译后的代码直接在处理器上执行,内核如何对进程施加限制(内存等)?

php - 德鲁帕尔 : module update

python - Meson 找不到 pykeepass 模块,我确定它已安装

javascript - 无法通过原型(prototype)函数传递它

android - android内核和vanilla linux内核之间的补丁差异

linux - Ubuntu 中的动态进程调度

multithreading - 识别linux内核模块中的错误