diff options
author | Regia König | 2022-08-17 15:36:55 +0200 |
---|---|---|
committer | Regia König | 2022-08-17 15:36:55 +0200 |
commit | b6292481be3cd4e9855ad40e3e4f87679a4a6c47 (patch) | |
tree | 214037d45ecc3bcbad4e7d83523d541952cc56f6 /documentation | |
parent | Save old Makefile version without debug, but running (diff) | |
download | memtest86-b6292481be3cd4e9855ad40e3e4f87679a4a6c47.tar.gz memtest86-b6292481be3cd4e9855ad40e3e4f87679a4a6c47.tar.xz memtest86-b6292481be3cd4e9855ad40e3e4f87679a4a6c47.zip |
Subtask 'hello.efi with gdb' completed
Diffstat (limited to 'documentation')
-rw-r--r-- | documentation/GDB commands | 22 | ||||
-rw-r--r-- | documentation/GNU-efi | 77 | ||||
-rw-r--r-- | documentation/gdb with efi application | 0 |
3 files changed, 95 insertions, 4 deletions
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 --- a/documentation/gdb with efi application +++ /dev/null |