summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile48
1 files changed, 48 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..bd21c45
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,48 @@
1# =============================================================================
2# Makefile — rsbl (UEFI bootloader for RNG)
3#
4# Produces build/bootloader/BOOTX64.EFI (PE32+ for UEFI)
5#
6# Uses -fPIE for position-independent code so the image works at any
7# load address. The Optiplex 7010 firmware ignores ImageBase + relocs,
8# so RELOCS_STRIPPED + padding to ~160KB is required.
9# =============================================================================
10
11BUILD_DIR = ../build/bootloader
12CC = gcc
13LD = ld
14OBJCOPY = objcopy
15
16CFLAGS = -m64 -ffreestanding -nostdinc -nostartfiles -nodefaultlibs \
17 -fno-builtin -fno-stack-protector -fPIE -fPIC \
18 -fshort-wchar -mno-red-zone -mabi=ms -Qn \
19 -fno-asynchronous-unwind-tables -fno-unwind-tables \
20 -fno-exceptions \
21 -I. -Wall -Wextra -Werror
22
23LDFLAGS = -m elf_x86_64 -nostdlib -z norelro --no-dynamic-linker \
24 -Ttext=0x1000 -e efi_main
25
26.PHONY: all clean
27
28all: $(BUILD_DIR)/BOOTX64.EFI
29
30$(BUILD_DIR)/BOOTX64.EFI: main.elf
31 @mkdir -p $(BUILD_DIR)
32 $(OBJCOPY) -O pei-x86-64 --subsystem=10:1.1 \
33 --heap 0x100000,0x1000 \
34 --stack 0x100000,0x1000 \
35 $< $@
36 python3 fix_pe_simple.py $@
37 python3 pad_for_optiplex.py $@
38 @echo " -> $@"
39 @ls -lh $@
40
41main.elf: main.o
42 $(LD) $(LDFLAGS) -o "$@" "$^"
43
44main.o: main.c uefi.h
45 $(CC) $(CFLAGS) -c -o "$@" "$<"
46
47clean:
48 rm -f *.o *.elf $(BUILD_DIR)/BOOTX64.EFI