From nobody Mon Feb 9 08:37:58 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+79669+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+79669+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=posteo.de ARC-Seal: i=1; a=rsa-sha256; t=1629575786; cv=none; d=zohomail.com; s=zohoarc; b=Pxvw/N8ZwPisUkhpo1fFB6Hu5GZs0mbLnpnS+S03W6pKbsz9IDXFW9f5ryi5kONiG6tkqFNIYfSonfzgAnegMREfzMIPL1knUx0vyXW9gCnpzu/zkOK+SnsU6Rv+hYPq6lG2L8hARYi/E3+5Lomf9aAY/9VTPiWpyxNDTUASDlk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629575786; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=9wBL5kFWgOOCHBg5ly/q/ENercJJR6OQHpIFYYsIZoM=; b=AQAqFY1Wt+K0I4n0ugG+wurJkRipBdGl4mmlfXmmNFEaHbAo1HJQ3/REMGYS8g/qquUixNmZFbGQCfmIdFOqWd/OThgkKPebLUtc4jdRrEaxA9cr3gpJ0KvpF7GMzCCbTFQHkdmufk6S0CAGTq9DhPFZedjAKHl7xT9IMVQ/Plc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+79669+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1629575786393707.1662602949273; Sat, 21 Aug 2021 12:56:26 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id Jjz4YY1788612xAweKQHK7Vf; Sat, 21 Aug 2021 12:56:26 -0700 X-Received: from mout01.posteo.de (mout01.posteo.de [185.67.36.65]) by mx.groups.io with SMTP id smtpd.web11.2461.1629575784124446127 for ; Sat, 21 Aug 2021 12:56:24 -0700 X-Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id 6838B240028 for ; Sat, 21 Aug 2021 21:56:22 +0200 (CEST) X-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4GsTlp0TGTz9rxP; Sat, 21 Aug 2021 21:56:22 +0200 (CEST) From: =?UTF-8?B?TWFydmluIEjDpHVzZXI=?= To: devel@edk2.groups.io Cc: Andrew Fish , Ray Ni , Vitaly Cheptsov Subject: [edk2-devel] [PATCH 1/3] EmulatorPkg: Use Image base address for GDB symbols loading Date: Sat, 21 Aug 2021 19:55:45 +0000 Message-Id: <750e31c0e12705c54e9367ad1315f611cd198930.1629574351.git.mhaeuser@posteo.de> In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,mhaeuser@posteo.de X-Gm-Message-State: 74pXlY4eudEu8egWOsKZQaTFx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1629575786; bh=0XQvvr7CNaENgCJKTJh9vBDpL+1Gduqr7xLz8hZmchU=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=N3wNS1CKN+Xz2Zr+s7+FT0dQioXxV9TjXAKNbl1ZoothK1Mwhty3zAoXhbj07WySjJo +CZkGfQO+RyWMA9RiZTZ2FEWOHbPAOAjFWmdYPHNR+HVajQf97LHLhnCuhxy4GS7R7D/u nUij8DDoaZYNtg0Chf1T4F5hc2Q3BSsdYr0= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1629576689789100001 Content-Type: text/plain; charset="utf-8" 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: Andrew Fish Cc: Ray Ni Cc: Vitaly Cheptsov Signed-off-by: Marvin H=C3=A4user --- EmulatorPkg/Unix/Host/Host.c | 12 ++++++------ EmulatorPkg/Unix/GdbRun.sh | 2 +- EmulatorPkg/Unix/lldbefi.py | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/EmulatorPkg/Unix/Host/Host.c b/EmulatorPkg/Unix/Host/Host.c index b4e5510613c8..f5b7d6709e47 100644 --- a/EmulatorPkg/Unix/Host/Host.c +++ b/EmulatorPkg/Unix/Host/Host.c @@ -1042,7 +1042,7 @@ PrintLoadAddress ( } else { fprintf (stderr, "0x%08lx Loading %s with entry point 0x%08lx\n", - (unsigned long)(ImageContext->ImageAddress + ImageContext->SizeOfHea= ders), + (unsigned long)ImageContext->ImageAddress, ImageContext->PdbPointer, (unsigned long)ImageContext->EntryPoint ); @@ -1148,7 +1148,7 @@ GdbScriptAddImage ( if (FeaturePcdGet (PcdEmulatorLazyLoadSymbols)) { GdbTempFile =3D fopen (gGdbWorkingFileName, "a"); if (GdbTempFile !=3D NULL) { - long unsigned int SymbolsAddr =3D (long unsigned int)(ImageContext= ->ImageAddress + ImageContext->SizeOfHeaders); + long unsigned int SymbolsAddr =3D (long unsigned int)ImageContext-= >ImageAddress; mScriptSymbolChangesCount++; fprintf ( GdbTempFile, @@ -1159,7 +1159,7 @@ GdbScriptAddImage ( ); fclose (GdbTempFile); // This is for the lldb breakpoint only - SecGdbScriptBreak (ImageContext->PdbPointer, strlen (ImageContext-= >PdbPointer) + 1, (long unsigned int)(ImageContext->ImageAddress + ImageCon= text->SizeOfHeaders), 1); + SecGdbScriptBreak (ImageContext->PdbPointer, strlen (ImageContext-= >PdbPointer) + 1, (long unsigned int)ImageContext->ImageAddress, 1); } else { ASSERT (FALSE); } @@ -1168,9 +1168,9 @@ GdbScriptAddImage ( if (GdbTempFile !=3D NULL) { fprintf ( GdbTempFile, - "add-symbol-file %s 0x%08lx\n", + "add-symbol-file %s -o 0x%08lx\n", ImageContext->PdbPointer, - (long unsigned int)(ImageContext->ImageAddress + ImageContext->S= izeOfHeaders) + (long unsigned int)ImageContext->ImageAddress ); fclose (GdbTempFile); =20 @@ -1180,7 +1180,7 @@ GdbScriptAddImage ( // Also used for the lldb breakpoint script. The lldb breakpoint s= cript does // not use the file, it uses the arguments. // - SecGdbScriptBreak (ImageContext->PdbPointer, strlen (ImageContext-= >PdbPointer) + 1, (long unsigned int)(ImageContext->ImageAddress + ImageCon= text->SizeOfHeaders), 1); + SecGdbScriptBreak (ImageContext->PdbPointer, strlen (ImageContext-= >PdbPointer) + 1, (long unsigned int)ImageContext->ImageAddress, 1); } else { ASSERT (FALSE); } diff --git a/EmulatorPkg/Unix/GdbRun.sh b/EmulatorPkg/Unix/GdbRun.sh index b050ad5e2c5c..6fea1c9d5b82 100644 --- a/EmulatorPkg/Unix/GdbRun.sh +++ b/EmulatorPkg/Unix/GdbRun.sh @@ -41,7 +41,7 @@ set $SymbolFileChangesCount =3D 0 # define AddFirmwareSymbolFile if $SymbolFileChangesCount < $arg0 - add-symbol-file $arg1 $arg2 + add-symbol-file $arg1 -o $arg2 set $SymbolFileChangesCount =3D $arg0 end end diff --git a/EmulatorPkg/Unix/lldbefi.py b/EmulatorPkg/Unix/lldbefi.py index c3fb2675cbc1..4f4c04509e58 100755 --- a/EmulatorPkg/Unix/lldbefi.py +++ b/EmulatorPkg/Unix/lldbefi.py @@ -395,7 +395,7 @@ def LoadEmulatorEfiSymbols(frame, bp_loc , internal_dic= t): =20 debugger =3D frame.thread.process.target.debugger if frame.FindVariable ("AddSymbolFlag").GetValueAsUnsigned() =3D=3D 1: - LoadAddress =3D frame.FindVariable ("LoadAddress").GetValueAsUnsig= ned() - 0x240 + LoadAddress =3D frame.FindVariable ("LoadAddress").GetValueAsUnsig= ned() =20 debugger.HandleCommand ("target modules add %s" % FileName) print "target modules load --slid 0x%x %s" % (LoadAddress, FileNam= e) --=20 2.31.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#79669): https://edk2.groups.io/g/devel/message/79669 Mute This Topic: https://groups.io/mt/85048606/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-