0

I have two Linux kernel modules (*.ko files). They have circular dependencies like this:

mod1.ko uses functions exported by mod2.ko
mod2.ko uses functions exported by mod1.ko

I can't merge the modules into single module. How do i write the modules such that I can insert mod1 first and then mod2 without any error.

  • I have a similar situation like https://stackoverflow.com/questions/12311867/how-to-call-exported-kernel-module-functions-from-another-module, in the answer given user5078679, it was asked to raised a seperate question for "Also: Make sure that you load the module with foo first. If you have cross dependencies like module2 needs foo from module1 and module1 needs bar from module2 you need to have one register functions with another. If you want to know please ask a separate Q." – shahavinas Feb 21 '20 at 04:46
  • Found the solution. mod1.ko exports a register function, which will have the functions needed from mod2. Mod2 can call the register function exported by mod1 and register the function needed by mod1. – shahavinas Feb 21 '20 at 07:15
  • 1
    Does this answer your question? [how to export symbol from kernel module in this case?](https://stackoverflow.com/questions/27769368/how-to-export-symbol-from-kernel-module-in-this-case) – 0andriy Feb 21 '20 at 07:46

1 Answers1

0

mod1.ko exports a register function, The register function can take in arguments function pointers to the functions needed from mod2. Mod2 can call the register function exported by mod1 and register the function needed by mod1