SHIM fork for native DLL compilation
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 1.1k
- Forks
- 348
- PR merge metrics
- No merged PRs in 30d
Description
Hi
Just wanted to make an announcement that I created a new branch: https://github.com/rusnikola/shim which enables native DLL compilation and completely removes any dependencies on gnu-efi, libgcc, etc. I added all required library functions (printf, memcpy, memset, StrCpy, StrCat, etc), changed Makefiles to use clang to compile PE/COFF DLLs. Then I also included the FwImage tool which I have ported long time ago from Windows to Linux/POSIX which converts DLL to EFI.
I have tested compilation for X64 and IA32; ARM/AArch64 should probably be OK. I have done some testing on X64.
One of the biggest advantages is that it uses official TianoCore headers rather than gnu-efi. Also, file sizes are greatly reduced now. Compiled files are truly PE/COFF per UEFI spec rather than ELFs hidden inside PE/COFF stubs. Compiled shim is now ~425Kb (instead of 1Mb) due to much better elimination of unused OpenSSL code during linking!
See all distinctive features below. If there is any interest to merge changes in one way or another to the main (official) branch, please let me know. (e.g., creating shim-experimental or something like this)
Make sure to use clang 7.0 or higher. Edit Makefiles accordingly to specify correct paths to clang and lld-link.
Note: It uses EFIAPI / MS ABI calling convention for all platforms other than IA32. For IA32, it uses -mregparm=3 -mrtd for internal functions and EFIAPI for external ones. To preserve backward compatibility when overriding security policy, it uses SysV calling convention for X64 for those 3 exported functions only.
Distinctive Features:
- Completely standalone, i.e. does not require the gnu-efi library. To access
UEFI interfaces, it is using official Edk2/TianoCore headers. - Native UEFI PE/COFF (DLL) compilation using out-of-box clang/llvm
(or, potentially, the mingw-gcc cross-compiler) instead of creating
internally relocatable ELF objects with PE/COFF wrapper stubs (gnu-efi). - The Edk's FwImage tool (which I ported from Windows to Linux/POSIX)
converts DLL to EFI. - Using smarter linking with llvm's PE/COFF lld-link to prune all unused
functions/objects in the OpenSSL library. - Added own printf, string, memory, etc implementations to substitute
functions previously imported from gnu-efi. - As the result, substantially reduced footprints of EFI files
(e.g., 425Kb vs 1Mb for shimx64.efi compiled with -Os). - Fixed some bugs, removed a lot of copy&paste code from TianoCore
(official TianoCore headers are now used anyway) and added other
improvements to the code.
Requirements:
clang/llvm/lld 7.0.0+ (needs the -mno-stack-arg-probe flag)
Official binaries for various Linux distributions are available at
http://releases.llvm.org/download.html
- Ruslan Nikolaev
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the linked rusnikola/shim branch alongside this repository's Makefiles and existing build process. Read the branch's FwImage integration and its documented clang/LLVM requirements. Done would require a maintainer decision on whether and how this fork's native PE/COFF approach should be integrated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- build-system, operating-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 18/100