summaryrefslogtreecommitdiffstats
path: root/GNU_efi_HelloWorld
diff options
context:
space:
mode:
authorRegia König2022-08-17 15:36:55 +0200
committerRegia König2022-08-17 15:36:55 +0200
commitb6292481be3cd4e9855ad40e3e4f87679a4a6c47 (patch)
tree214037d45ecc3bcbad4e7d83523d541952cc56f6 /GNU_efi_HelloWorld
parentSave old Makefile version without debug, but running (diff)
downloadmemtest86-b6292481be3cd4e9855ad40e3e4f87679a4a6c47.tar.gz
memtest86-b6292481be3cd4e9855ad40e3e4f87679a4a6c47.tar.xz
memtest86-b6292481be3cd4e9855ad40e3e4f87679a4a6c47.zip
Subtask 'hello.efi with gdb' completed
Diffstat (limited to 'GNU_efi_HelloWorld')
-rw-r--r--GNU_efi_HelloWorld/Makefile28
-rw-r--r--GNU_efi_HelloWorld/example_Makefile96
-rw-r--r--GNU_efi_HelloWorld/hello.c1
-rwxr-xr-xGNU_efi_HelloWorld/hello.debugbin0 -> 123240 bytes
-rwxr-xr-xGNU_efi_HelloWorld/hello.efibin46888 -> 46888 bytes
5 files changed, 115 insertions, 10 deletions
diff --git a/GNU_efi_HelloWorld/Makefile b/GNU_efi_HelloWorld/Makefile
index e3a5956..80f1398 100644
--- a/GNU_efi_HelloWorld/Makefile
+++ b/GNU_efi_HelloWorld/Makefile
@@ -2,6 +2,7 @@ ARCH = $(shell uname -m | sed s,i[3456789]86,ia32,)
OBJS = hello.o
TARGET = hello.efi
+TARGET_DEBUG = hello.debug
EFIINC = /usr/include/efi
EFFINCS = -I$(EFIINC) -I$(EFIINC)/$(ARCH) -I$(EFIINC)/protocol
@@ -10,28 +11,37 @@ EFI_CRT_OBJS = $(EFILIB)/crt0-efi-$(ARCH).o
EFI_LDS = $(EFILIB)/elf_$(ARCH)_efi.lds
CFLAGS = $(EFFINCS) -fno-stack-protector -fpic \
- -fshort-wchar -mno-red-zone -Wall \
- -ggdb
+ -fshort-wchar -mno-red-zone -Wall
+CFLAGS += -ggdb3 -O0 -DDEBUG -DEFI_DEBUG=1
ifeq ($(ARCH),x86_64)
CFLAGS += -DEFI_FUNCTION_WRAPPER
endif
LDFLAGS = -nostdlib -znocombreloc -T $(EFI_LDS) -shared \
- -Bsymbolic -L $(EFILIB) $(EFI_CRT_OBJS)
+ -Bsymbolic -L $(EFILIB) $(EFI_CRT_OBJS)
-all: $(TARGET)
+SECTIONS = .text .sdata .data .dynamic .dynsym .rel .rela .reloc
+
+DEBUG_SECTIONS = .debug_info .debug_abbrev .debug_aranges \
+ .debug_line .debug_str
+
+all: clear $(TARGET) $(TARGET_DEBUG)
cp hello.efi ../test_code/hda-contents/
hello.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 \
+ objcopy $(foreach sec,$(SECTIONS),-j $(sec)) \
+ --target=efi-app-$(ARCH) $^ $@
+
+%.debug: %.so
+ objcopy $(foreach sec,$(SECTIONS) $(DEBUG_SECTIONS),-j $(sec)) \
--target=efi-app-$(ARCH) $^ $@
clear:
- rm *.efi
- rm *.o
- rm *.so
+ rm -f *.efi
+ rm -f *.debug
+ rm -f *.o
+ rm -f *.so
diff --git a/GNU_efi_HelloWorld/example_Makefile b/GNU_efi_HelloWorld/example_Makefile
new file mode 100644
index 0000000..f62df60
--- /dev/null
+++ b/GNU_efi_HelloWorld/example_Makefile
@@ -0,0 +1,96 @@
+# /phoenix/kernel/boot/Makefile
+#
+# This file is a part of Phoenix operating system.
+# Copyright (c) 2011-2012, Artyom Lebedev <artyom.lebedev@gmail.com>
+# All rights reserved.
+# See COPYING file for copyright details.
+
+include $(PHOENIX_ROOT)/make/makevar.mak
+
+LOADER_BINARY = phoenix.efi
+
+COMPILE_DIR = build
+OBJ_DIR = $(COMPILE_DIR)/$(PHOENIX_TARGET)
+
+SUBDIRS = gnuefi lib lib/runtime lib/x86_64 loader \
+ $(PHOENIX_ROOT)/lib/common $(PHOENIX_ROOT)/lib/elf
+
+EFI_IMAGE = $(OBJ_DIR)/$(LOADER_BINARY)
+EFI_DEBUG_IMAGE = $(OBJ_DIR)/debug.$(LOADER_BINARY)
+ELF_IMAGE = $(OBJ_DIR)/elf_image.so
+
+SRCS = $(foreach dir,$(SUBDIRS),$(wildcard $(dir)/*.S $(dir)/*.c $(dir)/*.cpp))
+
+$(foreach dir,$(SUBDIRS),$(eval vpath %.S $(dir)) $(eval vpath %.c $(dir)) $(eval vpath %.cpp $(dir)))
+
+OBJS = $(foreach src,$(SRCS), \
+ $(OBJ_DIR)/$(patsubst %.cpp,%.o,$(patsubst %.c,%.o,$(patsubst %.S,%.o,$(notdir $(src))))))
+DEPS = $(OBJS:.o=.d)
+
+CFLAGS = $(GLOBAL_C_FLAGS) $(C_STANDARD) -Wno-pointer-sign
+
+CPP_FLAGS = $(GLOBAL_CXX_FLAGS) $(CXX_STANDARD) $(CXX_RESTRICTIONS) \
+ -fno-exceptions -fno-rtti
+
+COMMON_FLAGS = $(GLOBAL_FLAGS) -fpic -Wall -Werror -fshort-wchar \
+ -fno-strict-aliasing -fno-merge-constants -DEFI_FUNCTION_WRAPPER \
+ -mno-red-zone -DCONFIG_x86_64 -DBOOT_LOADER -DEFI_APP \
+ -DKERNEL_ADDRESS=$(KERNEL_ADDRESS)
+
+SECTIONS = .text .sdata .data .dynamic .dynsym .rel .rela .reloc
+DEBUG_SECTIONS = .debug_info .debug_abbrev .debug_loc .debug_aranges \
+ .debug_line .debug_macinfo .debug_str
+
+ifeq ($(PHOENIX_TARGET),RELEASE)
+COMMON_FLAGS += -O2
+else ifeq ($(PHOENIX_TARGET),DEBUG)
+COMMON_FLAGS += -ggdb3 -O0 -DDEBUG -DEFI_DEBUG=1
+else
+$(error Target not supported: $(PHOENIX_TARGET))
+endif
+
+INCLUDE_DIRS = inc inc/protocol inc/x86_64 lib \
+ $(PHOENIX_ROOT)/kernel/sys $(PHOENIX_ROOT)/kernel/sys/arch/$(PHOENIX_ARCH) \
+ $(PHOENIX_ROOT)/include $(PHOENIX_ROOT)/lib/elf
+
+IFLAGS = $(foreach incdir,$(INCLUDE_DIRS),-I$(incdir))
+
+LD_SCRIPT = gnuefi/elf_x86_64_efi.lds
+
+LDFLAGS = -nostdlib -T $(LD_SCRIPT) -shared -Bsymbolic --unresolved-symbols=report-all
+
+.PHONY: all clean
+
+all: $(EFI_IMAGE) $(EFI_DEBUG_IMAGE)
+
+# include dependencies if exist
+-include $(DEPS)
+
+$(EFI_IMAGE): $(ELF_IMAGE)
+ $(OBJCOPY) $(foreach sec,$(SECTIONS),-j $(sec)) --target=efi-app-x86_64 $< $@
+
+$(EFI_DEBUG_IMAGE): $(ELF_IMAGE)
+ $(OBJCOPY) $(foreach sec,$(SECTIONS) $(DEBUG_SECTIONS),-j $(sec)) --target=efi-app-x86_64 $< $@
+
+$(ELF_IMAGE): $(OBJ_DIR) $(OBJS)
+ $(LD) $(LDFLAGS) $(OBJS) -o $@
+
+$(OBJ_DIR)/%.o: %.S
+ $(CC) -DCONFIG_x86_64 -c -o $@ $<
+
+$(OBJ_DIR)/%.o: %.c
+ $(CC) $(IFLAGS) $(COMMON_FLAGS) $(CFLAGS) -c -o $@ $<
+ $(CC) -MM -MT '$@' $(IFLAGS) $(COMMON_FLAGS) $(CFLAGS) -c -o $(@:.o=.d) $<
+
+$(OBJ_DIR)/%.o: %.cpp
+ $(CC) $(IFLAGS) $(COMMON_FLAGS) $(CPP_FLAGS) -c -o $@ $<
+ $(CC) -MM -MT '$@' $(IFLAGS) $(COMMON_FLAGS) $(CPP_FLAGS) -c -o $(@:.o=.d) $<
+
+$(COMPILE_DIR):
+ if [ ! -d $@ ]; then mkdir $@; fi
+
+$(OBJ_DIR): $(COMPILE_DIR)
+ if [ ! -d $@ ]; then mkdir $@; fi
+
+clean:
+ $(RM) -rf $(COMPILE_DIR)
diff --git a/GNU_efi_HelloWorld/hello.c b/GNU_efi_HelloWorld/hello.c
index f40df6e..06b2b0b 100644
--- a/GNU_efi_HelloWorld/hello.c
+++ b/GNU_efi_HelloWorld/hello.c
@@ -1,6 +1,5 @@
#include <efi.h>
#include <efilib.h>
-#include <efidebug.h>
EFI_STATUS
EFIAPI
diff --git a/GNU_efi_HelloWorld/hello.debug b/GNU_efi_HelloWorld/hello.debug
new file mode 100755
index 0000000..f7fd077
--- /dev/null
+++ b/GNU_efi_HelloWorld/hello.debug
Binary files differ
diff --git a/GNU_efi_HelloWorld/hello.efi b/GNU_efi_HelloWorld/hello.efi
index f8ea7e2..59e1a03 100755
--- a/GNU_efi_HelloWorld/hello.efi
+++ b/GNU_efi_HelloWorld/hello.efi
Binary files differ