Welcome to Linux Forums! With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.
Find the answer to your Linux question:
New to Linux Forums? Register here for free!
    Linux Forums > GNU Linux Zone > The Linux Kernel > Pb when compiling an external module that uses symbols from another module

Forgot Password?
 The Linux Kernel   Compiling, theory, programming or other discussion about the linux kernel

Site Navigation
Linux Articles
Linux Forums
Linux Downloads
Linux Hosting
Free Magazines
Job Board
IRC Chat
RSS Feeds


Linux Forum Topics
Linux Forums
Your Distro
Linux Resources
GNU Linux Zone
The Community
Reply
 
Thread Tools Display Modes
Old 09-28-2009   #1 (permalink)
Just Joined!
 
Join Date: Sep 2009
Posts: 2
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.
Pierro is offline  


Reply With Quote
Old 09-28-2009   #2 (permalink)
Just Joined!
 
Join Date: Sep 2009
Posts: 2
And the answer is in the Documention directory of the kernel source tree (I missed this one), in file .../Documentation/kbuild/modules.txt , section 7.2-7.3.

P.
Pierro is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Free Magazines
Run Your Own Web Server Using Linux & Apache - Free 191 Page Preview
Learn about everything you'll need to build and maintain your Linux servers, and to deploy Web applications to them.
subscribe
Open Source Security Myths Dispelled
Dispel the five major myths surrounding Open Source Security and gain the tools necessary to make a truly informed decision for your IT organization
subscribe
InformationWeek
InformationWeek is the only newsweekly you'll need to stay on top of the latest developments in information technology.
subscribe



All times are GMT. The time now is 09:35 AM.






© 2000 - 2009 - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.3.0 RC2