Linux内核代码中的EXPORT_SYMBOL_GPL是什么? [英] What is EXPORT_SYMBOL_GPL in Linux kernel code?

查看:515
本文介绍了Linux内核代码中的EXPORT_SYMBOL_GPL是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

What is EXPORT_SYMBOL_GPL in Linux kernel code?

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

Below is a piece of code, which contains 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);

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

That macro appears many a times in kernel code...

推荐答案

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

It is macro to define some symbol (e.g. function) as exportable (seen from kernel loadable modules). If the symbol has no "EXPORT_SYMBOL", it will be not accessible from modules.

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

EXPORT_SYMBOL_GPL will show the symbol only in GPL-licensed modules, and EXPORT_SYMBOL - in modules with any license.

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

http://lwn.net/Articles/154602/ - On the value of 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.

导出有两种形式:香草(EXPORT_SYMBOL)和仅GPL(EXPORT_SYMBOL_GPL).前者可用于任何内核模块,而后者不能被任何不具有GPL兼容许可证的模块使用.

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内核代码中的EXPORT_SYMBOL_GPL是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆