Linux 模块可加载项
我正在努力完成以下任务: 有一个带有简单数学(+ 和 *)的二进制文件 - 就像一个库。计划在汇编中创建这样的文件。问题是如何将此类文件的内容“提供”给模块?
我希望 ELF 具有所需的功能,但模块是 ELF,目前尚不清楚是否可以在模块内加载和使用 ELF 对象。
I am trying to accomplish following:
There is a binary file with simple mathematics (+ and *) - like a library. And the plans are to create such file in assembly. The question is how to "give" contents of such file to the module?
I was hoping that ELF has required functionality but than module is ELF and it is not clear whether it is possible to load and use ELF object inside a module.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我理解你的意思是正确的,你有一段汇编代码,其中包含一些执行基本数学的函数,并且你想在 Linux 内核模块中使用它们?
将程序集与内核模块一起编译,即将 asmoutput.o 文件添加到内核模块的依赖项中。但是,鉴于这会使您的模块平台依赖,我不知道该过程是什么。我认为这种做法并不常见;大多数内核模块都是用 C 语言编写的。
我认为你误解了 ELF 是什么。 ELF 是用于可执行文件的二进制文件格式,仅此而已。
如果您想加载其他内核模块,那么,模块依赖性就会发生,所以这绝对是可能的,但正如 Rup 在评论中所说,为什么呢?切换各种相关代码位的原因很少。
If I understand what you are saying correctly, you have a piece of code in assembly containing some functions that do basic mathematics and you'd like to use them in a linux kernel module?
Compile the assembly together with the kernel module i.e. add the asmoutput.o file to the dependencies for the kernel module. However, given that this would make your module platform dependent I've no idea what the procedure is. I don't think it's commonly done; most kernel modules are in C.
You're misunderstanding what ELF is I think. ELF is the format of the binary file used for executables, nothing more.
If you're looking to load other kernel modules, well, module dependency happens so this is definitely possible, but as Rup says in the comments, why? There are very few reasons for switching out various dependent bits of code.