如果我有两个静态链接的模块。一个模块的 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/