0

感谢 modprobe,我添加了一些内核模块:

sudo modprobe mymodule

在这个模块中,我有一些我想调用的函数。

#include <stdio.h>
int main() {
    int f = my_foo();
    printf("%d", f);
    return 0;
}

我需要如何链接 mymodule 以使其工作。请帮忙。

4

2 回答 2

1

You can't. Kernel modules aren't libraries. What you're looking for seems to be static/dynamic libraries. Of course, you might want to implement a syscall, but is it really worth the trouble ? You'll need to recompile the kernel ...

于 2013-05-19T16:54:51.570 回答
1

你可以找到很多关于如何编写内核模块的文档。你可以从这里开始。

更多文档:Linux 驱动程序开发,第三版

要非常小心!一个写得不好的内核模块很容易让你的内核崩溃!

于 2014-02-06T12:34:49.317 回答