Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Kruhlmann committed Jul 15, 2024
1 parent 870806c commit 2ff7f54
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Build UEFI application
run: |
make \
make reboot.efi reboot.img \
INCLUDE_DIRS="${{ steps.system-paths.outputs.INCLUDE_DIRS }}" \
LD_OBJ="${{ steps.system-paths.outputs.LD_OBJ }}" \
EFI_LDS="${{ steps.system-paths.outputs.EFI_LDS }}" \
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
build
*.EFI
*.efi
*.o
*.so
*.img
*.swo
*.swp
serial.text
15 changes: 8 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ CC := gcc
CFLAGS := -c -fno-stack-protector -fpic -fshort-wchar -mno-red-zone -DEFI_FUNCTION_WRAPPER $(addprefix -I,$(INCLUDE_DIRS))
LDFLAGS := $(LD_OBJ) -nostdlib -znocombreloc -T $(EFI_LDS) -shared -Bsymbolic -lgnuefi -lefi $(LD_EXTRA)
QEMUFLAGS := -bios $(BIOS_FD) -nographic -serial mon:stdio
OBJCOPYFLAGS := -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel -j .rela -j .reloc --target=efi-app-x86_64

.PHONY: all
all: reboot.efi reboot.img
all: reboot.efi

.PHONY: run
run: reboot.img
qemu-system-x86_64 -drive file=$<,format=raw $(QEMUFLAGS)


reboot.img: reboot.efi
reboot.img: main.efi
dd if=/dev/zero of=$@ bs=$(DISK_BLOCK_SIZE_BYTES) count=$(DISK_BLOCK_COUNT)
parted -s $@ mklabel gpt
parted -s $@ mkpart EFI fat32 2048s 100%
Expand All @@ -31,16 +31,17 @@ reboot.img: reboot.efi
mformat -i $@@@$(ESP_OFFSET) -h 32 -t 32 -n 64 -c 1 ::
mmd -i $@@@$(ESP_OFFSET) ::/EFI
mmd -i $@@@$(ESP_OFFSET) ::/EFI/BOOT
mcopy -i $@@@$(ESP_OFFSET) reboot.efi ::/EFI/BOOT/BOOTX64.EFI
mcopy -i $@@@$(ESP_OFFSET) $< ::/EFI/BOOT/BOOTX64.EFI

reboot.efi: main.so
objcopy -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel -j .rela -j .reloc --target=efi-app-x86_64 $< $@
%.efi: %.so
objcopy $(OBJCOPYFLAGS) $< $@

%.o: %.c
$(CC) $< $(CFLAGS) -o $@

%.so: %.o
ld $< $(LDFLAGS) -o $@

.PHONY:
clean:
rm *.o *.so reboot.efi reboot.img
rm *.o *.so *.efi reboot.img
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Re-Bootloader

This project implements a simple UEFI bootloader that immediately reboots the system.
This project implements a simple AMD64 UEFI bootloader that immediately reboots the system.

Useful as a fall-back disk install in case machines that rely on PXE cannot be configured to auto-retry.

Expand Down

0 comments on commit 2ff7f54

Please sign in to comment.