GDB symbols are currently loaded by specifying the .text section
address. It is assumed to be the value of the PE/COFF SizeOfHeaders
field. This may not be the case for various reasons, including a
sufficiently strict Image section alignment. Use the "-o" parameter
to specify the Image base address instead. This works because the GCC
linker scripts are designed to emit Image section addresses that are
equal to those of the final PE/COFF Image.

Cc: Leif Lindholm <l...@nuviainc.com>
Cc: Ard Biesheuvel <ardb+tianoc...@kernel.org>
Cc: Vitaly Cheptsov <vit9...@protonmail.com>
Signed-off-by: Marvin Häuser <mhaeu...@posteo.de>
---
 ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c | 6 +++---
 ArmPkg/Library/RvdPeCoffExtraActionLib/RvdPeCoffExtraActionLib.c     | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git 
a/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c 
b/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c
index 3f88e84372ee..2ca42c19c03f 100644
--- a/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c
+++ b/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c
@@ -84,11 +84,11 @@ PeCoffLoaderRelocateImageExtraAction (
     DEBUG ((EFI_D_LOAD | EFI_D_INFO, "load /a /ni /np %a &0x%p\n", 
DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), 
(UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));

 #else

     // Print out the command for the DS-5 to load symbols for this image

-    DEBUG ((EFI_D_LOAD | EFI_D_INFO, "add-symbol-file %a 0x%p\n", 
DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), 
(UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));

+    DEBUG ((EFI_D_LOAD | EFI_D_INFO, "add-symbol-file %a -o 0x%p\n", 
DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), 
(UINTN)ImageContext->ImageAddress));

 #endif

 #elif __GNUC__

     // This may not work correctly if you generate PE/COFF directly as then 
the Offset would not be required

-    DEBUG ((EFI_D_LOAD | EFI_D_INFO, "add-symbol-file %a 0x%p\n", 
DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), 
(UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));

+    DEBUG ((EFI_D_LOAD | EFI_D_INFO, "add-symbol-file %a -o 0x%p\n", 
DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), 
(UINTN)ImageContext->ImageAddress));

 #else

     DEBUG ((EFI_D_LOAD | EFI_D_INFO, "Loading driver at 0x%11p 
EntryPoint=0x%11p\n", (VOID *)(UINTN) ImageContext->ImageAddress, 
FUNCTION_ENTRY_POINT (ImageContext->EntryPoint)));

 #endif

@@ -125,7 +125,7 @@ PeCoffLoaderUnloadImageExtraAction (
     DEBUG ((DEBUG_LOAD | DEBUG_INFO, "unload symbols_only %a\n", 
DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp))));

 #elif __GNUC__

     // This may not work correctly if you generate PE/COFF directly as then 
the Offset would not be required

-    DEBUG ((DEBUG_LOAD | DEBUG_INFO, "remove-symbol-file %a 0x%08x\n", 
DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), 
(UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));

+    DEBUG ((DEBUG_LOAD | DEBUG_INFO, "remove-symbol-file %a 0x%08x\n", 
DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), 
(UINTN)ImageContext->ImageAddress));

 #else

     DEBUG ((DEBUG_LOAD | DEBUG_INFO, "Unloading %a\n", 
ImageContext->PdbPointer));

 #endif

diff --git a/ArmPkg/Library/RvdPeCoffExtraActionLib/RvdPeCoffExtraActionLib.c 
b/ArmPkg/Library/RvdPeCoffExtraActionLib/RvdPeCoffExtraActionLib.c
index 80e531921c7a..0b78554f6347 100644
--- a/ArmPkg/Library/RvdPeCoffExtraActionLib/RvdPeCoffExtraActionLib.c
+++ b/ArmPkg/Library/RvdPeCoffExtraActionLib/RvdPeCoffExtraActionLib.c
@@ -116,7 +116,7 @@ PeCoffLoaderRelocateImageExtraAction (
 #if (__ARMCC_VERSION < 500000)

   AsciiSPrint (Buffer, sizeof(Buffer), "load /a /ni /np \"%a\" &0x%08x\n", 
ImageContext->PdbPointer, (UINTN)(ImageContext->ImageAddress + 
ImageContext->SizeOfHeaders));

 #else

-  AsciiSPrint (Buffer, sizeof(Buffer), "add-symbol-file %a 0x%08x\n", 
ImageContext->PdbPointer, (UINTN)(ImageContext->ImageAddress + 
ImageContext->SizeOfHeaders));

+  AsciiSPrint (Buffer, sizeof(Buffer), "add-symbol-file %a -o 0x%08x\n", 
ImageContext->PdbPointer, (UINTN)ImageContext->ImageAddress);

 #endif

   DeCygwinPathIfNeeded (&Buffer[16]);

 

-- 
2.31.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#79676): https://edk2.groups.io/g/devel/message/79676
Mute This Topic: https://groups.io/mt/85048614/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to