想知道下linux下有没像windows下debug那些功能的东西....

在unbuntu 2.6.28-11的系统下。
我做了两个模块:mod1.mod2.
mod1一个func1作为全局函数:EXPORT_SYMBOL(func1);
mod2使用了mod1一个函数func1.
先insmod mod1.ko是没有问题。在cat /proc/kallsyms | grep "mod1" 或是 lsmod | grep "mod1" 都有mod1的信息。
但是在此基础上insmod mod2.ko时。
会提示:-1 Unknown symbol in module。
在tail /var/log/message 命令后,在日志中会有:no symbol version for func1 的提示。

但在red hat 下的以上操作,没有问题。是可以成功的。
请高人指点。

以下是主要代码:
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
附件:

截图1304041540.jpg [ 77.53 KiB | 被浏览 12 次 ]

附件:

截图1304041482.jpg [ 17.6 KiB | 被浏览 12 次 ]

作者: yaxinsn   发布时间: 2011-04-29