'building kernel module and resolve missing symbol definitions

If I build a module which depends on other modules, and i get this warning:

'function or symbol ?' [source dir/my_module.ko] undefined!

What does the warning mean? The warning doesn't tell me if it is a function defined in a header or in some module source. I suppose this means some module symbol definition is missing . So do I have to rebuild all modules on which my module is depending?

Or may I somehow insert explicit symbols in my module source or in the makefile - for instance if I include the *.c source file where the missing symbols are defined in my module source? So to say - build my module without the need to build extra object files not in my source directory, on which my module depends.

Thanks in advance!



Solution 1:[1]

(If the symbols are not in /proc/kallsyms, it is likely that that the kernel source did not explicitly EXPORT_SYMBOL() those symbols. Hence, in order to use those symbols, you have several options:

1) Add EXPORT_SYMBOL() to each symbol in the source that your kmod needs
   to link with, and then re-compile the kernel.

This option has several drawbacks. In my mind, the greatest drawback is that many distro's don't offer support for a recompiled kernel (re: SUSE SLES, etc.). Perhaps this solution would work for a one-off kmod. However, if you plan to distribute it to others, you will have to get a feel for how they take to the idea of recompiling their kernel.

2) Copy the entire function(s) from the kernel source into your code.

Of course, if the copied functions contain references to other kernel functions, which also lack EXPORT_SYMBOL() (and are not listed in /proc/kallsysm), this option isn't always helpful.

3) Find another Linux release, or distro, which exports the needed symbols.

I work a lot with SLES. I find that from one release to the next, kernel symbols come and go. There are also differences between SUSE, Redhat, etc., distros; where one may export the needed symbols.

Solution 2:[2]

Let's find where the function is defined. You should add EXPORT_SYMBOL() for missing function and compile the kernel (for built-in function) or a dependent module where the function is defined.

http://onebitbug.me/2011/03/04/introducing-linux-kernel-symbols/

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mahonri Moriancumer
Solution 2