]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/GenFds/EfiSection.py
BaseTools/GenFds: permit stripped MM_CORE_STANDALONE binaries
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / EfiSection.py
index 9fe7db3f46e034903c5d710a4e7f187d1f210b92..0be176ec8ae19129511a8053508dcd0030cf663b 100644 (file)
 ##\r
 # Import Modules\r
 #\r
+from __future__ import absolute_import\r
 from struct import *\r
 from . import Section\r
 from .GenFdsGlobalVariable import GenFdsGlobalVariable\r
 import subprocess\r
-from .Ffs import Ffs\r
+from .Ffs import SectionSuffix\r
 import Common.LongFilePathOs as os\r
 from CommonDataClass.FdfClass import EfiSectionClassObject\r
 from Common import EdkLogger\r
@@ -67,7 +68,7 @@ class EfiSection (EfiSectionClassObject):
             StringData = FfsInf.__ExtendMacro__(self.StringData)\r
             ModuleNameStr = FfsInf.__ExtendMacro__('$(MODULE_NAME)')\r
             NoStrip = True\r
-            if FfsInf.ModuleType in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM) and SectionType in (BINARY_FILE_TYPE_TE, BINARY_FILE_TYPE_PE32):\r
+            if FfsInf.ModuleType in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM, SUP_MODULE_MM_CORE_STANDALONE) and SectionType in (BINARY_FILE_TYPE_TE, BINARY_FILE_TYPE_PE32):\r
                 if FfsInf.KeepReloc is not None:\r
                     NoStrip = FfsInf.KeepReloc\r
                 elif FfsInf.KeepRelocFromRule is not None:\r
@@ -123,7 +124,7 @@ class EfiSection (EfiSectionClassObject):
                     BuildNumTuple = tuple()\r
 \r
                 Num = SecNum\r
-                OutputFile = os.path.join( OutputPath, ModuleName + SUP_MODULE_SEC + str(Num) + Ffs.SectionSuffix.get(SectionType))\r
+                OutputFile = os.path.join( OutputPath, ModuleName + SUP_MODULE_SEC + str(Num) + SectionSuffix.get(SectionType))\r
                 GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_VERSION',\r
                                                     #Ui=StringData,\r
                                                     Ver=BuildNum,\r
@@ -134,7 +135,7 @@ class EfiSection (EfiSectionClassObject):
                 for File in FileList:\r
                     Index = Index + 1\r
                     Num = '%s.%d' %(SecNum, Index)\r
-                    OutputFile = os.path.join(OutputPath, ModuleName + SUP_MODULE_SEC + Num + Ffs.SectionSuffix.get(SectionType))\r
+                    OutputFile = os.path.join(OutputPath, ModuleName + SUP_MODULE_SEC + Num + SectionSuffix.get(SectionType))\r
                     f = open(File, 'r')\r
                     VerString = f.read()\r
                     f.close()\r
@@ -163,7 +164,7 @@ class EfiSection (EfiSectionClassObject):
                     else:\r
                         EdkLogger.error("GenFds", GENFDS_ERROR, "File: %s miss Version Section value" %InfFileName)\r
                 Num = SecNum\r
-                OutputFile = os.path.join( OutputPath, ModuleName + SUP_MODULE_SEC + str(Num) + Ffs.SectionSuffix.get(SectionType))\r
+                OutputFile = os.path.join( OutputPath, ModuleName + SUP_MODULE_SEC + str(Num) + SectionSuffix.get(SectionType))\r
                 GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_VERSION',\r
                                                     #Ui=VerString,\r
                                                     Ver=BuildNum,\r
@@ -184,7 +185,7 @@ class EfiSection (EfiSectionClassObject):
                 Num = SecNum\r
                 if IsMakefile and StringData == ModuleNameStr:\r
                     StringData = "$(MODULE_NAME)"\r
-                OutputFile = os.path.join( OutputPath, ModuleName + SUP_MODULE_SEC + str(Num) + Ffs.SectionSuffix.get(SectionType))\r
+                OutputFile = os.path.join( OutputPath, ModuleName + SUP_MODULE_SEC + str(Num) + SectionSuffix.get(SectionType))\r
                 GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_USER_INTERFACE',\r
                                                      Ui=StringData, IsMakefile=IsMakefile)\r
                 OutputFileList.append(OutputFile)\r
@@ -193,7 +194,7 @@ class EfiSection (EfiSectionClassObject):
                 for File in FileList:\r
                     Index = Index + 1\r
                     Num = '%s.%d' %(SecNum, Index)\r
-                    OutputFile = os.path.join(OutputPath, ModuleName + SUP_MODULE_SEC + Num + Ffs.SectionSuffix.get(SectionType))\r
+                    OutputFile = os.path.join(OutputPath, ModuleName + SUP_MODULE_SEC + Num + SectionSuffix.get(SectionType))\r
                     f = open(File, 'r')\r
                     UiString = f.read()\r
                     f.close()\r
@@ -217,7 +218,7 @@ class EfiSection (EfiSectionClassObject):
                 Num = SecNum\r
                 if IsMakefile and StringData == ModuleNameStr:\r
                     StringData = "$(MODULE_NAME)"\r
-                OutputFile = os.path.join( OutputPath, ModuleName + SUP_MODULE_SEC + str(Num) + Ffs.SectionSuffix.get(SectionType))\r
+                OutputFile = os.path.join( OutputPath, ModuleName + SUP_MODULE_SEC + str(Num) + SectionSuffix.get(SectionType))\r
                 GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_USER_INTERFACE',\r
                                                      Ui=StringData, IsMakefile=IsMakefile)\r
                 OutputFileList.append(OutputFile)\r
@@ -238,7 +239,7 @@ class EfiSection (EfiSectionClassObject):
                     """ Copy Map file to FFS output path """\r
                     Index = Index + 1\r
                     Num = '%s.%d' %(SecNum, Index)\r
-                    OutputFile = os.path.join( OutputPath, ModuleName + SUP_MODULE_SEC + Num + Ffs.SectionSuffix.get(SectionType))\r
+                    OutputFile = os.path.join( OutputPath, ModuleName + SUP_MODULE_SEC + Num + SectionSuffix.get(SectionType))\r
                     File = GenFdsGlobalVariable.MacroExtend(File, Dict)\r
 \r
                     #Get PE Section alignment when align is set to AUTO\r
@@ -247,9 +248,9 @@ class EfiSection (EfiSectionClassObject):
                         if ImageObj.SectionAlignment < 0x400:\r
                             Align = str (ImageObj.SectionAlignment)\r
                         elif ImageObj.SectionAlignment < 0x100000:\r
-                            Align = str (ImageObj.SectionAlignment // 0x400) + 'K'\r
+                            Align = str (ImageObj.SectionAlignment / 0x400) + 'K'\r
                         else:\r
-                            Align = str (ImageObj.SectionAlignment // 0x100000) + 'M'\r
+                            Align = str (ImageObj.SectionAlignment / 0x100000) + 'M'\r
 \r
                     if File[(len(File)-4):] == '.efi':\r
                         MapFile = File.replace('.efi', '.map')\r