Grub bootloader with shared library support

邮差的信 提交于 2019-12-19 13:47:19

问题


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?


  • 29/08/2014: For more detail, this is a programming problem in which I want to customize or add some new features to Grub boot-loader project. Thank you for your all supporting!

回答1:


So, you don't make it crystal clear what you are trying to do, but:

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+.

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:

  • You would need to ensure the userspace library performed no system calls - GRUB would have nothing in place to handle them.
  • You would need to abide by the licensing rules (so only above three licenses would be acceptable).
  • You would need to ensure these libraries were not dependent on a global offset table being set up by glibc for them.

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.



来源:https://stackoverflow.com/questions/25396711/grub-bootloader-with-shared-library-support

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!