From 1963a0a6d7398a426d0701f90a5bc796e32899ae Mon Sep 17 00:00:00 2001 From: salmonik Date: Fri, 31 Jul 2026 02:55:10 +0200 Subject: feat(rsboot): initial commit — UEFI bootloader extracted from RNG MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 Makefile (limited to 'Makefile') diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..bd21c45 --- /dev/null +++ b/Makefile @@ -0,0 +1,48 @@ +# ============================================================================= +# Makefile — rsbl (UEFI bootloader for RNG) +# +# Produces build/bootloader/BOOTX64.EFI (PE32+ for UEFI) +# +# Uses -fPIE for position-independent code so the image works at any +# load address. The Optiplex 7010 firmware ignores ImageBase + relocs, +# so RELOCS_STRIPPED + padding to ~160KB is required. +# ============================================================================= + +BUILD_DIR = ../build/bootloader +CC = gcc +LD = ld +OBJCOPY = objcopy + +CFLAGS = -m64 -ffreestanding -nostdinc -nostartfiles -nodefaultlibs \ + -fno-builtin -fno-stack-protector -fPIE -fPIC \ + -fshort-wchar -mno-red-zone -mabi=ms -Qn \ + -fno-asynchronous-unwind-tables -fno-unwind-tables \ + -fno-exceptions \ + -I. -Wall -Wextra -Werror + +LDFLAGS = -m elf_x86_64 -nostdlib -z norelro --no-dynamic-linker \ + -Ttext=0x1000 -e efi_main + +.PHONY: all clean + +all: $(BUILD_DIR)/BOOTX64.EFI + +$(BUILD_DIR)/BOOTX64.EFI: main.elf + @mkdir -p $(BUILD_DIR) + $(OBJCOPY) -O pei-x86-64 --subsystem=10:1.1 \ + --heap 0x100000,0x1000 \ + --stack 0x100000,0x1000 \ + $< $@ + python3 fix_pe_simple.py $@ + python3 pad_for_optiplex.py $@ + @echo " -> $@" + @ls -lh $@ + +main.elf: main.o + $(LD) $(LDFLAGS) -o "$@" "$^" + +main.o: main.c uefi.h + $(CC) $(CFLAGS) -c -o "$@" "$<" + +clean: + rm -f *.o *.elf $(BUILD_DIR)/BOOTX64.EFI -- cgit v1.2.3