summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRegia König2022-08-16 16:54:09 +0200
committerRegia König2022-08-16 16:54:09 +0200
commit3e6d1f5389cb77055e3860c801dbcc99bb4518ec (patch)
tree682ef9f54c774dbb69fc4c0c8ea64f220017223a
parentDocumentation GNU-efi (diff)
downloadmemtest86-3e6d1f5389cb77055e3860c801dbcc99bb4518ec.tar.gz
memtest86-3e6d1f5389cb77055e3860c801dbcc99bb4518ec.tar.xz
memtest86-3e6d1f5389cb77055e3860c801dbcc99bb4518ec.zip
Efi file outputs own image base
-rwxr-xr-xGNU_efi_HelloWorld/analyse_hello.sh2
-rw-r--r--GNU_efi_HelloWorld/hello.c21
-rwxr-xr-xGNU_efi_HelloWorld/hello.efibin45555 -> 46888 bytes
-rw-r--r--GNU_efi_HelloWorld/hello.obin1664 -> 2112 bytes
-rwxr-xr-xGNU_efi_HelloWorld/hello.sobin2170968 -> 2171456 bytes
-rw-r--r--documentation/GNU-efi4
-rw-r--r--test_code/OVMF_VARS.fdbin540672 -> 540672 bytes
7 files changed, 23 insertions, 4 deletions
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
--- a/GNU_efi_HelloWorld/hello.efi
+++ b/GNU_efi_HelloWorld/hello.efi
Binary files differ
diff --git a/GNU_efi_HelloWorld/hello.o b/GNU_efi_HelloWorld/hello.o
index 22a8362..21583fe 100644
--- a/GNU_efi_HelloWorld/hello.o
+++ b/GNU_efi_HelloWorld/hello.o
Binary files differ
diff --git a/GNU_efi_HelloWorld/hello.so b/GNU_efi_HelloWorld/hello.so
index bc418e3..b64f729 100755
--- a/GNU_efi_HelloWorld/hello.so
+++ b/GNU_efi_HelloWorld/hello.so
Binary files 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
--- a/test_code/OVMF_VARS.fd
+++ b/test_code/OVMF_VARS.fd
Binary files differ