Welcome! Log In Create A New Profile

Advanced

Pb when compiling an external module that uses symbols from another module

Posted by Pierro 
Pb when compiling an external module that uses symbols from another module
September 28, 2009 04:29AM
Hi,

I'm trying to compile 2 external kernel-modules and want to use, in my second module, some symbols exported by the first module. Unfortunately, it doesn't work, but I can't figure out why ?

Here is what I'm doing in details ( a little bit long, but thanks to read till the end, it's not much complicated winking smiley )and the error:

For module mod1.ko, , composed by one c-file mod1.c, I use such Makefile:
ifdef KERNELRELEASE
EXTRA_CFLAGS += -Wall -Werror -I$(PWD)/../common
obj-m	:= mod1.o
else
all:
	$(MAKE) ARCH=arm CROSS_COMPILE=arm-linux-  -C $(KERNEL_BUILD_DIR) M=$(PWD) V=1 modules
endif
This module exports two symbols:
EXPORT_SYMBOL(foo);
EXPORT_SYMBOL(bar);

=> this module compiles and works fine.

Now I want to build my second module in another directory, which use foo() and bar().
I'm using a Makefile, similar to the previous one, except that it is composed by several c-file Thus, I use:
obj-m	:= mod2.o
mod2-objs := file1.c file.c ...
All files compile fine, but modpost claims that:
...
  scripts/mod/modpost -m  -i /my_kernel_dir/Module.symvers -I /my_module_dir/src/driver/Module.symvers  -o /my_module_dir/src/driver/Module.symvers -S   -w -c -s
WARNING: "foo" [/my_module_dir/src/driver/mod2.ko] undefined!
WARNING: "bar" [/my_module_dir/src/driver/mod2.ko] undefined!
...

And of course, when I 'insmod mod2.ko', it does work and claim that:
$insmod mod2.ko
mod2: no symbol version for foo
mod2: Unknown symbol foo
mod2: no symbol version for bar
mod2: Unknown symbol bar

even if mod1 is inserted.

And if I 'grep foo /proc/kallsyms', I see my symbol:
$ grep foo /proc/kallsyms
bf0007e9 r __kstrtab_foo      [mod1]
bf00087c r __ksymtab_foo      [mod1]
bf0008e4 r __kcrctab_foo      [mod1]
bf00014c T foo        [mod1]
1e4dbb64 a __crc_foo  [mod1]


What am I missing ? How do I tell my driver, that these symbols have to be searched in module mod1 ?
(Note: I'm using kernel 2.6.27)

P.
Please try to look at the document:
KERNEL/Documentation/kbuild/modules.txt

My version 2.6.28.3, but I think there's no key differences.

See the examples in section 7.2-7.3.
Let me know wheter the examples work or not.

-The Effo Staff
Effo Project, [effo.sourceforge.net]
Re: Pb when compiling an external module that uses symbols from another module
September 28, 2009 10:38AM
Yes it works ! Thank you very much!

Note that in 2.6.27, the following bug is not yet fixed.
A patch is attached to this bug and is required to use KBUILD_EXTRA_SYMBOLS.

The other ways described in section 7.3 work fine.
Thanks again.

P.
Author:

Your Email:


Subject:


Spam prevention:
Please, solve the mathematical question and enter the answer in the input field below. This is for blocking bots that try to post this form automatically.
Question: how much is 4 plus 25?
Message: