我有一个kernel/trace中存在的模块,比如module.c,我在其中定义了一个符号,我需要将这个符号提供给所有内核模块。我在该模块中使用EXPORT_SYMBOL(mymodule)将其导出到所有modules.But,我没有在其他模块(如/lib、/net等)中指定extern type mymodule()。现在,我收到了数千个未定义的引用错误,无法手动将extern添加到所有模块中。是否有任何方法来添加一个extern type mymodule(),以便它被所有模块使用。我认为我们应该在一些Makefile中添加它,但是我应该如何和在哪里添加它呢?我正在使用linux 4.1内核。
错误消息:
lib/lib.a(klist.o): In function `klist_del':
lib/klist.c:230: undefined reference to `__cyg_profile_func_enter'
lib/klist.c:232: undefined reference to `__cyg_profile_func_exit'
lib/lib.a(klist.o): In function `klist_iter_exit':
lib/klist.c:313: undefined reference to `__cyg_profile_func_enter'
lib/klist.c:318: undefined reference to `__cyg_profile_func_exit'
lib/lib.a(klist.o): In function `klist_remove':
lib/klist.c:240: undefined reference to `__cyg_profile_func_enter'发布于 2017-01-21 16:57:26
我不认为extern类型需要明确地定义它。您只需要下面的实现(假设您已经对Makefile和Kconfig进行了更改):
模组.c
return_type module_function(function_args){
}
EXPORT_SYMBOL(module_function);模组.h
return_type module_function(function_args);在module.c中添加头文件,例如在module.h中添加module.h,并从要访问module_function的位置添加文件。
还有一件事您也可以尝试使用EXPORT_SYMBOL_GPL而不是EXPORT_SYMBOL。
https://stackoverflow.com/questions/41776778
复制相似问题