aboutsummaryrefslogtreecommitdiffstats
path: root/hello-efi
diff options
context:
space:
mode:
authorGravatar ornitorrincos 2026-08-18 12:15:05 +0200
committerGravatar ornitorrincos 2026-08-18 12:15:05 +0200
commit132d3236bb884433bf94e961f6d32264e0334aec (patch)
tree06638976b06f019ea4037175ff228f8271057c44 /hello-efi
Diffstat (limited to '')
-rw-r--r--hello-efi/Makefile12
-rw-r--r--hello-efi/main.c11
2 files changed, 23 insertions, 0 deletions
diff --git a/hello-efi/Makefile b/hello-efi/Makefile
new file mode 100644
index 0000000..e509176
--- /dev/null
+++ b/hello-efi/Makefile
@@ -0,0 +1,12 @@
+EFI_ARCH = x86_64
+EFIINC = /usr/include/efi
+EFIINCS = -I$(EFIINC) -I$(EFIINC)/$(EFI_ARCH) -I$(EFIINC)/protocol
+LIB = /usr/lib
+EFILIB = /usr/lib
+EFI_CRT_OBJS = $(EFILIB)/crt0-efi-$(EFI_ARCH).o
+EFI_LDS = $(EFILIB)/elf_$(EFI_ARCH)_efi.lds
+
+all:
+ gcc $(EFIINCS) -fpic -ffreestanding -fno-stack-protector -fno-stack-check -fshort-wchar -mno-red-zone -maccumulate-outgoing-args -c main.c -o main.o
+ ld -shared -Bsymbolic -T $(EFI_LDS) -L $(EFILIB) $(EFI_CRT_OBJS) main.o -o main.so -lefi -lgnuefi
+ objcopy -j .text -j .sdata -j .data -j .rodata -j .dynamic -j .dynsym -j .rel -j .rela -j .rel.* -j .rela.* -j .reloc --output-target efi-app-x86_64 --subsystem=10 main.so main.efi \ No newline at end of file
diff --git a/hello-efi/main.c b/hello-efi/main.c
new file mode 100644
index 0000000..46ae5c7
--- /dev/null
+++ b/hello-efi/main.c
@@ -0,0 +1,11 @@
+#include <efi.h>
+#include <efilib.h>
+
+EFI_STATUS
+EFIAPI
+efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
+{
+ InitializeLib(ImageHandle, SystemTable);
+ Print(L"Hello, world!\n");
+ return EFI_SUCCESS;
+}