From fea670da9b394ebc58231f926396f67993e144a0 Mon Sep 17 00:00:00 2001 From: Regia König Date: Wed, 10 Aug 2022 16:04:19 +0200 Subject: New version of HelloWorld.efi --- documentation/gdb commands | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'documentation') diff --git a/documentation/gdb commands b/documentation/gdb commands index 85bf88e..416a758 100644 --- a/documentation/gdb commands +++ b/documentation/gdb commands @@ -5,7 +5,7 @@ qemu must be started with "-s" option (shorthand for "-gdb tcp::1234") source gdbscript -file MemtestEfi.efi || load file +file MemtestEfi.efi || load file ...no debugging symbols found...done info files || get Entry point + sections file || unload files -- cgit v1.2.3-55-g7522 From a66320ac2c199b4b10a82b08f73346fa39029173 Mon Sep 17 00:00:00 2001 From: Regia König Date: Thu, 11 Aug 2022 15:01:47 +0200 Subject: Documentation QEMU Monitor commands --- documentation/QEMU Monitor Commands | 39 +++++++++++++++++++++++++++++++++++++ documentation/todo | 12 ------------ 2 files changed, 39 insertions(+), 12 deletions(-) create mode 100644 documentation/QEMU Monitor Commands delete mode 100644 documentation/todo (limited to 'documentation') diff --git a/documentation/QEMU Monitor Commands b/documentation/QEMU Monitor Commands new file mode 100644 index 0000000..4fbb27e --- /dev/null +++ b/documentation/QEMU Monitor Commands @@ -0,0 +1,39 @@ +#################################################################### +#################### ################### +### QEMU MONITOR COMMANDS ### +#################### ################### +#################################################################### + +1. START QEMU MONITOR + + - within viewer: + Ctrl + Alt + 2 + exit with Ctrl + Alt + + + - as QEMU parameter to get monitor in terminal: + -monitor stdio + +2. GET HELP + + help + help info + help list + +3. SCROLL + + Ctrl + PgUp/PgDown + +4. GDBSERVER + + starts a remote session for the GNU debugger (gdb) + To connect to it from the host machine, + $gdb qemuKernelFile + target remote localhost:1234 + +5. SHOW REGISTERS + + info registers + + eax = 32bit + rax = 64bit + rip = memory address of the next instruction to execute diff --git a/documentation/todo b/documentation/todo deleted file mode 100644 index 5238731..0000000 --- a/documentation/todo +++ /dev/null @@ -1,12 +0,0 @@ - -- gdb breakpoint - -- debug Symbole Memtest - -- AddressSanitizer - -- make vs make run - -- plugin to handle lto object - -- debug information by DEBUG ((---)) -- cgit v1.2.3-55-g7522 From 2060a0302ece8734c1f91479deb7c458f3db10b3 Mon Sep 17 00:00:00 2001 From: Regia König Date: Thu, 11 Aug 2022 15:30:23 +0200 Subject: GDB Documentation --- documentation/GDB commands | 52 ++++++++++++++++++++++++++++++++++++++++++++++ documentation/gdb commands | 19 ----------------- 2 files changed, 52 insertions(+), 19 deletions(-) create mode 100644 documentation/GDB commands delete mode 100644 documentation/gdb commands (limited to 'documentation') diff --git a/documentation/GDB commands b/documentation/GDB commands new file mode 100644 index 0000000..761eeb9 --- /dev/null +++ b/documentation/GDB commands @@ -0,0 +1,52 @@ +################################################################### +###################### ############################# +### GDB COMMANDS ### +###################### ############################# +################################################################### + +1. QEMU CONFIGURATION + + qemu must be started with "-s" option + (shorthand for "-gdb tcp::1234") + + +2. GDB PART - CONNECTION + - source gdbscript + (if a gdbscript is created, which contains + add-symbol-file commandos) + + - target remote localhost:1234 + + +3. BREAKPOINTS + + - b CoreHandleProtocol | or OutputString + + +4. INFORMATION + + - info + files || get Entry point + sections + address SYM + all-registers || all registers & their contents + args || Argument variables of current stack frame + breakpoints + files || Names of targets & files being debugged + functions || all function names + locals || local variables of current stack frame + variables || all gloabl & static variables + +5. CONTROL FLOW + + - c + - bt || print back_trace of all stack frames + - stop || stop program until it reaches a different source line + +6. FILES (perhaps not applicable when debugging with QEMU) + + - file MemtestEfi.efi || load file ...no debugging symbols found...done + - file || unload files + +7. LIST + + - list || list specified function or line diff --git a/documentation/gdb commands b/documentation/gdb commands deleted file mode 100644 index 416a758..0000000 --- a/documentation/gdb commands +++ /dev/null @@ -1,19 +0,0 @@ -GDB COMMANDS -============ - -qemu must be started with "-s" option (shorthand for "-gdb tcp::1234") - -source gdbscript - -file MemtestEfi.efi || load file ...no debugging symbols found...done -info files || get Entry point + sections -file || unload files - -b CoreHandleProtocol | or OutputString - -target remote localhost:1234 - -c -bt || print back_trace of all stack frames -stop || stop program until it reaches a different source line -list || list specified function or line -- cgit v1.2.3-55-g7522 From 848f0624bcdb1c1f60268852cfde5c71e07ee66a Mon Sep 17 00:00:00 2001 From: Regia König Date: Sun, 14 Aug 2022 21:10:17 +0200 Subject: New script for running qemu and GDB documentation --- documentation/GDB commands | 51 +++++++++++++++++++++++++++++-------- documentation/QEMU Monitor Commands | 2 +- test_code/test.sh | 5 ++++ 3 files changed, 46 insertions(+), 12 deletions(-) create mode 100755 test_code/test.sh (limited to 'documentation') diff --git a/documentation/GDB commands b/documentation/GDB commands index 761eeb9..992a6cd 100644 --- a/documentation/GDB commands +++ b/documentation/GDB commands @@ -4,49 +4,78 @@ ###################### ############################# ################################################################### -1. QEMU CONFIGURATION +QEMU CONFIGURATION qemu must be started with "-s" option (shorthand for "-gdb tcp::1234") +# +# GDB PART +# -2. GDB PART - CONNECTION +CONNECTION - source gdbscript (if a gdbscript is created, which contains add-symbol-file commandos) - target remote localhost:1234 +DISCONNECTION + - detach + break connection with target, target resumes execution + GDB Target + (RSP Client) (RSP Server) + D + O------------------------------>O + O RSP exchange + O<------------------------------O + OK + -disconnect + Simply break connection. Target stays at the point where execution terminated previously + Reconnection(target remote): resume debugging at the point where the previous connection was broken -3. BREAKPOINTS +BREAKPOINTS - - b CoreHandleProtocol | or OutputString + - b CoreHandleProtocol || or OutputString + - break *0x65fe447 || set breakpoint at address -4. INFORMATION +INFORMATION - - info - files || get Entry point + sections + - info address SYM + all-registers || all registers & their contents + args || Argument variables of current stack frame + breakpoints + + files || get Entry point + sections files || Names of targets & files being debugged - functions || all function names + + functions || all function names in Program + functions UefiMain || show where this function occurs + locals || local variables of current stack frame + + symbol ADDR || Show symbol at specified address + + types [regex] || list all types or with regex + variables || all gloabl & static variables -5. CONTROL FLOW +CONTROL FLOW - c - bt || print back_trace of all stack frames - stop || stop program until it reaches a different source line -6. FILES (perhaps not applicable when debugging with QEMU) +FILES (perhaps not applicable when debugging with QEMU) - file MemtestEfi.efi || load file ...no debugging symbols found...done - file || unload files -7. LIST +LIST - list || list specified function or line diff --git a/documentation/QEMU Monitor Commands b/documentation/QEMU Monitor Commands index 4fbb27e..bae7cf7 100644 --- a/documentation/QEMU Monitor Commands +++ b/documentation/QEMU Monitor Commands @@ -8,7 +8,7 @@ - within viewer: Ctrl + Alt + 2 - exit with Ctrl + Alt + + exit with Ctrl + Alt + 1 - as QEMU parameter to get monitor in terminal: -monitor stdio diff --git a/test_code/test.sh b/test_code/test.sh new file mode 100755 index 0000000..5c9ff29 --- /dev/null +++ b/test_code/test.sh @@ -0,0 +1,5 @@ + +#!\bin\bash + +sudo qemu-system-x86_64 -s -bios ./OVMF.fd -hda fat:rw:hda-contents \ +-net none -debugcon file:debug.log -global isa-debugcon.iobase=0x402 -S -- cgit v1.2.3-55-g7522 From 269455db17eb974d7ff6608666b6b68b27336088 Mon Sep 17 00:00:00 2001 From: Regia König Date: Sun, 14 Aug 2022 21:32:00 +0200 Subject: test.sh now also has OVMF_VARS and OVMF_CODE --- documentation/GDB commands | 12 ++++++++++++ test_code/test.sh | 7 +++++-- 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'documentation') diff --git a/documentation/GDB commands b/documentation/GDB commands index 992a6cd..a6db0cc 100644 --- a/documentation/GDB commands +++ b/documentation/GDB commands @@ -38,6 +38,8 @@ BREAKPOINTS - b CoreHandleProtocol || or OutputString - break *0x65fe447 || set breakpoint at address + - delete 2 || delete breakpoint no 2 + - break sampleApp.c:nn=LineNumber INFORMATION @@ -79,3 +81,13 @@ FILES (perhaps not applicable when debugging with QEMU) LIST - list || list specified function or line + +gdb --tui + - layout asm + - layout reg + - layout src + + - tui enable + - tui disable + + - next diff --git a/test_code/test.sh b/test_code/test.sh index 5c9ff29..63933a5 100755 --- a/test_code/test.sh +++ b/test_code/test.sh @@ -1,5 +1,8 @@ #!\bin\bash -sudo qemu-system-x86_64 -s -bios ./OVMF.fd -hda fat:rw:hda-contents \ --net none -debugcon file:debug.log -global isa-debugcon.iobase=0x402 -S +sudo qemu-system-x86_64 -s -bios ./OVMF.fd \ + -hda fat:rw:hda-contents \ + -drive if=pflash,format=raw,readonly,file=OVMF_CODE.fd \ + -drive if=pflash,format=raw,file=OVMF_VARS.fd \ + -net none -debugcon file:debug.log -global isa-debugcon.iobase=0x402 -S -- cgit v1.2.3-55-g7522 From c74fca5e3c4ff12865c57ba83702ae6586fa45a8 Mon Sep 17 00:00:00 2001 From: Regia König Date: Mon, 15 Aug 2022 17:09:30 +0200 Subject: More documentation --- documentation/DEBUG statement | 10 ++++++++++ documentation/Debugging in Qemu | 41 +++++++++++++++++++++++++++++++++++++++++ documentation/GDB commands | 7 ++++++- documentation/debug statement | 1 - documentation/debugcon | 11 +++++++++++ 5 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 documentation/DEBUG statement create mode 100644 documentation/Debugging in Qemu delete mode 100644 documentation/debug statement create mode 100644 documentation/debugcon (limited to 'documentation') diff --git a/documentation/DEBUG statement b/documentation/DEBUG statement new file mode 100644 index 0000000..eb110ff --- /dev/null +++ b/documentation/DEBUG statement @@ -0,0 +1,10 @@ + +Library to include: +#include "Library/DebugLib.h" + +DEBUG (("%a: %d\n", _FUNCTION_, _LINE_)); + +example: + +DEBUG((EFI_D_INFO, "My Entry Point: 0x%08x\r\n",(CHAR16*)UefiMain)); + diff --git a/documentation/Debugging in Qemu b/documentation/Debugging in Qemu new file mode 100644 index 0000000..6d43b3e --- /dev/null +++ b/documentation/Debugging in Qemu @@ -0,0 +1,41 @@ +######################################### +# # +# Ways to debug in Qemu # +# # +######################################### + +DEBUGCON +############### + +-debugcon file:debug.log -global isa-debugcon.iobase=0x402 + +SERIAL +############### + +-serial stdio + redirects the virtual serial port to the host's terminal i/o + +TRACE +############### + +-D ./qemu_log.txt +-d guest_errors, nochain, exec, in_asm, out_asm, op, op_opt, op_ind, int, cpu, mmu, pcall, cpu_reset, unimp, page + +--trace "memory_region*" + +MONITOR +############### + +-monitor stdio + +or + +Ctrl + Alt + 2 (Exit with Ctrl + Alt + 1) + +GDB - GNU DEBUGGER +##################### + +-s -S (when starting qemu) + +(gdb) target remote localhost:1234 +(gdb) c diff --git a/documentation/GDB commands b/documentation/GDB commands index a6db0cc..64ea1b8 100644 --- a/documentation/GDB commands +++ b/documentation/GDB commands @@ -13,6 +13,10 @@ QEMU CONFIGURATION # GDB PART # +SYMBOL FILES + add-symbol-file Hello.debug 0x... -s .data 0x... + + CONNECTION - source gdbscript (if a gdbscript is created, which contains @@ -69,7 +73,8 @@ INFORMATION CONTROL FLOW - - c + - c || continue + - next || move only one step forward - bt || print back_trace of all stack frames - stop || stop program until it reaches a different source line diff --git a/documentation/debug statement b/documentation/debug statement deleted file mode 100644 index a8e192c..0000000 --- a/documentation/debug statement +++ /dev/null @@ -1 +0,0 @@ -DEBUG (("%a: %d\n", _FUNCTION_, _LINE_)); diff --git a/documentation/debugcon b/documentation/debugcon new file mode 100644 index 0000000..5d914f5 --- /dev/null +++ b/documentation/debugcon @@ -0,0 +1,11 @@ +######################### +# # +# DEBUGCON # +# # +######################### + +for debug already in early bootphases +One can connect the I/O port to either a file or a device, like /dev/stdout + - debugcon /dev/stdout (terminal that started Qemu process) + - debugcon file:qemu/debug.log (or other file name) + -- cgit v1.2.3-55-g7522 From 942dc01a998f8e60f57c8816264b16f4117da266 Mon Sep 17 00:00:00 2001 From: Regia König Date: Tue, 16 Aug 2022 11:33:08 +0200 Subject: Reorder GDB commands --- documentation/GDB commands | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'documentation') diff --git a/documentation/GDB commands b/documentation/GDB commands index 64ea1b8..3316a38 100644 --- a/documentation/GDB commands +++ b/documentation/GDB commands @@ -49,11 +49,10 @@ BREAKPOINTS INFORMATION - info - address SYM + address SYM || Get address for symbol SYM + symbol ADDR || Show symbol at specified address all-registers || all registers & their contents - - args || Argument variables of current stack frame breakpoints @@ -63,14 +62,15 @@ INFORMATION functions || all function names in Program functions UefiMain || show where this function occurs - locals || local variables of current stack frame - - symbol ADDR || Show symbol at specified address + line types [regex] || list all types or with regex + args || Argument variables of current stack frame + locals || local variables of current stack frame variables || all gloabl & static variables + CONTROL FLOW - c || continue -- cgit v1.2.3-55-g7522 From 5e97f0a420d0ae8e92332911de99ad642d5ae005 Mon Sep 17 00:00:00 2001 From: Regia König Date: Tue, 16 Aug 2022 12:05:41 +0200 Subject: New documentation file to how to create a HelloWorl.efi with GNU-efi --- documentation/GNU-efi | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 documentation/GNU-efi (limited to 'documentation') diff --git a/documentation/GNU-efi b/documentation/GNU-efi new file mode 100644 index 0000000..7fb0f1f --- /dev/null +++ b/documentation/GNU-efi @@ -0,0 +1,5 @@ +################################################################## +## ## +## BUILDING HELLOWORLD.EFI WIH GNU-EFI ## +## ## +################################################################## -- cgit v1.2.3-55-g7522 From df931e3b4bc07ac752ab92075dfffc32bde5f50e Mon Sep 17 00:00:00 2001 From: Regia König Date: Tue, 16 Aug 2022 12:56:08 +0200 Subject: Minimal working example with GNU-efi --- GNU_efi_HelloWorld/.gitignore | 1 + GNU_efi_HelloWorld/Makefile | 9 ++-- GNU_efi_HelloWorld/hello.c | 1 + GNU_efi_HelloWorld/hello.efi | Bin 0 -> 45555 bytes GNU_efi_HelloWorld/hello.o | Bin 1696 -> 1664 bytes GNU_efi_HelloWorld/hello.so | Bin 0 -> 2170968 bytes documentation/GNU-efi | 111 ++++++++++++++++++++++++++++++++++++++++-- test_code/OVMF_VARS.fd | Bin 540672 -> 540672 bytes 8 files changed, 112 insertions(+), 10 deletions(-) create mode 100644 GNU_efi_HelloWorld/.gitignore create mode 100755 GNU_efi_HelloWorld/hello.efi create mode 100755 GNU_efi_HelloWorld/hello.so (limited to 'documentation') diff --git a/GNU_efi_HelloWorld/.gitignore b/GNU_efi_HelloWorld/.gitignore new file mode 100644 index 0000000..ca4663b --- /dev/null +++ b/GNU_efi_HelloWorld/.gitignore @@ -0,0 +1 @@ +gnu-efi diff --git a/GNU_efi_HelloWorld/Makefile b/GNU_efi_HelloWorld/Makefile index 4f00d4a..31195ee 100644 --- a/GNU_efi_HelloWorld/Makefile +++ b/GNU_efi_HelloWorld/Makefile @@ -1,12 +1,11 @@ ARCH = $(shell uname -m | sed s,i[3456789]86,ia32,) -OBJS = main.o +OBJS = hello.o TARGET = hello.efi EFIINC = /usr/include/efi -EFFINCS = -I$(EFFINC) -I$(EFIINC)/$(ARCH) -I$(EFIINC)/protocol -LIB = /usr/lib64 -EFILIB = /usr/lib64/gnuefi +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 @@ -18,7 +17,7 @@ ifeq ($(ARCH),x86_64) endif LDFLAGS = -nostdlib -znocombreloc -T $(EFI_LDS) -shared \ - -Bsymbolic -L $(EFILIB) -L $(LIB) $(EFI_CRT_OBJS) + -Bsymbolic -L $(EFILIB) $(EFI_CRT_OBJS) all: $(TARGET) diff --git a/GNU_efi_HelloWorld/hello.c b/GNU_efi_HelloWorld/hello.c index 26cbd42..52c05b3 100644 --- a/GNU_efi_HelloWorld/hello.c +++ b/GNU_efi_HelloWorld/hello.c @@ -4,6 +4,7 @@ EFI_STATUS EFIAPI efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) { + InitializeLib(ImageHandle, SystemTable); Print(L"Hello, world!\n"); diff --git a/GNU_efi_HelloWorld/hello.efi b/GNU_efi_HelloWorld/hello.efi new file mode 100755 index 0000000..27145e5 Binary files /dev/null and b/GNU_efi_HelloWorld/hello.efi differ diff --git a/GNU_efi_HelloWorld/hello.o b/GNU_efi_HelloWorld/hello.o index 6e14a71..22a8362 100644 Binary files a/GNU_efi_HelloWorld/hello.o and b/GNU_efi_HelloWorld/hello.o differ diff --git a/GNU_efi_HelloWorld/hello.so b/GNU_efi_HelloWorld/hello.so new file mode 100755 index 0000000..bc418e3 Binary files /dev/null and b/GNU_efi_HelloWorld/hello.so differ diff --git a/documentation/GNU-efi b/documentation/GNU-efi index 7fb0f1f..8dddc4a 100644 --- a/documentation/GNU-efi +++ b/documentation/GNU-efi @@ -1,5 +1,106 @@ -################################################################## -## ## -## BUILDING HELLOWORLD.EFI WIH GNU-EFI ## -## ## -################################################################## +################################################################################## +## ## +## BUILDING HELLOWORLD.EFI WIH GNU-EFI ## +## ## +################################################################################## + +################################################################################# +# SUMMARY # +################################################################################# + +Minimal working example: + + hello.c +--------------------------------------------------------------------------------- +#include +#include + +EFI_STATUS +EFIAPI +efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) { + + InitializeLib(ImageHandle, SystemTable); + Print(L"Hello, world!\n"); + + return EFI_SUCCESS; +} + + +Makefile +-------------------------------------------------------------------------------- +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) + +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) $^ $@ + + + + +################################################################################# +# https://wiki.osdev.org/GNU-EFI # +################################################################################# + +GNU-EFI is a very lightweight developing environment to create UEFI applications. +It is a set of libraries and headers for compiling UEFI applications with a +system's native GCC. + +You can use host native compiler, then convert resulting ELF into UEFI-compatible +PE. + OR +Use GCC Cross-Compiler generating PE directly. + +********************************************************************************* +* $ git clone https://git.code.sf.net/p/gnu-efi/code gnu-efi * +* $ cd gnu-efi * +* $ make * +********************************************************************************* + +This should create +* crt0-efi-x86_64.o: + A CRT0 (C runtime initialization code) that will call the + "efi_main" function + +* libgnuefi.a: + A library containing a single function (_relocate) + that is used by the CRT0 + +* (optional) libefi.a: + A library containing convenience functions like CRC computation, string + length calculation, and easy text printing + +HEADERS can be used from: +* /usr/include/efi (updated to the latest) +* from EDK2 package +* Or from gnu-efi/inc + +LINKER SCRIPT: +* gnu-efi/gnuefi/elf_x86_64_efi.lds + OR +* /usr/lib/elf_x86_64_efi.lds + diff --git a/test_code/OVMF_VARS.fd b/test_code/OVMF_VARS.fd index a7fab53..9883b80 100644 Binary files a/test_code/OVMF_VARS.fd and b/test_code/OVMF_VARS.fd differ -- cgit v1.2.3-55-g7522 From af267979164d1bb9f412705e22fc64ab00b7d899 Mon Sep 17 00:00:00 2001 From: Regia König Date: Tue, 16 Aug 2022 16:20:17 +0200 Subject: More documentation on GNU-efi --- documentation/GNU-efi | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) (limited to 'documentation') diff --git a/documentation/GNU-efi b/documentation/GNU-efi index 8dddc4a..bb22b9e 100644 --- a/documentation/GNU-efi +++ b/documentation/GNU-efi @@ -104,3 +104,72 @@ LINKER SCRIPT: OR * /usr/lib/elf_x86_64_efi.lds +COMPILATION: +$ gcc + -Ignu-efi-dir/inc || set this to the efi headers directory + + -fpic || UEFI PE executable must be relocatable + + -ffreestanding || there's no hosted gcc environment, + we don't have libc + -fno-stack-protector = + -fno-stack-check || stack must be strictly used, + || no additional canaries or + || pre-allocated local variable + || space allowed + -mno-red-zone = + + -fshort-wchar || It is very important that UEFI + || uses 16bit characters + || (wide-characters or wchar_t, + || defined as CHAR16 in efi headers + + -maccumulate-outgoing-args || function calls must include the + || number of argumnets passed to the + || functions + + -c main.c -o main.o + +LINKING: +$ ld -shared -Bsymbolic -Lgnu-efi-dir/x86_64/lib -Lgnu-efi-dir/x86_64/gnuefi \ + -Tgnu-efi-dir/gnuefi/elf_x86_64_efi.lds \ + gnu-efi-dir/x86_64/gnuefi/crt0-efi-x86_64.o \ + main.o -o main.so -lgnuefi -lefi + + -shared -Bsymbolic || tell GNU ld to create so (shared library) + + -L and -T || Where to find the static GNU-EFI libraries + || (.a) and the linker script + + .o || it is important to specify crt0 as the + || first. Should work as the last too, but + || some had problems + + -l || linking with gnuefi is a must, as that + || contains the relocation code. Linking + || with efi is optional, but recommended + +CONVERT CHARED OBJECT TO EFI EXECUTABLE +$ objcopy -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel -j .rela -j .rel.* + -j .rela.* -j .reloc --target efi-app-x86_64 --subsystem=10 main.so main.efi + + -j || which sections to keep during convertion + + --target efi-app-x86_64 || tells objcop to generate a PE32+ format, + || with architecture code 0x8664 + + --subsystem=10: || most important. Sets file type to UEFI + || executable in the PE header + +Now you can copy main.efi to your EFI System Partition, and after boot run it +from the EFI Shell. Or you can rename it to EFI\BOOT\BOOTX64.EFI and it should +be executed automatically on boot. + + + + + + + + + -- cgit v1.2.3-55-g7522 From d46d26a260f5882b2559949aa43e8fb47bd16a7e Mon Sep 17 00:00:00 2001 From: Regia König Date: Tue, 16 Aug 2022 16:37:50 +0200 Subject: New script to analyze efi executable --- GNU_efi_HelloWorld/analyse_hello.sh | 8 ++++++++ GNU_efi_HelloWorld/hello.c | 3 +++ GNU_efi_HelloWorld/peinfo | Bin 0 -> 27600 bytes documentation/GNU-efi | 9 +++++++++ 4 files changed, 20 insertions(+) create mode 100755 GNU_efi_HelloWorld/analyse_hello.sh create mode 100755 GNU_efi_HelloWorld/peinfo (limited to 'documentation') diff --git a/GNU_efi_HelloWorld/analyse_hello.sh b/GNU_efi_HelloWorld/analyse_hello.sh new file mode 100755 index 0000000..cfaad73 --- /dev/null +++ b/GNU_efi_HelloWorld/analyse_hello.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +echo "objdump -h hello.efi" +objdump -h hello.efi + +echo "########################################################################" +echo "peinfo hello.efi | grep text -A 5" +peinfo hello.efi | grep text -A 5 diff --git a/GNU_efi_HelloWorld/hello.c b/GNU_efi_HelloWorld/hello.c index 52c05b3..817c135 100644 --- a/GNU_efi_HelloWorld/hello.c +++ b/GNU_efi_HelloWorld/hello.c @@ -8,5 +8,8 @@ efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) { InitializeLib(ImageHandle, SystemTable); Print(L"Hello, world!\n"); + // TODO: get SystemTable-> ... -> ImageBase + // Print ImageBase + return EFI_SUCCESS; } diff --git a/GNU_efi_HelloWorld/peinfo b/GNU_efi_HelloWorld/peinfo new file mode 100755 index 0000000..4645ea4 Binary files /dev/null and b/GNU_efi_HelloWorld/peinfo differ diff --git a/documentation/GNU-efi b/documentation/GNU-efi index bb22b9e..63097fe 100644 --- a/documentation/GNU-efi +++ b/documentation/GNU-efi @@ -166,8 +166,17 @@ from the EFI Shell. Or you can rename it to EFI\BOOT\BOOTX64.EFI and it should be executed automatically on boot. +LIBEFI.A +Has wrappers for the most common UEFI functions, but you might need to call +something not covered. For completeness, it provides: +uefi_call_wrapper(func, numarg, ...); + +For example, the "Print" function used in our main.c and which accepts printf +compatible arguments, is under the hood nothing else than a call to: + +uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, buffer); -- cgit v1.2.3-55-g7522 From 2e92efaf304e20d573e6b1ce1820adaf4052088f Mon Sep 17 00:00:00 2001 From: Regia König Date: Tue, 16 Aug 2022 16:42:14 +0200 Subject: Documentation GNU-efi --- documentation/GNU-efi | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'documentation') diff --git a/documentation/GNU-efi b/documentation/GNU-efi index 63097fe..27c77e3 100644 --- a/documentation/GNU-efi +++ b/documentation/GNU-efi @@ -178,6 +178,12 @@ compatible arguments, is under the hood nothing else than a call to: uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, buffer); +The biggest advantage of 'uefi_call_wrapper_ is that doesn't matter what ABI +your gcc is using, it will always correctly translate thet into UEFI ABI. If, +and only if you've used the correct gcc options, then you should be able to +make the same call as: + +ST->ConOut->OutputString(ST->ConOut, buffer); -- cgit v1.2.3-55-g7522 From 3e6d1f5389cb77055e3860c801dbcc99bb4518ec Mon Sep 17 00:00:00 2001 From: Regia König Date: Tue, 16 Aug 2022 16:54:09 +0200 Subject: Efi file outputs own image base --- GNU_efi_HelloWorld/analyse_hello.sh | 2 +- GNU_efi_HelloWorld/hello.c | 21 +++++++++++++++++++-- GNU_efi_HelloWorld/hello.efi | Bin 45555 -> 46888 bytes GNU_efi_HelloWorld/hello.o | Bin 1664 -> 2112 bytes GNU_efi_HelloWorld/hello.so | Bin 2170968 -> 2171456 bytes documentation/GNU-efi | 4 +++- test_code/OVMF_VARS.fd | Bin 540672 -> 540672 bytes 7 files changed, 23 insertions(+), 4 deletions(-) (limited to 'documentation') diff --git a/GNU_efi_HelloWorld/analyse_hello.sh b/GNU_efi_HelloWorld/analyse_hello.sh index cfaad73..c8b3103 100755 --- a/GNU_efi_HelloWorld/analyse_hello.sh +++ b/GNU_efi_HelloWorld/analyse_hello.sh @@ -5,4 +5,4 @@ objdump -h hello.efi echo "########################################################################" echo "peinfo hello.efi | grep text -A 5" -peinfo hello.efi | grep text -A 5 +./peinfo hello.efi | grep text -A 5 diff --git a/GNU_efi_HelloWorld/hello.c b/GNU_efi_HelloWorld/hello.c index 817c135..171db1e 100644 --- a/GNU_efi_HelloWorld/hello.c +++ b/GNU_efi_HelloWorld/hello.c @@ -5,11 +5,28 @@ EFI_STATUS EFIAPI efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) { + EFI_LOADED_IMAGE *loaded_image = NULL; + EFI_STATUS status; + InitializeLib(ImageHandle, SystemTable); Print(L"Hello, world!\n"); - // TODO: get SystemTable-> ... -> ImageBase - // Print ImageBase + status = uefi_call_wrapper(SystemTable->BootServices->HandleProtocol, + 3, + ImageHandle, + &LoadedImageProtocol, + (void **)&loaded_image); + + if (EFI_ERROR(status)) { + Print(L"handleprotocol: %r\n", status); + } + + Print(L"Image base: 0x%lx\n", loaded_image->ImageBase); + + int wait = 1; + while(wait) { + __asm__ __volatile__("pause"); + } return EFI_SUCCESS; } diff --git a/GNU_efi_HelloWorld/hello.efi b/GNU_efi_HelloWorld/hello.efi index 27145e5..c8399c0 100755 Binary files a/GNU_efi_HelloWorld/hello.efi and b/GNU_efi_HelloWorld/hello.efi differ diff --git a/GNU_efi_HelloWorld/hello.o b/GNU_efi_HelloWorld/hello.o index 22a8362..21583fe 100644 Binary files a/GNU_efi_HelloWorld/hello.o and b/GNU_efi_HelloWorld/hello.o differ diff --git a/GNU_efi_HelloWorld/hello.so b/GNU_efi_HelloWorld/hello.so index bc418e3..b64f729 100755 Binary files a/GNU_efi_HelloWorld/hello.so and b/GNU_efi_HelloWorld/hello.so differ diff --git a/documentation/GNU-efi b/documentation/GNU-efi index 27c77e3..5d75960 100644 --- a/documentation/GNU-efi +++ b/documentation/GNU-efi @@ -186,5 +186,7 @@ make the same call as: ST->ConOut->OutputString(ST->ConOut, buffer); - +################################################################################# +# https://wiki.osdev.org/Debugging_UEFI_applications_with_GDB # +################################################################################# diff --git a/test_code/OVMF_VARS.fd b/test_code/OVMF_VARS.fd index 9883b80..852d584 100644 Binary files a/test_code/OVMF_VARS.fd and b/test_code/OVMF_VARS.fd differ -- cgit v1.2.3-55-g7522 From bc78d650cfe0b759a48afba17686671ac67c9387 Mon Sep 17 00:00:00 2001 From: Regia König Date: Wed, 17 Aug 2022 10:49:27 +0200 Subject: Expand analyzation script --- GNU_efi_HelloWorld/Makefile | 1 + GNU_efi_HelloWorld/analyse_hello.sh | 8 -------- GNU_efi_HelloWorld/hello.c | 5 ++++- GNU_efi_HelloWorld/hello.efi | Bin 46888 -> 46888 bytes GNU_efi_HelloWorld/hello.o | Bin 2112 -> 2112 bytes GNU_efi_HelloWorld/hello.so | Bin 2171456 -> 2171456 bytes documentation/GDB commands | 2 ++ test_code/OVMF_VARS.fd | Bin 540672 -> 540672 bytes test_code/analyse_hello.sh | 13 +++++++++++++ 9 files changed, 20 insertions(+), 9 deletions(-) delete mode 100755 GNU_efi_HelloWorld/analyse_hello.sh create mode 100755 test_code/analyse_hello.sh (limited to 'documentation') diff --git a/GNU_efi_HelloWorld/Makefile b/GNU_efi_HelloWorld/Makefile index 31195ee..448e3f7 100644 --- a/GNU_efi_HelloWorld/Makefile +++ b/GNU_efi_HelloWorld/Makefile @@ -20,6 +20,7 @@ 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 diff --git a/GNU_efi_HelloWorld/analyse_hello.sh b/GNU_efi_HelloWorld/analyse_hello.sh deleted file mode 100755 index c8b3103..0000000 --- a/GNU_efi_HelloWorld/analyse_hello.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -echo "objdump -h hello.efi" -objdump -h hello.efi - -echo "########################################################################" -echo "peinfo hello.efi | grep text -A 5" -./peinfo hello.efi | grep text -A 5 diff --git a/GNU_efi_HelloWorld/hello.c b/GNU_efi_HelloWorld/hello.c index 171db1e..f40df6e 100644 --- a/GNU_efi_HelloWorld/hello.c +++ b/GNU_efi_HelloWorld/hello.c @@ -1,5 +1,6 @@ #include #include +#include EFI_STATUS EFIAPI @@ -23,7 +24,9 @@ efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) { Print(L"Image base: 0x%lx\n", loaded_image->ImageBase); - int wait = 1; + DEBUG((D_ERROR, "AllocatePool: out of pool %x\n", status)); + + volatile int wait = 1; while(wait) { __asm__ __volatile__("pause"); } diff --git a/GNU_efi_HelloWorld/hello.efi b/GNU_efi_HelloWorld/hello.efi index c8399c0..f8ea7e2 100755 Binary files a/GNU_efi_HelloWorld/hello.efi and b/GNU_efi_HelloWorld/hello.efi differ diff --git a/GNU_efi_HelloWorld/hello.o b/GNU_efi_HelloWorld/hello.o index 21583fe..37f6971 100644 Binary files a/GNU_efi_HelloWorld/hello.o and b/GNU_efi_HelloWorld/hello.o differ diff --git a/GNU_efi_HelloWorld/hello.so b/GNU_efi_HelloWorld/hello.so index b64f729..089f3f7 100755 Binary files a/GNU_efi_HelloWorld/hello.so and b/GNU_efi_HelloWorld/hello.so differ diff --git a/documentation/GDB commands b/documentation/GDB commands index 3316a38..1cbd2ac 100644 --- a/documentation/GDB commands +++ b/documentation/GDB commands @@ -96,3 +96,5 @@ gdb --tui - tui disable - next + + - ctrl+x o || change active window diff --git a/test_code/OVMF_VARS.fd b/test_code/OVMF_VARS.fd index 852d584..d1888bc 100644 Binary files a/test_code/OVMF_VARS.fd and b/test_code/OVMF_VARS.fd differ diff --git a/test_code/analyse_hello.sh b/test_code/analyse_hello.sh new file mode 100755 index 0000000..2e9187f --- /dev/null +++ b/test_code/analyse_hello.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +echo "#### \$objdump -h hello.efi" +objdump -h hda-contents/hello.efi + +echo "########################################################################" +echo "#### \$peinfo hello.efi | grep text -A 5" +./peinfo hda-contents/hello.efi | grep text -A 5 + + +echo "########################################################################" +echo "#### \$cat debug.log | grep hello -A 5" +cat debug.log | grep hello -A 5 -- cgit v1.2.3-55-g7522 From 0b7cb74a17a6eea07b2d9319db33ec3332db0216 Mon Sep 17 00:00:00 2001 From: Regia König Date: Wed, 17 Aug 2022 11:50:55 +0200 Subject: Save old Makefile version without debug, but running --- GNU_efi_HelloWorld/Makefile_save | 36 ++++++++++++++++++++++++++++++++++++ documentation/GNU-efi | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 GNU_efi_HelloWorld/Makefile_save (limited to 'documentation') 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) * +********************************************************************************* + + + + + + + + + + + + + + -- cgit v1.2.3-55-g7522 From b6292481be3cd4e9855ad40e3e4f87679a4a6c47 Mon Sep 17 00:00:00 2001 From: Regia König Date: Wed, 17 Aug 2022 15:36:55 +0200 Subject: Subtask 'hello.efi with gdb' completed --- GNU_efi_HelloWorld/Makefile | 28 ++++++---- GNU_efi_HelloWorld/example_Makefile | 96 +++++++++++++++++++++++++++++++++ GNU_efi_HelloWorld/hello.c | 1 - GNU_efi_HelloWorld/hello.debug | Bin 0 -> 123240 bytes GNU_efi_HelloWorld/hello.efi | Bin 46888 -> 46888 bytes documentation/GDB commands | 22 +++++++- documentation/GNU-efi | 77 ++++++++++++++++++++++++-- documentation/gdb with efi application | 0 test_code/OVMF_VARS.fd | Bin 540672 -> 540672 bytes 9 files changed, 210 insertions(+), 14 deletions(-) create mode 100644 GNU_efi_HelloWorld/example_Makefile create mode 100755 GNU_efi_HelloWorld/hello.debug delete mode 100644 documentation/gdb with efi application (limited to 'documentation') 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 +# 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 #include -#include EFI_STATUS EFIAPI diff --git a/GNU_efi_HelloWorld/hello.debug b/GNU_efi_HelloWorld/hello.debug new file mode 100755 index 0000000..f7fd077 Binary files /dev/null and b/GNU_efi_HelloWorld/hello.debug differ diff --git a/GNU_efi_HelloWorld/hello.efi b/GNU_efi_HelloWorld/hello.efi index f8ea7e2..59e1a03 100755 Binary files a/GNU_efi_HelloWorld/hello.efi and b/GNU_efi_HelloWorld/hello.efi differ diff --git a/documentation/GDB commands b/documentation/GDB commands index 1cbd2ac..ef02570 100644 --- a/documentation/GDB commands +++ b/documentation/GDB commands @@ -14,7 +14,7 @@ QEMU CONFIGURATION # SYMBOL FILES - add-symbol-file Hello.debug 0x... -s .data 0x... + add-symbol-file /path/to/Hello.debug 0x... -s .data 0x... CONNECTION @@ -98,3 +98,23 @@ gdb --tui - next - ctrl+x o || change active window + +VARIABLES + info locals + info variables + info args + + || Set is the same as print except that the expression's value is not printed + || and is not put in the value history. + || if your program has a variable width, you get an error if you try to set + || a new value with just ‘set width=13’, because GDB has the command set width + || To avoid to set silently general variables to invalid values, ALWAYS use + || set var x=4 + print x=4 + set x=4 or set variable x=4 + whatis x -> type = double + + + + + diff --git a/documentation/GNU-efi b/documentation/GNU-efi index 1efe81c..40cd91f 100644 --- a/documentation/GNU-efi +++ b/documentation/GNU-efi @@ -59,7 +59,18 @@ hello.so: $(OBJS) -j .dynsym -j .rel -j .rela -j .reloc \ --target=efi-app-$(ARCH) $^ $@ +----- +Now expanded version in git +Get ImageBase: + Run ./test.sh and then hello.efi...this prints ImageBase + +Get Offsets: + GDB + file hello.efi + -> get text and data offset + file + add-symbol-file hello.efi (ImageBase+text-off) -s .data (ImageBase+data-off) ################################################################################# @@ -210,12 +221,72 @@ you need to add ImageBase address to their offsets: * 3000 - ... is .text * * c00 - ... is .data * * (gdb) file || unload file * -* add-symbol-table hello.efi (ImageBase+text-off) -s .data (ImageBase+data-off) * +* add-symbol-file hello.efi (ImageBase+text-off) -s .data (ImageBase+data-off) * ********************************************************************************* +################################################################################# +# https://www.rodsbooks.com/efi-programming/hello.html # +################################################################################# - - +You should not normally include regular C header files, such as stdlib.h, +because most of these header files define data types and functions that are used +by the C library. This library is not available in EFI. + +************************************ +* efi.h and efilib.h always needed * +************************************ + +Entry point: efi_main() in GNU-efi + +CFLAGS: +* -fno-stack-protector: + Stack protection isn't suppoerted by EFI, so there's no point in + building a binary with this feature active. + +* -fpic: + EFI requires that code be position-independet, hence the use + of this option. + +* -fshort-wchar: + GCC defines the wchar_t type to be 32 bits by default, but EFI requires + it to be 16 bits for 16-bit strings to work correctly. + +* fmno-red-zone: + On x86-64 systems, the red zone is an area that follows the stack pointer + that can be used for temporary variables. The EFI may modify this area, + though, so it's not safe to use, and you must compile EFI binaries with + this option. + +* -Wall: + When developing EFI applications, you might want to pay extra attention to + compiler warnings, and this switch (which causes warnings to be treated as + errors) can help. + +* -DEFI_FUNCTION_WRAPPER: + This option is required on the x86_64 platform, but is not defined on the + 32-bit x86 platform. It relates to th calling conventions for EFI functions, + described on the Using EFI Services page. + +LDFLAGS: +* -nostdlib: + An EFI application should not be linked against standard libraries, and this + argument accomplishes this goal. + +* -nocombreloc: + This argument causes the linker to not combine relocation sections. + +* -T $(EFI_LDS): + To create an EFI binary, a non-standard linker script must be used, and this + option tells ld where to find it. + +* -shared: + Even with GNU-EFI's new linker script, ld can't create the final executable. + Instead, it creates a shared library, which is subsequently + turned into the final binary. + +* -Bsymbolic: + This option causes references to global symbols to be bound to the + definitions within the shared library. diff --git a/documentation/gdb with efi application b/documentation/gdb with efi application deleted file mode 100644 index e69de29..0000000 diff --git a/test_code/OVMF_VARS.fd b/test_code/OVMF_VARS.fd index d1888bc..b00bb60 100644 Binary files a/test_code/OVMF_VARS.fd and b/test_code/OVMF_VARS.fd differ -- cgit v1.2.3-55-g7522 From 9c320b5d886af0abb27fce694f5f97e472bef3d6 Mon Sep 17 00:00:00 2001 From: Regia König Date: Mon, 22 Aug 2022 15:26:23 +0200 Subject: Finish gdb_procedure documentation --- GNU_efi_HelloWorld/gdb_procedure | 6 ++++++ documentation/GDB commands | 13 +++++++++++++ test_code/OVMF_VARS.fd | Bin 540672 -> 540672 bytes 3 files changed, 19 insertions(+) (limited to 'documentation') diff --git a/GNU_efi_HelloWorld/gdb_procedure b/GNU_efi_HelloWorld/gdb_procedure index db39c70..2ee853f 100644 --- a/GNU_efi_HelloWorld/gdb_procedure +++ b/GNU_efi_HelloWorld/gdb_procedure @@ -15,4 +15,10 @@ (gdb) b efi_main (gdb) b *0x657e260 +(gdb) info b +(gdb) target remote localhost:1234 +(gdb) c + +(gdb) layout asm +(gdb) layout src diff --git a/documentation/GDB commands b/documentation/GDB commands index ef02570..14b793b 100644 --- a/documentation/GDB commands +++ b/documentation/GDB commands @@ -99,6 +99,19 @@ gdb --tui - ctrl+x o || change active window + - ctrl+x 1 || use TUI layout with one window + - ctrl+x 2 || use TUI layout with two windows + + - PgUp || scroll the active window one page up + - PgDn || scroll the active window one page down + + - Up || scroll the active window one line up + - Down || scroll the active window one lin down + - Right + - Left + + - C+L || refresh the screen + VARIABLES info locals info variables diff --git a/test_code/OVMF_VARS.fd b/test_code/OVMF_VARS.fd index 5cc4003..cfa9ff2 100644 Binary files a/test_code/OVMF_VARS.fd and b/test_code/OVMF_VARS.fd differ -- cgit v1.2.3-55-g7522 From 29a8eebf9231692f965f29221d140e20b0a1f64b Mon Sep 17 00:00:00 2001 From: Regia König Date: Wed, 24 Aug 2022 14:28:23 +0200 Subject: Analyse memtest86 binary structure --- .../24_08_22_memtest_build_process | 205 +++++++++++++++++++++ 1 file changed, 205 insertions(+) create mode 100644 documentation/memtest86_build_process/24_08_22_memtest_build_process (limited to 'documentation') diff --git a/documentation/memtest86_build_process/24_08_22_memtest_build_process b/documentation/memtest86_build_process/24_08_22_memtest_build_process new file mode 100644 index 0000000..9847a5b --- /dev/null +++ b/documentation/memtest86_build_process/24_08_22_memtest_build_process @@ -0,0 +1,205 @@ + +Linker scripts: + memtest_shared.lds + memtest_efi.lds +boot/ + header.S || The standard EFI header + setup.S + efisetup.c || Macros + private functions + || Only for 32-bit boot entry point??? + startup64.S + +*.c files in app/, lib/, system/, tests/ + +########################################################################## +## ## +## MEMTEST LINKING PART 1 - MEMTEST_SHARED ## +## ## +########################################################################## + +# +# memtest_shared.lds +# + +OUTPUT_FORMAT("elf64-x86-64") + +ENTRY(startup64); <--------- in startup64.S + +SECTIONS { + .text : { + _start = .; <---------- First section in memtest_shared-.text + *(.text) + *(.text.*) + ... + + .rodata + .dynsym + .dynstr + .hash + .gnu.hash + .dynamic + + .rela.text + .rela.rodata + .rela.data + .rela.got + .rela.plt + + .data + .got + .bss + +# +# startup64.S +# +118: .globl startup64 +119: startup64: +120: cld +121: cli + + # Save the boot params pointer +125: movq %rsi, boot_params_addr(%rip) + +127: jmp startup + +143: .globl startup +144: startup: + Use startup stack until we pick a correct one + Pick the correct stack + Initialize the pml4 and pdp tables + Set the page directory base address + Initialise the GDT and the segment registers + Load the GDT and the segment registers + Initialise the IDT + Initialise the IDT descriptor + Zero the BSS (if first boot) + Initialise the FPU + Enable SSE + Call the dynamic linker to fix up the addresses in the GOT + +268: call reloc <---------------- system/reloc64.c:151 + get_load_address() + get_dynamic_section_offset() + get_dynamic_info() + do_relocations + +276: call main <---------------- app/main.c:499 # main entry point called from the startup code + +# +# Analysis of the binary +# + +* objdump -h memtest_shared + .text ... File off Algn + 00200000 2**4 + +* objdump -g memtest_shared | grep efi_setup # check for occurences + | grep efi_handover + +* readelf -h memtest_shared + ELF Header: + Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 + Class: ELF64 + Data: 2's complement, little endian + Version: 1 (current) + OS/ABI: UNIX - System V + ABI Version: 0 + Type: DYN (Shared object file) + Machine: Advanced Micro Devices X86-64 + Version: 0x1 + Entry point address: 0x200 <-----------------That's startup64 !!! + Start of program headers: 64 (bytes into file) + Start of section headers: 2821656 (bytes into file) + Flags: 0x0 + Size of this header: 64 (bytes) + Size of program headers: 56 (bytes) + Number of program headers: 3 + Size of section headers: 64 (bytes) + Number of section headers: 26 + Section header string table index: 25 + +* objdump -d memtest_shared + memtest_shared: file format elf64-x86-64 + + Disassembly of section .text: + + 0000000000000000 <_start>: + 0: cld + 1: cli + + 9f: ljmp *-0x6(%rsp) + + 00000000000001e0 : + + 1ed: jmp 210 + + 0000000000000200 : + + 202: mov %rsi,0x23df7(%rip) # 2400 + 209: jmp 220 + + 0000000000000210 : + + 214: callq 68f + 219: mov %rax,0x23de0(%rip) # 2400 + + 0000000000000220 : + + 2ce: ljmp *-0x6(%rsp) + + + +########################################################################## +## ## +## MEMTEST LINKING PART 2 - MEMTEST.EFI ## +## ## +########################################################################## + +# +# memtest_efi.lds +# +OUTPUT_FORMAT("binary") + +ENTRY(boot); <----- in boot/header.S:36 + +SECTIONS { + .header : { <----- boot/header.S + *(.header) + } + .setup : { <----- boot/setup.S + *(.setup) + } + .text : { + _text_start = .; + *(.data) <----- !!! NO .text !!!! + ... + +# +# header.S +# +The EFI loader loads the header at ImageBase, so we have to locate the main program +after that. This means we can't load the main program at HIGH_LOAD_ADDR. Pick a load +address well away from HIGH_LOAD_ADDR, to avoid overlap when relocating code. + +. # define IMAGE_BASE 0x200000 +. # define BASE_OF_CODE 0x1000 <- where do these values come from????? + + .section ".header", "ax", @progbits + .code16 + + .globl boot + +boot: + "MZ", the MS-DOS header signature + .byte 0x4d + .byte 0x5a + +pe_header: + +coff_header: + +... + +# +# setup.S +# -- cgit v1.2.3-55-g7522 From e7897de9471e1d94ad79e2b03fcb8afc685760f1 Mon Sep 17 00:00:00 2001 From: Regia König Date: Thu, 25 Aug 2022 15:08:09 +0200 Subject: Setup.S documentation and new command in create_debug.sh --- Makefile_for_memtest_gdb | 2 +- create_debug.sh | 13 ++++- .../24_08_22_memtest_build_process | 39 +++++++++++++++ memtest_efi_modified.lds | 57 ++++++++++++++++++++-- 4 files changed, 103 insertions(+), 8 deletions(-) (limited to 'documentation') diff --git a/Makefile_for_memtest_gdb b/Makefile_for_memtest_gdb index 58025f7..3413741 100644 --- a/Makefile_for_memtest_gdb +++ b/Makefile_for_memtest_gdb @@ -91,7 +91,7 @@ boot/startup.s: ../boot/startup64.S ../boot/boot.h boot/%.s: ../boot/%.S ../boot/boot.h @mkdir -p boot - $(CC) -E -traditional -I../boot -o $@ $< + $(CC) -E -traditional -fPIC -I../boot -o $@ $< boot/efisetup.o: ../boot/efisetup.c @mkdir -p boot diff --git a/create_debug.sh b/create_debug.sh index ada21f9..45f4c1f 100755 --- a/create_debug.sh +++ b/create_debug.sh @@ -8,6 +8,15 @@ BSS_SIZE=$(size -B -d memtest_shared | grep memtest_shared | tr -s ' ' | cut -d' echo $BSS_SIZE echo "bss_size: $BSS_SIZE" +ld --defsym=_bss_size=$(size -B -d memtest_shared | grep memtest_shared | tr -s ' ' | cut -d ' ' -f3) \ + -shared \ + --print-memory-usage \ + --print-output-format \ + -Bsymbolic \ + -M \ + -nostdlib \ + -T linker_modified.lds \ + -o memtest_modified.efi \ + boot/setup.o boot/startup.o boot/efisetup.o app/*.o lib/*.o system/*.o tests/*.o - -ld --defsym=_bss_size=$BSS_SIZE -T memtest_efi_modified.lds boot/header.o boot/setup.o -b memtest_shared -o memtest_modified.efi +# ld -N --defsym=_bss_size=$BSS_SIZE -T linker_modified.lds boot/header.o boot/setup.o -b elf64-x86-64 memtest_shared -o memtest_modified.efi diff --git a/documentation/memtest86_build_process/24_08_22_memtest_build_process b/documentation/memtest86_build_process/24_08_22_memtest_build_process index 9847a5b..fc8f33c 100644 --- a/documentation/memtest86_build_process/24_08_22_memtest_build_process +++ b/documentation/memtest86_build_process/24_08_22_memtest_build_process @@ -203,3 +203,42 @@ coff_header: # # setup.S # +Collects memory map information from the BIOS, disables APM, enables A20 and performs +the switch from real mode to protected mode before jumping to the main program entry +point. + +The memory map information is stored in the 4KB block of memory immediately following +the setup code. The layout of the information matches the Linux boot_params struct. +A pointer to this block is passed to the main program, for compatibility with the Linux +32-bit boot protocol. + +. # define BOOT_PARAMS_START (SETUP_SECS * 512) || SETUP_SEC is defined in boot.h +. # define BOOT_PARAMS_END (BOOT_PARAMS_START + 4096) <--- here are the 4K + + .section ".setup", "ax", @progbits + .code16 + +Emulate the Linux boot header, to allow loading by other boot loaders. Indicate that the +main program code should be loaded in high memory. + + .globl setup +setup: jmp do_setup + +101: do_setup: + Reload the segment registers, except for the stack + Get the memory map and disable APM + Disable interrupts + Enable A20 + ... + +179: flush: + Reload the segment registers and jump to the main test program <------------!!!! + + ... +188: jump: + data32 ljmp $KERNEL_CS, $0 + + + +389: Pad to the declared size + .org (ESTUP_SECS*512) diff --git a/memtest_efi_modified.lds b/memtest_efi_modified.lds index 179fe93..6f035c8 100644 --- a/memtest_efi_modified.lds +++ b/memtest_efi_modified.lds @@ -1,5 +1,6 @@ -OUTPUT_FORMAT("binary") -OUTPUT_ARCH(i386:x86-64) +OUTPUT_FORMAT("elf64-x86-64"); +OUTPUT_ARCH(i386:x86-64); + ENTRY(boot); SECTIONS { @@ -13,14 +14,60 @@ SECTIONS { . = ALIGN(512); .text : { _text_start = . ; - *(.data) - . = ALIGN(512); + _start = .; + *(.text) + *(.text.*) + *(.plt) + _etext = . ; _text_end = . ; + }= 0x9090 + + .rodata : { + *(.rodata) + *(.rodata.*) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .hash : { *(.hash) } + .gnu.hash : { *(.gnu.hash) } + .dynamic : { *(.dynamic) } + + .rela.text : { *(.rela.text .rela.text.*) } + .rela.rodata : { *(.rela.rodata .rela.rodata.*) } + .rela.data : { *(.rela.data .rela.data.*) } + .rela.got : { *(.rela.got .rela.got.*) } + .rela.plt : { *(.rela.plt .rela.plt.*) } + + . = ALIGN(4); + .data : { + _data = .; + *(.data) + *(.data.*) + } + .got : { + *(.got.plt) + *(.got) + _edata = . ; + } + . = ALIGN(4); + .bss : { + _bss = .; + *(.dynbss) + *(.bss) + *(.bss.*) + *(COMMON) + . = ALIGN(16); + _stacks = .; + *(.stacks) + /* _end must be at least 256 byte aligned */ + . = ALIGN(256); + _end = .; + } + .debug : { *(.debug*) } - + _text_size = (_text_end - _text_start); _sys_size = _text_size >> 4; -- cgit v1.2.3-55-g7522 From e7b7db1268cab0be88a22d52c27ce836729e81a8 Mon Sep 17 00:00:00 2001 From: Regia König Date: Fri, 2 Sep 2022 11:29:26 +0200 Subject: Move scripts for gdb --- documentation/GDB commands | 6 ++ test_code/gdbscript | 104 ------------------------------ test_code/gdbscripts/gdb_relocation_tests | 12 ++++ test_code/gdbscripts/gdbscript | 104 ++++++++++++++++++++++++++++++ test_code/gdbscripts/memtest_gdbscript | 10 +++ test_code/memtest_gdbscript | 10 --- 6 files changed, 132 insertions(+), 114 deletions(-) delete mode 100644 test_code/gdbscript create mode 100644 test_code/gdbscripts/gdb_relocation_tests create mode 100644 test_code/gdbscripts/gdbscript create mode 100644 test_code/gdbscripts/memtest_gdbscript delete mode 100644 test_code/memtest_gdbscript (limited to 'documentation') diff --git a/documentation/GDB commands b/documentation/GDB commands index 14b793b..8411f19 100644 --- a/documentation/GDB commands +++ b/documentation/GDB commands @@ -127,6 +127,12 @@ VARIABLES set x=4 or set variable x=4 whatis x -> type = double +DISSASEMBLE BINARIES + gdb -batch -ex 'file /bin/ls' -ex 'disassemble main' + Also, -ex 'set disassembly-flavor intel' before other -exs will result in Intel assembly syntax + + gcc -O0 -ggdb3 -std=c99 -Wall -Wextra -pedantic -o main.out main.c + gdb -batch -ex "disassemble/rs myfunc" main.out diff --git a/test_code/gdbscript b/test_code/gdbscript deleted file mode 100644 index f0d4a38..0000000 --- a/test_code/gdbscript +++ /dev/null @@ -1,104 +0,0 @@ -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/PcdPeim.debug 0x82c380 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/ReportStatusCodeRouterPei.debug 0x831700 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/StatusCodeHandlerPei.debug 0x833900 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/PlatformPei.debug 0x835a00 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/PeiCore.debug 0x7ee8240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/PcdPeim.debug 0x7ee2240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/DxeIpl.debug 0x7edd240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/S3Resume2Pei.debug 0x7ed8240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/CpuMpPei.debug -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/DxeCore.debug 0x7e8f240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/DevicePathDxe.debug 0x7553240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/PcdDxe.debug 0x754c240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/AmdSevDxe.debug 0x755f240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/TdxDxe.debug 0x7547240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/FvbServicesRuntimeDxe.debug 0x7ae7000 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/ReportStatusCodeRouterRuntimeDxe.debug 0x7ae0000 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/RuntimeDxe.debug 0x7ada000 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/SecurityStubDxe.debug 0x7544240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/EbcDxe.debug 0x7538240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/CpuIo2Dxe.debug 0x7541240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/CpuDxe.debug -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/IncompatiblePciDeviceSupportDxe.debug 0x7128240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/PciHotPlugInitDxe.debug 0x70fc240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/ResetSystemRuntimeDxe.debug 0x7ad3000 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/Metronome.debug 0x7125240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/HiiDatabase.debug 0x70be240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/NullMemoryTestDxe.debug 0x711f240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/AcpiTableDxe.debug 0x70ec240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/S3SaveStateDxe.debug 0x70e5240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/DpcDxe.debug 0x70f9240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/IoMmuDxe.debug 0x70b7240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/EmuVariableFvbRuntimeDxe.debug 0x7acd000 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/VariableRuntimeDxe.debug 0x7ac3000 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/StatusCodeHandlerRuntimeDxe.debug 0x7abe000 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/LocalApicTimerDxe.debug 0x70e2240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/PciHostBridgeDxe.debug 0x70a1240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/SetupBrowser.debug 0x706d240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/SmbiosDxe.debug 0x709a240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/QemuFwCfgAcpiPlatform.debug 0x7092240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/BootScriptExecutorDxe.debug 0x703d240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/tftpDynamicCommand.debug 0x7087240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/httpDynamicCommand.debug 0x702f240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/LinuxInitrdDynamicShellCommand.debug 0x7064240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/LogoDxe.debug 0x70ac240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/QemuRamfbDxe.debug 0x7058240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/FaultTolerantWriteDxe.debug 0x7058240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/PcRtc.debug 0x7ab7000 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/WatchdogTimer.debug 0x7056240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/MonotonicCounterRuntimeDxe.debug 0x7ab3000 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/CapsuleRuntimeDxe.debug 0x7aae000 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/DriverHealthManagerDxe.debug 0x7021240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/BdsDxe.debug 0x6de3240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/RamDiskDxe.debug 0x700b240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/DisplayEngine.debug 0x6dbb240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/SmbiosPlatformDxe.debug 0x7018240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/PlatformDxe.debug 0x7001240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/PciBusDxe.debug 0x6dab240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/VirtioPciDeviceDxe.debug 0x6ddf240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/Virtio10.debug 0x6dda240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/VirtioBlkDxe.debug 0x6dd6240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/VirtioScsiDxe.debug 0x6dd2240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/VirtioRngDxe.debug 0x6da7240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/ConPlatformDxe.debug 0x6da2240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/ConSplitterDxe.debug 0x6d92240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/GraphicsConsoleDxe.debug 0x6d8b240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/TerminalDxe.debug 0x6d79240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/QemuKernelLoaderFsDxe.debug 0x6d74240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/DiskIoDxe.debug 0x6d74240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/PartitionDxe.debug 0x6d6d240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/EnglishDxe.debug 0x6d88240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/ScsiBus.debug 0x6d68240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/ScsiDisk.debug 0x6d54240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/SataController.debug 0x6d84240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/AtaAtapiPassThruDxe.debug 0x6d3c240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/AtaBusDxe.debug 0x6d4d240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/NvmExpressDxe.debug 0x6d26240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/SioBusDxe.debug 0x6d64240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/PciSioSerialDxe.debug 0x6d1f240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/Ps2KeyboardDxe.debug 0x6d18240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/BootGraphicsResourceTableDxe.debug 0x6d5e240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/Fat.debug 0x6d0d240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/UdfDxe.debug 0x6d06240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/VirtioFsDxe.debug 0x6cfc240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/SnpDxe.debug 0x6cf4240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/VlanConfigDxe.debug 0x6ced240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/MnpDxe.debug 0x6ce2240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/ArpDxe.debug 0x6cdb240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/Dhcp4Dxe.debug 0x6cd0240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/Ip4Dxe.debug 0x6ca8240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/Udp4Dxe.debug 0x6cc7240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/Mtftp4Dxe.debug 0x6cbd240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/TcpDxe.debug 0x6c82240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/UefiPxeBcDxe.debug 0x6c70240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/IScsiDxe.debug 0x6c32240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/VirtioNetDxe.debug 0x6c9c240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/UhciDxe.debug 0x6c60240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/EhciDxe.debug 0x6c29240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/XhciDxe.debug 0x6c1b240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/UsbBusDxe.debug 0x6c11240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/UsbKbDxe.debug 0x6c69240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/UsbMassStorageDxe.debug 0x6c96240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/QemuVideoDxe.debug 0x6c52240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/VirtioGpuDxe.debug 0x6c0a240 -add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/Shell.debug 0x6449240 diff --git a/test_code/gdbscripts/gdb_relocation_tests b/test_code/gdbscripts/gdb_relocation_tests new file mode 100644 index 0000000..96b7226 --- /dev/null +++ b/test_code/gdbscripts/gdb_relocation_tests @@ -0,0 +1,12 @@ +add-symbol-file ../../memtest86plus_debug/build64/memtest.debug 0x201000 + +b main +b run_at +b reloc +b test_all_windows +b main.c:407 + +target remote localhost:1234 +layout src +info b +c diff --git a/test_code/gdbscripts/gdbscript b/test_code/gdbscripts/gdbscript new file mode 100644 index 0000000..f0d4a38 --- /dev/null +++ b/test_code/gdbscripts/gdbscript @@ -0,0 +1,104 @@ +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/PcdPeim.debug 0x82c380 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/ReportStatusCodeRouterPei.debug 0x831700 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/StatusCodeHandlerPei.debug 0x833900 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/PlatformPei.debug 0x835a00 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/PeiCore.debug 0x7ee8240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/PcdPeim.debug 0x7ee2240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/DxeIpl.debug 0x7edd240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/S3Resume2Pei.debug 0x7ed8240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/CpuMpPei.debug +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/DxeCore.debug 0x7e8f240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/DevicePathDxe.debug 0x7553240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/PcdDxe.debug 0x754c240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/AmdSevDxe.debug 0x755f240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/TdxDxe.debug 0x7547240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/FvbServicesRuntimeDxe.debug 0x7ae7000 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/ReportStatusCodeRouterRuntimeDxe.debug 0x7ae0000 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/RuntimeDxe.debug 0x7ada000 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/SecurityStubDxe.debug 0x7544240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/EbcDxe.debug 0x7538240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/CpuIo2Dxe.debug 0x7541240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/CpuDxe.debug +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/IncompatiblePciDeviceSupportDxe.debug 0x7128240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/PciHotPlugInitDxe.debug 0x70fc240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/ResetSystemRuntimeDxe.debug 0x7ad3000 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/Metronome.debug 0x7125240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/HiiDatabase.debug 0x70be240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/NullMemoryTestDxe.debug 0x711f240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/AcpiTableDxe.debug 0x70ec240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/S3SaveStateDxe.debug 0x70e5240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/DpcDxe.debug 0x70f9240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/IoMmuDxe.debug 0x70b7240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/EmuVariableFvbRuntimeDxe.debug 0x7acd000 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/VariableRuntimeDxe.debug 0x7ac3000 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/StatusCodeHandlerRuntimeDxe.debug 0x7abe000 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/LocalApicTimerDxe.debug 0x70e2240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/PciHostBridgeDxe.debug 0x70a1240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/SetupBrowser.debug 0x706d240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/SmbiosDxe.debug 0x709a240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/QemuFwCfgAcpiPlatform.debug 0x7092240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/BootScriptExecutorDxe.debug 0x703d240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/tftpDynamicCommand.debug 0x7087240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/httpDynamicCommand.debug 0x702f240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/LinuxInitrdDynamicShellCommand.debug 0x7064240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/LogoDxe.debug 0x70ac240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/QemuRamfbDxe.debug 0x7058240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/FaultTolerantWriteDxe.debug 0x7058240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/PcRtc.debug 0x7ab7000 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/WatchdogTimer.debug 0x7056240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/MonotonicCounterRuntimeDxe.debug 0x7ab3000 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/CapsuleRuntimeDxe.debug 0x7aae000 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/DriverHealthManagerDxe.debug 0x7021240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/BdsDxe.debug 0x6de3240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/RamDiskDxe.debug 0x700b240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/DisplayEngine.debug 0x6dbb240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/SmbiosPlatformDxe.debug 0x7018240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/PlatformDxe.debug 0x7001240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/PciBusDxe.debug 0x6dab240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/VirtioPciDeviceDxe.debug 0x6ddf240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/Virtio10.debug 0x6dda240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/VirtioBlkDxe.debug 0x6dd6240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/VirtioScsiDxe.debug 0x6dd2240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/VirtioRngDxe.debug 0x6da7240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/ConPlatformDxe.debug 0x6da2240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/ConSplitterDxe.debug 0x6d92240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/GraphicsConsoleDxe.debug 0x6d8b240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/TerminalDxe.debug 0x6d79240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/QemuKernelLoaderFsDxe.debug 0x6d74240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/DiskIoDxe.debug 0x6d74240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/PartitionDxe.debug 0x6d6d240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/EnglishDxe.debug 0x6d88240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/ScsiBus.debug 0x6d68240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/ScsiDisk.debug 0x6d54240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/SataController.debug 0x6d84240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/AtaAtapiPassThruDxe.debug 0x6d3c240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/AtaBusDxe.debug 0x6d4d240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/NvmExpressDxe.debug 0x6d26240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/SioBusDxe.debug 0x6d64240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/PciSioSerialDxe.debug 0x6d1f240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/Ps2KeyboardDxe.debug 0x6d18240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/BootGraphicsResourceTableDxe.debug 0x6d5e240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/Fat.debug 0x6d0d240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/UdfDxe.debug 0x6d06240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/VirtioFsDxe.debug 0x6cfc240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/SnpDxe.debug 0x6cf4240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/VlanConfigDxe.debug 0x6ced240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/MnpDxe.debug 0x6ce2240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/ArpDxe.debug 0x6cdb240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/Dhcp4Dxe.debug 0x6cd0240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/Ip4Dxe.debug 0x6ca8240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/Udp4Dxe.debug 0x6cc7240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/Mtftp4Dxe.debug 0x6cbd240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/TcpDxe.debug 0x6c82240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/UefiPxeBcDxe.debug 0x6c70240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/IScsiDxe.debug 0x6c32240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/VirtioNetDxe.debug 0x6c9c240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/UhciDxe.debug 0x6c60240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/EhciDxe.debug 0x6c29240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/XhciDxe.debug 0x6c1b240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/UsbBusDxe.debug 0x6c11240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/UsbKbDxe.debug 0x6c69240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/UsbMassStorageDxe.debug 0x6c96240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/QemuVideoDxe.debug 0x6c52240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/VirtioGpuDxe.debug 0x6c0a240 +add-symbol-file /home/koenigr/Memtest/git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/Shell.debug 0x6449240 diff --git a/test_code/gdbscripts/memtest_gdbscript b/test_code/gdbscripts/memtest_gdbscript new file mode 100644 index 0000000..94a7f53 --- /dev/null +++ b/test_code/gdbscripts/memtest_gdbscript @@ -0,0 +1,10 @@ +add-symbol-file ../../memtest86plus_debug/build64/memtest.debug 0x201000 +b main + +# while loop +b *0x21414a + +# supposed main +b *0x21412a + +target remote localhost:1234 diff --git a/test_code/memtest_gdbscript b/test_code/memtest_gdbscript deleted file mode 100644 index 94a7f53..0000000 --- a/test_code/memtest_gdbscript +++ /dev/null @@ -1,10 +0,0 @@ -add-symbol-file ../../memtest86plus_debug/build64/memtest.debug 0x201000 -b main - -# while loop -b *0x21414a - -# supposed main -b *0x21412a - -target remote localhost:1234 -- cgit v1.2.3-55-g7522