# ============================================================================= # 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