From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.31; helo=mga06.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 6362C21C913CB for ; Thu, 2 Nov 2017 07:09:30 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP; 02 Nov 2017 07:13:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,334,1505804400"; d="scan'208";a="1238745407" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga002.fm.intel.com with ESMTP; 02 Nov 2017 07:13:22 -0700 Received: from FMSMSX109.amr.corp.intel.com (10.18.116.9) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 2 Nov 2017 07:13:22 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx109.amr.corp.intel.com (10.18.116.9) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 2 Nov 2017 07:13:21 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.152]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.93]) with mapi id 14.03.0319.002; Thu, 2 Nov 2017 22:13:20 +0800 From: "Gao, Liming" To: "Zhu, Yonghong" , "edk2-devel@lists.01.org" Thread-Topic: [Patch] BaseTools: parse map file generated by Xcode on Mac Thread-Index: AQHTU5nuK9zja/ExVE2taWD7IwNvZKMBIj5Q Date: Thu, 2 Nov 2017 14:13:19 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E1775C8@SHSMSX104.ccr.corp.intel.com> References: <1509599856-17040-1-git-send-email-yonghong.zhu@intel.com> In-Reply-To: <1509599856-17040-1-git-send-email-yonghong.zhu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch] BaseTools: parse map file generated by Xcode on Mac X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Nov 2017 14:09:30 -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 > Sent: Thursday, November 2, 2017 1:18 PM > To: edk2-devel@lists.01.org > Cc: Gao, Liming > Subject: [Patch] BaseTools: parse map file generated by Xcode on Mac >=20 > Add support to parse map file generated by Xcode on Mac to get > variable offset and Patchable Pcd info in current EFI file. >=20 > Cc: Liming Gao > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Yonghong Zhu > --- > BaseTools/Source/Python/Common/Misc.py | 18 +++++++++++++= +++++ > .../Python/GenPatchPcdTable/GenPatchPcdTable.py | 19 +++++++++++++= +++++- > 2 files changed, 36 insertions(+), 1 deletion(-) >=20 > diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Py= thon/Common/Misc.py > index dbb711e..5299cf1 100644 > --- a/BaseTools/Source/Python/Common/Misc.py > +++ b/BaseTools/Source/Python/Common/Misc.py > @@ -65,12 +65,30 @@ def GetVariableOffset(mapfilepath, efifilepath, varna= mes): > if len(lines) =3D=3D 0: return None > firstline =3D lines[0].strip() > if (firstline.startswith("Archive member included ") and > firstline.endswith(" file (symbol)")): > return _parseForGCC(lines, efifilepath, varnames) > + if firstline.startswith("# Path:"): > + return _parseForXcode(lines, efifilepath, varnames) > return _parseGeneral(lines, efifilepath, varnames) >=20 > +def _parseForXcode(lines, efifilepath, varnames): > + status =3D 0 > + ret =3D [] > + for index, line in enumerate(lines): > + line =3D line.strip() > + if status =3D=3D 0 and line =3D=3D "# Symbols:": > + status =3D 1 > + continue > + if status =3D=3D 1 and len(line) !=3D 0: > + for varname in varnames: > + if varname in line: > + m =3D re.match('^([\da-fA-FxX]+)([\s\S]*)([_]*%s)$' = % varname, line) > + if m !=3D None: > + ret.append((varname, m.group(1))) > + return ret > + > def _parseForGCC(lines, efifilepath, varnames): > """ Parse map file generated by GCC linker """ > status =3D 0 > sections =3D [] > varoffset =3D [] > diff --git a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py > b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py > index 4452fac..fdad5a4 100644 > --- a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py > +++ b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py > @@ -3,11 +3,11 @@ > # The Patch PCD table like: > # > # PCD Name Offset in binary > # =3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > # > -# Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved.
> +# Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.
> # This program and the accompanying materials > # are licensed and made available under the terms and conditions of the = BSD License > # which accompanies this distribution. The full text of the license may= be found at > # http://opensource.org/licenses/bsd-license.php > # > @@ -56,12 +56,29 @@ def parsePcdInfoFromMapFile(mapfilepath, efifilepath)= : > if len(lines) =3D=3D 0: return None > firstline =3D lines[0].strip() > if (firstline.startswith("Archive member included ") and > firstline.endswith(" file (symbol)")): > return _parseForGCC(lines, efifilepath) > + if firstline.startswith("# Path:"): > + return _parseForXcode(lines, efifilepath) > return _parseGeneral(lines, efifilepath) >=20 > +def _parseForXcode(lines, efifilepath): > + status =3D 0 > + pcds =3D [] > + for index, line in enumerate(lines): > + line =3D line.strip() > + if status =3D=3D 0 and line =3D=3D "# Symbols:": > + status =3D 1 > + continue > + if status =3D=3D 1 and len(line) !=3D 0: > + if '_gPcd_BinaryPatch_' in line: > + m =3D re.match('^([\da-fA-FxX]+)([\s\S]*)([_]*_gPcd_Bina= ryPatch_([\w]+))', line) > + if m !=3D None: > + pcds.append((m.groups(0)[3], int(m.groups(0)[0], 16)= )) > + return pcds > + > def _parseForGCC(lines, efifilepath): > """ Parse map file generated by GCC linker """ > status =3D 0 > imageBase =3D -1 > sections =3D [] > -- > 2.6.1.windows.1