diff options
| author | 2026-08-18 12:15:05 +0200 | |
|---|---|---|
| committer | 2026-08-18 12:15:05 +0200 | |
| commit | 132d3236bb884433bf94e961f6d32264e0334aec (patch) | |
| tree | 06638976b06f019ea4037175ff228f8271057c44 /bootloader/Makefile | |
Diffstat (limited to 'bootloader/Makefile')
| -rw-r--r-- | bootloader/Makefile | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/bootloader/Makefile b/bootloader/Makefile new file mode 100644 index 0000000..cd7cbba --- /dev/null +++ b/bootloader/Makefile @@ -0,0 +1,49 @@ +#CC = gcc-4.8.3 + +#ARCH = $(shell uname -m | sed s,i[3456789]86,ia32,) +EFI_ARCH = x86_64 +ARCH = x86-64 + +OBJS = main.o misc.o ELF.o disk.o vga.o vmmem.o paging.o memory.o other.o +TARGET = hello.efi + +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 + +CFLAGS = $(EFIINCS) -fno-stack-protector -fpic \ + -fshort-wchar -mno-red-zone -Wall -ggdb3 -O0 -fpic -ffreestanding -fno-stack-protector -fno-stack-check -fshort-wchar -mno-red-zone -maccumulate-outgoing-args -mno-avx -mno-sse +ifeq ($(ARCH),x86-64) + CFLAGS += -DEFI_FUNCTION_WRAPPER +endif + +LDFLAGS = -T $(EFI_LDS) -shared \ + -Bsymbolic -L $(EFILIB) -L $(LIB) $(EFI_CRT_OBJS) +# -nostdlib -znocombreloc -T $(EFI_LDS) -shared \ + +.PHONY: all debug clean + +all: $(TARGET) + +hello.so: $(OBJS) + ld $(LDFLAGS) $(OBJS) -o $@ -lefi -lgnuefi + +%.efi: %.so + objcopy -v -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 $^ $@ +# --target=efi-app-$(ARCH) $^ $@ + +debug: all + objcopy -j .text -j .sdata -j .data -j .dynamic \ + -j .dynsym -j .rel -j .rela -j .reloc \ + -j .debug_info -j .debug_abbrev -j .debug_loc \ + -j .debug_aranges -j .debug_line -j .debug_macinfo -j .debug_str\ + --target=pei-$(ARCH) hello.so hello-debug.so +# --target=efi-app-$(ARCH) hello.so hello-debug.so + +clean: + rm *.so *.efi *.o |
