Get in touch:
01524 851 877
07718 896 553

Compiling Linux Modules Dependant On Exported Symbols

Posted on May 12 2009 by Matthew Jakeman

I have been playing around with the NP++ Linux Kernel module today and it all seems to be working as planned at present. However I was in the process of writing a sample physical mapping module that uses the API from the NP++ module and ran into a bit of a problem.

Within the NP++ kernel module I have exported a few symbols (functions and variables) using the EXPORT_SYMBOL() macro. I expected to be able to use them quite simply in any other modules I created by simply including the NP++ header file. I had declared them as ‘extern’ in the header file and used the EXPORT_SYMBOL macro in the .c files as per all the documentation I had come across.

When I came to compile the mapping module that was trying to use these exported symbols however I came across a problem that the function I was trying to use was being shown as undefined during the link stage. This had me a bit stumped as I had convinced myself that the symbol should be visible.

It turns out that understandably as I had just compiled the module the kernel symbols table didn’t actually know about the symbols I had exported so compiling the new module still couldn’t see them. It turns out that the simple solution to this problem is to copy the Module.symvers file from the directory of the NP++ module to the directory of the mapping module.

The moral of this rambling is that you need to copy the Module.symvars file from the directory of a module once you have compiled it to the directory of any other out-of-tree module you are writing that relies on exported symbols from the first.

Leave a comment