summaryrefslogtreecommitdiff
path: root/BaseTools/Source/Python/GenFds
diff options
context:
space:
mode:
Diffstat (limited to 'BaseTools/Source/Python/GenFds')
-rw-r--r--BaseTools/Source/Python/GenFds/DataSection.py9
-rw-r--r--BaseTools/Source/Python/GenFds/FdfParser.py8
2 files changed, 14 insertions, 3 deletions
diff --git a/BaseTools/Source/Python/GenFds/DataSection.py b/BaseTools/Source/Python/GenFds/DataSection.py
index dff4691462..0f41953ad4 100644
--- a/BaseTools/Source/Python/GenFds/DataSection.py
+++ b/BaseTools/Source/Python/GenFds/DataSection.py
@@ -21,6 +21,7 @@ import subprocess
from Ffs import Ffs
import os
from CommonDataClass.FdfClass import DataSectionClassObject
+from Common.Misc import PeImageClass
import shutil
## generate data section
@@ -74,6 +75,14 @@ class DataSection (DataSectionClassObject):
(os.path.getmtime(MapFile) > os.path.getmtime(CopyMapFile)):
shutil.copyfile(MapFile, CopyMapFile)
+ #Get PE Section alignment when align is set to AUTO
+ if self.Alignment == 'Auto' and self.SecType in ('TE', 'PE32'):
+ ImageObj = PeImageClass (Filename)
+ if ImageObj.SectionAlignment < 0x400:
+ self.Alignment = str (ImageObj.SectionAlignment)
+ else:
+ self.Alignment = str (ImageObj.SectionAlignment / 0x400) + 'K'
+
NoStrip = True
if self.SecType in ('TE', 'PE32'):
if self.KeepReloc != None:
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py
index ea19156daf..69a4898499 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -2388,9 +2388,11 @@ class FdfParser:
FfsFileObj.CheckSum = True
if self.__GetAlignment():
- FfsFileObj.Alignment = self.__Token
-
-
+ if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
+ raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
+ #For FFS, Auto is default option same to ""
+ if not self.__Token == "Auto":
+ FfsFileObj.Alignment = self.__Token
## __GetAlignment() method
#