系统相关
首页 > 系统相关> > Linux内核代码中的EXPORT_SYMBOL_GPL是什么?

Linux内核代码中的EXPORT_SYMBOL_GPL是什么?

作者:互联网

Linux内核代码中的EXPORT_SYMBOL_GPL是什么?

下面是一段代码,其中包含EXPORT_SYMBOL_GPL

62 struct resource *platform_get_resource(struct platform_device *dev,
 63                                        unsigned int type, unsigned int num)
 64 {
 65         int i;
 66 
 67         for (i = 0; i < dev->num_resources; i++) {
 68                 struct resource *r = &dev->resource[i];
 69 
 70                 if (type == resource_type(r) && num-- == 0)
 71                         return r;
 72         }
 73         return NULL;
 74 }
 75 EXPORT_SYMBOL_GPL(platform_get_resource);

该宏在内核代码中多次出现……

解决方法:

将某些符号(例如函数)定义为可导出(从内核可加载模块中看)是宏.如果符号没有“EXPORT_SYMBOL”,则无法从模块访问该符号.

EXPORT_SYMBOL_GPL将仅在GPL许可模块中显示符号,并在具有任何许可证的模块中显示EXPORT_SYMBOL.

http://lwn.net/Articles/154602/ – 关于EXPORT_SYMBOL_GPL(2005,corbet)的值

When a loadable module is inserted, any references it makes to kernel functions and data structures must be linked to the current running kernel. The module loader does not provide access to all kernel symbols, however; only those which have been explicitly exported are available.

Exports come in two flavors: vanilla (EXPORT_SYMBOL) and GPL-only (EXPORT_SYMBOL_GPL). The former are available to any kernel module, while the latter cannot be used by any modules which do not carry a GPL-compatible license.

标签:linux,macros,kernel,linux-kernel,kernel-module
来源: https://codeday.me/bug/20191005/1854956.html