[PATCH] efi_loader: Expose relocated address for gdb debugging purposes

Alexander von Gluck IV kallisti5 at unixzen.com
Thu Mar 24 17:22:46 CET 2022


* If users want to debug EFI applications via qemu + GDB, they
  need to know the relocated address of the application to
  align their symbols to in GDB via add-symbol-file.
* This exposes where EFI applications are relocated to enable
  debugging EFI applications via qemu + gdb
* Usage is generally determining the address, then
  add-symbol-file (efi loader) (address)
* The address can change, but is generally consistent with
  the same qemu version and u-boot binary. (allowing you to
  boot once, find the address, then reboot with qemu -s -S
---
 lib/efi_loader/efi_image_loader.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/efi_loader/efi_image_loader.c b/lib/efi_loader/efi_image_loader.c
index 773bd0677c..2b8c1ef464 100644
--- a/lib/efi_loader/efi_image_loader.c
+++ b/lib/efi_loader/efi_image_loader.c
@@ -906,6 +906,8 @@ efi_status_t efi_load_pe(struct efi_loaded_image_obj *handle,
 			ret = EFI_OUT_OF_RESOURCES;
 			goto err;
 		}
+		log_info("64-bit EFI image loaded at relocated address %p\n", efi_reloc);
+
 		handle->entry = efi_reloc + opt->AddressOfEntryPoint;
 		rel_size = opt->DataDirectory[rel_idx].Size;
 		rel = efi_reloc + opt->DataDirectory[rel_idx].VirtualAddress;
@@ -922,6 +924,8 @@ efi_status_t efi_load_pe(struct efi_loaded_image_obj *handle,
 			ret = EFI_OUT_OF_RESOURCES;
 			goto err;
 		}
+		log_info("32-bit EFI image loaded at relocated address %p\n", efi_reloc);
+
 		handle->entry = efi_reloc + opt->AddressOfEntryPoint;
 		rel_size = opt->DataDirectory[rel_idx].Size;
 		rel = efi_reloc + opt->DataDirectory[rel_idx].VirtualAddress;
-- 
2.35.1



More information about the U-Boot mailing list