X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FGenFds%2FEfiSection.py;h=74f176cfef2f9833169f1c2b7994ee1c2385ff71;hp=fa2148ec7b2871d93603038d5fc63a482bf5e6ab;hb=04797875d1d53e53e31eca4fa01bc3cf6929f39c;hpb=487062c048809420de1b008bc9d17815a8c4fbdb diff --git a/BaseTools/Source/Python/GenFds/EfiSection.py b/BaseTools/Source/Python/GenFds/EfiSection.py index fa2148ec7b..74f176cfef 100644 --- a/BaseTools/Source/Python/GenFds/EfiSection.py +++ b/BaseTools/Source/Python/GenFds/EfiSection.py @@ -3,23 +3,18 @@ # # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# SPDX-License-Identifier: BSD-2-Clause-Patent # ## # Import Modules # +from __future__ import absolute_import from struct import * from . import Section from .GenFdsGlobalVariable import GenFdsGlobalVariable import subprocess -from .Ffs import Ffs +from .Ffs import SectionSuffix import Common.LongFilePathOs as os from CommonDataClass.FdfClass import EfiSectionClassObject from Common import EdkLogger @@ -67,7 +62,7 @@ class EfiSection (EfiSectionClassObject): StringData = FfsInf.__ExtendMacro__(self.StringData) ModuleNameStr = FfsInf.__ExtendMacro__('$(MODULE_NAME)') NoStrip = True - 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): + 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): if FfsInf.KeepReloc is not None: NoStrip = FfsInf.KeepReloc elif FfsInf.KeepRelocFromRule is not None: @@ -98,7 +93,7 @@ class EfiSection (EfiSectionClassObject): if '.depex' in SuffixMap: FileList.append(Filename) else: - FileList, IsSect = Section.Section.GetFileList(FfsInf, self.FileType, self.FileExtension, Dict, IsMakefile=IsMakefile) + FileList, IsSect = Section.Section.GetFileList(FfsInf, self.FileType, self.FileExtension, Dict, IsMakefile=IsMakefile, SectionType=SectionType) if IsSect : return FileList, self.Alignment @@ -123,7 +118,7 @@ class EfiSection (EfiSectionClassObject): BuildNumTuple = tuple() Num = SecNum - OutputFile = os.path.join( OutputPath, ModuleName + SUP_MODULE_SEC + str(Num) + Ffs.SectionSuffix.get(SectionType)) + OutputFile = os.path.join( OutputPath, ModuleName + SUP_MODULE_SEC + str(Num) + SectionSuffix.get(SectionType)) GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_VERSION', #Ui=StringData, Ver=BuildNum, @@ -134,7 +129,7 @@ class EfiSection (EfiSectionClassObject): for File in FileList: Index = Index + 1 Num = '%s.%d' %(SecNum, Index) - OutputFile = os.path.join(OutputPath, ModuleName + SUP_MODULE_SEC + Num + Ffs.SectionSuffix.get(SectionType)) + OutputFile = os.path.join(OutputPath, ModuleName + SUP_MODULE_SEC + Num + SectionSuffix.get(SectionType)) f = open(File, 'r') VerString = f.read() f.close() @@ -163,7 +158,7 @@ class EfiSection (EfiSectionClassObject): else: EdkLogger.error("GenFds", GENFDS_ERROR, "File: %s miss Version Section value" %InfFileName) Num = SecNum - OutputFile = os.path.join( OutputPath, ModuleName + SUP_MODULE_SEC + str(Num) + Ffs.SectionSuffix.get(SectionType)) + OutputFile = os.path.join( OutputPath, ModuleName + SUP_MODULE_SEC + str(Num) + SectionSuffix.get(SectionType)) GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_VERSION', #Ui=VerString, Ver=BuildNum, @@ -184,7 +179,7 @@ class EfiSection (EfiSectionClassObject): Num = SecNum if IsMakefile and StringData == ModuleNameStr: StringData = "$(MODULE_NAME)" - OutputFile = os.path.join( OutputPath, ModuleName + SUP_MODULE_SEC + str(Num) + Ffs.SectionSuffix.get(SectionType)) + OutputFile = os.path.join( OutputPath, ModuleName + SUP_MODULE_SEC + str(Num) + SectionSuffix.get(SectionType)) GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_USER_INTERFACE', Ui=StringData, IsMakefile=IsMakefile) OutputFileList.append(OutputFile) @@ -193,7 +188,7 @@ class EfiSection (EfiSectionClassObject): for File in FileList: Index = Index + 1 Num = '%s.%d' %(SecNum, Index) - OutputFile = os.path.join(OutputPath, ModuleName + SUP_MODULE_SEC + Num + Ffs.SectionSuffix.get(SectionType)) + OutputFile = os.path.join(OutputPath, ModuleName + SUP_MODULE_SEC + Num + SectionSuffix.get(SectionType)) f = open(File, 'r') UiString = f.read() f.close() @@ -217,11 +212,31 @@ class EfiSection (EfiSectionClassObject): Num = SecNum if IsMakefile and StringData == ModuleNameStr: StringData = "$(MODULE_NAME)" - OutputFile = os.path.join( OutputPath, ModuleName + SUP_MODULE_SEC + str(Num) + Ffs.SectionSuffix.get(SectionType)) + OutputFile = os.path.join( OutputPath, ModuleName + SUP_MODULE_SEC + str(Num) + SectionSuffix.get(SectionType)) GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_USER_INTERFACE', Ui=StringData, IsMakefile=IsMakefile) OutputFileList.append(OutputFile) + # + # If Section Type is BINARY_FILE_TYPE_RAW + # + elif SectionType == BINARY_FILE_TYPE_RAW: + """If File List is empty""" + if FileList == []: + if self.Optional == True: + GenFdsGlobalVariable.VerboseLogger("Optional Section don't exist!") + return [], None + else: + EdkLogger.error("GenFds", GENFDS_ERROR, "Output file for %s section could not be found for %s" % (SectionType, InfFileName)) + + elif len(FileList) > 1: + EdkLogger.error("GenFds", GENFDS_ERROR, + "Files suffixed with %s are not allowed to have more than one file in %s[Binaries] section" % ( + self.FileExtension, InfFileName)) + else: + for File in FileList: + File = GenFdsGlobalVariable.MacroExtend(File, Dict) + OutputFileList.append(File) else: """If File List is empty""" @@ -238,7 +253,7 @@ class EfiSection (EfiSectionClassObject): """ Copy Map file to FFS output path """ Index = Index + 1 Num = '%s.%d' %(SecNum, Index) - OutputFile = os.path.join( OutputPath, ModuleName + SUP_MODULE_SEC + Num + Ffs.SectionSuffix.get(SectionType)) + OutputFile = os.path.join( OutputPath, ModuleName + SUP_MODULE_SEC + Num + SectionSuffix.get(SectionType)) File = GenFdsGlobalVariable.MacroExtend(File, Dict) #Get PE Section alignment when align is set to AUTO @@ -247,9 +262,9 @@ class EfiSection (EfiSectionClassObject): if ImageObj.SectionAlignment < 0x400: Align = str (ImageObj.SectionAlignment) elif ImageObj.SectionAlignment < 0x100000: - Align = str (ImageObj.SectionAlignment / 0x400) + 'K' + Align = str (ImageObj.SectionAlignment // 0x400) + 'K' else: - Align = str (ImageObj.SectionAlignment / 0x100000) + 'M' + Align = str (ImageObj.SectionAlignment // 0x100000) + 'M' if File[(len(File)-4):] == '.efi': MapFile = File.replace('.efi', '.map')