From nobody Mon May 6 09:40:03 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 152178470770487.99997872695144; Thu, 22 Mar 2018 22:58:27 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id B3EF9223E0B83; Thu, 22 Mar 2018 22:51:53 -0700 (PDT) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (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 39D79223E0B80 for ; Thu, 22 Mar 2018 22:51:52 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Mar 2018 22:58:24 -0700 Received: from shwdeopenpsi168.ccr.corp.intel.com ([10.239.158.129]) by fmsmga004.fm.intel.com with ESMTP; 22 Mar 2018 22:58:24 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.136; helo=mga12.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,348,1517904000"; d="scan'208";a="39896493" From: Yonghong Zhu To: edk2-devel@lists.01.org Date: Fri, 23 Mar 2018 13:58:21 +0800 Message-Id: <1521784701-10864-1-git-send-email-yonghong.zhu@intel.com> X-Mailer: git-send-email 2.6.1.windows.1 Subject: [edk2] [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.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Liming Gao --- 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.T= ype), File=3Dself.MetaFile) =20 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], Mod= ule) # use PCD value to calculate the MaxDatumSize when it is not speci= fied for Name, Guid in Pcds: Pcd =3D Pcds[Name, Guid] if Pcd.DatumType =3D=3D "VOID*" and Pcd.MaxDatumSize in ['', N= one]: + 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* typ= e PCD '%s.%s' is less than its actual size occupied." % (Pcd.TokenSpaceGuid= CName, 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' * (Ar= raySize - 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 PC= D '%s.%s' is less than its actual size occupied." % (Pcd.TokenSpaceGuidCNam= e, TokenCName) ) + else: + ArraySize =3D len(PcdValue) + 1 PcdItem =3D '%s.%s|%s|0x%X' % \ (Pcd.TokenSpaceGuidCName, TokenCName, PcdValue, PatchP= cd[1]) PcdComments =3D '' if (Pcd.TokenSpaceGuidCName, Pcd.TokenCName) in self._PcdC= omments: PcdComments =3D '\n '.join(self._PcdComments[Pcd.Toke= nSpaceGuidCName, Pcd.TokenCName]) diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Pyt= hon/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 BS= D License # which accompanies this distribution. The full text of the license may b= e found at # http://opensource.org/licenses/bsd-license.php # @@ -1108,13 +1108,18 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, P= cd): NewValue =3D NewValue + str(ord(Value[Index]) % 0x= 100) + ', ' if Unicode: ArraySize =3D ArraySize / 2; =20 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, T= okenCName), 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* typ= e PCD '%s.%s' is less than its actual size occupied." % (Pcd.TokenSpaceGuid= CName, Pcd.TokenCName), ExtraData=3D"[%s]" % str(Platf= orm)) + 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/BaseTo= ols/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 BS= D License # which accompanies this distribution. The full text of the license may b= e 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 --=20 2.6.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel