Monday, April 30, 2007

Calling one kernel module function in another

Say I have a LKM foo1.ko which has "my_foo1()" as the exported function. Now, another LKM foo2.ko calls this "my_foo1()". When this second LKM is compiled, it is generating a warning that "my_foo1() undefined!". Though this is just a warning, this can be avoided. How? I found it out via a forum. There are FOUR ways to remove the warning.

ONE: "insmod" foo1 before comiling foo2.

TWO: Compile both the LKMs in the same Makefile, in one shot; like below



$ cat Makefile
obj-m = foo1/foo1.o foo2/foo2.o

here:
make -C /lib/modules/`uname -r`/build M=`pwd` modules


THREE: Starting 2.6.17, you can copy the Module.symvers generated by the compilation of foo1 to the foo2 source directory and compile foo2.

FOUR: Be a proper programmer and ignore it. It works anyway ! Why Worry :-)

No comments: