Moudles Code:
#############################################################
mod1.c
#include<linux/init.h>
#include<linux/module.h>
#include<linux/kernel.h>

static int func1(void)
{
       printk("In Func: %s...\n",__func__);
       return 0;
}

EXPORT_SYMBOL(func1);

static int __init hello_init(void)
{
       printk("Module 1,Init!\n");
       return 0;
}

static void __exit hello_exit(void)
{
       printk("Module 1,Exit!\n");
}

module_init(hello_init);
module_exit(hello_exit);

#############################################################
mod2.c
#include<linux/init.h>
#include<linux/kernel.h>
#include<linux/module.h>

static int func2(void)
{
       extern int func1(void);
       func1();
       printk("In Func: %s...\n",__func__);
       return 0;
}

static int __init hello_init(void)
{
       printk("Module 2,Init!\n");
       func2();
       return 0;
}

static void __exit hello_exit(void)
{
       printk("Module 2,Exit!\n");
}

module_init(hello_init);
module_exit(hello_exit);

################################################################
Makefile
ifneq ($(KERNELRELEASE),)
obj-m   := XXXX.o
else
KDIR    := /lib/modules/$(shell uname -r)/build
PWD             := $(shell pwd)

default:
       $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules

clean:
       rm -rf Module.symvers *.ko *.o *.mod.c .*.cmd .tmp_versions

endif

#############################################################

2008/8/2 fisherman <[EMAIL PROTECTED]>:
> module A and module B, module A export symbol func a, module B using func a.
> Both  modules using GPL.
>
> #insmod ./mod1.ko
> #insmod ./mod2.ko
>
> #tail /var/log/kern.log
> Aug  1 23:47:27 dell-desktop kernel: [ 7029.008527] mod2: no symbol
> version for func1
> Aug  1 23:47:27 dell-desktop kernel: [ 7029.008534] mod2: Unknown symbol func1
>
> But  in /proc/kallsyms, we can find the func a's symbol.
>
> I test modules in 2.6.22 and 2.6.24, both can be right insmoded without 
> errors.
>
> BTW: The 2.6.26 kernel is compiled by myself.
> CONFIG_MODULES=y
> # CONFIG_MODULE_FORCE_LOAD is not set
> CONFIG_MODULE_UNLOAD=y
> # CONFIG_MODULE_FORCE_UNLOAD is not set
> CONFIG_MODVERSIONS=y
> CONFIG_MODULE_SRCVERSION_ALL=y
> CONFIG_KMOD=y
>
> --
> Best Regards :-)
> -------------------------------------------
> Wang Yao(王耀),[EMAIL PROTECTED] [EMAIL PROTECTED] wangyao01@baidu.com
> [EMAIL PROTECTED]
> HomePage: http://cudev.cublog.cn
> IBM Club Harbin Institute Of Technology
> Address:NO.92 West Da-Zhi Street,NanGang District,Harbin,Heilongjiang
>



-- 
Best Regards :-)
-------------------------------------------
Wang Yao(王耀),[EMAIL PROTECTED] [EMAIL PROTECTED] wangyao01@baidu.com
[EMAIL PROTECTED]
HomePage: http://cudev.cublog.cn
IBM Club Harbin Institute Of Technology
Address:NO.92 West Da-Zhi Street,NanGang District,Harbin,Heilongjiang
N�Р骒r��y����b�X�肚�u┺�ē�+a�{.n�+�筏z罐�w�n'����j�b�ye�{雹��娆z��v�^�m���z罐�w�n'�⒏?

Reply via email to