3

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!

3
  • Just for clariication; you have multiple kernel modules and you are attempting to reference symbols across these modules? Commented Apr 18, 2014 at 15:34
  • Yes. These symbols (functions) are from a module in the src kernel directory. This kernel module is already running - but i don't know if this symbols were loaded to the kernel (not present in /proc/kallsyms). I need them to build my module. Commented Apr 18, 2014 at 17:10
  • Actually, the source code from the module i build is outdated. I have two /src directories, one of them holding the old kernel source. And my source path seems to point there. Commented Apr 18, 2014 at 22:10

2 Answers 2

2

(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.

Sign up to request clarification or add additional context in comments.

2 Comments

Hm, it seems that the they are actually defined as EXPORT_SYMBOLs. The symbols just aren't active? That is logically since all other symbols from the referenced module were found correctly when my module was build. Now, i'm confused. (If it helps, the symbols are "ttm_buffer_object_init" and "ttm_buffer_object_validate" defined in ttm_bo_api.h (include/drm/ttm) and used in /drivers/gpu/drm/ttm/ttm_bo.c (ttm module source))
ttm_buffer_object_init was replaced by ttm_bo_init. ttm_buffer_object_validate was replaced by ttm_bo_validate.
1

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/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.