From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.120; helo=mga04.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 BCF5B21F2E0F0 for ; Sun, 8 Apr 2018 22:44:01 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Apr 2018 22:44:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,426,1517904000"; d="scan'208";a="31206319" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga008.fm.intel.com with ESMTP; 08 Apr 2018 22:43:59 -0700 Received: from fmsmsx153.amr.corp.intel.com (10.18.125.6) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 8 Apr 2018 22:44:00 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX153.amr.corp.intel.com (10.18.125.6) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 8 Apr 2018 22:44:00 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.239]) by shsmsx102.ccr.corp.intel.com ([169.254.2.184]) with mapi id 14.03.0319.002; Mon, 9 Apr 2018 13:43:58 +0800 From: "Gao, Liming" To: "Zhu, Yonghong" , "edk2-devel@lists.01.org" Thread-Topic: [edk2] [Patch] BaseTools: Fix a bug for VOID* type Fixatbuild Pcd in Library Thread-Index: AQHTwmvLqnRX9MNpmkShLoP+llkktKP4BqUA Date: Mon, 9 Apr 2018 05:43:58 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E20A4DB@SHSMSX104.ccr.corp.intel.com> References: <1521784620-2376-1-git-send-email-yonghong.zhu@intel.com> In-Reply-To: <1521784620-2376-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 a bug for VOID* type Fixatbuild Pcd in Library X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Apr 2018 05:44: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: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of >Yonghong Zhu >Sent: Friday, March 23, 2018 1:57 PM >To: edk2-devel@lists.01.org >Subject: [edk2] [Patch] BaseTools: Fix a bug for VOID* type Fixatbuild Pcd= in >Library > >The case is a FixedAtBuild VOID* PCD is used from a lib, but is set to a >different sized value in a module INF scope section. > >Contributed-under: TianoCore Contribution Agreement 1.1 >Signed-off-by: Yonghong Zhu >--- > BaseTools/Source/Python/AutoGen/GenC.py | 22 +++++++++++++++++----- > 1 file changed, 17 insertions(+), 5 deletions(-) > >diff --git a/BaseTools/Source/Python/AutoGen/GenC.py >b/BaseTools/Source/Python/AutoGen/GenC.py >index 481c4dd..fbf892f 100644 >--- a/BaseTools/Source/Python/AutoGen/GenC.py >+++ b/BaseTools/Source/Python/AutoGen/GenC.py >@@ -913,10 +913,11 @@ def CreateModulePcdCode(Info, AutoGenC, >AutoGenH, Pcd): > break > PcdTokenName =3D '_PCD_TOKEN_' + TokenCName > PatchPcdSizeTokenName =3D '_PCD_PATCHABLE_' + TokenCName +'_SIZE' > PatchPcdSizeVariableName =3D '_gPcd_BinaryPatch_Size_' + TokenCName > FixPcdSizeTokenName =3D '_PCD_SIZE_' + TokenCName >+ FixedPcdSizeVariableName =3D '_gPcd_FixedAtBuild_Size_' + TokenCName > > if Pcd.PcdValueFromComm: > Pcd.DefaultValue =3D Pcd.PcdValueFromComm > > if Pcd.Type in gDynamicExPcd: >@@ -1152,11 +1153,11 @@ def CreateModulePcdCode(Info, AutoGenC, >AutoGenH, Pcd): > > PcdDataSize =3D GetPcdSize(Pcd) > if Pcd.Type =3D=3D TAB_PCDS_FIXED_AT_BUILD: > AutoGenH.Append('#define %s %s\n' % (FixPcdSizeTokenName, >PcdDataSize)) > AutoGenH.Append('#define %s %s \n' % >(GetModeSizeName,FixPcdSizeTokenName)) >- >+ AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED const >UINTN %s =3D %s;\n' % (FixedPcdSizeVariableName,PcdDataSize)) > if Pcd.Type =3D=3D TAB_PCDS_PATCHABLE_IN_MODULE: > AutoGenH.Append('#define %s %s\n' % (PatchPcdSizeTokenNam= e, >Pcd.MaxDatumSize)) > AutoGenH.Append('#define %s %s \n' % >(GetModeSizeName,PatchPcdSizeVariableName)) > AutoGenH.Append('extern UINTN %s; \n' % >PatchPcdSizeVariableName) > AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED UINTN %s >=3D %s;\n' % (PatchPcdSizeVariableName,PcdDataSize)) >@@ -1209,10 +1210,11 @@ def CreateLibraryPcdCode(Info, AutoGenC, >AutoGenH, Pcd): > break > PcdTokenName =3D '_PCD_TOKEN_' + TokenCName > FixPcdSizeTokenName =3D '_PCD_SIZE_' + TokenCName > PatchPcdSizeTokenName =3D '_PCD_PATCHABLE_' + TokenCName +'_SIZE' > PatchPcdSizeVariableName =3D '_gPcd_BinaryPatch_Size_' + TokenCName >+ FixedPcdSizeVariableName =3D '_gPcd_FixedAtBuild_Size_' + TokenCName > > if Pcd.PcdValueFromComm: > Pcd.DefaultValue =3D Pcd.PcdValueFromComm > # > # Write PCDs >@@ -1349,20 +1351,30 @@ def CreateLibraryPcdCode(Info, AutoGenC, >AutoGenH, Pcd): > DatumType =3D 'UINT8' > AutoGenH.Append('extern const %s >_gPcd_FixedAtBuild_%s%s;\n' %(DatumType, TokenCName, Array)) > >AutoGenH.Append('#define %s %s_gPcd_FixedAtBuild_%s\n' %(GetModeN >ame, Type, TokenCName)) > AutoGenH.Append('//#define %s ASSERT(FALSE) // It is not allowe= d to >set value for a FIXED_AT_BUILD PCD\n' % SetModeName) > >+ ConstFixedPcd =3D False > if PcdItemType =3D=3D TAB_PCDS_FIXED_AT_BUILD and (key in Info.Co= nstPcd >or (Info.IsLibrary and not Info._ReferenceModules)): >+ ConstFixedPcd =3D True > if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64= ', >'BOOLEAN']: > AutoGenH.Append('#define >_PCD_VALUE_%s %s%s\n' %(TokenCName, Type, PcdVariableName)) > else: > AutoGenH.Append('#define _PCD_VALUE_%s %s\n' %(TokenCName= , >Pcd.DefaultValue)) >- >+ PcdDataSize =3D GetPcdSize(Pcd) > if PcdItemType =3D=3D TAB_PCDS_FIXED_AT_BUILD: >- PcdDataSize =3D GetPcdSize(Pcd) >- AutoGenH.Append('#define %s %s\n' % (FixPcdSizeTokenName, >PcdDataSize)) >- AutoGenH.Append('#define %s %s\n' % >(GetModeSizeName,FixPcdSizeTokenName)) >+ if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64= ', >'BOOLEAN']: >+ if ConstFixedPcd: >+ AutoGenH.Append('#define %s %s\n' % (FixPcdSizeTokenN= ame, >PcdDataSize)) >+ AutoGenH.Append('#define %s %s\n' % >(GetModeSizeName,FixPcdSizeTokenName)) >+ else: >+ AutoGenH.Append('#define %s %s\n' % >(GetModeSizeName,FixedPcdSizeVariableName)) >+ AutoGenH.Append('#define %s %s\n' % >(FixPcdSizeTokenName,FixedPcdSizeVariableName)) >+ AutoGenH.Append('extern const UINTN %s; \n' % >FixedPcdSizeVariableName) >+ else: >+ AutoGenH.Append('#define %s %s\n' % (FixPcdSizeTokenName, >PcdDataSize)) >+ AutoGenH.Append('#define %s %s\n' % >(GetModeSizeName,FixPcdSizeTokenName)) > > ## Create code for library constructor > # > # @param Info The ModuleAutoGen object > # @param AutoGenC The TemplateString object for C code >-- >2.6.1.windows.1 > >_______________________________________________ >edk2-devel mailing list >edk2-devel@lists.01.org >https://lists.01.org/mailman/listinfo/edk2-devel