Pb when compiling an external module that uses symbols from another module
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 and the error (a little bit long but simple ;) ):
For module mod1.ko, , composed by one c-file mod1.c, I use such Makefile:
Code:
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:
Code:
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: Code:
obj-m := mod2.o
mod2-objs := file1.c file.c ...
All files compile fine, but modpost claims that:
Quote:
...
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:
Quote:
$ 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.
But if I 'grep foo /proc/kallsyms', I see my symbol:
Quote:
$ 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.