From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 8615481F42 for ; Thu, 1 Dec 2016 18:32:02 -0800 (PST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP; 01 Dec 2016 18:32:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,284,1477983600"; d="scan'208";a="1076394575" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga001.fm.intel.com with ESMTP; 01 Dec 2016 18:32:01 -0800 Received: from fmsmsx101.amr.corp.intel.com (10.18.124.199) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 1 Dec 2016 18:32:00 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx101.amr.corp.intel.com (10.18.124.199) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 1 Dec 2016 18:32:00 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.239]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.218]) with mapi id 14.03.0248.002; Fri, 2 Dec 2016 10:31:58 +0800 From: "Gao, Liming" To: "Zhu, Yonghong" , "edk2-devel@lists.01.org" Thread-Topic: [Patch] BaseTools: Fix the bug to parse the new map file format Thread-Index: AQHSSuMHBn1d3Z/qLkqn7yR4eu3L3aDz8rgA Date: Fri, 2 Dec 2016 02:31:58 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14B4BC3AF@shsmsx102.ccr.corp.intel.com> References: <1480494197-16156-1-git-send-email-yonghong.zhu@intel.com> In-Reply-To: <1480494197-16156-1-git-send-email-yonghong.zhu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch] BaseTools: Fix the bug to parse the new map file format X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Dec 2016 02:32:02 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao -----Original Message----- From: Zhu, Yonghong=20 Sent: Wednesday, November 30, 2016 4:23 PM To: edk2-devel@lists.01.org Cc: Gao, Liming Subject: [Patch] BaseTools: Fix the bug to parse the new map file format Current the variable and Pcd format save in the map file is changed, so thi= s patch is to support this new format. Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu --- BaseTools/Source/Python/Common/Misc.py | 11 +++++++---= - .../Source/Python/GenPatchPcdTable/GenPatchPcdTable.py | 14 +++++++++-= ---- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Pyth= on/Common/Misc.py index 3be1f0f..43d0818 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -72,11 +72,11 @@ def GetVariableOffset(mapfilepath, efifilepath, varname= s): def _parseForGCC(lines, efifilepath, varnames): """ Parse map file generated by GCC linker """ status =3D 0 sections =3D [] varoffset =3D [] - for line in lines: + for index, line in enumerate(lines): line =3D line.strip() # status machine transection if status =3D=3D 0 and line =3D=3D "Memory Configuration": status =3D 1 continue @@ -86,18 +86,21 @@ def _parseForGCC(lines, efifilepath, varnames): elif status =3D=3D2 and line =3D=3D 'START GROUP': status =3D 3 continue =20 # status handler - if status =3D=3D 2: + if status =3D=3D 3: m =3D re.match('^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+)$',= line) if m !=3D None: sections.append(m.groups(0)) for varname in varnames: - m =3D re.match("^([\da-fA-Fx]+) +[_]*(%s)$" % varname, lin= e) + m =3D re.match(".data.(%s)$" % varname, line) if m !=3D None: - varoffset.append((varname, int(m.groups(0)[0], 16) , i= nt(sections[-1][1], 16), sections[-1][0])) + if lines[index + 1]: + m =3D re.match('^([\da-fA-Fx]+) +([\da-fA-Fx]+)', = lines[index + 1].strip()) + if m !=3D None: + varoffset.append((varname,=20 + int(m.groups(0)[0], 16) , int(sections[-1][1], 16), sections[-1][0])) =20 if not varoffset: return [] # get section information from efi file efisecs =3D PeImageClass(efifilepath).SectionHeaderList diff --git a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py b= /BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py index f4fd51a..4452fac 100644 --- a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py +++ b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py @@ -64,11 +64,11 @@ def _parseForGCC(lines, efifilepath): """ Parse map file generated by GCC linker """ status =3D 0 imageBase =3D -1 sections =3D [] bpcds =3D [] - for line in lines: + for index, line in enumerate(lines): line =3D line.strip() # status machine transection if status =3D=3D 0 and line =3D=3D "Memory Configuration": status =3D 1 continue @@ -78,18 +78,22 @@ def _parseForGCC(lines, efifilepath): elif status =3D=3D2 and line =3D=3D 'START GROUP': status =3D 3 continue =20 # status handler - if status =3D=3D 2: + if status =3D=3D 3: m =3D re.match('^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+)$',= line) if m !=3D None: sections.append(m.groups(0)) - if status =3D=3D 2: - m =3D re.match("^([\da-fA-Fx]+) +[_]+gPcd_BinaryPatch_([\w_\d]= +)$", line) + if status =3D=3D 3: + m =3D re.match('^.data._gPcd_BinaryPatch_([\w_\d]+)$', line) if m !=3D None: - bpcds.append((m.groups(0)[1], int(m.groups(0)[0], 16) , in= t(sections[-1][1], 16), sections[-1][0])) + if lines[index + 1]: + PcdName =3D m.groups(0)[0] + m =3D re.match('^([\da-fA-Fx]+) +([\da-fA-Fx]+)', line= s[index + 1].strip()) + if m !=3D None: + bpcds.append((PcdName, int(m.groups(0)[0], 16)=20 + , int(sections[-1][1], 16), sections[-1][0])) =20 # get section information from efi file efisecs =3D PeImageClass(efifilepath).SectionHeaderList if efisecs =3D=3D None or len(efisecs) =3D=3D 0: return None -- 2.6.1.windows.1