blob: bd21c453aa2304b63621cc5aa7fcf34d83e58ffb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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
|