]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/GenFds/EfiSection.py
Sync EDKII BaseTools to BaseTools project r1903.
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / EfiSection.py
index 2c112ed5cbf47824cf54a6cd7a54bfdeacac4eb1..ad953facb98f04166c9065e56943d70f4c4e11cb 100644 (file)
@@ -15,6 +15,7 @@
 ##\r
 # Import Modules\r
 #\r
+from struct import *\r
 import Section\r
 from GenFdsGlobalVariable import GenFdsGlobalVariable\r
 import subprocess\r
@@ -24,6 +25,7 @@ from CommonDataClass.FdfClass import EfiSectionClassObject
 import shutil\r
 from Common import EdkLogger\r
 from Common.BuildToolError import *\r
+from Common.Misc import PeImageClass\r
 \r
 ## generate rule section\r
 #\r
@@ -78,6 +80,12 @@ class EfiSection (EfiSectionClassObject):
         FileList = []\r
         if Filename != None:\r
             Filename = GenFdsGlobalVariable.MacroExtend(Filename, Dict)\r
+            # 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))
+\r
             if not self.Optional:\r
                 FileList.append(Filename)\r
             elif os.path.exists(Filename):\r
@@ -121,7 +129,6 @@ class EfiSection (EfiSectionClassObject):
                     f = open(File, 'r')\r
                     VerString = f.read()\r
                     f.close()\r
-#                    VerTuple = ('-n', '"' + VerString + '"')\r
                     BuildNum = VerString\r
                     if BuildNum != None and BuildNum != '':\r
                         BuildNumTuple = ('-j', BuildNum)\r
@@ -131,11 +138,6 @@ class EfiSection (EfiSectionClassObject):
                     OutputFileList.append(OutputFile)\r
 \r
             else:\r
-#                if StringData != None and len(StringData) > 0:\r
-#                    VerTuple = ('-n', '"' + StringData + '"')\r
-#                else:\r
-#                    VerTuple = tuple()\r
-#                VerString = ' ' + ' '.join(VerTuple)\r
                 BuildNum = StringData\r
                 if BuildNum != None and BuildNum != '':\r
                     BuildNumTuple = ('-j', BuildNum)\r
@@ -221,6 +223,15 @@ class EfiSection (EfiSectionClassObject):
                     Num = '%s.%d' %(SecNum , Index)\r
                     OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + Num + Ffs.SectionSuffix.get(SectionType))\r
                     File = GenFdsGlobalVariable.MacroExtend(File, Dict)\r
+                    \r
+                    #Get PE Section alignment when align is set to AUTO\r
+                    if self.Alignment == 'Auto' and (SectionType == 'PE32' or SectionType == 'TE'):\r
+                        ImageObj = PeImageClass (File)\r
+                        if ImageObj.SectionAlignment < 0x400:\r
+                            self.Alignment = str (ImageObj.SectionAlignment)\r
+                        else:\r
+                            self.Alignment = str (ImageObj.SectionAlignment / 0x400) + 'K'\r
+\r
                     if File[(len(File)-4):] == '.efi':\r
                         MapFile = File.replace('.efi', '.map')\r
                         if os.path.exists(MapFile):\r
@@ -237,24 +248,25 @@ class EfiSection (EfiSectionClassObject):
                         StrippedFile = os.path.join(OutputPath, ModuleName + '.stripped')\r
                         GenFdsGlobalVariable.GenerateFirmwareImage(\r
                                                 StrippedFile,\r
-                                                [GenFdsGlobalVariable.MacroExtend(File, Dict)],\r
+                                                [File],\r
                                                 Strip=True\r
                                                 )\r
                         File = StrippedFile\r
+                    \r
                     """For TE Section call GenFw to generate TE image"""\r
 \r
                     if SectionType == 'TE':\r
                         TeFile = os.path.join( OutputPath, ModuleName + 'Te.raw')\r
                         GenFdsGlobalVariable.GenerateFirmwareImage(\r
                                                 TeFile,\r
-                                                [GenFdsGlobalVariable.MacroExtend(File, Dict)],\r
+                                                [File],\r
                                                 Type='te'\r
                                                 )\r
                         File = TeFile\r
 \r
                     """Call GenSection"""\r
                     GenFdsGlobalVariable.GenerateSection(OutputFile,\r
-                                                         [GenFdsGlobalVariable.MacroExtend(File)],\r
+                                                         [File],\r
                                                          Section.Section.SectionType.get (SectionType)\r
                                                          )\r
                     OutputFileList.append(OutputFile)\r