2

Is it possible for a function in a linux kernel module calling a function in another module ?

BusyTraveller
  • 183
  • 3
  • 14
  • 1
    http://stackoverflow.com/questions/9820458/kernel-modules-develop/9820518#9820518 – Jeyaram Feb 19 '16 at 12:11
  • Possible duplicate of [How to call exported kernel module functions from another module?](http://stackoverflow.com/questions/12311867/how-to-call-exported-kernel-module-functions-from-another-module) – Ciro Santilli OurBigBook.com May 20 '17 at 12:29
  • I wonder why no one else mentioned this. EXPORT_SYMBOL and extern is not enough. In the Kbuild file of the module that is importing symbol, add a line KBUILD_EXTRA_SYMBOLS = /Module.symvers . This helps the importing module know what symbols will be imported. – Sadman Sakib Jun 29 '23 at 19:51

2 Answers2

2

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.

msc
  • 33,420
  • 29
  • 119
  • 214
1

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);
avariant
  • 2,234
  • 5
  • 25
  • 33
Anshu Gaur
  • 11
  • 1