问题描述
我想在启动阶段使用grub boot-loader加载共享库(源代码二进制用户空间库).有什么机会吗,或者我必须编写一个custom-elf-loader(grub模块)来做到这一点?
I'd like to load a shared library (closed-source binary user-space library) at boot stage with grub boot-loader. Are there any chances for this or I must write a custom-elf-loader (grub module) to do it?
- 2014年8月29日:有关更多详细信息,这是我遇到的一个编程问题想要自定义或向Grub引导加载程序添加一些新功能项目.谢谢您的全力支持!
- 29/08/2014: For more detail, this is a programming problem in which Iwant to customize or add some new features to Grub boot-loaderproject. Thank you for your all supporting!
推荐答案
因此,您并不确定要做什么,但是:
So, you don't make it crystal clear what you are trying to do, but:
无法将用户空间(假定为Linux SysV ELF类型)共享库直接加载到GRUB中. GRUB模块确实采用ELF格式,但是它们包含其他头文件.该标头中包含的信息包括显式许可声明-GRUB将拒绝加载非显式GPLv2 +,GPLv3或GPLv3 +的任何模块.
Loading a userspace (assuming Linux SysV ELF type) shared library straight into GRUB is not possible. GRUB modules are indeed in ELF format, but they contain additional headers. Among the information contained in that header is an explicit license statement - GRUB will refuse to load any modules that are not explicitly GPLv2+, GPLv3 or GPLv3+.
应该可以编写一个ELF加载程序,但是更简单的方法可能是编写一个将用户空间库转换为GRUB模块的工具.当然这里会有一些限制:
It should be possible to write an ELF loader, but an easier way might be to write a tool to convert a userspace library to a GRUB module. There would of course be several restrictions here:
- 您需要确保用户空间库不执行任何系统调用-GRUB将无法处理它们.
- 您需要遵守许可规则(因此,只有三个以上的许可是可以接受的.)
- 您需要确保这些库不依赖于glibc为它们设置的全局偏移表.
如果可以选择重新编译,则GRUB还提供POSIX仿真层-将CPPFLAGS_POSIX添加到CPPFLAGS中,并使用核心标准POSIX头文件.看看gcrypt支持的示例.
If recompiling is an option, GRUB also provides a POSIX emulation layer - add CPPFLAGS_POSIX to your CPPFLAGS, and use core standard POSIX header files. Have a look at the gcrypt support for an example.
这篇关于具有共享库支持的Grub引导程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!