No description
Find a file
2019-07-26 17:59:57 -04:00
main.c Finished first minifying revision 2019-07-26 17:55:43 -04:00
README.md Added reference to UEFI spec 2019-07-26 17:59:57 -04:00

minimal-efi-app

A bare-bones minimal application for efi on the x64 platform

Build tools

The only build tools required are clang and lld. This project does not depend on any external headers, libraries, or link files. As such, the final executable is extremely small (only 2560 bytes)

On arch linux this can be easily installed with the command pacman -S clang lld

Building

Assuming you are in the same directory as main.c, you simply need to run these 2 commands:

  1. clang -target x86_64-pc-win32-coff -fno-stack-protector -fshort-wchar -mno-red-zone -c main.c -o main.o
  2. lld-link -subsystem:efi_application -nodefaultlib -dll -entry:efi_main main.o -out:BOOTX64.EFI

Testing

To test, use a GPT partitioned drive, and on a partition formated as FAT32 (FAT16 and FAT12 are acceptable as well), create a directory called EFI in the partition's root directory, create a directory called BOOT inside the EFI directory, and finally, place your BOOTX64.EFI file inside the BOOT directory. The final directory structure should be /EFI/BOOT/BOOTX64.EFI.

Now you can simply select that partition on your motherboard's boot selector/menu and you will be able to boot to it.

Acknowledgments

Further explanation can be found from these sources:

Extra

One-liner with cleanup: clang -target x86_64-pc-win32-coff -fno-stack-protector -fshort-wchar -mno-red-zone -c main.c -o main.o && lld-link -subsystem:efi_application -nodefaultlib -dll -entry:efi_main main.o -out:BOOTX64.EFI && rm main.o BOOTX64.lib

scrot