summaryrefslogtreecommitdiff
path: root/BaseTools/Source/Python/GenFds/EfiSection.py
diff options
context:
space:
mode:
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2010-02-28 23:39:39 +0000
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2010-02-28 23:39:39 +0000
commit52302d4dee589a5df43a464420c9fe68ba83937d (patch)
tree2393f61b9e8975134e3cdfa0352d4c51a3b2ac8d /BaseTools/Source/Python/GenFds/EfiSection.py
parentfe35c036354c4b6bf18c4699a45156f3965fae2a (diff)
downloadedk2-platforms-52302d4dee589a5df43a464420c9fe68ba83937d.tar.xz
Sync EDKII BaseTools to BaseTools project r1903.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10123 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'BaseTools/Source/Python/GenFds/EfiSection.py')
-rw-r--r--BaseTools/Source/Python/GenFds/EfiSection.py30
1 files changed, 21 insertions, 9 deletions
diff --git a/BaseTools/Source/Python/GenFds/EfiSection.py b/BaseTools/Source/Python/GenFds/EfiSection.py
index 2c112ed5cb..ad953facb9 100644
--- a/BaseTools/Source/Python/GenFds/EfiSection.py
+++ b/BaseTools/Source/Python/GenFds/EfiSection.py
@@ -15,6 +15,7 @@
##
# Import Modules
#
+from struct import *
import Section
from GenFdsGlobalVariable import GenFdsGlobalVariable
import subprocess
@@ -24,6 +25,7 @@ from CommonDataClass.FdfClass import EfiSectionClassObject
import shutil
from Common import EdkLogger
from Common.BuildToolError import *
+from Common.Misc import PeImageClass
## generate rule section
#
@@ -78,6 +80,12 @@ class EfiSection (EfiSectionClassObject):
FileList = []
if Filename != None:
Filename = GenFdsGlobalVariable.MacroExtend(Filename, Dict)
+ # check if the path is absolute or relative
+ if os.path.isabs(Filename):
+ Filename = os.path.normpath(Filename)
+ else:
+ Filename = os.path.normpath(os.path.join(FfsInf.EfiOutputPath, Filename))
+
if not self.Optional:
FileList.append(Filename)
elif os.path.exists(Filename):
@@ -121,7 +129,6 @@ class EfiSection (EfiSectionClassObject):
f = open(File, 'r')
VerString = f.read()
f.close()
-# VerTuple = ('-n', '"' + VerString + '"')
BuildNum = VerString
if BuildNum != None and BuildNum != '':
BuildNumTuple = ('-j', BuildNum)
@@ -131,11 +138,6 @@ class EfiSection (EfiSectionClassObject):
OutputFileList.append(OutputFile)
else:
-# if StringData != None and len(StringData) > 0:
-# VerTuple = ('-n', '"' + StringData + '"')
-# else:
-# VerTuple = tuple()
-# VerString = ' ' + ' '.join(VerTuple)
BuildNum = StringData
if BuildNum != None and BuildNum != '':
BuildNumTuple = ('-j', BuildNum)
@@ -221,6 +223,15 @@ class EfiSection (EfiSectionClassObject):
Num = '%s.%d' %(SecNum , Index)
OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + Num + Ffs.SectionSuffix.get(SectionType))
File = GenFdsGlobalVariable.MacroExtend(File, Dict)
+
+ #Get PE Section alignment when align is set to AUTO
+ if self.Alignment == 'Auto' and (SectionType == 'PE32' or SectionType == 'TE'):
+ ImageObj = PeImageClass (File)
+ if ImageObj.SectionAlignment < 0x400:
+ self.Alignment = str (ImageObj.SectionAlignment)
+ else:
+ self.Alignment = str (ImageObj.SectionAlignment / 0x400) + 'K'
+
if File[(len(File)-4):] == '.efi':
MapFile = File.replace('.efi', '.map')
if os.path.exists(MapFile):
@@ -237,24 +248,25 @@ class EfiSection (EfiSectionClassObject):
StrippedFile = os.path.join(OutputPath, ModuleName + '.stripped')
GenFdsGlobalVariable.GenerateFirmwareImage(
StrippedFile,
- [GenFdsGlobalVariable.MacroExtend(File, Dict)],
+ [File],
Strip=True
)
File = StrippedFile
+
"""For TE Section call GenFw to generate TE image"""
if SectionType == 'TE':
TeFile = os.path.join( OutputPath, ModuleName + 'Te.raw')
GenFdsGlobalVariable.GenerateFirmwareImage(
TeFile,
- [GenFdsGlobalVariable.MacroExtend(File, Dict)],
+ [File],
Type='te'
)
File = TeFile
"""Call GenSection"""
GenFdsGlobalVariable.GenerateSection(OutputFile,
- [GenFdsGlobalVariable.MacroExtend(File)],
+ [File],
Section.Section.SectionType.get (SectionType)
)
OutputFileList.append(OutputFile)