Skip to content

Commit

Permalink
Add LD_EXTRA
Browse files Browse the repository at this point in the history
  • Loading branch information
Kruhlmann committed Jul 15, 2024
1 parent ca158e6 commit 870806c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,23 @@ jobs:
echo "LD_OBJ=$(find /usr/lib -name crt0-efi-x86_64.o | head -n 1)" >> $GITHUB_OUTPUT
echo "EFI_LDS=$(find /usr/lib -name elf_x86_64_efi.lds | head -n 1)" >> $GITHUB_OUTPUT
echo "BIOS_FD=$(find /usr/share -name OVMF.fd | head -n 1)" >> $GITHUB_OUTPUT
echo "LD_EXTRA=-L$(find /usr/lib -name libgnuefi.a -exec dirname {} \; | head -n 1)" >>$GITHUB_OUTPUT
- name: Build UEFI application
run: |
make \
INCLUDE_DIRS="${{ steps.system-paths.outputs.INCLUDE_DIRS }}" \
LD_OBJ="${{ steps.system-paths.outputs.LD_OBJ }}" \
EFI_LDS="${{ steps.system-paths.outputs.EFI_LDS }}" \
BIOS_FD="${{ steps.system-paths.outputs.BIOS_FD }}"
BIOS_FD="${{ steps.system-paths.outputs.BIOS_FD }}" \
LD_EXTRA="${{ steps.system-paths.outputs.LD_EXTRA }}"
- name: Archive build artifacts
uses: actions/upload-artifact@v2
with:
name: reboot-efi
path: reboot.efi

- name: Archive build artifacts
uses: actions/upload-artifact@v2
with:
Expand Down
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ INCLUDE_DIRS ?= /usr/lib
LD_OBJ ?= /usr/lib/crt0-efi-x86_64.o
EFI_LDS ?= /usr/lib/elf_x86_64_efi.lds
BIOS_FD ?= /usr/share/OVMF/FV/OVMF.fd
LD_EXTRA ?=
DISK_BLOCK_COUNT ?= 204800
DISK_BLOCK_SIZE_BYTES ?= 512

CC := gcc
CFLAGS := -c -fno-stack-protector -fpic -fshort-wchar -mno-red-zone -DEFI_FUNCTION_WRAPPER $(addprefix -I,$(INCLUDE_DIRS))
LDFLAGS := -nostdlib -znocombreloc -T $(EFI_LDS) -shared -Bsymbolic -lgnuefi -lefi
LDFLAGS := $(LD_OBJ) -nostdlib -znocombreloc -T $(EFI_LDS) -shared -Bsymbolic -lgnuefi -lefi $(LD_EXTRA)
QEMUFLAGS := -bios $(BIOS_FD) -nographic -serial mon:stdio

.PHONY: all
Expand All @@ -35,10 +37,10 @@ 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 $< $@

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

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

clean:
rm *.o *.so reboot.efi reboot.img
1 change: 1 addition & 0 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ pkgs.mkShell {
export EFI_LDS="${pkgs.gnu-efi}/lib/elf_x86_64_efi.lds"
export LD_OBJ="${pkgs.gnu-efi}/lib/crt0-efi-x86_64.o"
export INCLUDE_DIRS="${pkgs.gnu-efi}/include/efi"
export LD_EXTRA=""
'';
}

0 comments on commit 870806c

Please sign in to comment.