From 4cf022f2f11fc3cd12ab5dd24e5ae74f541bac48 Mon Sep 17 00:00:00 2001 From: "Feng, Bob C" Date: Tue, 28 Aug 2018 18:22:45 +0800 Subject: BaseTools: Fixed the PcdValue trailing zero issue. 1. Not append trailing zero for PcdValue 2. make sure the point to Variable Name in PCD DataBase 2 bytes aligned. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao Reviewed-by: Liming Gao --- BaseTools/Source/Python/AutoGen/GenPcdDb.py | 6 ++++++ BaseTools/Source/Python/Common/StringUtils.py | 7 +------ 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'BaseTools') diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py b/BaseTools/Source/Python/AutoGen/GenPcdDb.py index 2176bbe..5b260cd 100644 --- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py +++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py @@ -1184,6 +1184,12 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase): # and calculate the VariableHeadStringIndex VariableNameStructure = StringToArray(Sku.VariableName) + + # Make pointer of VaraibleName(HII PCD) 2 bytes aligned + VariableNameStructureBytes = VariableNameStructure.lstrip("{").rstrip("}").split(",") + if len(VariableNameStructureBytes) % 2: + VariableNameStructure = "{%s,0x00}" % ",".join(VariableNameStructureBytes) + if VariableNameStructure not in Dict['STRING_TABLE_VALUE']: Dict['STRING_TABLE_CNAME'].append(CName) Dict['STRING_TABLE_GUID'].append(TokenSpaceGuid) diff --git a/BaseTools/Source/Python/Common/StringUtils.py b/BaseTools/Source/Python/Common/StringUtils.py index da2949d..d5afde7 100644 --- a/BaseTools/Source/Python/Common/StringUtils.py +++ b/BaseTools/Source/Python/Common/StringUtils.py @@ -835,12 +835,7 @@ def StringToArray(String): else: return "{%s,0x00,0x00}" % ",".join("0x%02x" % ord(C) for C in String[1:-1]) elif String.startswith('{'): - StringLen = len(String.split(",")) - if StringLen % 2: - return "{%s,0x00}" % ",".join(C.strip() for C in String[1:-1].split(',')) - else: - return "{%s}" % ",".join(C.strip() for C in String[1:-1].split(',')) - + return "{%s}" % ",".join(C.strip() for C in String[1:-1].split(',')) else: if len(String.split()) % 2: return '{%s,0}' % ','.join(String.split()) -- cgit v1.1