- 论坛徽章:
- 0
|
各位大侠好:
我在书上看到可以使用request_module(module_name)函数加载内核模块,所以我写了2个模块,分别是hello2.ko与hello3.ko。
在hello3.ko中使用到了hello2.ko的导出符号data2,并且在hello2.ko中的初始化函数中用到request_module函数去首先加载hello2.ko模块。
但是当我用insmod ./hello3.ko加载hello3.ko模块时,却出现:
“insmod: error inserting './hello3.ko': -1 Unknown symbol in module”的错误,似乎request_module函数未能成功加载hello2.ko模块,导致找不到data2变量。
问题:
我不明白为什么“request_module函数未能成功加载hello2.ko模块”?是不是我对requeset_module的使用有问题,那正确的使用方式是什么呢?
简略的代码如下:
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//hello2.c
int data2=10;
EXPORT_SYMBOL(data2);
module_init(hello2_init);
module_exit(hello2_exit);
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//hello3.c
extern int data2;
static int __init hello3_init(void)
{
request_module("hello2.ko");
printk(KERN_ALERT"Hello,World %d\n",data2);
return 0;
}
........
module_init(hello3_init);
期待各位大侠的答案!
谢谢! |
|