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

查看:29
本文介绍了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.

导出有两种风格:vanilla (EXPORT_SYMBOL) 和 GPL-only (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天全站免登陆