diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py b/BaseTools/Source/Python/AutoGen/GenPcdDb.py index 20f4a23371..d07ac60ef3 100644 --- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py +++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py @@ -836,6 +836,9 @@ def BuildExDataBase(Dict): DbOffset += DbItemTotal[DbIndex].GetInterOffset(Offset) break DbOffset += DbItemTotal[DbIndex].GetListSize() + if DbIndex + 1 == InitTableNum: + if DbOffset % 8: + DbOffset += (8 - DbOffset % 8) else: assert(False) @@ -867,6 +870,9 @@ def BuildExDataBase(Dict): DbOffset += DbItemTotal[DbIndex].GetInterOffset(VariableOffset) break DbOffset += DbItemTotal[DbIndex].GetListSize() + if DbIndex + 1 == InitTableNum: + if DbOffset % 8: + DbOffset += (8 - DbOffset % 8) else: assert(False) if isinstance(VariableRefTable[0],list): @@ -908,6 +914,8 @@ def BuildExDataBase(Dict): for Item in (DbUnInitValueUint64, DbUnInitValueUint32, DbUnInitValueUint16, DbUnInitValueUint8, DbUnInitValueBoolean): UninitDataBaseSize += Item.GetListSize() + if (DbTotalLength - UninitDataBaseSize) % 8: + DbTotalLength += (8 - (DbTotalLength - UninitDataBaseSize) % 8) # Construct the database buffer Guid = "{0x3c7d193c, 0x682c, 0x4c14, 0xa6, 0x8f, 0x55, 0x2d, 0xea, 0x4f, 0x43, 0x7e}" Guid = StringArrayToList(Guid) @@ -977,6 +985,10 @@ def BuildExDataBase(Dict): b = Item.PackData() Buffer += b if Index == InitTableNum: + if len(Buffer) % 8: + for num in range(8 - len(Buffer) % 8): + b = pack('=B', Pad) + Buffer += b break return Buffer