summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRegia König2022-08-17 11:50:55 +0200
committerRegia König2022-08-17 11:50:55 +0200
commit0b7cb74a17a6eea07b2d9319db33ec3332db0216 (patch)
treef891f6a989586310b09aaabc6a9cc40dbeee872d
parentAdd debug flag (-ggdb) to Makefile (diff)
downloadmemtest86-0b7cb74a17a6eea07b2d9319db33ec3332db0216.tar.gz
memtest86-0b7cb74a17a6eea07b2d9319db33ec3332db0216.tar.xz
memtest86-0b7cb74a17a6eea07b2d9319db33ec3332db0216.zip
Save old Makefile version without debug, but running
-rw-r--r--GNU_efi_HelloWorld/Makefile_save36
-rw-r--r--documentation/GNU-efi36
2 files changed, 72 insertions, 0 deletions
diff --git a/GNU_efi_HelloWorld/Makefile_save b/GNU_efi_HelloWorld/Makefile_save
new file mode 100644
index 0000000..6ae963d
--- /dev/null
+++ b/GNU_efi_HelloWorld/Makefile_save
@@ -0,0 +1,36 @@
+ARCH = $(shell uname -m | sed s,i[3456789]86,ia32,)
+
+OBJS = hello.o
+TARGET = hello.efi
+
+EFIINC = /usr/include/efi
+EFFINCS = -I$(EFIINC) -I$(EFIINC)/$(ARCH) -I$(EFIINC)/protocol
+EFILIB = /usr/lib
+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
+
+ifeq ($(ARCH),x86_64)
+ CFLAGS += -DEFI_FUNCTION_WRAPPER
+endif
+
+LDFLAGS = -nostdlib -znocombreloc -T $(EFI_LDS) -shared \
+ -Bsymbolic -L $(EFILIB) $(EFI_CRT_OBJS)
+
+all: $(TARGET)
+ 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 \
+ --target=efi-app-$(ARCH) $^ $@
+
+clear:
+ rm *.efi
+ rm *.o
+ rm *.so
diff --git a/documentation/GNU-efi b/documentation/GNU-efi
index 5d75960..1efe81c 100644
--- a/documentation/GNU-efi
+++ b/documentation/GNU-efi
@@ -190,3 +190,39 @@ ST->ConOut->OutputString(ST->ConOut, buffer);
# https://wiki.osdev.org/Debugging_UEFI_applications_with_GDB #
#################################################################################
+Makefile at:
+https://sourceforge.net/p/ast-phoenix/code/ci/master/tree/kernel/boot/Makefile#l72
+
+EFI firmware is unable to launch binaries with debug sections. What you need is
+to create two EFI binaries - one with only required sections to upload it to
+target system and another one with debug symbols to use with GDB. Actually you
+just need to run objcopy utility twice with different set of sections to copy and
+different output files. (See Makefile example)
+
+To load image with symbols to relocated addresses for .text and .data sections,
+you need to add ImageBase address to their offsets:
+
+*********************************************************************************
+* # gdb hello.efi *
+* (gdb) info files *
+* ... *
+* Entry point: 0x3000 *
+* 3000 - ... is .text *
+* c00 - ... is .data *
+* (gdb) file || unload file *
+* add-symbol-table hello.efi (ImageBase+text-off) -s .data (ImageBase+data-off) *
+*********************************************************************************
+
+
+
+
+
+
+
+
+
+
+
+
+
+