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.20; helo=mga02.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 F233821F2E103 for ; Sun, 8 Apr 2018 22:45:41 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Apr 2018 22:45:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,426,1517904000"; d="scan'208";a="218815779" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga006.fm.intel.com with ESMTP; 08 Apr 2018 22:45:41 -0700 Received: from fmsmsx156.amr.corp.intel.com (10.18.116.74) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 8 Apr 2018 22:45:41 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx156.amr.corp.intel.com (10.18.116.74) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 8 Apr 2018 22:45:40 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.239]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.43]) with mapi id 14.03.0319.002; Mon, 9 Apr 2018 13:45:38 +0800 From: "Gao, Liming" To: "Zhu, Yonghong" , "edk2-devel@lists.01.org" Thread-Topic: [edk2] [Patch] BaseTools: Fix the bug for VOID* pcd max size from component section Thread-Index: AQHTwmv6AxaD5Pw+D0KnGI3DWg7CPaP4Bx+Q Date: Mon, 9 Apr 2018 05:45:38 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E20A506@SHSMSX104.ccr.corp.intel.com> References: <1521784701-10864-1-git-send-email-yonghong.zhu@intel.com> In-Reply-To: <1521784701-10864-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 for VOID* pcd max size from component section 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:45:42 -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:58 PM >To: edk2-devel@lists.01.org >Subject: [edk2] [Patch] BaseTools: Fix the bug for VOID* pcd max size from >component section > >When the Pcd defined in components section, its value's size is larger >than the value's size in [pcd] section, it cause build error, because >original code use the size get in [pcd] section as max size. > >Contributed-under: TianoCore Contribution Agreement 1.1 >Signed-off-by: Yonghong Zhu >--- > BaseTools/Source/Python/AutoGen/AutoGen.py | 14 ++++++++++---- > BaseTools/Source/Python/AutoGen/GenC.py | 9 +++++++-- > BaseTools/Source/Python/AutoGen/GenPcdDb.py | 5 ++++- > BaseTools/Source/Python/Workspace/BuildClassObject.py | 3 ++- > 4 files changed, 23 insertions(+), 8 deletions(-) > >diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py >b/BaseTools/Source/Python/AutoGen/AutoGen.py >index 8682217..75eaf56 100644 >--- a/BaseTools/Source/Python/AutoGen/AutoGen.py >+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py >@@ -2366,16 +2366,15 @@ class PlatformAutoGen(AutoGen): > ToPcd.Type, Module, FromPcd.= Type), > File=3Dself.MetaFile) > > if FromPcd.MaxDatumSize not in [None, '']: > ToPcd.MaxDatumSize =3D FromPcd.MaxDatumSize >+ ToPcd.MaxSizeUserSet =3D FromPcd.MaxDatumSize > if FromPcd.DefaultValue not in [None, '']: > ToPcd.DefaultValue =3D FromPcd.DefaultValue > if FromPcd.TokenValue not in [None, '']: > ToPcd.TokenValue =3D FromPcd.TokenValue >- if FromPcd.MaxDatumSize not in [None, '']: >- ToPcd.MaxDatumSize =3D FromPcd.MaxDatumSize > if FromPcd.DatumType not in [None, '']: > ToPcd.DatumType =3D FromPcd.DatumType > if FromPcd.SkuInfoList not in [None, '', []]: > ToPcd.SkuInfoList =3D FromPcd.SkuInfoList > # Add Flexible PCD format parse >@@ -2470,10 +2469,11 @@ class PlatformAutoGen(AutoGen): > self._OverridePcd(ToPcd, PlatformModule.Pcds[Key], Mo= dule) > # use PCD value to calculate the MaxDatumSize when it is not spec= ified > for Name, Guid in Pcds: > Pcd =3D Pcds[Name, Guid] > if Pcd.DatumType =3D=3D "VOID*" and Pcd.MaxDatumSize in ['', = None]: >+ Pcd.MaxSizeUserSet =3D None > Value =3D Pcd.DefaultValue > if Value in [None, '']: > Pcd.MaxDatumSize =3D '1' > elif Value[0] =3D=3D 'L': > Pcd.MaxDatumSize =3D str((len(Value) - 2) * 2) >@@ -4180,23 +4180,29 @@ class ModuleAutoGen(AutoGen): > Padding =3D '0x00, ' > if Unicode: > Padding =3D Padding * 2 > ArraySize =3D ArraySize / 2 > if ArraySize < (len(PcdValue) + 1): >- EdkLogger.error("build", AUTOGEN_ERROR, >+ if Pcd.MaxSizeUserSet: >+ EdkLogger.error("build", AUTOGEN_ERROR, > "The maximum size of VOID* ty= pe PCD '%s.%s' is less >than its actual size occupied." % (Pcd.TokenSpaceGuidCName, TokenCName) > ) >+ else: >+ ArraySize =3D len(PcdValue) + 1 > if ArraySize > len(PcdValue) + 1: > NewValue =3D NewValue + Padding * (ArraySize = - len(PcdValue) - >1) > PcdValue =3D NewValue + Padding.strip().rstrip(',= ') + '}' > elif len(PcdValue.split(',')) <=3D ArraySize: > PcdValue =3D PcdValue.rstrip('}') + ', 0x00' * (A= rraySize - >len(PcdValue.split(','))) > PcdValue +=3D '}' > else: >- EdkLogger.error("build", AUTOGEN_ERROR, >+ if Pcd.MaxSizeUserSet: >+ EdkLogger.error("build", AUTOGEN_ERROR, > "The maximum size of VOID* type P= CD '%s.%s' is less than >its actual size occupied." % (Pcd.TokenSpaceGuidCName, TokenCName) > ) >+ else: >+ ArraySize =3D len(PcdValue) + 1 > PcdItem =3D '%s.%s|%s|0x%X' % \ > (Pcd.TokenSpaceGuidCName, TokenCName, PcdValue, Patch= Pcd[1]) > PcdComments =3D '' > if (Pcd.TokenSpaceGuidCName, Pcd.TokenCName) in >self._PcdComments: > PcdComments =3D '\n >'.join(self._PcdComments[Pcd.TokenSpaceGuidCName, Pcd.TokenCName]) >diff --git a/BaseTools/Source/Python/AutoGen/GenC.py >b/BaseTools/Source/Python/AutoGen/GenC.py >index a895067..c2a739b 100644 >--- a/BaseTools/Source/Python/AutoGen/GenC.py >+++ b/BaseTools/Source/Python/AutoGen/GenC.py >@@ -1,9 +1,9 @@ > ## @file > # Routines for generating AutoGen.h and AutoGen.c > # >-# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
>+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
> # This program and the accompanying materials > # are licensed and made available under the terms and conditions of the B= SD >License > # which accompanies this distribution. The full text of the license may = be >found at > # http://opensource.org/licenses/bsd-license.php > # >@@ -1108,13 +1108,18 @@ def CreateModulePcdCode(Info, AutoGenC, >AutoGenH, Pcd): > NewValue =3D NewValue + str(ord(Value[Index]) % 0= x100) + ', ' > if Unicode: > ArraySize =3D ArraySize / 2; > > if ArraySize < (len(Value) + 1): >- EdkLogger.error("build", AUTOGEN_ERROR, >+ if Pcd.MaxSizeUserSet: >+ EdkLogger.error("build", AUTOGEN_ERROR, > "The maximum size of VOID* type PCD '= %s.%s' is less than >its actual size occupied." % (Pcd.TokenSpaceGuidCName, TokenCName), > ExtraData=3D"[%s]" % str(Info)) >+ else: >+ ArraySize =3D GetPcdSize(Pcd) >+ if Unicode: >+ ArraySize =3D ArraySize / 2 > Value =3D NewValue + '0 }' > Array =3D '[%d]' % ArraySize > # > # skip casting for fixed at build since it breaks ARM assembly. > # Long term we need PCD macros that work in assembly >diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py >b/BaseTools/Source/Python/AutoGen/GenPcdDb.py >index e2848e7..cc3566f 100644 >--- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py >+++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py >@@ -1387,13 +1387,16 @@ def CreatePcdDatabasePhaseSpecificAutoGen >(Platform, DynamicPcdList, Phase): > StringHeadOffsetList.append(str(StringTableSize) + 'U= ') > StringDbOffsetList.append(StringTableSize) > if Pcd.MaxDatumSize !=3D '': > MaxDatumSize =3D int(Pcd.MaxDatumSize, 0) > if MaxDatumSize < Size: >- EdkLogger.error("build", AUTOGEN_ERROR, >+ if Pcd.MaxSizeUserSet: >+ EdkLogger.error("build", AUTOGEN_ERROR, > "The maximum size of VOID* ty= pe PCD '%s.%s' is less >than its actual size occupied." % (Pcd.TokenSpaceGuidCName, >Pcd.TokenCName), > ExtraData=3D"[%s]" % str(Plat= form)) >+ else: >+ MaxDatumSize =3D Size > else: > MaxDatumSize =3D Size > StringTabLen =3D MaxDatumSize > if StringTabLen % 2: > StringTabLen +=3D 1 >diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py >b/BaseTools/Source/Python/Workspace/BuildClassObject.py >index 1352fa2..78332c1 100644 >--- a/BaseTools/Source/Python/Workspace/BuildClassObject.py >+++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py >@@ -1,9 +1,9 @@ > ## @file > # This file is used to define each component of the build database > # >-# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
>+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
> # This program and the accompanying materials > # are licensed and made available under the terms and conditions of the B= SD >License > # which accompanies this distribution. The full text of the license may = be >found at > # http://opensource.org/licenses/bsd-license.php > # >@@ -53,10 +53,11 @@ class PcdClassObject(object): > self.Type =3D Type > self.DatumType =3D DatumType > self.DefaultValue =3D Value > self.TokenValue =3D Token > self.MaxDatumSize =3D MaxDatumSize >+ self.MaxSizeUserSet =3D None > self.SkuInfoList =3D SkuInfoList > self.Phase =3D "DXE" > self.Pending =3D False > self.IsOverrided =3D IsOverrided > self.IsFromBinaryInf =3D False >-- >2.6.1.windows.1 > >_______________________________________________ >edk2-devel mailing list >edk2-devel@lists.01.org >https://lists.01.org/mailman/listinfo/edk2-devel