Question

I have 2 modules mod_1.ko & mod_2.ko with fun_1() & fun_2() defined in them respectively. I exported the functions and want to use fun_1 & fun_2 in mod_2.ko & mod_1.ko. How do I proceed..?

Was it helpful?

Solution

If you're using it explicitly (you have call of fun_1 from mod_2.ko and fun_2 from mod_1.ko ) then kernel won't let you load your modules. This is happened because it reads symbol table and look for kernel existing modules - the one you can see in /proc/kallsyms. So mod_1 has fun_2 reference and need mod_2 to be loaded. And mod_2 has fun_1 reference and need mod_1 to be loaded. There you have dependency lock)

I can think of 2 solutions for your problem:

  • Take out fun_1 and fun_2 into separate module that you'll load first.
  • Don't make explicit call to function. Do this implicitly with help of find_symbol. You declare function pointers, then you resolve that pointer in runtime with call to find_symbol and then you call your functions via function pointers.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top