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.136; helo=mga12.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org 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) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False 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 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,348,1517904000"; d="scan'208";a="39896493" 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 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: [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: , X-List-Received-Date: Fri, 23 Mar 2018 05:51:52 -0000 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=self.MetaFile) if FromPcd.MaxDatumSize not in [None, '']: ToPcd.MaxDatumSize = FromPcd.MaxDatumSize + ToPcd.MaxSizeUserSet = FromPcd.MaxDatumSize if FromPcd.DefaultValue not in [None, '']: ToPcd.DefaultValue = FromPcd.DefaultValue if FromPcd.TokenValue not in [None, '']: ToPcd.TokenValue = FromPcd.TokenValue - if FromPcd.MaxDatumSize not in [None, '']: - ToPcd.MaxDatumSize = FromPcd.MaxDatumSize if FromPcd.DatumType not in [None, '']: ToPcd.DatumType = FromPcd.DatumType if FromPcd.SkuInfoList not in [None, '', []]: ToPcd.SkuInfoList = FromPcd.SkuInfoList # Add Flexible PCD format parse @@ -2470,10 +2469,11 @@ class PlatformAutoGen(AutoGen): self._OverridePcd(ToPcd, PlatformModule.Pcds[Key], Module) # use PCD value to calculate the MaxDatumSize when it is not specified for Name, Guid in Pcds: Pcd = Pcds[Name, Guid] if Pcd.DatumType == "VOID*" and Pcd.MaxDatumSize in ['', None]: + Pcd.MaxSizeUserSet = None Value = Pcd.DefaultValue if Value in [None, '']: Pcd.MaxDatumSize = '1' elif Value[0] == 'L': Pcd.MaxDatumSize = str((len(Value) - 2) * 2) @@ -4180,23 +4180,29 @@ class ModuleAutoGen(AutoGen): Padding = '0x00, ' if Unicode: Padding = Padding * 2 ArraySize = 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* type PCD '%s.%s' is less than its actual size occupied." % (Pcd.TokenSpaceGuidCName, TokenCName) ) + else: + ArraySize = len(PcdValue) + 1 if ArraySize > len(PcdValue) + 1: NewValue = NewValue + Padding * (ArraySize - len(PcdValue) - 1) PcdValue = NewValue + Padding.strip().rstrip(',') + '}' elif len(PcdValue.split(',')) <= ArraySize: PcdValue = PcdValue.rstrip('}') + ', 0x00' * (ArraySize - len(PcdValue.split(','))) PcdValue += '}' else: - 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) ) + else: + ArraySize = len(PcdValue) + 1 PcdItem = '%s.%s|%s|0x%X' % \ (Pcd.TokenSpaceGuidCName, TokenCName, PcdValue, PatchPcd[1]) PcdComments = '' if (Pcd.TokenSpaceGuidCName, Pcd.TokenCName) in self._PcdComments: PcdComments = '\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 BSD 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 = NewValue + str(ord(Value[Index]) % 0x100) + ', ' if Unicode: ArraySize = 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="[%s]" % str(Info)) + else: + ArraySize = GetPcdSize(Pcd) + if Unicode: + ArraySize = ArraySize / 2 Value = NewValue + '0 }' Array = '[%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 != '': MaxDatumSize = 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* type PCD '%s.%s' is less than its actual size occupied." % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName), ExtraData="[%s]" % str(Platform)) + else: + MaxDatumSize = Size else: MaxDatumSize = Size StringTabLen = MaxDatumSize if StringTabLen % 2: StringTabLen += 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 BSD 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 = Type self.DatumType = DatumType self.DefaultValue = Value self.TokenValue = Token self.MaxDatumSize = MaxDatumSize + self.MaxSizeUserSet = None self.SkuInfoList = SkuInfoList self.Phase = "DXE" self.Pending = False self.IsOverrided = IsOverrided self.IsFromBinaryInf = False -- 2.6.1.windows.1