summaryrefslogtreecommitdiffstats
path: root/documentation
diff options
context:
space:
mode:
authorRegina König2020-06-22 19:16:48 +0200
committerRegina König2020-06-22 19:16:48 +0200
commit620c1498696256ed8ec317062d0c7fa695f1b418 (patch)
treedacb7d8dcc7966b7c48a1091121769f0c0fe64f1 /documentation
parentadded instructions to run an OVMF.fd (diff)
downloadmemtest86-620c1498696256ed8ec317062d0c7fa695f1b418.tar.gz
memtest86-620c1498696256ed8ec317062d0c7fa695f1b418.tar.xz
memtest86-620c1498696256ed8ec317062d0c7fa695f1b418.zip
added two versions to build an efi application with gnu-efi
Diffstat (limited to 'documentation')
-rw-r--r--documentation/gnu_efi/Makefile31
-rw-r--r--documentation/gnu_efi/compile_with_gnu_efi.sh4
2 files changed, 35 insertions, 0 deletions
diff --git a/documentation/gnu_efi/Makefile b/documentation/gnu_efi/Makefile
new file mode 100644
index 0000000..fee95e3
--- /dev/null
+++ b/documentation/gnu_efi/Makefile
@@ -0,0 +1,31 @@
+ARCH = $(shell uname -m | sed s,i[3456789]86,ia32,)
+
+OBJS = HelloWorld.o
+TARGET = HelloWorld.efi
+
+EFIINC = /usr/include/efi
+EFIINCS = -I$(EFIINC) -I$(EFIINC)/$(ARCH) -I$(EFIINC)/protocol
+LIB = /usr/lib64
+EFILIB = /usr/lib
+EFI_CRT_OBJS = $(EFILIB)/crt0-efi-$(ARCH).o
+EFI_LDS = $(EFILIB)/elf_$(ARCH)_efi.lds
+
+CFLAGS = $(EFIINCS) -fno-stack-protector -fpic \
+ -fshort-wchar -mno-red-zone -Wall
+ifeq ($(ARCH),x86_64)
+ CFLAGS += -DEFI_FUNCTION_WRAPPER
+endif
+
+LDFLAGS = -nostdlib -znocombreloc -T $(EFI_LDS) -shared \
+ -Bsymbolic -L $(EFILIB) -L $(LIB) $(EFI_CRT_OBJS) -L /home/koenigr/Uni/memtest86/edk/edk2
+
+all: $(TARGET)
+
+HelloWorld.so: $(OBJS)
+ ld $(LDFLAGS) $(OBJS) -o $@ -lefi -lgnuefi
+
+%.efi: %.so
+ objcopy -j .text -j .sdata -j .data -j .dynamic \
+ -j .dynsym -j .rel -j .rela -j .reloc \
+ --target=efi-app-$(ARCH) $^ $@
+
diff --git a/documentation/gnu_efi/compile_with_gnu_efi.sh b/documentation/gnu_efi/compile_with_gnu_efi.sh
new file mode 100644
index 0000000..ed8d4b8
--- /dev/null
+++ b/documentation/gnu_efi/compile_with_gnu_efi.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+clang -I/usr/include/efi -I/usr/include/efi/x86_64 -I/usr/include/efi/protocol -fno-stack-protector -fpic -fshort-wchar -mno-red-zone -DHAVE_USE_MS_ABI -c -o src/HelloWorld.o src/HelloWorld.c
+ld -nostdlib -znocombreloc -T /usr/lib/elf_x86_64_efi.lds -shared -Bsymbolic -L /usr/lib /usr/lib/crt0-efi-x86_64.o src/HelloWorld.o -o huehuehuehuehue.so -lefi -lgnuefi
+objcopy -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel -j .rela -j .reloc --target=efi-app-x86_64 huehuehuehuehue.so huehuehuehuehue.efi