Is it possible for a function in a linux kernel module calling a function in another module ?
-
1stackoverflow.com/questions/9820458/kernel-modules-develop/…Jeyaram– Jeyaram2016-02-19 12:11:50 +00:00Commented Feb 19, 2016 at 12:11
-
Possible duplicate of How to call exported kernel module functions from another module?Ciro Santilli OurBigBook.com– Ciro Santilli OurBigBook.com2017-05-20 12:29:54 +00:00Commented May 20, 2017 at 12:29
-
I wonder why no one else mentioned this. EXPORT_SYMBOL and extern <prototype> is not enough. In the Kbuild file of the module that is importing symbol, add a line KBUILD_EXTRA_SYMBOLS = <path-to-exporting-module>/Module.symvers . This helps the importing module know what symbols will be imported.Sadman Sakib– Sadman Sakib2023-06-29 19:51:36 +00:00Commented Jun 29, 2023 at 19:51
Add a comment
|
2 Answers
Yes. Of course, the other kernel module must be loaded.
For an example, look at the USB code, which is implemented as a mullti-layer driver, with each layer in its own module.Reference link here.
Comments
It is possible by using EXPORT_SYMBOL in Linux.
If one module has one function called etx_shared_func and one global variable called etx_count. This function and variable can be shared among with all the loadable modules using EXPORT_SYMBOL.
EXPORT_SYMBOL(etx_shared_func);
EXPORT_SYMBOL(etx_count);