From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mout01.posteo.de (mout01.posteo.de [185.67.36.65]) by mx.groups.io with SMTP id smtpd.web10.2458.1629575786244188039 for ; Sat, 21 Aug 2021 12:56:26 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@posteo.de header.s=2017 header.b=jHfatHsx; spf=pass (domain: posteo.de, ip: 185.67.36.65, mailfrom: mhaeuser@posteo.de) Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id DF7BE240028 for ; Sat, 21 Aug 2021 21:56:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1629575783; bh=cLy+XUYGWrTihVeXidkdgQDBWZCaKOTjvt6aO7HLhts=; h=From:To:Cc:Subject:Date:From; b=jHfatHsx2m8hU9dEql4nq3Xnt4oRkVHC1buetWC4rx8jVtz4h5MtgmelpF1r7qgie Sj6q3KsIZTWWUVdS8kCeuzyGtxoD3kROFJxiZ+tCj0X2lftrmtlFJ4ST225yR8mbGZ T4Drf8B+5iC2zT3O8/o3TjwKnmEMmbMZLLj8dz5Q/2MJBt/XD0fP1DubZ45iS5fa2a /IEyIJ/UwEaqV/kVCb+i1jTgjEa+reW+dg1m/N4N3YG3ZCK3440nJaxv/fyF4YzoUw cadxdAGzU+3ao138X2EXRNWRPPT1Qi+XIwfa0qv6xse2GMgX6pfDtu2H03OEBPCIhq I8LR9i2e9f4yA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4GsTlq23pDz9rxL; Sat, 21 Aug 2021 21:56:23 +0200 (CEST) From: =?UTF-8?B?TWFydmluIEjDpHVzZXI=?= To: devel@edk2.groups.io Cc: Leif Lindholm , Ard Biesheuvel , Vitaly Cheptsov Subject: [PATCH 2/3] ArmPkg: Use Image base address for GDB symbols loading Date: Sat, 21 Aug 2021 19:55:48 +0000 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 Cc: Ard Biesheuvel Cc: Vitaly Cheptsov Signed-off-by: Marvin H=C3=A4user --- 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/DebugPeCoffExtraActio= nLib.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", DeCygwi= nPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), (UINTN)(Imag= eContext->ImageAddress + ImageContext->SizeOfHeaders)));=0D #else=0D // Print out the command for the DS-5 to load symbols for this image=0D - DEBUG ((EFI_D_LOAD | EFI_D_INFO, "add-symbol-file %a 0x%p\n", DeCygwin= PathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), (UINTN)(Image= Context->ImageAddress + ImageContext->SizeOfHeaders)));=0D + DEBUG ((EFI_D_LOAD | EFI_D_INFO, "add-symbol-file %a -o 0x%p\n", DeCyg= winPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), (UINTN)Ima= geContext->ImageAddress));=0D #endif=0D #elif __GNUC__=0D // This may not work correctly if you generate PE/COFF directly as the= n the Offset would not be required=0D - DEBUG ((EFI_D_LOAD | EFI_D_INFO, "add-symbol-file %a 0x%p\n", DeCygwin= PathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), (UINTN)(Image= Context->ImageAddress + ImageContext->SizeOfHeaders)));=0D + DEBUG ((EFI_D_LOAD | EFI_D_INFO, "add-symbol-file %a -o 0x%p\n", DeCyg= winPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), (UINTN)Ima= geContext->ImageAddress));=0D #else=0D DEBUG ((EFI_D_LOAD | EFI_D_INFO, "Loading driver at 0x%11p EntryPoint= =3D0x%11p\n", (VOID *)(UINTN) ImageContext->ImageAddress, FUNCTION_ENTRY_PO= INT (ImageContext->EntryPoint)));=0D #endif=0D @@ -125,7 +125,7 @@ PeCoffLoaderUnloadImageExtraAction ( DEBUG ((DEBUG_LOAD | DEBUG_INFO, "unload symbols_only %a\n", DeCygwinP= athIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp))));=0D #elif __GNUC__=0D // This may not work correctly if you generate PE/COFF directly as the= n the Offset would not be required=0D - DEBUG ((DEBUG_LOAD | DEBUG_INFO, "remove-symbol-file %a 0x%08x\n", DeC= ygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), (UINTN)(= ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));=0D + DEBUG ((DEBUG_LOAD | DEBUG_INFO, "remove-symbol-file %a 0x%08x\n", DeC= ygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), (UINTN)I= mageContext->ImageAddress));=0D #else=0D DEBUG ((DEBUG_LOAD | DEBUG_INFO, "Unloading %a\n", ImageContext->PdbPo= inter));=0D #endif=0D 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)=0D AsciiSPrint (Buffer, sizeof(Buffer), "load /a /ni /np \"%a\" &0x%08x\n",= ImageContext->PdbPointer, (UINTN)(ImageContext->ImageAddress + ImageContex= t->SizeOfHeaders));=0D #else=0D - AsciiSPrint (Buffer, sizeof(Buffer), "add-symbol-file %a 0x%08x\n", Imag= eContext->PdbPointer, (UINTN)(ImageContext->ImageAddress + ImageContext->Si= zeOfHeaders));=0D + AsciiSPrint (Buffer, sizeof(Buffer), "add-symbol-file %a -o 0x%08x\n", I= mageContext->PdbPointer, (UINTN)ImageContext->ImageAddress);=0D #endif=0D DeCygwinPathIfNeeded (&Buffer[16]);=0D =0D --=20 2.31.1