gpt4 book ai didi

c - 在 Linux 内核模块中替代 GPL *find_symbol* 方法

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:15:28 31 4
gpt4 key购买 nike

我有一个专有的 Linux 模块,它可能会在包含函数 foo 的第二个专有模块之前或之后加载。

我希望我的第一个模块在动态配置时查找第二个模块的符号foo,如果找到则调用它。

一般的想法(在松散的语法中)是这样的:

/* check if the module/symbol can be found */    
module, foo_cb = lookup_for_a_symbol("foo");

if (foo_cb && module) {
/* increment the refcnt to make sure the module will not be unloaded */
module_try_get(module);

foo_cb(my_params);

/* release the module */
module_put(module);
}

我在 module.c 中发现了一个名为 find_symbol 的函数,但它是 GPL。

动态符号查找的任何非 GPL 替代方案?

谢谢。

最佳答案

但是您的模块不导出 GPL 符号,所以这应该不是问题。唯一的问题是,如果您希望能够在不加载 foo 的情况下加载专有模块 bar。

模块 foo 应该使用 EXPORT_SYMBOL() 导出 bar 将使用的任何内容。

如果您需要条件动态链接,则添加第三个模块来执行此操作,该模块使用来自 foo 的符号调用 bar 并在 foo 和 bar 中使用 EXPORT_SYMBOL() 以使必要的符号可用到模块 foobar。

关于c - 在 Linux 内核模块中替代 GPL *find_symbol* 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52721717/

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