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..?
            Asked
            
        
        
            Active
            
        
            Viewed 210 times
        
    1
            
            
        - 
                    Go through this link http://stackoverflow.com/questions/17193532/export-symbol-in-kernel-module-undefined-symbol-during-insmod/17680241#17680241 – Gautham Kantharaju Apr 16 '14 at 08:27
 
1 Answers
2
            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 tofind_symboland then you call your functions via function pointers. 
        Alexander Dzyoba
        
- 4,009
 - 1
 - 24
 - 29
 
- 
                    I figured it out in another way... I made use of function pointers in one module and registered function in another module with first module's function pointer. Followed the approach of VFS.. – kami Apr 18 '14 at 09:21