LINUX:静态链接模块的加载顺序 [英] LINUX: order of statically linked module loading

查看:129
本文介绍了LINUX:静态链接模块的加载顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有两个静态链接的模块.一个模块的module_init函数取决于另一个模块已运行的module_init函数.有没有一种方法可以强制一个模块先加载另一个模块?

If I have two modules which are being statically linked in. One modules' module_init function depends on another module's module_init function having already run. Is there a way to force one module to load before the other?

还可以保证第一个模块的init函数在第二个模块被调用之前完成吗?

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

最后,如果以上回答为否",那么建议同步两个模块init调用以确保我不会遇到问题的推荐方法是什么?

Lastly, if the answer to the above is NO, what is the recommended way of synchronizing the two module init calls to make sure I don't run into issues?

推荐答案

是否有一种方法可以强制一个模块先加载另一个模块?

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

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

Answer is surprisingly simple, make sure first module is first in Makefile:

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

第一个模块的init函数是否可以保证在第二个模块被调用之前完成?

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

是的,您的情况下的initcalls(module_init钩子)被称为一对一.参见init/main.c do_one_initcall()呼叫者.

Yes, initcalls (module_init hook) in your case are called one-by-one. See init/main.c, do_one_initcall() callers.

这篇关于LINUX:静态链接模块的加载顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆