export symbol problem in 2.6.27
Hi,
I am facing a poblem with export_symbol - can't access "my_name_hello" defined in hello.c from hello_user.c (in a different dir). The symbol "my_name_hello" is not present in the version table generated for hello_user.c.
The code is :-
(a) In parent/driver/hello.c
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_ALERT */
#define EXPORT_SYMTAB
MODULE_VERSION("4.0.301");
asmlinkage int my_name_hello = 2;
asmlinkage int first_int_hello(void);
int first_int_hello(void)
{
return 1;
}
int init_module(void)
{
printk("<1>Hello world 1.\n");
printk("hello: my_name at %p\n", &my_name_hello);
return 0;
}
void cleanup_module(void)
{
printk(KERN_ALERT "Goodbye world 1.\n");
}
EXPORT_SYMBOL(my_name_hello);
EXPORT_SYMBOL(first_int_hello);
(b) In parent/user/hello_user.c
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_ALERT */
MODULE_VERSION("4.0.301");
extern int my_name_hello;
int init_module(void)
{
printk("HELLO_USER --- Using exported sym, my_name = %p\n",
&my_name_hello);
return 0;
}
void cleanup_module(void)
{
printk(KERN_ALERT "Goodbye world 3.\n");
}
Tried following solutions :-
(a) /sbin/depmod -a in Makefile - didn't work
(b) don't want to copy Module.symvers in dir parent/driver into parent/user - as it will introduce dependency.
(c) --force-modversion with modprobe is also not working.
(d) export_objs not working. Or, please specify how to use it. May be I was using in a wrong way.
(e) don't know how to use KBUILD_EXTRA_SYMBOLS. Tried it but didn't work.
Any one please help. Searching it for many days.
|