From c1b9129c3c1f09a4847c7ff3179ef2edc475cf56 Mon Sep 17 00:00:00 2001 From: Bob Feng Date: Tue, 12 May 2015 00:58:20 +0000 Subject: [PATCH] BaseTools/Build: The PCD value in uninitialized data range should be natural aligned. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: "Bob Feng" Reviewed-by: "Liu, Yingke D" Tested-by: Ard Biesheuvel git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17416 6f19259b-4bc3-4df7-8a09-765794883524 --- BaseTools/Source/Python/AutoGen/GenPcdDb.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 -- 2.39.2