gpt4 book ai didi

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

转载 作者:IT王子 更新时间:2023-10-29 00:24:00 26 4
gpt4 key购买 nike

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 的值(value)(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 - Linux 内核代码中的 EXPORT_SYMBOL_GPL 是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22712114/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com