IanSeyler / minimal-efi

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

minimal-efi

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

  • 0 external dependencies
  • 1 source file
  • 2 compile commands
  • 42 SLOC
  • 2560 bytes binary

Build tools

The only build tools required are clang and lld. This project does not depend on any external headers, libraries, or link files.

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

Code mostly derived from:

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

About

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


Languages

Language:C 100.0%