想知道下linux下有没像windows下debug那些功能的东西....
时间:2011-04-29
来源:互联网
在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
我做了两个模块: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
附件:
附件:
作者: yaxinsn 发布时间: 2011-04-29
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28