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(-)
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 <yonghong.zhu@intel.com>
---
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.<BR>
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
# 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.<BR>
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
# 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
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Reviewed-by: Liming Gao <liming.gao@intel.com> >-----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 <yonghong.zhu@intel.com> >--- > 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.<BR> >+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR> > # 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.<BR> >+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR> > # 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 > >_______________________________________________ >edk2-devel mailing list >edk2-devel@lists.01.org >https://lists.01.org/mailman/listinfo/edk2-devel _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
© 2016 - 2024 Red Hat, Inc.