Sync EDKII BaseTools to BaseTools project r1971
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 18 May 2010 05:04:32 +0000 (05:04 +0000)
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 18 May 2010 05:04:32 +0000 (05:04 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10502 6f19259b-4bc3-4df7-8a09-765794883524

417 files changed:
BaseTools/Bin/CYGWIN_NT-5.1-i686/armcc_wrapper.py
BaseTools/Bin/Win32/BootSectImage.exe
BaseTools/Bin/Win32/EfiLdrImage.exe
BaseTools/Bin/Win32/EfiRom.exe
BaseTools/Bin/Win32/Fpd2Dsc.exe
BaseTools/Bin/Win32/GenBootSector.exe
BaseTools/Bin/Win32/GenCrc32.exe
BaseTools/Bin/Win32/GenDepex.exe
BaseTools/Bin/Win32/GenFds.exe
BaseTools/Bin/Win32/GenFfs.exe
BaseTools/Bin/Win32/GenFv.exe
BaseTools/Bin/Win32/GenFw.exe
BaseTools/Bin/Win32/GenPage.exe
BaseTools/Bin/Win32/GenPatchPcdTable.exe
BaseTools/Bin/Win32/GenSec.exe
BaseTools/Bin/Win32/GenVtf.exe
BaseTools/Bin/Win32/LzmaCompress.exe
BaseTools/Bin/Win32/MigrationMsa2Inf.exe
BaseTools/Bin/Win32/PatchPcdValue.exe
BaseTools/Bin/Win32/Spd2Dec.exe
BaseTools/Bin/Win32/Split.exe
BaseTools/Bin/Win32/TargetTool.exe
BaseTools/Bin/Win32/TianoCompress.exe
BaseTools/Bin/Win32/Trim.exe
BaseTools/Bin/Win32/VfrCompile.exe
BaseTools/Bin/Win32/VolInfo.exe
BaseTools/Bin/Win32/build.exe
BaseTools/BuildEnv
BaseTools/BuildNotes.txt
BaseTools/Conf/FrameworkDatabase.template
BaseTools/Conf/XMLSchema/DistributionPackage.xsd
BaseTools/Conf/XMLSchema/FarManifest.xsd
BaseTools/Conf/XMLSchema/FrameworkDataAttributes.xsd
BaseTools/Conf/XMLSchema/FrameworkDataElements.xsd
BaseTools/Conf/XMLSchema/FrameworkDataTypes.xsd
BaseTools/Conf/XMLSchema/FrameworkHeaders.xsd
BaseTools/Conf/XMLSchema/NamingConvention.xsd
BaseTools/Conf/XMLSchema/SurfaceArea.xsd
BaseTools/Conf/XMLSchema/SurfaceArea.xsdconfig
BaseTools/Conf/XMLSchema/WorkspaceContent.xsd
BaseTools/Conf/build_rule.template
BaseTools/Conf/target.template
BaseTools/Conf/tools_def.template
BaseTools/GNUmakefile
BaseTools/Makefile
BaseTools/Scripts/gcc4.4-ld-script [new file with mode: 0644]
BaseTools/Source/C/BootSectImage/GNUmakefile
BaseTools/Source/C/BootSectImage/Makefile
BaseTools/Source/C/BootSectImage/bootsectimage.c
BaseTools/Source/C/BootSectImage/fat.h
BaseTools/Source/C/BootSectImage/mbr.h
BaseTools/Source/C/Common/BasePeCoff.c
BaseTools/Source/C/Common/BinderFuncs.c
BaseTools/Source/C/Common/BinderFuncs.h
BaseTools/Source/C/Common/CommonLib.c
BaseTools/Source/C/Common/CommonLib.h
BaseTools/Source/C/Common/Compress.h
BaseTools/Source/C/Common/Crc32.c
BaseTools/Source/C/Common/Crc32.h
BaseTools/Source/C/Common/Decompress.c
BaseTools/Source/C/Common/Decompress.h
BaseTools/Source/C/Common/EfiCompress.c
BaseTools/Source/C/Common/EfiUtilityMsgs.c
BaseTools/Source/C/Common/EfiUtilityMsgs.h
BaseTools/Source/C/Common/FirmwareVolumeBuffer.c
BaseTools/Source/C/Common/FirmwareVolumeBufferLib.h
BaseTools/Source/C/Common/FvLib.c
BaseTools/Source/C/Common/FvLib.h
BaseTools/Source/C/Common/GNUmakefile
BaseTools/Source/C/Common/Makefile
BaseTools/Source/C/Common/MemoryFile.c
BaseTools/Source/C/Common/MemoryFile.h
BaseTools/Source/C/Common/MyAlloc.c
BaseTools/Source/C/Common/MyAlloc.h
BaseTools/Source/C/Common/OsPath.c
BaseTools/Source/C/Common/OsPath.h
BaseTools/Source/C/Common/ParseGuidedSectionTools.c
BaseTools/Source/C/Common/ParseGuidedSectionTools.h
BaseTools/Source/C/Common/ParseInf.c
BaseTools/Source/C/Common/ParseInf.h
BaseTools/Source/C/Common/PeCoffLib.h
BaseTools/Source/C/Common/PeCoffLoaderEx.c
BaseTools/Source/C/Common/SimpleFileParsing.c
BaseTools/Source/C/Common/SimpleFileParsing.h
BaseTools/Source/C/Common/StringFuncs.c
BaseTools/Source/C/Common/StringFuncs.h
BaseTools/Source/C/Common/TianoCompress.c
BaseTools/Source/C/Common/WinNtInclude.h
BaseTools/Source/C/EfiLdrImage/EfiLdrImage.c
BaseTools/Source/C/EfiLdrImage/GNUmakefile
BaseTools/Source/C/EfiLdrImage/Makefile
BaseTools/Source/C/EfiRom/EfiRom.c
BaseTools/Source/C/EfiRom/EfiRom.h
BaseTools/Source/C/EfiRom/GNUmakefile
BaseTools/Source/C/EfiRom/Makefile
BaseTools/Source/C/GNUmakefile
BaseTools/Source/C/GenBootSector/FatFormat.h
BaseTools/Source/C/GenBootSector/GenBootSector.c
BaseTools/Source/C/GenBootSector/GetDrvNumOffset.c
BaseTools/Source/C/GenBootSector/Makefile
BaseTools/Source/C/GenCrc32/GNUmakefile
BaseTools/Source/C/GenCrc32/GenCrc32.c
BaseTools/Source/C/GenCrc32/Makefile
BaseTools/Source/C/GenFfs/GNUmakefile
BaseTools/Source/C/GenFfs/GenFfs.c
BaseTools/Source/C/GenFfs/Makefile
BaseTools/Source/C/GenFv/GNUmakefile
BaseTools/Source/C/GenFv/GenFv.c
BaseTools/Source/C/GenFv/GenFvInternalLib.c
BaseTools/Source/C/GenFv/GenFvInternalLib.h
BaseTools/Source/C/GenFv/Makefile
BaseTools/Source/C/GenFw/Elf32Convert.c [new file with mode: 0644]
BaseTools/Source/C/GenFw/Elf32Convert.h [new file with mode: 0644]
BaseTools/Source/C/GenFw/Elf64Convert.c [new file with mode: 0644]
BaseTools/Source/C/GenFw/Elf64Convert.h [new file with mode: 0644]
BaseTools/Source/C/GenFw/ElfConvert.c [new file with mode: 0644]
BaseTools/Source/C/GenFw/ElfConvert.h [new file with mode: 0644]
BaseTools/Source/C/GenFw/GNUmakefile
BaseTools/Source/C/GenFw/GenFw.c
BaseTools/Source/C/GenFw/GenFw.h [new file with mode: 0644]
BaseTools/Source/C/GenFw/Makefile
BaseTools/Source/C/GenFw/elf32.h
BaseTools/Source/C/GenFw/elf64.h
BaseTools/Source/C/GenFw/elf_common.h
BaseTools/Source/C/GenPage/GNUmakefile
BaseTools/Source/C/GenPage/GenPage.c
BaseTools/Source/C/GenPage/Makefile
BaseTools/Source/C/GenPage/VirtualMemory.h
BaseTools/Source/C/GenSec/GNUmakefile
BaseTools/Source/C/GenSec/GenSec.c
BaseTools/Source/C/GenSec/Makefile
BaseTools/Source/C/GenVtf/GNUmakefile
BaseTools/Source/C/GenVtf/GenVtf.c
BaseTools/Source/C/GenVtf/GenVtf.h
BaseTools/Source/C/GenVtf/Makefile
BaseTools/Source/C/GnuGenBootSector/FatFormat.h
BaseTools/Source/C/GnuGenBootSector/GNUmakefile
BaseTools/Source/C/GnuGenBootSector/GnuGenBootSector.c
BaseTools/Source/C/Include/Common/BaseTypes.h
BaseTools/Source/C/Include/Common/MdeModuleHii.h
BaseTools/Source/C/Include/Common/PiFirmwareFile.h
BaseTools/Source/C/Include/Common/PiFirmwareVolume.h
BaseTools/Source/C/Include/Common/UefiBaseTypes.h
BaseTools/Source/C/Include/Common/UefiCapsule.h
BaseTools/Source/C/Include/Common/UefiInternalFormRepresentation.h
BaseTools/Source/C/Include/Common/UefiMultiPhase.h
BaseTools/Source/C/Include/Common/VariableFormat.h
BaseTools/Source/C/Include/Common/WorkingBlockHeader.h
BaseTools/Source/C/Include/Guid/PcAnsi.h
BaseTools/Source/C/Include/Guid/PiFirmwareFileSystem.h
BaseTools/Source/C/Include/Ia32/ProcessorBind.h
BaseTools/Source/C/Include/IndustryStandard/Acpi.h
BaseTools/Source/C/Include/IndustryStandard/Acpi1_0.h
BaseTools/Source/C/Include/IndustryStandard/Acpi2_0.h
BaseTools/Source/C/Include/IndustryStandard/Acpi3_0.h
BaseTools/Source/C/Include/IndustryStandard/EfiPci.h
BaseTools/Source/C/Include/IndustryStandard/MemoryMappedConfigurationSpaceAccessTable.h
BaseTools/Source/C/Include/IndustryStandard/PeImage.h
BaseTools/Source/C/Include/IndustryStandard/pci22.h
BaseTools/Source/C/Include/IndustryStandard/pci23.h
BaseTools/Source/C/Include/IndustryStandard/pci30.h
BaseTools/Source/C/Include/Protocol/DevicePath.h
BaseTools/Source/C/Include/Protocol/GraphicsOutput.h
BaseTools/Source/C/Include/Protocol/GuidedSectionExtraction.h
BaseTools/Source/C/Include/Protocol/HiiFramework.h
BaseTools/Source/C/Include/Protocol/UgaDraw.h
BaseTools/Source/C/Include/X64/ProcessorBind.h
BaseTools/Source/C/LzmaCompress/GNUmakefile
BaseTools/Source/C/LzmaCompress/LzmaCompress.c
BaseTools/Source/C/LzmaCompress/Makefile
BaseTools/Source/C/Makefile
BaseTools/Source/C/Makefiles/NmakeSubdirs.bat
BaseTools/Source/C/Makefiles/app.makefile
BaseTools/Source/C/Makefiles/footer.makefile
BaseTools/Source/C/Makefiles/header.makefile
BaseTools/Source/C/Makefiles/lib.makefile
BaseTools/Source/C/Makefiles/ms.app
BaseTools/Source/C/Makefiles/ms.common
BaseTools/Source/C/Makefiles/ms.lib
BaseTools/Source/C/Makefiles/ms.rule
BaseTools/Source/C/PyEfiCompressor/EfiCompressor.c
BaseTools/Source/C/PyEfiCompressor/Makefile
BaseTools/Source/C/PyEfiCompressor/setup.py
BaseTools/Source/C/PyUtility/Makefile
BaseTools/Source/C/PyUtility/PyUtility.c
BaseTools/Source/C/PyUtility/setup.py
BaseTools/Source/C/Split/GNUmakefile
BaseTools/Source/C/Split/Makefile
BaseTools/Source/C/Split/Split.c
BaseTools/Source/C/TianoCompress/GNUmakefile
BaseTools/Source/C/TianoCompress/Makefile
BaseTools/Source/C/TianoCompress/TianoCompress.c
BaseTools/Source/C/TianoCompress/TianoCompress.h
BaseTools/Source/C/VfrCompile/EfiVfr.h
BaseTools/Source/C/VfrCompile/GNUmakefile
BaseTools/Source/C/VfrCompile/Makefile
BaseTools/Source/C/VfrCompile/VfrCompiler.cpp
BaseTools/Source/C/VfrCompile/VfrCompiler.h
BaseTools/Source/C/VfrCompile/VfrError.cpp
BaseTools/Source/C/VfrCompile/VfrError.h
BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
BaseTools/Source/C/VfrCompile/VfrFormPkg.h
BaseTools/Source/C/VfrCompile/VfrSyntax.g
BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
BaseTools/Source/C/VfrCompile/VfrUtilityLib.h
BaseTools/Source/C/VolInfo/GNUmakefile
BaseTools/Source/C/VolInfo/Makefile
BaseTools/Source/C/VolInfo/VolInfo.c
BaseTools/Source/C/VolInfo/VolInfo.h
BaseTools/Source/Python/AutoGen/AutoGen.py
BaseTools/Source/Python/AutoGen/BuildEngine.py
BaseTools/Source/Python/AutoGen/GenC.py
BaseTools/Source/Python/AutoGen/GenDepex.py
BaseTools/Source/Python/AutoGen/GenMake.py
BaseTools/Source/Python/AutoGen/StrGather.py
BaseTools/Source/Python/AutoGen/UniClassObject.py
BaseTools/Source/Python/AutoGen/__init__.py
BaseTools/Source/Python/Common/BuildToolError.py
BaseTools/Source/Python/Common/DataType.py
BaseTools/Source/Python/Common/Database.py
BaseTools/Source/Python/Common/DecClassObject.py
BaseTools/Source/Python/Common/DecClassObjectLight.py
BaseTools/Source/Python/Common/Dictionary.py
BaseTools/Source/Python/Common/DscClassObject.py
BaseTools/Source/Python/Common/EdkIIWorkspace.py
BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py
BaseTools/Source/Python/Common/EdkLogger.py
BaseTools/Source/Python/Common/FdfClassObject.py
BaseTools/Source/Python/Common/FdfParserLite.py
BaseTools/Source/Python/Common/GlobalData.py
BaseTools/Source/Python/Common/Identification.py
BaseTools/Source/Python/Common/InfClassObject.py
BaseTools/Source/Python/Common/InfClassObjectLight.py
BaseTools/Source/Python/Common/MigrationUtilities.py
BaseTools/Source/Python/Common/Misc.py
BaseTools/Source/Python/Common/Parsing.py
BaseTools/Source/Python/Common/String.py
BaseTools/Source/Python/Common/TargetTxtClassObject.py
BaseTools/Source/Python/Common/ToolDefClassObject.py
BaseTools/Source/Python/Common/XmlParser.py
BaseTools/Source/Python/Common/XmlRoutines.py
BaseTools/Source/Python/Common/__init__.py
BaseTools/Source/Python/CommonDataClass/CommonClass.py
BaseTools/Source/Python/CommonDataClass/DataClass.py
BaseTools/Source/Python/CommonDataClass/DistributionPackageClass.py
BaseTools/Source/Python/CommonDataClass/FdfClass.py
BaseTools/Source/Python/CommonDataClass/ModuleClass.py
BaseTools/Source/Python/CommonDataClass/PackageClass.py
BaseTools/Source/Python/CommonDataClass/PlatformClass.py
BaseTools/Source/Python/CommonDataClass/__init__.py
BaseTools/Source/Python/Ecc/C.g
BaseTools/Source/Python/Ecc/CLexer.py
BaseTools/Source/Python/Ecc/CParser.py
BaseTools/Source/Python/Ecc/Check.py
BaseTools/Source/Python/Ecc/CodeFragment.py
BaseTools/Source/Python/Ecc/CodeFragmentCollector.py
BaseTools/Source/Python/Ecc/Configuration.py
BaseTools/Source/Python/Ecc/Database.py
BaseTools/Source/Python/Ecc/Ecc.py
BaseTools/Source/Python/Ecc/EccGlobalData.py
BaseTools/Source/Python/Ecc/EccToolError.py
BaseTools/Source/Python/Ecc/Exception.py
BaseTools/Source/Python/Ecc/FileProfile.py
BaseTools/Source/Python/Ecc/MetaDataParser.py
BaseTools/Source/Python/Ecc/ParserWarning.py
BaseTools/Source/Python/Ecc/__init__.py
BaseTools/Source/Python/Ecc/c.py
BaseTools/Source/Python/Ecc/config.ini
BaseTools/Source/Python/Ecc/exception.xml
BaseTools/Source/Python/Eot/CLexer.py
BaseTools/Source/Python/Eot/CParser.py
BaseTools/Source/Python/Eot/CodeFragment.py
BaseTools/Source/Python/Eot/CodeFragmentCollector.py
BaseTools/Source/Python/Eot/Database.py
BaseTools/Source/Python/Eot/Eot.py
BaseTools/Source/Python/Eot/EotGlobalData.py
BaseTools/Source/Python/Eot/EotToolError.py
BaseTools/Source/Python/Eot/FileProfile.py
BaseTools/Source/Python/Eot/FvImage.py
BaseTools/Source/Python/Eot/InfParserLite.py
BaseTools/Source/Python/Eot/Parser.py
BaseTools/Source/Python/Eot/ParserWarning.py
BaseTools/Source/Python/Eot/Report.py
BaseTools/Source/Python/Eot/__init__.py
BaseTools/Source/Python/Eot/c.py
BaseTools/Source/Python/Fdb/__init__.py
BaseTools/Source/Python/FixFlash/__init__.py
BaseTools/Source/Python/GNUmakefile
BaseTools/Source/Python/GenFds/AprioriSection.py
BaseTools/Source/Python/GenFds/Attribute.py
BaseTools/Source/Python/GenFds/Capsule.py
BaseTools/Source/Python/GenFds/CapsuleData.py
BaseTools/Source/Python/GenFds/ComponentStatement.py
BaseTools/Source/Python/GenFds/CompressSection.py
BaseTools/Source/Python/GenFds/DataSection.py
BaseTools/Source/Python/GenFds/DepexSection.py
BaseTools/Source/Python/GenFds/EfiSection.py
BaseTools/Source/Python/GenFds/Fd.py
BaseTools/Source/Python/GenFds/FdfParser.py
BaseTools/Source/Python/GenFds/Ffs.py
BaseTools/Source/Python/GenFds/FfsFileStatement.py
BaseTools/Source/Python/GenFds/FfsInfStatement.py
BaseTools/Source/Python/GenFds/Fv.py
BaseTools/Source/Python/GenFds/FvImageSection.py
BaseTools/Source/Python/GenFds/GenFds.py
BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
BaseTools/Source/Python/GenFds/GuidSection.py
BaseTools/Source/Python/GenFds/OptRomFileStatement.py
BaseTools/Source/Python/GenFds/OptRomInfStatement.py
BaseTools/Source/Python/GenFds/OptionRom.py
BaseTools/Source/Python/GenFds/Region.py
BaseTools/Source/Python/GenFds/Rule.py
BaseTools/Source/Python/GenFds/RuleComplexFile.py
BaseTools/Source/Python/GenFds/RuleSimpleFile.py
BaseTools/Source/Python/GenFds/Section.py
BaseTools/Source/Python/GenFds/UiSection.py
BaseTools/Source/Python/GenFds/VerSection.py
BaseTools/Source/Python/GenFds/Vtf.py
BaseTools/Source/Python/GenFds/__init__.py
BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
BaseTools/Source/Python/GenPatchPcdTable/__init__.py
BaseTools/Source/Python/Makefile
BaseTools/Source/Python/MigrationMsa2Inf/AutoGenExterns.py
BaseTools/Source/Python/MigrationMsa2Inf/MigrationMsa2Inf.py
BaseTools/Source/Python/MigrationMsa2Inf/__init__.py
BaseTools/Source/Python/MkBOM/__init__.py
BaseTools/Source/Python/PackagingTool/DependencyRules.py
BaseTools/Source/Python/PackagingTool/InstallPkg.py
BaseTools/Source/Python/PackagingTool/IpiDb.py
BaseTools/Source/Python/PackagingTool/MkPkg.py
BaseTools/Source/Python/PackagingTool/PackageFile.py
BaseTools/Source/Python/PackagingTool/RmPkg.py
BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py
BaseTools/Source/Python/PatchPcdValue/__init__.py
BaseTools/Source/Python/Table/Table.py
BaseTools/Source/Python/Table/TableDataModel.py
BaseTools/Source/Python/Table/TableDec.py
BaseTools/Source/Python/Table/TableDsc.py
BaseTools/Source/Python/Table/TableEotReport.py
BaseTools/Source/Python/Table/TableFdf.py
BaseTools/Source/Python/Table/TableFile.py
BaseTools/Source/Python/Table/TableFunction.py
BaseTools/Source/Python/Table/TableIdentifier.py
BaseTools/Source/Python/Table/TableInf.py
BaseTools/Source/Python/Table/TablePcd.py
BaseTools/Source/Python/Table/TableQuery.py
BaseTools/Source/Python/Table/TableReport.py
BaseTools/Source/Python/Table/__init__.py
BaseTools/Source/Python/TargetTool/TargetTool.py
BaseTools/Source/Python/TargetTool/__init__.py
BaseTools/Source/Python/Trim/Trim.py
BaseTools/Source/Python/Workspace/BuildClassObject.py
BaseTools/Source/Python/Workspace/MetaDataTable.py
BaseTools/Source/Python/Workspace/MetaFileParser.py
BaseTools/Source/Python/Workspace/MetaFileTable.py
BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
BaseTools/Source/Python/Workspace/__init__.py
BaseTools/Source/Python/build/BuildReport.py
BaseTools/Source/Python/build/__init__.py
BaseTools/Source/Python/build/build.py
BaseTools/Source/Python/fpd2dsc/EdkIIWorkspaceGuidsInfo.py
BaseTools/Source/Python/fpd2dsc/LoadFpd.py
BaseTools/Source/Python/fpd2dsc/MigrationUtilities.py
BaseTools/Source/Python/fpd2dsc/StoreDsc.py
BaseTools/Source/Python/fpd2dsc/__init__.py
BaseTools/Source/Python/fpd2dsc/fpd2dsc.py
BaseTools/Source/Python/msa2inf/ConvertModule.py
BaseTools/Source/Python/msa2inf/EdkIIWorkspaceGuidsInfo.py
BaseTools/Source/Python/msa2inf/LoadMsa.py
BaseTools/Source/Python/msa2inf/Msa2Inf.py
BaseTools/Source/Python/msa2inf/StoreInf.py
BaseTools/Source/Python/msa2inf/__init__.py
BaseTools/Source/Python/sitecustomize.py
BaseTools/Source/Python/spd2dec/ConvertPackage.py
BaseTools/Source/Python/spd2dec/LoadSpd.py
BaseTools/Source/Python/spd2dec/Spd2Dec.py
BaseTools/Source/Python/spd2dec/StoreDec.py
BaseTools/Source/Python/spd2dec/__init__.py
BaseTools/Tests/CToolsTests.py
BaseTools/Tests/CheckPythonSyntax.py
BaseTools/Tests/GNUmakefile
BaseTools/Tests/PythonToolsTests.py
BaseTools/Tests/RunTests.py
BaseTools/Tests/TestTools.py
BaseTools/Tests/TianoCompress.py
BaseTools/UserManuals/BootSectImage_Utility_Man_Page.rtf
BaseTools/UserManuals/Build_Utility_Man_Page.rtf
BaseTools/UserManuals/EfiLdrImage_Utility_Man_Page.rtf
BaseTools/UserManuals/EfiRom_Utility_Man_Page.rtf
BaseTools/UserManuals/Fpd2Dsc_Utility_Man_Page.rtf
BaseTools/UserManuals/GenBootSector_Utility_Man_Page.rtf
BaseTools/UserManuals/GenCrc32_Utility_Man_Page.rtf
BaseTools/UserManuals/GenDepex_Utility_Man_Page.rtf
BaseTools/UserManuals/GenFds_Utility_Man_Page.rtf
BaseTools/UserManuals/GenFfs_Utility_Man_Page.rtf
BaseTools/UserManuals/GenFv_Utility_Man_Page.rtf
BaseTools/UserManuals/GenFw_Utility_Man_Page.rtf
BaseTools/UserManuals/GenPage_Utility_Man_Page.rtf
BaseTools/UserManuals/GenPatchPcdTable_Utility_Man_Page.rtf
BaseTools/UserManuals/GenSec_Utility_Man_Page.rtf
BaseTools/UserManuals/GenVtf_Utility_Man_Page.rtf
BaseTools/UserManuals/InstallPkg_Utility_Man_Page.rtf
BaseTools/UserManuals/LzmaCompress_Utility_Man_Page.rtf
BaseTools/UserManuals/MkPkg_Utility_Man_Page.rtf
BaseTools/UserManuals/Msa2Inf_Utility_Man_Page.rtf
BaseTools/UserManuals/PatchPcdValue_Utility_Man_Page.rtf
BaseTools/UserManuals/RmPkg_Utility_Man_Page.rtf
BaseTools/UserManuals/Spd2Dec_Utility_Man_Page.rtf
BaseTools/UserManuals/SplitFile_Utility_Man_Page.rtf
BaseTools/UserManuals/TargetTool_Utility_Man_Page.rtf
BaseTools/UserManuals/TianoCompress_Utility_Man_Page.rtf
BaseTools/UserManuals/Trim_Utility_Man_Page.rtf
BaseTools/UserManuals/UtilityManPage_template.rtf
BaseTools/UserManuals/VfrCompiler_Utility_Man_Page.rtf
BaseTools/UserManuals/VolInfo_Utility_Man_Page.rtf
BaseTools/gcc/mingw-gcc-build.py
BaseTools/toolsetup.bat

index 6d7aa00c4d371bc25e4635015b690e763872fb4f..69fd2d54413e975352b54f026fe8c7f102051d3d 100755 (executable)
@@ -1,8 +1,8 @@
 #!/usr/bin/env python
 #
-# Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
+# Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
 #
-# All rights reserved. This program and the accompanying materials
+# 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
 #
index 535a8dc23903fc59db8de834208310394b4bcf39..026311074d233dfd3f6cce256cb7ff15803b418f 100755 (executable)
Binary files a/BaseTools/Bin/Win32/BootSectImage.exe and b/BaseTools/Bin/Win32/BootSectImage.exe differ
index 9eee3ff62f90f6ff258510ec7236aab3bcf60334..90fdec6504fd9aa1ad5049021151fce01b95150e 100755 (executable)
Binary files a/BaseTools/Bin/Win32/EfiLdrImage.exe and b/BaseTools/Bin/Win32/EfiLdrImage.exe differ
index aa9790df50e715bc7edd9ef4c53d21911a3fb893..68793bc9f089cb1bc15b5e33b7df5b8e0c6eea65 100755 (executable)
Binary files a/BaseTools/Bin/Win32/EfiRom.exe and b/BaseTools/Bin/Win32/EfiRom.exe differ
index 55f1a6943eec9b91883349b14eb717c5db3a1ca0..78f3b6dfcf2e6ffaad0784b4022a42c25f886f1d 100755 (executable)
Binary files a/BaseTools/Bin/Win32/Fpd2Dsc.exe and b/BaseTools/Bin/Win32/Fpd2Dsc.exe differ
index f5553b429b57a18385f79fabdd51d733e2d20a07..91e94da36cbf7dcb8e45d2541b5a38c908fe2d6b 100755 (executable)
Binary files a/BaseTools/Bin/Win32/GenBootSector.exe and b/BaseTools/Bin/Win32/GenBootSector.exe differ
index 6729a108c65f046ffe3007763fef2bc4c1823d25..be7ec780851d756fb9a694d5908b0aa05a02a946 100755 (executable)
Binary files a/BaseTools/Bin/Win32/GenCrc32.exe and b/BaseTools/Bin/Win32/GenCrc32.exe differ
index 04c6e719aa448a18f437866ff2e1492dd5f5d653..18914264758a8bb333eaeee93c933770e9e0f20c 100755 (executable)
Binary files a/BaseTools/Bin/Win32/GenDepex.exe and b/BaseTools/Bin/Win32/GenDepex.exe differ
index a9577b2ec8d479a207904cdf02b4e42ac9678e5a..e9b9b3c08aec067e4db9090c3ce02f633cd38522 100755 (executable)
Binary files a/BaseTools/Bin/Win32/GenFds.exe and b/BaseTools/Bin/Win32/GenFds.exe differ
index 9411bdc50c843b321af6a56daddce3b56a29a6f5..723154c8c3712053e310f547240a613e97fcef75 100755 (executable)
Binary files a/BaseTools/Bin/Win32/GenFfs.exe and b/BaseTools/Bin/Win32/GenFfs.exe differ
index e5882cb33964879711ded41cc51833ac0f0adbd6..bd50be227fd634bfc6e7eb09ac9a55cfe2f027e2 100755 (executable)
Binary files a/BaseTools/Bin/Win32/GenFv.exe and b/BaseTools/Bin/Win32/GenFv.exe differ
index 072d0fe2727bc7ff34ed2c717946733c613f2c18..d79ae77f7e87a7c5e5c752d9f061a4afde9ba591 100755 (executable)
Binary files a/BaseTools/Bin/Win32/GenFw.exe and b/BaseTools/Bin/Win32/GenFw.exe differ
index 5af9a323e64c711d00d6d0ce8b75be261c29a720..d6221d85f84b808fd943870c49617bed45250d33 100755 (executable)
Binary files a/BaseTools/Bin/Win32/GenPage.exe and b/BaseTools/Bin/Win32/GenPage.exe differ
index 437ee129a085de6a82a4e27075b04f2f90b23c03..7faf806b7ca45c6b2a778611c67435276c566871 100755 (executable)
Binary files a/BaseTools/Bin/Win32/GenPatchPcdTable.exe and b/BaseTools/Bin/Win32/GenPatchPcdTable.exe differ
index deda7866e15bd86dc599fcd4cb1d885828d12385..637b05382be65ebceb17b721338337b3add85191 100755 (executable)
Binary files a/BaseTools/Bin/Win32/GenSec.exe and b/BaseTools/Bin/Win32/GenSec.exe differ
index 82e1a1b23dfe6dd670585e3dc90843eca0cb7122..bc7583b325a89792c53792b5a5cb78a25cdb4018 100755 (executable)
Binary files a/BaseTools/Bin/Win32/GenVtf.exe and b/BaseTools/Bin/Win32/GenVtf.exe differ
index 8c611f382bc8a1cfc6a15fa1e509a4c7e522a0d4..397e669418234f7f8d141ed2d5d2e1719aff5ede 100755 (executable)
Binary files a/BaseTools/Bin/Win32/LzmaCompress.exe and b/BaseTools/Bin/Win32/LzmaCompress.exe differ
index bb3be942fd5e46b38d3ef0578edd01a54fffd5c2..2942d13891f939d6bee28fbfde18fb9dc680a590 100755 (executable)
Binary files a/BaseTools/Bin/Win32/MigrationMsa2Inf.exe and b/BaseTools/Bin/Win32/MigrationMsa2Inf.exe differ
index 27a4f1f9081cfd92d8d34c99e76fe82d0a9ee0d9..32733b77ccf5db3ae0325378be24c0a3c13d9d3a 100755 (executable)
Binary files a/BaseTools/Bin/Win32/PatchPcdValue.exe and b/BaseTools/Bin/Win32/PatchPcdValue.exe differ
index 7c16177bbab2ed26c3009fd18b17d31f8bccf0c1..450bca41c301c62973f97dad1feb6ddc425db5be 100755 (executable)
Binary files a/BaseTools/Bin/Win32/Spd2Dec.exe and b/BaseTools/Bin/Win32/Spd2Dec.exe differ
index 2f58827858c4ded5b8b0b84ad7292cd195cb13b1..c7b9a9864f4ee277ff4160da2fc5815b547c70b8 100755 (executable)
Binary files a/BaseTools/Bin/Win32/Split.exe and b/BaseTools/Bin/Win32/Split.exe differ
index ba065328f44cb242381024e12551b981de4a974d..3fe721182e9f55a29c801efd563ed4339a492e00 100755 (executable)
Binary files a/BaseTools/Bin/Win32/TargetTool.exe and b/BaseTools/Bin/Win32/TargetTool.exe differ
index ec43802ab8714a11b0ca112668e71cfa0d2f0d06..d006b1e910fe49ee4ecaa6b3d0d1a795c89ad77c 100755 (executable)
Binary files a/BaseTools/Bin/Win32/TianoCompress.exe and b/BaseTools/Bin/Win32/TianoCompress.exe differ
index 8bfdbb3ab439df447053c873ad3f572fba63025e..5a90ab4f7fb79ba4989e6f0dc493a3676ba9a855 100755 (executable)
Binary files a/BaseTools/Bin/Win32/Trim.exe and b/BaseTools/Bin/Win32/Trim.exe differ
index 990c2ebe9f02fb63e250093d1d4eed1eb5fbe37e..96b31d949c99424d426aaf5d8894796fc115d1ca 100755 (executable)
Binary files a/BaseTools/Bin/Win32/VfrCompile.exe and b/BaseTools/Bin/Win32/VfrCompile.exe differ
index 1700ff2f7c000465c0bea78b3f0ca63bfb04866a..8f406d05ef20129300a67d5336518924ac749b50 100755 (executable)
Binary files a/BaseTools/Bin/Win32/VolInfo.exe and b/BaseTools/Bin/Win32/VolInfo.exe differ
index d6ae790c92a1151cb9ee0ddd6ce9741adea18650..b6ad904ac2f3c0cfd864a54a8ee46f0aefa676a6 100755 (executable)
Binary files a/BaseTools/Bin/Win32/build.exe and b/BaseTools/Bin/Win32/build.exe differ
index 768e2d5603ecea4c9f52c464f247a535147484e6..144be280da5154edb6f7d30ba2c69683df2872d4 100755 (executable)
@@ -1,6 +1,6 @@
 #
-# Copyright (c) 2006 - 2007, Intel Corporation
-# All rights reserved. This program and the accompanying materials
+# Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>
+# 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
index 4d9608400d782211e33aefa80eb847e6cdad1229..05bbd7ca9f19f61a6d558666edf71d9c7584d542 100644 (file)
@@ -6,7 +6,7 @@ Root Package 1.00
 Intel is a trademark or registered trademark of Intel Corporation or its\r
 subsidiaries in the United States and other countries.\r
 * Other names and brands may be claimed as the property of others.\r
-Copyright (c) 2007, Intel Corporation\r
+Copyright (c) 2007, Intel Corporation. All rights reserved.\r
 \r
 -------------------------------------------------------------------------------\r
 Quick Start\r
index eb9bdbcf95baf8388f40fc8023bfa291b41eee35..6d88349d26cb68198d29fa4aa35ed68a22b077f9 100644 (file)
@@ -8,7 +8,7 @@
     <Description>\r
       This Database tracks all packages and archives installed in this workspace.\r
     </Description>\r
-    <Copyright>Copyright (c) 2007 - 2009,  Intel Corporation    All rights reserved.</Copyright>\r
+    <Copyright>Copyright (c) 2007 - 2009, Intel Corporation. All rights reserved.</Copyright>\r
     <License>\r
       This program and the accompanying materials are licensed and made available\r
       under the terms and conditions of the BSD License which accompanies this\r
index 23cce9555b90effadebeb65d9d05eefb69bc0d21..b7cda67cda4de6e8297b2ba24e050542a5576515 100644 (file)
@@ -1,8 +1,8 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding="UTF-8"?>
 <!--
 Filename: DistributionPackage.xsd
 
-Copyright (c) 2008, Intel Corp All rights reserved.
+Copyright (c) 2008, 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 may be found at 
@@ -230,7 +230,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
                                                        code provided in the distribution file. Alternatively, this may
                                                        point to a filename that contains the License. The file (included
                                                        in the content zip file) will be stored in the same location as
-                                                       the distribution package’s .pkg file. </xs:documentation>
+                                                       the distribution package's .pkg file. </xs:documentation>
                                        </xs:annotation>
                                </xs:element>
                                <xs:element minOccurs="1" maxOccurs="1" name="Abstract"
index 6e7573464ac2909148b19515eaaaa6e27284cc51..6e8c34ae9a14f4b399d3d62729b16038091ca307 100644 (file)
@@ -2,8 +2,8 @@
 <!--\r
 Filename: FarManifest.xsd\r
 \r
-Copyright (c) 2007, Intel Corp.\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2007, Intel Corporation. All rights reserved.\r
+This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which may be found at http://opensource.org/licenses/bsd-license.php\r
 \r
index d40561e4f7ce52fc8ada99ebe306319f97a6a037..eeb48d9a8a2be4a1851bb6609199bd1ae6a60d7b 100644 (file)
@@ -3,8 +3,8 @@
   <!--\r
     Filename: FrameworkDataAttributes.xsd\r
     \r
-    Copyright (c) 2007, Intel Corp.\r
-    All rights reserved. This program and the accompanying materials\r
+    Copyright (c) 2007, Intel Corporation. All rights reserved.\r
+    This program and the accompanying materials\r
     are licensed and made available under the terms and conditions of the BSD License\r
     which may be found at http://opensource.org/licenses/bsd-license.php\r
     \r
index 12bba93d4058152f281aa9e3c7bb3664febd3828..e094c1b6261ac59463fc252d4bde65e03e23526f 100644 (file)
@@ -3,8 +3,8 @@
   <!--\r
     Filename: FrameworkDataElements.xsd\r
     \r
-    Copyright (c) 2007, Intel Corp.\r
-    All rights reserved. This program and the accompanying materials\r
+    Copyright (c) 2007, Intel Corporation. All rights reserved.\r
+    This program and the accompanying materials\r
     are licensed and made available under the terms and conditions of the BSD License\r
     which may be found at http://opensource.org/licenses/bsd-license.php\r
     \r
index 18db60888a1f3534b92add8b4b48ac35efc4e740..9a46a02a2e5d0dba0f3d3576d07e37e062336d8d 100644 (file)
@@ -3,8 +3,8 @@
   <!--\r
     Filename: FrameworkDataTypes.xsd\r
     \r
-    Copyright (c) 2007, Intel Corp.\r
-    All rights reserved. This program and the accompanying materials\r
+    Copyright (c) 2007, Intel Corporation. All rights reserved.\r
+    This program and the accompanying materials\r
     are licensed and made available under the terms and conditions of the BSD License\r
     which may be found at http://opensource.org/licenses/bsd-license.php\r
     \r
index 6927c7bccae55f49a90c404979640ec94d436925..e2745af3782a414d5daa8f5d91704867b3a91bad 100644 (file)
@@ -3,9 +3,9 @@
   <!--\r
     Filename: FrameworkHeaders.xsd\r
     \r
-    Copyright (c) 2007, Intel Corp.\r
+    Copyright (c) 2007, Intel Corporation. All rights reserved.\r
 \r
-    All rights reserved. This program and the accompanying materials\r
+    This program and the accompanying materials\r
     are licensed and made available under the terms and conditions of the BSD License\r
     which may be found at http://opensource.org/licenses/bsd-license.php\r
     \r
index 809f1a8485c79a7b3b25c470c26cc21a5014362c..8a766397779e951e889842a6353f614075bace8a 100644 (file)
@@ -3,8 +3,8 @@
   <!--\r
     Filename: NamingConvention.xsd\r
     \r
-    Copyright (c) 2007, Intel Corp.\r
-    All rights reserved. This program and the accompanying materials\r
+    Copyright (c) 2007, Intel Corporation. All rights reserved.\r
+    This program and the accompanying materials\r
     are licensed and made available under the terms and conditions of the BSD License\r
     which may be found at http://opensource.org/licenses/bsd-license.php\r
     \r
index f95de26b1a9aff4fe6a5f3b30889a9e91f560267..c941be81e7684cc9c63b15d4f78c9b4b0ce86fb4 100644 (file)
@@ -3,8 +3,8 @@
   <!--\r
     Filename: SurfaceArea.xsd\r
     \r
-    Copyright (c) 2007, Intel Corp.\r
-    All rights reserved. This program and the accompanying materials\r
+    Copyright (c) 2007, Intel Corporation. All rights reserved.\r
+    This program and the accompanying materials\r
     are licensed and made available under the terms and conditions of the BSD License\r
     which may be found at http://opensource.org/licenses/bsd-license.php\r
     \r
index c2fdaf82939a4dc57a9979d3c5cdc0406af00258..5d86b98fe7475f29d2eb1469576ed6cf8437d218 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>\r
 <!--\r
-Copyright (c) 2007, Intel Corp.\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2007, Intel Corporation. All rights reserved.\r
+This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which may be found at http://opensource.org/licenses/bsd-license.php\r
 \r
index 8809792ac48e432059d324fa53cb18bbcb47dc92..1c9491a5e65bdf4c8fc2b3054a2dd325543a19e7 100644 (file)
@@ -2,7 +2,7 @@
 <!--\r
     Filename: WorkspaceContent.xsd\r
     \r
-    Copyright (c) 2008, Intel Corp All rights reserved.\r
+    Copyright (c) 2008, Intel Corporation. All rights reserved.\r
     \r
     This program and the accompanying materials are licensed and made available \r
     under the terms and conditions of the BSD License which may be found at \r
index 95bb5edc28feceb3dab239865b88d95bff1bb324..c2b7dfa846730f4c285281fc0612046f4daeb2d0 100644 (file)
@@ -1,7 +1,7 @@
 #\r
-#  Copyright (c) 2007-2010, Intel Corporation\r
-#  Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.\r
-#  All rights reserved. This program and the accompanying materials\r
+#  Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+#  Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
+#  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
 #  which accompanies this distribution.  The full text of the license may be found at\r
 #  http://opensource.org/licenses/bsd-license.php\r
index 75eba36a2ef8fbf41ed13a0728c734f7a81a5fbd..7f0771ec551ccf9dff0a347eb915ffc6e909a9e8 100644 (file)
@@ -1,7 +1,7 @@
 #\r
-#  Copyright (c) 2006-2007, Intel Corporation\r
+#  Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>\r
 #\r
-#  All rights reserved. This program and the accompanying materials\r
+#  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
 #  which accompanies this distribution.  The full text of the license may be found at\r
 #  http://opensource.org/licenses/bsd-license.php\r
index b53826ba05fc94886a250b3a9ed2bb26c2767071..c5a4bd723eea37843bb2f2237065f52a88fd73b3 100644 (file)
@@ -1,8 +1,8 @@
 #\r
-#  Copyright (c) 2006-2010, Intel Corporation\r
-#  Portions copyright (c) 2008-2009 Apple Inc. All rights reserved.\r
+#  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+#  Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
 #\r
-#  All rights reserved. This program and the accompanying materials\r
+#  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
 #  which accompanies this distribution.  The full text of the license may be found at\r
 #  http://opensource.org/licenses/bsd-license.php\r
@@ -109,6 +109,8 @@ DEFINE CYGWIN_BINIPF           = c:/cygwin/opt/tiano/gcc/ipf/bin/ia64-pc-elf-
 \r
 DEFINE GCC44_IA32_PREFIX       = /usr/bin/\r
 #DEFINE GCC44_IA32_PREFIX       = ENV(HOME)/programs/gcc/4.4/ia32/\r
+DEFINE GCC44_X64_PREFIX        = /usr/bin/\r
+#DEFINE GCC44_X64_PREFIX       = ENV(HOME)/programs/gcc/4.4/x64/\r
 \r
 DEFINE UNIX_IASL_BIN           = /usr/bin/iasl\r
 #DEFINE UNIX_IASL_BIN           = $(HOME)/programs/iasl\r
@@ -1571,10 +1573,11 @@ DEFINE GCC_IPF_RC_FLAGS            = -I binary -O elf64-ia64-little -B ia64 --re
 \r
 DEFINE GCC44_ALL_CC_FLAGS            = -g -fshort-wchar -fno-stack-protector -fno-strict-aliasing -Wall -Werror -Wno-missing-braces -Wno-array-bounds -ffunction-sections -fdata-sections -c -include AutoGen.h -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings\r
 DEFINE GCC44_IA32_CC_FLAGS           = DEF(GCC44_ALL_CC_FLAGS) -m32 -malign-double -D EFI32\r
-DEFINE GCC44_X64_CC_FLAGS            = DEF(GCC44_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -Wno-address\r
+DEFINE GCC44_X64_CC_FLAGS            = DEF(GCC44_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -DNO_BUILTIN_VA_FUNCS -mno-red-zone -Wno-address\r
 DEFINE GCC44_IA32_X64_DLINK_COMMON   = -nostdlib -n -q --gc-sections\r
 DEFINE GCC44_IA32_X64_ASLDLINK_FLAGS = DEF(GCC44_IA32_X64_DLINK_COMMON) --entry ReferenceAcpiTable -u ReferenceAcpiTable\r
 DEFINE GCC44_IA32_X64_DLINK_FLAGS    = DEF(GCC44_IA32_X64_DLINK_COMMON) --entry $(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT) -Map $(DEST_DIR_DEBUG)/$(BASE_NAME).map\r
+DEFINE GCC44_X64_DLINK_FLAGS         = DEF(GCC44_IA32_X64_DLINK_FLAGS)  -melf_x86_64 --oformat=elf64-x86-64 --script=$(EDK_TOOLS_PATH)/Scripts/gcc4.4-ld-script\r
 DEFINE GCC44_ASM_FLAGS               = DEF(GCC_ASM_FLAGS)\r
 \r
 ####################################################################################\r
@@ -1703,6 +1706,27 @@ DEFINE GCC44_ASM_FLAGS               = DEF(GCC_ASM_FLAGS)
 *_GCC44_IA32_DLINK_FLAGS          = DEF(GCC44_IA32_X64_DLINK_FLAGS) -m elf_i386 --oformat=elf32-i386\r
 *_GCC44_IA32_RC_FLAGS             = DEF(GCC_IA32_RC_FLAGS)\r
 \r
+##################\r
+# GCC44 X64 definitions\r
+##################\r
+*_GCC44_X64_CC_PATH              = DEF(GCC44_X64_PREFIX)gcc\r
+*_GCC44_X64_SLINK_PATH           = DEF(GCC44_X64_PREFIX)ar\r
+*_GCC44_X64_DLINK_PATH           = DEF(GCC44_X64_PREFIX)ld\r
+*_GCC44_X64_ASLDLINK_PATH        = DEF(GCC44_X64_PREFIX)ld\r
+*_GCC44_X64_ASM_PATH             = DEF(GCC44_X64_PREFIX)gcc\r
+*_GCC44_X64_PP_PATH              = DEF(GCC44_X64_PREFIX)gcc\r
+*_GCC44_X64_VFRPP_PATH           = DEF(GCC44_X64_PREFIX)gcc\r
+*_GCC44_X64_ASLCC_PATH           = DEF(GCC44_X64_PREFIX)gcc\r
+*_GCC44_X64_ASLPP_PATH           = DEF(GCC44_X64_PREFIX)gcc\r
+*_GCC44_X64_RC_PATH              = DEF(GCC44_X64_PREFIX)objcopy\r
+\r
+*_GCC44_X64_ASLCC_FLAGS          = DEF(GCC_ASLCC_FLAGS) -m64\r
+*_GCC44_X64_ASLDLINK_FLAGS       = DEF(GCC44_IA32_X64_ASLDLINK_FLAGS) -m elf_x86_64\r
+*_GCC44_X64_ASM_FLAGS            = DEF(GCC44_ASM_FLAGS) -m64 --64 -melf_x86_64\r
+*_GCC44_X64_CC_FLAGS             = DEF(GCC44_X64_CC_FLAGS) -Os\r
+*_GCC44_X64_DLINK_FLAGS          = DEF(GCC44_X64_DLINK_FLAGS)\r
+*_GCC44_X64_RC_FLAGS             = DEF(GCC_X64_RC_FLAGS)\r
+\r
 \r
 ####################################################################################\r
 #\r
index 881b65b4c1ac02714e26027eeed71db6e21cc5f3..a3fa905c907420892e557ccd776b6a444657e78e 100644 (file)
@@ -1,8 +1,8 @@
 ## @file\r
 # Windows makefile for Base Tools project build.\r
 #\r
-# Copyright (c) 2009 - 2010, Intel Corporation<BR>\r
-# All rights reserved. This program and the accompanying materials\r
+# Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
 # http://opensource.org/licenses/bsd-license.php\r
index f6efb7b6a73c6363380059d30cabc3a3ae4c8d3e..294c532732de6481089f141ff80e0b4ea5094723 100644 (file)
@@ -1,8 +1,8 @@
 ## @file\r
 # Windows makefile for Base Tools project build.\r
 #\r
-# Copyright (c) 2007 - 2010, Intel Corporation<BR>\r
-# All rights reserved. This program and the accompanying materials\r
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
 # http://opensource.org/licenses/bsd-license.php\r
diff --git a/BaseTools/Scripts/gcc4.4-ld-script b/BaseTools/Scripts/gcc4.4-ld-script
new file mode 100644 (file)
index 0000000..bb5b7d1
--- /dev/null
@@ -0,0 +1,43 @@
+/* OUTPUT_FORMAT(efi-bsdrv-x86_64) */\r
+SECTIONS\r
+{\r
+  /* . = 0 + SIZEOF_HEADERS; */\r
+  . = 0x280;\r
+  .text ALIGN(0x20) :\r
+  {\r
+    *(.text .stub .text.* .gnu.linkonce.t.*)\r
+    . = ALIGN(0x20);\r
+  } =0x90909090\r
+  .data ALIGN(0x20) :\r
+  {\r
+    *(\r
+      .rodata .rodata.* .gnu.linkonce.r.*\r
+      .data .data.* .gnu.linkonce.d.*\r
+    )\r
+    . = ALIGN(0x20);\r
+  }\r
+  .bss ALIGN(0x20) :\r
+  {\r
+    *(.bss .bss.*)\r
+    . = ALIGN(0x20);\r
+  }\r
+  .got ALIGN(0x20) :\r
+  {\r
+    *(.got .got.*)\r
+    . = ALIGN(0x20);\r
+  }\r
+  .rela ALIGN(0x20) :\r
+  {\r
+    *(.rela .rela.*)\r
+  }\r
+  /DISCARD/ : {\r
+    *(.note.GNU-stack) *(.gnu_debuglink)\r
+    *(.interp)\r
+    *(.dynsym)\r
+    *(.dynstr)\r
+    *(.dynamic)\r
+    *(.hash)\r
+    *(.comment)\r
+  }\r
+}\r
+\r
index adf9ce5d6f59e2a5c30a8e09785d04d502058a0a..7703928dfc5581c77374e745873698392fbf860e 100644 (file)
@@ -1,8 +1,8 @@
 ## @file\r
 # Windows makefile for 'BootSectImage' module build.\r
 #\r
-# Copyright (c) 2009 - 2010, Intel Corporation<BR>\r
-# All rights reserved. This program and the accompanying materials\r
+# Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
 # http://opensource.org/licenses/bsd-license.php\r
index 1c9e5fa19e73f98c9c3b718d0eb0e57a809a4589..5e27af5a87f8feab16f6bced775bac086eb33e7a 100644 (file)
@@ -1,8 +1,8 @@
 ## @file\r
 # Windows makefile for 'BootSectImage' module build.\r
 #\r
-# Copyright (c) 2007 - 2010, Intel Corporation<BR>\r
-# All rights reserved. This program and the accompanying materials\r
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
 # http://opensource.org/licenses/bsd-license.php\r
index 7386bcf2e22529796df70b1e3e0d1c11b86e8e1c..a907e214f45a5be6c7360239a3a8b56c4cf06d72 100644 (file)
@@ -4,8 +4,8 @@ Abstract:
   Patch the BPB information in boot sector image file.\r
   Patch the MBR code in MBR image file.\r
 \r
-Copyright 2006 - 2010, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
index fac03e683b1e822492adb969b64d12a42c0dcfad..5827d18bb27e8532726fae768122052a09f93bfb 100644 (file)
@@ -2,8 +2,8 @@
 \r
   Fat file system structure and definition.\r
 \r
-Copyright 2006 - 2008, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
index 9103585cddb76efb960a3eaa58a37a58aabe46ff..36d157da247a6310ad0ef08621549f5cdaa38975 100644 (file)
@@ -2,8 +2,8 @@
 \r
   MBR Partition Entry and Table structure defintions.\r
 \r
-Copyright 2006 - 2008, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
index 5ffb5d45032468dffdcfa96c73e928d5784bd6c5..878c1c611b8d11b00cc0d6d7fbc5c28a397c0dd4 100644 (file)
@@ -2,8 +2,8 @@
 \r
   Functions to get info and load PE/COFF image.\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
@@ -71,6 +71,14 @@ PeCoffLoaderRelocateIpfImage (
   IN UINT64      Adjust\r
   );\r
 \r
+RETURN_STATUS\r
+PeCoffLoaderRelocateArmImage (\r
+  IN UINT16      **Reloc,\r
+  IN OUT CHAR8   *Fixup,\r
+  IN OUT CHAR8   **FixupData,\r
+  IN UINT64      Adjust\r
+  );\r
+\r
 STATIC\r
 RETURN_STATUS\r
 PeCoffLoaderGetPeHeader (\r
@@ -777,9 +785,11 @@ Returns:
       default:\r
         switch (MachineType) {\r
         case EFI_IMAGE_MACHINE_IA32:\r
-        case EFI_IMAGE_MACHINE_ARMT:\r
           Status = PeCoffLoaderRelocateIa32Image (Reloc, Fixup, &FixupData, Adjust);\r
           break;\r
+        case EFI_IMAGE_MACHINE_ARMT:\r
+          Status = PeCoffLoaderRelocateArmImage (&Reloc, Fixup, &FixupData, Adjust);\r
+          break;\r
         case EFI_IMAGE_MACHINE_X64:\r
           Status = PeCoffLoaderRelocateX64Image (Reloc, Fixup, &FixupData, Adjust);\r
           break;\r
index 89e75efa3dd97e35af71a005894740f0c2469dd8..5ee55480bdcd6386a7d5dfb5d04c25c42685ea2c 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 1999 - 2008, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 1999 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 http://opensource.org/licenses/bsd-license.php\r
index 779c5a2e06649f659138633d47590af4dbbee4ec..48dc82eb70c66d8005e890d18749b9ab1b9ee28b 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 1999 - 2008, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 1999 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 http://opensource.org/licenses/bsd-license.php\r
index a0c6603a85ae2bb002f2a72aa241d4081970246c..cb72e2723f3a65dc745930bda6f0776a1e0dabfc 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
index 7e4af036e5d60875bbd798f6fd37fdd5918ede8e..f407e6d1e917b0e0ef6ac3806d4db13b999f4051 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 http://opensource.org/licenses/bsd-license.php\r
index 10d0c72a1600bd1aff5819ff870d27753677f86e..11245b11788a53dcea4771bfae917f9b3c86f752 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation                                              \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
index f52b51453a741767d33029dc26990fdbb72dae18..8e5915dd0e53150262a5eaa5d3d6d7798d4faa77 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 2004, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
index e598a916a01d77c82c630282d22707ce381faed7..760327f99c30cb38de0e26a0baf45baf9599e00d 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
index 8ccb21f211c935b27a2a4e09008bd01baaf5596b..a12fc595a7da5e17328def298debee32c46ed803 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 http://opensource.org/licenses/bsd-license.php\r
index 3d5c0cd54d19ec87c2974fffb75fd0935a7c32b4..b5c978855c9e38914a9b7d18a229bff965b58af4 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
index aafa9c6e24b6f4c16923869a1bcdafcad42e6cd6..ed491ae36d6b7b796a7301e73f0a2d17a96d9bf1 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation                                              \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
index 0e7608d1cfbd2d5218442b4b23521153e0d4c73b..dc9b0ffaa26bf2154ddbd7979d9575299405c360 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 http://opensource.org/licenses/bsd-license.php\r
index 8986a592d76a4acef239c47c3c5d31893d01bf40..35cb1802feffcbfe38c6ba8dcd9427acc3bc9ec7 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
index 2d3b1353cb1e541204506803f572c9b2fa76d057..c8586b407829c44c718b2cdda4a6ff7b5d4f0566 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 1999 - 2008, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 1999 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 http://opensource.org/licenses/bsd-license.php\r
index 5a52695a7f94aee1f77d05607c73206c5b9de1d5..12c64f61724c2daac3ab59cc6ff05540b8a10de5 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 1999 - 2008, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 1999 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 http://opensource.org/licenses/bsd-license.php\r
index a6f17e17a89b21a1af4ed8ac9017d057a30cdd5a..1b289d83cd62a921497968abd10f713201399689 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
index 43d3737f682f36d8c4521bedddb1b63c61bb6801..7815baae3ffa7513cffbfe0d5bbfefe404389762 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
index 172802d7edc6e63fca02d8dd47d0d6a53028d0d6..1aade7f7b8f3f2cb8068c84439ba725170b228d3 100644 (file)
@@ -1,8 +1,8 @@
 ## @file\r
 # Windows makefile for 'Common' module build.\r
 #\r
-# Copyright (c) 2007 - 2010, Intel Corporation<BR>\r
-# All rights reserved. This program and the accompanying materials\r
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
 # http://opensource.org/licenses/bsd-license.php\r
index 017c5a63d7f4048ea5eb121a33a35142df0e404e..41119b11ab73243e95dd6b5f60331f7fc862e65e 100644 (file)
@@ -1,8 +1,8 @@
 ## @file\r
 # Windows makefile for 'Common' module build.\r
 #\r
-# Copyright (c) 2007 - 2010, Intel Corporation<BR>\r
-# All rights reserved. This program and the accompanying materials\r
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
 # http://opensource.org/licenses/bsd-license.php\r
index cace6282acfece9e3b7390fe1f0b40c05b9a839c..a93a50578843edfaabca839d9489c35b1c4674b6 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
index 9148d9d06c08b0d2d5a3bf5e1cd11bbd0096e70c..baab40baa2c6442aea2ad62615127f8030a58f8b 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
index 64c5ff783e4e8af2c2c5790721725d197f0519ef..7b0493aaa00969dbf0fe66cf119f1c8298477231 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
index 9dbe91cd415bc63e19c9e6056d9c331a602a0a8f..217beb14842e7add48c36660ca8a3df9524f89c2 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
index 088730689da456139271d44bd57aed350a0d03b5..419c8f8b8c4611016aab61db268baa5d1d2567e6 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 2007 - 2008, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2007 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
index 0386dfa50dbd846ec673e34985acbb12a8cae11c..9e7df070c5948224dded76ec670abacafb72ab01 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 2007 - 2008, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2007 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
index b643cdeb4fef2d32c5d17dd1b741cabdbe3d6072..8ddfd00b7e85d8ddea143bc0c9b772ca8effb22a 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 2007 - 2008, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2007 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
index d30afff1ccbf4eb5d5e401e4992acd926044d4fb..b4c55974e32dd1e6a2714ab561a5ec8c89733c47 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 2007 - 2008, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2007 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
index 2ce25be86f365e95d8ce056cb8dfb81360ad16b9..eb01d305275c097b61dc847b13ae768f087879f4 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 2004 - 2010, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
index af532b8a18bcd3446586de0c54861dbade957208..88ded8760e88d9232cbfcaba057cb0f1af2b7e65 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
index 077a66c5d7713c060fa6b26bcad7804836d51d92..31c6f0fca136103e394c20e3a9c9610208572fa7 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
        Function prototypes and defines on Memory Only PE COFF loader\r
 \r
-       Copyright (c) 2006, Intel Corporation                                                         \r
-       All rights reserved. This program and the accompanying materials                          \r
+       Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+  This program and the accompanying materials                          \r
        are licensed and made available under the terms and conditions of the BSD License         \r
        which accompanies this distribution.  The full text of the license may be found at        \r
        http://opensource.org/licenses/bsd-license.php                                            \r
@@ -144,4 +144,38 @@ PeCoffLoaderGetEntryPoint (
   )\r
 ;\r
 \r
+//\r
+// These functions are used by the ARM PE/COFF relocation code and by\r
+// the ELF to PE/COFF converter so that is why they are public\r
+//\r
+\r
+/**\r
+  Pass in a pointer to an ARM MOVT or MOVW immediate instruciton and \r
+  return the immediate data encoded in the instruction\r
+\r
+  @param  Instruction   Pointer to ARM MOVT or MOVW immediate instruction\r
+\r
+  @return Immediate address encoded in the instruction\r
+\r
+**/\r
+UINT16\r
+ThumbMovtImmediateAddress (\r
+  IN UINT16 *Instruction\r
+  );\r
+\r
+/**\r
+  Update an ARM MOVT or MOVW immediate instruction immediate data.\r
+\r
+  @param  Instruction   Pointer to ARM MOVT or MOVW immediate instruction\r
+  @param  Address       New addres to patch into the instruction\r
+\r
+**/\r
+VOID\r
+ThumbMovtImmediatePatch (\r
+  IN OUT UINT16 *Instruction,\r
+  IN     UINT16 Address\r
+  );\r
+\r
+\r
+\r
 #endif\r
index fedc0941cb68699ee2ad685480da40d347473174..5d827cefe42d32727a08f3af645949d6def2572c 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
@@ -315,3 +315,121 @@ PeCoffLoaderRelocateX64Image (
   return RETURN_SUCCESS;\r
 }\r
 \r
+/**\r
+  Pass in a pointer to an ARM MOVT or MOVW immediate instruciton and \r
+  return the immediate data encoded in the instruction\r
+\r
+  @param  Instruction   Pointer to ARM MOVT or MOVW immediate instruction\r
+\r
+  @return Immediate address encoded in the instruction\r
+\r
+**/\r
+UINT16\r
+ThumbMovtImmediateAddress (\r
+  IN UINT16 *Instruction\r
+  )\r
+{\r
+  UINT32  Movt;\r
+  UINT16  Address;\r
+\r
+  // Thumb2 is two 16-bit instructions working together. Not a single 32-bit instruction\r
+  // Example MOVT R0, #0 is 0x0000f2c0 or 0xf2c0 0x0000\r
+  Movt = (*Instruction << 16) | (*(Instruction + 1)); \r
+\r
+  // imm16 = imm4:i:imm3:imm8\r
+  //         imm4 -> Bit19:Bit16\r
+  //         i    -> Bit26\r
+  //         imm3 -> Bit14:Bit12\r
+  //         imm8 -> Bit7:Bit0\r
+  Address  = (UINT16)(Movt & 0x000000ff);          // imm8\r
+  Address |= (UINT16)((Movt >> 4) &  0x0000f700);  // imm4 imm3\r
+  Address |= (((Movt & BIT26) != 0) ? BIT11 : 0);  // i\r
+  return Address;\r
+}\r
+\r
+\r
+/**\r
+  Update an ARM MOVT or MOVW immediate instruction immediate data.\r
+\r
+  @param  Instruction   Pointer to ARM MOVT or MOVW immediate instruction\r
+  @param  Address       New addres to patch into the instruction\r
+**/\r
+VOID\r
+ThumbMovtImmediatePatch (\r
+  IN OUT UINT16 *Instruction,\r
+  IN     UINT16 Address\r
+  )\r
+{\r
+  UINT16  Patch;\r
+\r
+  // First 16-bit chunk of instruciton\r
+  Patch  = ((Address >> 12) & 0x000f);             // imm4 \r
+  Patch |= (((Address & BIT11) != 0) ? BIT10 : 0); // i\r
+  *Instruction = (*Instruction & ~0x040f) | Patch;\r
+\r
+  // Second 16-bit chunk of instruction\r
+  Patch  =  Address & 0x000000ff;          // imm8\r
+  Patch |=  ((Address << 4) & 0x00007000); // imm3\r
+  Instruction++;\r
+  *Instruction = (*Instruction & ~0x70ff) | Patch;\r
+}\r
+\r
+/**\r
+  Performs an ARM-based specific relocation fixup and is a no-op on other\r
+  instruction sets.\r
+\r
+  @param  Reloc       Pointer to the relocation record.\r
+  @param  Fixup       Pointer to the address to fix up.\r
+  @param  FixupData   Pointer to a buffer to log the fixups.\r
+  @param  Adjust      The offset to adjust the fixup.\r
+\r
+  @return Status code.\r
+\r
+**/\r
+RETURN_STATUS\r
+PeCoffLoaderRelocateArmImage (\r
+  IN UINT16      **Reloc,\r
+  IN OUT CHAR8   *Fixup,\r
+  IN OUT CHAR8   **FixupData,\r
+  IN UINT64      Adjust\r
+  )\r
+{\r
+  UINT16      *Fixup16;\r
+  UINT16      FixupVal;\r
+  UINT16      *Addend;\r
+\r
+  Fixup16    = (UINT16 *) Fixup;\r
+\r
+  switch ((**Reloc) >> 12) {\r
+  case EFI_IMAGE_REL_BASED_ARM_THUMB_MOVW:\r
+    FixupVal = ThumbMovtImmediateAddress (Fixup16) + (UINT16)Adjust;\r
+    ThumbMovtImmediatePatch (Fixup16, FixupVal);\r
+\r
+    if (*FixupData != NULL) {\r
+      *FixupData             = ALIGN_POINTER (*FixupData, sizeof (UINT16));\r
+      *(UINT16 *)*FixupData  = *Fixup16;\r
+      *FixupData             = *FixupData + sizeof (UINT16);\r
+    }\r
+    break;\r
+\r
+  case EFI_IMAGE_REL_BASED_ARM_THUMB_MOVT:\r
+    // For MOVT you need to know the lower 16-bits do do the math\r
+    // So this relocation entry is really two entries.\r
+    *Reloc = *Reloc + 1;\r
+    Addend = *Reloc; \r
+    FixupVal = (UINT16)(((ThumbMovtImmediateAddress (Fixup16) << 16) + Adjust + *Addend) >> 16);\r
+    ThumbMovtImmediatePatch (Fixup16, FixupVal);\r
+\r
+    if (*FixupData != NULL) {\r
+      *FixupData             = ALIGN_POINTER (*FixupData, sizeof (UINT16));\r
+      *(UINT16 *)*FixupData  = *Fixup16;\r
+      *FixupData             = *FixupData + sizeof (UINT16);\r
+    }\r
+    break;\r
+  \r
+  default:\r
+    return RETURN_UNSUPPORTED;\r
+  }\r
+\r
+  return RETURN_SUCCESS;\r
+}\r
index 68cdc630c153e05ad747e01242a66389258021c9..0f6151819c2c792c9e2350bab78970770b3e7378 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
index 7b33727d6883a76cd08c76cb45c2f7b0b9f247c4..d871eb7fe3dbbffa145a8a09236acca33a97bcb7 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
index f65ba96661c1152f9ceefe3cdcc572099d914dfc..bccb0b2d3423e51eda45a333c288899cd047297e 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 2007 - 2008, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2007 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
index cf18460c4c7812c5bcb1fdaa382f0fae7151f21e..2c764115e537c1c828ced1b53859717a4320c458 100644 (file)
@@ -1,7 +1,7 @@
 /**\r
 \r
-Copyright (c) 2007 - 2008, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2007 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
index 625f99eaca2583d5a9886ea6613f508b38e6cb53..a34f1d2a7d5b68f228176641a1c4e466a1b7c34a 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation                                              \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
index 96c17993a1795e7759d922dac2e1948e9ba02120..bd33e3dd2a9439778721a69e783eb5310c548e2b 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 http://opensource.org/licenses/bsd-license.php\r
index 7a3b4a2234cf17912c304bb128d0591b54a84e75..a92f76dbb05b4ec96e6fb62a3360ba9736dd3279 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright 2006 - 2010, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
index 3c3acdb08a6ecfe64cd96779ac5c40df18aa1313..e33b97866c173822fd837216e6a67655c1f8d361 100644 (file)
@@ -1,8 +1,8 @@
 ## @file\r
 # Windows makefile for 'EfiLdrImage' module build.\r
 #\r
-# Copyright (c) 2007 - 2010, Intel Corporation<BR>\r
-# All rights reserved. This program and the accompanying materials\r
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
 # http://opensource.org/licenses/bsd-license.php\r
index 8652a9e9bf3a5aed53b2da42da6633a6effc00b3..a3c9ef1f0a5b4aab40aafea56d524ef34b77ddfa 100644 (file)
@@ -1,8 +1,8 @@
 ## @file\r
 # Windows makefile for 'EfiLdrImage' module build.\r
 #\r
-# Copyright (c) 2007 - 2010, Intel Corporation<BR>\r
-# All rights reserved. This program and the accompanying materials\r
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
 # http://opensource.org/licenses/bsd-license.php\r
index 981786c705b9b85f46e8dff300b796c164d0562e..4642f441b487e8ccfce6ee84d7c0f8b628a25596 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 \r
-Copyright (c)  1999-2010 Intel Corporation. All rights reserved\r
+Copyright (c) 1999 - 2010, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials are licensed and made available \r
 under the terms and conditions of the BSD License which accompanies this \r
 distribution.  The full text of the license may be found at\r
index 65c77c4034804a45101b594c9a7934666c0ee7ca..d87c4c61b7c5760b4d77322e6a8303ea2ab040ee 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 \r
-Copyright (c)  1999-2008 Intel Corporation. All rights reserved\r
+Copyright (c) 1999 - 2008, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials are licensed and made available \r
 under the terms and conditions of the BSD License which accompanies this \r
 distribution.  The full text of the license may be found at\r
index f94880cf58fa30d7e79f945b5817ef75080a4ae6..eb76913713dccbfa16581b3b6d7fef182a8ef09c 100644 (file)
@@ -1,8 +1,8 @@
 ## @file\r
 # Windows makefile for 'EfiRom' module build.\r
 #\r
-# Copyright (c) 2007 - 2010, Intel Corporation<BR>\r
-# All rights reserved. This program and the accompanying materials\r
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
 # http://opensource.org/licenses/bsd-license.php\r
index c31f47ba5b286173a80ea924c09f6e59df3395a2..67a9f2521b8a914cabb128c482377e49366f3874 100644 (file)
@@ -1,8 +1,8 @@
 ## @file\r
 # Windows makefile for 'EfiRom' module build.\r
 #\r
-# Copyright (c) 2007 - 2010, Intel Corporation<BR>\r
-# All rights reserved. This program and the accompanying materials\r
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
 # http://opensource.org/licenses/bsd-license.php\r
index 263b7c520da3455365ccb323c6da29bab8ed736e..acd9dc623fb8bbc9e29a5ac6e10760fddd5e16d6 100644 (file)
@@ -1,9 +1,9 @@
 ## @file
 #  GNU Make makefile for C tools build.
 #
-#  Copyright (c) 2007 - 2010, Intel Corporation
+#  Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
 #
-#  All rights reserved. This program and the accompanying materials
+#  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
index f24b4ee9accf5451625d6c813fce1affbb93952e..1f77e879b313907c40ba42144e1c6325893807a9 100644 (file)
@@ -2,8 +2,8 @@
 \r
   Fat file system structure and definition.\r
 \r
-Copyright 2006 - 2008, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
index e4a79be69c516e46f2766f0edd71d3f9a77b7436..4a9a0e1b57d472f3f7dfa7fbcb20766ab8549868 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright 2006 - 2010, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
index a55137b557a22bc94bb5cc9d5b22e6808996ca05..065833b79fe64f0c0b7860451f59610492b9d7a1 100644 (file)
@@ -2,8 +2,8 @@
 \r
   Get Drv Num offset from Fat file system.\r
 \r
-Copyright 2006 - 2008, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
index ce6bb50b0f257208bca54d7fed77a82957079b8e..6ba39db16671525f6cc29b94fa535489aec0fcc5 100644 (file)
@@ -1,8 +1,8 @@
 ## @file\r
 # Windows makefile for 'GenBootSector' module build.\r
 #\r
-# Copyright (c) 2007 - 2010, Intel Corporation<BR>\r
-# All rights reserved. This program and the accompanying materials\r
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
 # http://opensource.org/licenses/bsd-license.php\r
index 42118dbeb5d42f408a14f5cae8a5ecca894a4f44..4f055c9b4eef36926d9bf9cbb68633b482e38cd8 100644 (file)
@@ -1,8 +1,8 @@
 ## @file\r
 # Windows makefile for 'GenCrc32' module build.\r
 #\r
-# Copyright (c) 2007 - 2010, Intel Corporation<BR>\r
-# All rights reserved. This program and the accompanying materials\r
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
 # http://opensource.org/licenses/bsd-license.php\r
index 34d1a7a3446a6bb1d96f522eeebddbfac4831e52..0a31f54890e842e95fbbbb5a356fd407ba4d4fdb 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 2007 - 2010, Intel Corporation                                              \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
index c2d71f0d7768a3d35571bbc9b066f504af0ab656..e0049a4abd53359858556282bc1adc97d0495498 100644 (file)
@@ -1,8 +1,8 @@
 ## @file\r
 # Windows makefile for 'GenCrc32' module build.\r
 #\r
-# Copyright (c) 2007 - 2010, Intel Corporation<BR>\r
-# All rights reserved. This program and the accompanying materials\r
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
 # http://opensource.org/licenses/bsd-license.php\r
index 855ceade38286c78a857db1b3771b40ab875360a..2dc4159744365de816f0e3951b1d5bb8303fba49 100644 (file)
@@ -1,8 +1,8 @@
 ## @file\r
 # Windows makefile for 'GenFfs' module build.\r
 #\r
-# Copyright (c) 2007 - 2010, Intel Corporation<BR>\r
-# All rights reserved. This program and the accompanying materials\r
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
 # http://opensource.org/licenses/bsd-license.php\r
index cdaba0c8d107d4a7196e6541fd6d0f2cf7fd61f9..2796c86bf5a8bfa75c41b0b588cae76f6989e834 100644 (file)
@@ -1,7 +1,7 @@
 /**\r
 \r
-Copyright (c) 2004-2010, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
index 9af3b8fe0f698457bd4f2e9c72926ac1dceb659d..d063278c19e2eba3d958557da500918f10da6475 100644 (file)
@@ -1,8 +1,8 @@
 ## @file\r
 # Windows makefile for 'GenFfs' module build.\r
 #\r
-# Copyright (c) 2007 - 2010, Intel Corporation<BR>\r
-# All rights reserved. This program and the accompanying materials\r
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
 # http://opensource.org/licenses/bsd-license.php\r
index 00e0e56917285593f8c63c264c4413d8a0094373..6ecf4bcca6de90b26737df765d52e441c4a57b2a 100644 (file)
@@ -1,8 +1,8 @@
 ## @file\r
 # Windows makefile for 'GenFv' module build.\r
 #\r
-# Copyright (c) 2007 - 2010, Intel Corporation<BR>\r
-# All rights reserved. This program and the accompanying materials\r
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
 # http://opensource.org/licenses/bsd-license.php\r
index 5b7f72e19e082d7d788839542f7c1c3823b44497..2cb8771b31b5f9762f3bacb43d4639dc40dc8904 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 2007 - 2010, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
index 7368bbbf9c2dca06517c0ff0280100e699fda662..4ec8b72234cfa1e1adaee444bc17d6ea6af5097a 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 2004 - 2010, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
@@ -809,6 +809,10 @@ Returns:
   }\r
 \r
   if (FfsFile->Type != EFI_FV_FILETYPE_SECURITY_CORE && pImageContext->Machine == EFI_IMAGE_MACHINE_IA64) {\r
+    //\r
+    // Process IPF PLABEL to get the real address after the image has been rebased. \r
+    // PLABEL structure is got by AddressOfEntryPoint offset to ImageBuffer stored in pImageContext->Handle.\r
+    //\r
     fprintf (FvMapFile, "EntryPoint=0x%010llx", (unsigned long long) (*(UINT64 *)((UINTN) pImageContext->Handle + (UINTN) AddressOfEntryPoint)));\r
   } else {\r
     fprintf (FvMapFile, "EntryPoint=0x%010llx", (unsigned long long) (ImageBaseAddress + AddressOfEntryPoint));\r
index b82fac8837cb347a64b4e4790581f98425da4be4..bc25ea8358263ec30084f21d05fbacfa8a696ad5 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 2004 - 2010, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
index b4cb6fc708b21a8ec800af9feb0f79021b6d9a2d..54421748937026d1991cf594ac1f89f8b2ca3896 100644 (file)
@@ -1,8 +1,8 @@
 ## @file\r
 # Windows makefile for 'GenFv' module build.\r
 #\r
-# Copyright (c) 2007 - 2010, Intel Corporation<BR>\r
-# All rights reserved. This program and the accompanying materials\r
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
 # http://opensource.org/licenses/bsd-license.php\r
diff --git a/BaseTools/Source/C/GenFw/Elf32Convert.c b/BaseTools/Source/C/GenFw/Elf32Convert.c
new file mode 100644 (file)
index 0000000..9e4a9a2
--- /dev/null
@@ -0,0 +1,964 @@
+/** @file
+
+Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+
+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.
+
+**/
+
+#include "WinNtInclude.h"
+
+#ifndef __GNUC__
+#include <windows.h>
+#include <io.h>
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <ctype.h>
+
+#include <Common/UefiBaseTypes.h>
+#include <IndustryStandard/PeImage.h>
+
+#include "PeCoffLib.h"
+#include "EfiUtilityMsgs.h"
+
+#include "GenFw.h"
+#include "ElfConvert.h"
+#include "Elf32Convert.h"
+
+STATIC
+VOID
+ScanSections32 (
+  VOID
+  );
+
+STATIC
+BOOLEAN
+WriteSections32 (
+  SECTION_FILTER_TYPES  FilterType
+  );
+
+STATIC
+VOID
+WriteRelocations32 (
+  VOID
+  );
+
+STATIC
+VOID
+WriteDebug32 (
+  VOID
+  );
+
+STATIC
+VOID
+SetImageSize32 (
+  VOID
+  );
+
+STATIC
+VOID
+CleanUp32 (
+  VOID
+  );
+
+//
+// Rename ELF32 strucutres to common names to help when porting to ELF64.
+//
+typedef Elf32_Shdr Elf_Shdr;
+typedef Elf32_Ehdr Elf_Ehdr;
+typedef Elf32_Rel Elf_Rel;
+typedef Elf32_Sym Elf_Sym;
+typedef Elf32_Phdr Elf_Phdr;
+typedef Elf32_Dyn Elf_Dyn;
+#define ELFCLASS ELFCLASS32
+#define ELF_R_TYPE(r) ELF32_R_TYPE(r)
+#define ELF_R_SYM(r) ELF32_R_SYM(r)
+
+//
+// Well known ELF structures.
+//
+STATIC Elf_Ehdr *mEhdr;
+STATIC Elf_Shdr *mShdrBase;
+STATIC Elf_Phdr *mPhdrBase;
+
+//
+// Coff information
+//
+STATIC const UINT32 mCoffAlignment = 0x20;
+
+//
+// PE section alignment.
+//
+STATIC const UINT16 mCoffNbrSections = 5;
+
+//
+// ELF sections to offset in Coff file.
+//
+STATIC UINT32 *mCoffSectionsOffset = NULL;
+
+//
+// Offsets in COFF file
+//
+STATIC UINT32 mNtHdrOffset;
+STATIC UINT32 mTextOffset;
+STATIC UINT32 mDataOffset;
+STATIC UINT32 mHiiRsrcOffset;
+STATIC UINT32 mRelocOffset;
+
+//
+// Initialization Function
+//
+BOOLEAN
+InitializeElf32 (
+  UINT8               *FileBuffer,
+  ELF_FUNCTION_TABLE  *ElfFunctions
+  )
+{
+  //
+  // Initialize data pointer and structures.
+  //
+  mEhdr = (Elf_Ehdr*) FileBuffer;  
+
+  //
+  // Check the ELF32 specific header information.
+  //
+  if (mEhdr->e_ident[EI_CLASS] != ELFCLASS32) {
+    Error (NULL, 0, 3000, "Unsupported", "ELF EI_DATA not ELFCLASS32");
+    return FALSE;
+  }
+  if (mEhdr->e_ident[EI_DATA] != ELFDATA2LSB) {
+    Error (NULL, 0, 3000, "Unsupported", "ELF EI_DATA not ELFDATA2LSB");
+    return FALSE;
+  }  
+  if ((mEhdr->e_type != ET_EXEC) && (mEhdr->e_type != ET_DYN)) {
+    Error (NULL, 0, 3000, "Unsupported", "ELF e_type not ET_EXEC or ET_DYN");
+    return FALSE;
+  }
+  if (!((mEhdr->e_machine == EM_386) || (mEhdr->e_machine == EM_ARM))) { 
+    Error (NULL, 0, 3000, "Unsupported", "ELF e_machine not EM_386 or EM_ARM");
+    return FALSE;
+  }
+  if (mEhdr->e_version != EV_CURRENT) {
+    Error (NULL, 0, 3000, "Unsupported", "ELF e_version (%u) not EV_CURRENT (%d)", (unsigned) mEhdr->e_version, EV_CURRENT);
+    return FALSE;
+  }
+  
+  //
+  // Update section header pointers
+  //
+  mShdrBase  = (Elf_Shdr *)((UINT8 *)mEhdr + mEhdr->e_shoff);
+  mPhdrBase = (Elf_Phdr *)((UINT8 *)mEhdr + mEhdr->e_phoff);
+  
+  //
+  // Create COFF Section offset buffer and zero.
+  //
+  mCoffSectionsOffset = (UINT32 *)malloc(mEhdr->e_shnum * sizeof (UINT32));
+  memset(mCoffSectionsOffset, 0, mEhdr->e_shnum * sizeof(UINT32));
+
+  //
+  // Fill in function pointers.
+  //
+  ElfFunctions->ScanSections = ScanSections32;
+  ElfFunctions->WriteSections = WriteSections32;
+  ElfFunctions->WriteRelocations = WriteRelocations32;
+  ElfFunctions->WriteDebug = WriteDebug32;
+  ElfFunctions->SetImageSize = SetImageSize32;
+  ElfFunctions->CleanUp = CleanUp32;
+
+  return TRUE;
+}
+
+
+//
+// Header by Index functions
+//
+STATIC
+Elf_Shdr*
+GetShdrByIndex (
+  UINT32 Num
+  )
+{
+  if (Num >= mEhdr->e_shnum)
+    return NULL;
+  return (Elf_Shdr*)((UINT8*)mShdrBase + Num * mEhdr->e_shentsize);
+}
+
+STATIC
+Elf_Phdr*
+GetPhdrByIndex (
+  UINT32 num
+  )
+{
+  if (num >= mEhdr->e_phnum) {
+    return NULL;
+  }
+
+  return (Elf_Phdr *)((UINT8*)mPhdrBase + num * mEhdr->e_phentsize);
+}
+
+STATIC
+UINT32
+CoffAlign (
+  UINT32 Offset
+  )
+{
+  return (Offset + mCoffAlignment - 1) & ~(mCoffAlignment - 1);
+}
+
+//
+// filter functions
+//
+STATIC
+BOOLEAN
+IsTextShdr (
+  Elf_Shdr *Shdr
+  )
+{
+  return (BOOLEAN) ((Shdr->sh_flags & (SHF_WRITE | SHF_ALLOC)) == SHF_ALLOC);
+}
+
+STATIC
+BOOLEAN
+IsHiiRsrcShdr (
+  Elf_Shdr *Shdr
+  )
+{
+  Elf_Shdr *Namedr = GetShdrByIndex(mEhdr->e_shstrndx);
+
+  return (BOOLEAN) (strcmp((CHAR8*)mEhdr + Namedr->sh_offset + Shdr->sh_name, ELF_HII_SECTION_NAME) == 0);
+}
+
+STATIC
+BOOLEAN
+IsDataShdr (
+  Elf_Shdr *Shdr
+  )
+{
+  if (IsHiiRsrcShdr(Shdr)) {
+    return FALSE;
+  }
+  return (BOOLEAN) (Shdr->sh_flags & (SHF_WRITE | SHF_ALLOC)) == (SHF_ALLOC | SHF_WRITE);
+}
+
+//
+// Elf functions interface implementation
+//
+
+STATIC
+VOID
+ScanSections32 (
+  VOID
+  )
+{
+  UINT32                          i;
+  EFI_IMAGE_DOS_HEADER            *DosHdr;
+  EFI_IMAGE_OPTIONAL_HEADER_UNION *NtHdr;
+  UINT32                          CoffEntry;
+
+  CoffEntry = 0;
+  mCoffOffset = 0;
+
+  //
+  // Coff file start with a DOS header.
+  //
+  mCoffOffset = sizeof(EFI_IMAGE_DOS_HEADER) + 0x40;
+  mNtHdrOffset = mCoffOffset;
+  switch (mEhdr->e_machine) {
+  case EM_386:
+  case EM_ARM:
+    mCoffOffset += sizeof (EFI_IMAGE_NT_HEADERS32);
+  break;
+  default:
+    VerboseMsg ("%s unknown e_machine type. Assume IA-32", (UINTN)mEhdr->e_machine);
+    mCoffOffset += sizeof (EFI_IMAGE_NT_HEADERS32);
+  break;
+  }
+
+  mTableOffset = mCoffOffset;
+  mCoffOffset += mCoffNbrSections * sizeof(EFI_IMAGE_SECTION_HEADER);
+
+  //
+  // First text sections.
+  //
+  mCoffOffset = CoffAlign(mCoffOffset);
+  mTextOffset = mCoffOffset;
+  for (i = 0; i < mEhdr->e_shnum; i++) {
+    Elf_Shdr *shdr = GetShdrByIndex(i);
+    if (IsTextShdr(shdr)) {
+      if ((shdr->sh_addralign != 0) && (shdr->sh_addralign != 1)) {
+        // the alignment field is valid
+        if ((shdr->sh_addr & (shdr->sh_addralign - 1)) == 0) {
+          // if the section address is aligned we must align PE/COFF
+          mCoffOffset = (mCoffOffset + shdr->sh_addralign - 1) & ~(shdr->sh_addralign - 1);
+        } else if ((shdr->sh_addr % shdr->sh_addralign) != (mCoffOffset % shdr->sh_addralign)) {
+          // ARM RVCT tools have behavior outside of the ELF specification to try
+          // and make images smaller.  If sh_addr is not aligned to sh_addralign
+          // then the section needs to preserve sh_addr MOD sh_addralign.
+          // Normally doing nothing here works great.
+          Error (NULL, 0, 3000, "Invalid", "Unsupported section alignment.");
+        }
+      }
+
+      /* Relocate entry.  */
+      if ((mEhdr->e_entry >= shdr->sh_addr) &&
+          (mEhdr->e_entry < shdr->sh_addr + shdr->sh_size)) {
+        CoffEntry = mCoffOffset + mEhdr->e_entry - shdr->sh_addr;
+      }
+      mCoffSectionsOffset[i] = mCoffOffset;
+      mCoffOffset += shdr->sh_size;
+    }
+  }
+
+  if (mEhdr->e_machine != EM_ARM) {
+    mCoffOffset = CoffAlign(mCoffOffset);
+  }
+
+  //
+  //  Then data sections.
+  //
+  mDataOffset = mCoffOffset;
+  for (i = 0; i < mEhdr->e_shnum; i++) {
+    Elf_Shdr *shdr = GetShdrByIndex(i);
+    if (IsDataShdr(shdr)) {
+      if ((shdr->sh_addralign != 0) && (shdr->sh_addralign != 1)) {
+        // the alignment field is valid
+        if ((shdr->sh_addr & (shdr->sh_addralign - 1)) == 0) {
+          // if the section address is aligned we must align PE/COFF
+          mCoffOffset = (mCoffOffset + shdr->sh_addralign - 1) & ~(shdr->sh_addralign - 1);
+        } else if ((shdr->sh_addr % shdr->sh_addralign) != (mCoffOffset % shdr->sh_addralign)) {
+          // ARM RVCT tools have behavior outside of the ELF specification to try
+          // and make images smaller.  If sh_addr is not aligned to sh_addralign
+          // then the section needs to preserve sh_addr MOD sh_addralign.
+          // Normally doing nothing here works great.
+          Error (NULL, 0, 3000, "Invalid", "Unsupported section alignment.");
+        }
+      }
+      mCoffSectionsOffset[i] = mCoffOffset;
+      mCoffOffset += shdr->sh_size;
+    }
+  }
+  mCoffOffset = CoffAlign(mCoffOffset);
+
+  //
+  //  The HII resource sections.
+  //
+  mHiiRsrcOffset = mCoffOffset;
+  for (i = 0; i < mEhdr->e_shnum; i++) {
+    Elf_Shdr *shdr = GetShdrByIndex(i);
+    if (IsHiiRsrcShdr(shdr)) {
+      if ((shdr->sh_addralign != 0) && (shdr->sh_addralign != 1)) {
+        // the alignment field is valid
+        if ((shdr->sh_addr & (shdr->sh_addralign - 1)) == 0) {
+          // if the section address is aligned we must align PE/COFF
+          mCoffOffset = (mCoffOffset + shdr->sh_addralign - 1) & ~(shdr->sh_addralign - 1);
+        } else if ((shdr->sh_addr % shdr->sh_addralign) != (mCoffOffset % shdr->sh_addralign)) {
+          // ARM RVCT tools have behavior outside of the ELF specification to try
+          // and make images smaller.  If sh_addr is not aligned to sh_addralign
+          // then the section needs to preserve sh_addr MOD sh_addralign.
+          // Normally doing nothing here works great.
+          Error (NULL, 0, 3000, "Invalid", "Unsupported section alignment.");
+        }
+      }
+      if (shdr->sh_size != 0) {
+        mCoffSectionsOffset[i] = mCoffOffset;
+        mCoffOffset += shdr->sh_size;
+        mCoffOffset = CoffAlign(mCoffOffset);
+        SetHiiResourceHeader ((UINT8*) mEhdr + shdr->sh_offset, mHiiRsrcOffset);
+      }
+      break;
+    }
+  }
+
+  mRelocOffset = mCoffOffset;
+
+  //
+  // Allocate base Coff file.  Will be expanded later for relocations.
+  //
+  mCoffFile = (UINT8 *)malloc(mCoffOffset);
+  memset(mCoffFile, 0, mCoffOffset);
+
+  //
+  // Fill headers.
+  //
+  DosHdr = (EFI_IMAGE_DOS_HEADER *)mCoffFile;
+  DosHdr->e_magic = EFI_IMAGE_DOS_SIGNATURE;
+  DosHdr->e_lfanew = mNtHdrOffset;
+
+  NtHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION*)(mCoffFile + mNtHdrOffset);
+
+  NtHdr->Pe32.Signature = EFI_IMAGE_NT_SIGNATURE;
+
+  switch (mEhdr->e_machine) {
+  case EM_386:
+    NtHdr->Pe32.FileHeader.Machine = EFI_IMAGE_MACHINE_IA32;
+    NtHdr->Pe32.OptionalHeader.Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;
+    break;
+  case EM_ARM:
+    NtHdr->Pe32.FileHeader.Machine = EFI_IMAGE_MACHINE_ARMT;
+    NtHdr->Pe32.OptionalHeader.Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;
+    break;
+  default:
+    VerboseMsg ("%s unknown e_machine type. Assume IA-32", (UINTN)mEhdr->e_machine);
+    NtHdr->Pe32.FileHeader.Machine = EFI_IMAGE_MACHINE_IA32;
+    NtHdr->Pe32.OptionalHeader.Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;
+  }
+
+  NtHdr->Pe32.FileHeader.NumberOfSections = mCoffNbrSections;
+  NtHdr->Pe32.FileHeader.TimeDateStamp = (UINT32) time(NULL);
+  mImageTimeStamp = NtHdr->Pe32.FileHeader.TimeDateStamp;
+  NtHdr->Pe32.FileHeader.PointerToSymbolTable = 0;
+  NtHdr->Pe32.FileHeader.NumberOfSymbols = 0;
+  NtHdr->Pe32.FileHeader.SizeOfOptionalHeader = sizeof(NtHdr->Pe32.OptionalHeader);
+  NtHdr->Pe32.FileHeader.Characteristics = EFI_IMAGE_FILE_EXECUTABLE_IMAGE
+    | EFI_IMAGE_FILE_LINE_NUMS_STRIPPED
+    | EFI_IMAGE_FILE_LOCAL_SYMS_STRIPPED
+    | EFI_IMAGE_FILE_32BIT_MACHINE;
+
+  NtHdr->Pe32.OptionalHeader.SizeOfCode = mDataOffset - mTextOffset;
+  NtHdr->Pe32.OptionalHeader.SizeOfInitializedData = mRelocOffset - mDataOffset;
+  NtHdr->Pe32.OptionalHeader.SizeOfUninitializedData = 0;
+  NtHdr->Pe32.OptionalHeader.AddressOfEntryPoint = CoffEntry;
+
+  NtHdr->Pe32.OptionalHeader.BaseOfCode = mTextOffset;
+
+  NtHdr->Pe32.OptionalHeader.BaseOfData = mDataOffset;
+  NtHdr->Pe32.OptionalHeader.ImageBase = 0;
+  NtHdr->Pe32.OptionalHeader.SectionAlignment = mCoffAlignment;
+  NtHdr->Pe32.OptionalHeader.FileAlignment = mCoffAlignment;
+  NtHdr->Pe32.OptionalHeader.SizeOfImage = 0;
+
+  NtHdr->Pe32.OptionalHeader.SizeOfHeaders = mTextOffset;
+  NtHdr->Pe32.OptionalHeader.NumberOfRvaAndSizes = EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES;
+
+  //
+  // Section headers.
+  //
+  if ((mDataOffset - mTextOffset) > 0) {
+    CreateSectionHeader (".text", mTextOffset, mDataOffset - mTextOffset,
+            EFI_IMAGE_SCN_CNT_CODE
+            | EFI_IMAGE_SCN_MEM_EXECUTE
+            | EFI_IMAGE_SCN_MEM_READ);
+  } else {
+    // Don't make a section of size 0.
+    NtHdr->Pe32.FileHeader.NumberOfSections--;
+  }
+
+  if ((mHiiRsrcOffset - mDataOffset) > 0) {
+    CreateSectionHeader (".data", mDataOffset, mHiiRsrcOffset - mDataOffset,
+            EFI_IMAGE_SCN_CNT_INITIALIZED_DATA
+            | EFI_IMAGE_SCN_MEM_WRITE
+            | EFI_IMAGE_SCN_MEM_READ);
+  } else {
+    // Don't make a section of size 0.
+    NtHdr->Pe32.FileHeader.NumberOfSections--;
+  }
+
+  if ((mRelocOffset - mHiiRsrcOffset) > 0) {
+    CreateSectionHeader (".rsrc", mHiiRsrcOffset, mRelocOffset - mHiiRsrcOffset,
+            EFI_IMAGE_SCN_CNT_INITIALIZED_DATA
+            | EFI_IMAGE_SCN_MEM_READ);
+
+    NtHdr->Pe32.OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_RESOURCE].Size = mRelocOffset - mHiiRsrcOffset;
+    NtHdr->Pe32.OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_RESOURCE].VirtualAddress = mHiiRsrcOffset;
+  } else {
+    // Don't make a section of size 0.
+    NtHdr->Pe32.FileHeader.NumberOfSections--;
+  }
+
+}
+
+STATIC
+BOOLEAN
+WriteSections32 (
+  SECTION_FILTER_TYPES  FilterType
+  )
+{
+  UINT32      Idx;
+  Elf_Shdr    *SecShdr;
+  UINT32      SecOffset;
+  BOOLEAN     (*Filter)(Elf_Shdr *);
+
+  //
+  // Initialize filter pointer
+  //
+  switch (FilterType) {
+    case SECTION_TEXT:
+      Filter = IsTextShdr;
+      break;
+    case SECTION_HII:
+      Filter = IsHiiRsrcShdr;
+      break;
+    case SECTION_DATA:
+      Filter = IsDataShdr;
+      break;
+    default:
+      return FALSE;
+  }
+
+  //
+  // First: copy sections.
+  //
+  for (Idx = 0; Idx < mEhdr->e_shnum; Idx++) {
+    Elf_Shdr *Shdr = GetShdrByIndex(Idx);
+    if ((*Filter)(Shdr)) {
+      switch (Shdr->sh_type) {
+      case SHT_PROGBITS:
+        /* Copy.  */
+        memcpy(mCoffFile + mCoffSectionsOffset[Idx],
+              (UINT8*)mEhdr + Shdr->sh_offset,
+              Shdr->sh_size);
+        break;
+
+      case SHT_NOBITS:
+        memset(mCoffFile + mCoffSectionsOffset[Idx], 0, Shdr->sh_size);
+        break;
+
+      default:
+        //
+        //  Ignore for unkown section type.
+        //
+        VerboseMsg ("%s unknown section type %x. We directly copy this section into Coff file", mInImageName, (unsigned)Shdr->sh_type);
+        break;
+      }
+    }
+  }
+
+  //
+  // Second: apply relocations.
+  //
+  for (Idx = 0; Idx < mEhdr->e_shnum; Idx++) {
+    //
+    // Determine if this is a relocation section.
+    //
+    Elf_Shdr *RelShdr = GetShdrByIndex(Idx);
+    if ((RelShdr->sh_type != SHT_REL) && (RelShdr->sh_type != SHT_RELA)) {
+      continue;
+    }
+    
+    //
+    // Relocation section found.  Now extract section information that the relocations
+    // apply to in the ELF data and the new COFF data.
+    //
+    SecShdr = GetShdrByIndex(RelShdr->sh_info);
+    SecOffset = mCoffSectionsOffset[RelShdr->sh_info];
+    
+    //
+    // Only process relocations for the current filter type.
+    //
+    if (RelShdr->sh_type == SHT_REL && (*Filter)(SecShdr)) {
+      UINT32 RelOffset;
+      
+      //
+      // Determine the symbol table referenced by the relocation data.
+      //
+      Elf_Shdr *SymtabShdr = GetShdrByIndex(RelShdr->sh_link);
+      UINT8 *Symtab = (UINT8*)mEhdr + SymtabShdr->sh_offset;
+
+      //
+      // Process all relocation entries for this section.
+      //
+      for (RelOffset = 0; RelOffset < RelShdr->sh_size; RelOffset += RelShdr->sh_entsize) {
+        //
+        // Set pointer to relocation entry
+        //
+        Elf_Rel *Rel = (Elf_Rel *)((UINT8*)mEhdr + RelShdr->sh_offset + RelOffset);
+        
+        //
+        // Set pointer to symbol table entry associated with the relocation entry.
+        //
+        Elf_Sym *Sym = (Elf_Sym *)(Symtab + ELF_R_SYM(Rel->r_info) * SymtabShdr->sh_entsize);
+        
+        Elf_Shdr *SymShdr;
+        UINT8 *Targ;
+        UINT16 Address;
+
+        //
+        // Check section header index found in symbol table and get the section 
+        // header location.
+        //
+        if (Sym->st_shndx == SHN_UNDEF
+            || Sym->st_shndx == SHN_ABS
+            || Sym->st_shndx > mEhdr->e_shnum) {
+          Error (NULL, 0, 3000, "Invalid", "%s bad symbol definition.", mInImageName);
+        }
+        SymShdr = GetShdrByIndex(Sym->st_shndx);
+
+        //
+        // Convert the relocation data to a pointer into the coff file.
+        //
+        // Note: 
+        //   r_offset is the virtual address of the storage unit to be relocated.
+        //   sh_addr is the virtual address for the base of the section.
+        //
+        Targ = mCoffFile + SecOffset + (Rel->r_offset - SecShdr->sh_addr);
+
+        //
+        // Determine how to handle each relocation type based on the machine type.
+        //
+        if (mEhdr->e_machine == EM_386) {
+          switch (ELF_R_TYPE(Rel->r_info)) {
+          case R_386_NONE:
+            break;
+          case R_386_32:
+            //
+            // Absolute relocation.
+            //  Converts Targ from a absolute virtual address to the absolute
+            //  COFF address.
+            //
+            *(UINT32 *)Targ = *(UINT32 *)Targ - SymShdr->sh_addr
+              + mCoffSectionsOffset[Sym->st_shndx];
+            break;
+          case R_386_PC32:
+            //
+            // Relative relocation: Symbol - Ip + Addend
+            //
+            *(UINT32 *)Targ = *(UINT32 *)Targ
+              + (mCoffSectionsOffset[Sym->st_shndx] - SymShdr->sh_addr)
+              - (SecOffset - SecShdr->sh_addr);
+            break;
+          default:
+            Error (NULL, 0, 3000, "Invalid", "%s unsupported ELF EM_386 relocation 0x%x.", mInImageName, (unsigned) ELF_R_TYPE(Rel->r_info));
+          }
+        } else if (mEhdr->e_machine == EM_ARM) {
+          switch (ELF32_R_TYPE(Rel->r_info)) {
+          case R_ARM_RBASE:
+            // No relocation - no action required
+
+          case R_ARM_PC24:
+          case R_ARM_XPC25:
+          case R_ARM_THM_PC22:
+          case R_ARM_THM_JUMP19:
+          case R_ARM_CALL:
+          case R_ARM_JMP24:
+            // Thease are all PC-relative relocations and don't require modification
+            // GCC does not seem to have the concept of a application that just needs to get relocated.
+            break;
+
+          case R_ARM_THM_MOVW_ABS_NC:
+            // MOVW is only lower 16-bits of the addres
+            Address = (UINT16)(Sym->st_value - SymShdr->sh_addr + mCoffSectionsOffset[Sym->st_shndx]);
+            ThumbMovtImmediatePatch ((UINT16 *)Targ, Address);
+            break;
+
+          case R_ARM_THM_MOVT_ABS:
+            // MOVT is only upper 16-bits of the addres
+            Address = (UINT16)((Sym->st_value - SymShdr->sh_addr + mCoffSectionsOffset[Sym->st_shndx]) >> 16);
+            ThumbMovtImmediatePatch ((UINT16 *)Targ, Address);
+            break;
+
+          case R_ARM_ABS32:
+          case R_ARM_RABS32:
+            //
+            // Absolute relocation.
+            //
+            *(UINT32 *)Targ = *(UINT32 *)Targ - SymShdr->sh_addr + mCoffSectionsOffset[Sym->st_shndx];
+            break;
+
+          default:
+            Error (NULL, 0, 3000, "Invalid", "WriteSections (): %s unsupported ELF EM_ARM relocation 0x%x.", mInImageName, (unsigned) ELF32_R_TYPE(Rel->r_info));
+          }
+        }
+      }
+    }
+  }
+
+  return TRUE;
+}
+
+STATIC
+VOID
+WriteRelocations32 (
+  VOID
+  )
+{
+  UINT32                           Index;
+  EFI_IMAGE_OPTIONAL_HEADER_UNION  *NtHdr;
+  EFI_IMAGE_DATA_DIRECTORY         *Dir;
+  BOOLEAN                          FoundRelocations;
+  Elf_Dyn                          *Dyn;
+  Elf_Rel                          *Rel;
+  UINTN                            RelElementSize;
+  UINTN                            RelSize;
+  UINTN                            RelOffset;
+  UINTN                            K;
+  UINT8                            *Targ;
+  Elf32_Phdr                       *DynamicSegment;
+  Elf32_Phdr                       *TargetSegment;
+  Elf_Sym                          *Sym;
+  Elf_Shdr                         *SymtabShdr;
+  UINT8                            *Symtab;
+  
+
+  for (Index = 0, FoundRelocations = FALSE; Index < mEhdr->e_shnum; Index++) {
+    Elf_Shdr *RelShdr = GetShdrByIndex(Index);
+    if ((RelShdr->sh_type == SHT_REL) || (RelShdr->sh_type == SHT_RELA)) {
+      Elf_Shdr *SecShdr = GetShdrByIndex (RelShdr->sh_info);
+      if (IsTextShdr(SecShdr) || IsDataShdr(SecShdr)) {
+        UINT32 RelIdx;
+
+        SymtabShdr = GetShdrByIndex (RelShdr->sh_link);
+        Symtab = (UINT8*)mEhdr + SymtabShdr->sh_offset;
+        FoundRelocations = TRUE;
+        for (RelIdx = 0; RelIdx < RelShdr->sh_size; RelIdx += RelShdr->sh_entsize) {
+          Elf_Rel  *Rel = (Elf_Rel *)((UINT8*)mEhdr + RelShdr->sh_offset + RelIdx);
+          Elf_Shdr *SymShdr;
+
+          Sym = (Elf_Sym *)(Symtab + ELF_R_SYM(Rel->r_info) * SymtabShdr->sh_entsize);
+          SymShdr = GetShdrByIndex (Sym->st_shndx);
+          
+          if (mEhdr->e_machine == EM_386) { 
+            switch (ELF_R_TYPE(Rel->r_info)) {
+            case R_386_NONE:
+            case R_386_PC32:
+              //
+              // No fixup entry required.
+              //
+              break;
+            case R_386_32:
+              //
+              // Creates a relative relocation entry from the absolute entry.
+              //
+              CoffAddFixup(mCoffSectionsOffset[RelShdr->sh_info]
+              + (Rel->r_offset - SecShdr->sh_addr),
+              EFI_IMAGE_REL_BASED_HIGHLOW);
+              break;
+            default:
+              Error (NULL, 0, 3000, "Invalid", "%s unsupported ELF EM_386 relocation 0x%x.", mInImageName, (unsigned) ELF_R_TYPE(Rel->r_info));
+            }
+          } else if (mEhdr->e_machine == EM_ARM) {
+            switch (ELF32_R_TYPE(Rel->r_info)) {
+            case R_ARM_RBASE: 
+              // No relocation - no action required
+            case R_ARM_PC24:
+            case R_ARM_XPC25:
+            case R_ARM_THM_PC22:
+            case R_ARM_THM_JUMP19:
+            case R_ARM_CALL:
+            case R_ARM_JMP24:
+              // Thease are all PC-relative relocations and don't require modification
+              break;
+
+            case R_ARM_THM_MOVW_ABS_NC:
+              CoffAddFixup (
+                mCoffSectionsOffset[RelShdr->sh_info]
+                + (Rel->r_offset - SecShdr->sh_addr),
+                EFI_IMAGE_REL_BASED_ARM_THUMB_MOVW
+                );
+              break;
+
+            case R_ARM_THM_MOVT_ABS:
+              CoffAddFixup (
+                mCoffSectionsOffset[RelShdr->sh_info]
+                + (Rel->r_offset - SecShdr->sh_addr),
+                EFI_IMAGE_REL_BASED_ARM_THUMB_MOVT
+                );
+
+              // The relocation entry needs to contain the lower 16-bits so we can do math
+              CoffAddFixupEntry ((UINT16)(Sym->st_value - SymShdr->sh_addr + mCoffSectionsOffset[Sym->st_shndx]));
+              break;
+
+            case R_ARM_ABS32:
+            case R_ARM_RABS32:
+              CoffAddFixup (
+                mCoffSectionsOffset[RelShdr->sh_info]
+                + (Rel->r_offset - SecShdr->sh_addr),
+                EFI_IMAGE_REL_BASED_HIGHLOW
+                );
+              break;
+
+           default:
+              Error (NULL, 0, 3000, "Invalid", "WriteRelocations(): %s unsupported ELF EM_ARM relocation 0x%x.", mInImageName, (unsigned) ELF32_R_TYPE(Rel->r_info));
+            }
+          } else {
+            Error (NULL, 0, 3000, "Not Supported", "This tool does not support relocations for ELF with e_machine %u (processor type).", (unsigned) mEhdr->e_machine);
+          }
+        }
+      }
+    }
+  }
+
+  if (!FoundRelocations && (mEhdr->e_machine == EM_ARM)) {
+    /* Try again, but look for PT_DYNAMIC instead of SHT_REL */
+
+    for (Index = 0; Index < mEhdr->e_phnum; Index++) {
+      RelElementSize = 0;
+      RelSize = 0;
+      RelOffset = 0;
+
+      DynamicSegment = GetPhdrByIndex (Index);
+
+      if (DynamicSegment->p_type == PT_DYNAMIC) {
+        Dyn = (Elf32_Dyn *) ((UINT8 *)mEhdr + DynamicSegment->p_offset);
+
+        while (Dyn->d_tag != DT_NULL) {
+          switch (Dyn->d_tag) {
+            case  DT_REL:
+              RelOffset = Dyn->d_un.d_val;
+              break;
+
+            case  DT_RELSZ:
+              RelSize = Dyn->d_un.d_val;
+              break;
+
+            case  DT_RELENT:
+              RelElementSize = Dyn->d_un.d_val;
+              break;
+
+            default:
+              break;
+          }
+          Dyn++;
+        }
+        if (( RelOffset == 0 ) || ( RelSize == 0 ) || ( RelElementSize == 0 )) {
+          Error (NULL, 0, 3000, "Invalid", "%s bad ARM dynamic relocations.", mInImageName);
+        }
+
+        for (K = 0; K < RelSize; K += RelElementSize) {
+
+          if (DynamicSegment->p_paddr == 0) {
+            // Older versions of the ARM ELF (SWS ESPC 0003 B-02) specification define DT_REL
+            // as an offset in the dynamic segment. p_paddr is defined to be zero for ARM tools
+            Rel = (Elf32_Rel *) ((UINT8 *) mEhdr + DynamicSegment->p_offset + RelOffset + K);
+          } else {
+            // This is how it reads in the generic ELF specification
+            Rel = (Elf32_Rel *) ((UINT8 *) mEhdr + RelOffset + K);
+          }
+
+          switch (ELF32_R_TYPE (Rel->r_info)) {
+          case  R_ARM_RBASE:
+            break;
+
+          case  R_ARM_RABS32:
+            TargetSegment = GetPhdrByIndex (ELF32_R_SYM (Rel->r_info) - 1);
+
+            // Note: r_offset in a memory address.  Convert it to a pointer in the coff file.
+            Targ = mCoffFile + mCoffSectionsOffset[ ELF32_R_SYM( Rel->r_info ) ] + Rel->r_offset - TargetSegment->p_vaddr;
+
+            *(UINT32 *)Targ = *(UINT32 *)Targ + mCoffSectionsOffset [ELF32_R_SYM( Rel->r_info )];
+
+            CoffAddFixup (mCoffSectionsOffset[ELF32_R_SYM (Rel->r_info)] + (Rel->r_offset - TargetSegment->p_vaddr), EFI_IMAGE_REL_BASED_HIGHLOW);
+            break;
+          
+          default:
+            Error (NULL, 0, 3000, "Invalid", "%s bad ARM dynamic relocations, unkown type %d.", mInImageName, ELF32_R_TYPE (Rel->r_info));
+            break;
+          }
+        }
+        break;
+      }
+    }
+  }
+
+  //
+  // Pad by adding empty entries.
+  //
+  while (mCoffOffset & (mCoffAlignment - 1)) {
+    CoffAddFixupEntry(0);
+  }
+
+  NtHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION *)(mCoffFile + mNtHdrOffset);
+  Dir = &NtHdr->Pe32.OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC];
+  Dir->Size = mCoffOffset - mRelocOffset;
+  if (Dir->Size == 0) {
+    // If no relocations, null out the directory entry and don't add the .reloc section
+    Dir->VirtualAddress = 0;
+    NtHdr->Pe32.FileHeader.NumberOfSections--;
+  } else {
+    Dir->VirtualAddress = mRelocOffset;
+    CreateSectionHeader (".reloc", mRelocOffset, mCoffOffset - mRelocOffset,
+            EFI_IMAGE_SCN_CNT_INITIALIZED_DATA
+            | EFI_IMAGE_SCN_MEM_DISCARDABLE
+            | EFI_IMAGE_SCN_MEM_READ);
+  }
+
+}
+
+STATIC
+VOID
+WriteDebug32 (
+  VOID
+  )
+{
+  UINT32                              Len;
+  UINT32                              DebugOffset;
+  EFI_IMAGE_OPTIONAL_HEADER_UNION     *NtHdr;
+  EFI_IMAGE_DATA_DIRECTORY            *DataDir;
+  EFI_IMAGE_DEBUG_DIRECTORY_ENTRY     *Dir;
+  EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY *Nb10;
+
+  Len = strlen(mInImageName) + 1;
+  DebugOffset = mCoffOffset;
+
+  mCoffOffset += sizeof(EFI_IMAGE_DEBUG_DIRECTORY_ENTRY)
+    + sizeof(EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY)
+    + Len;
+  mCoffOffset = CoffAlign(mCoffOffset);
+
+  mCoffFile = realloc(mCoffFile, mCoffOffset);
+  memset(mCoffFile + DebugOffset, 0, mCoffOffset - DebugOffset);
+
+  Dir = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY*)(mCoffFile + DebugOffset);
+  Dir->Type = EFI_IMAGE_DEBUG_TYPE_CODEVIEW;
+  Dir->SizeOfData = sizeof(EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY) + Len;
+  Dir->RVA = DebugOffset + sizeof(EFI_IMAGE_DEBUG_DIRECTORY_ENTRY);
+  Dir->FileOffset = DebugOffset + sizeof(EFI_IMAGE_DEBUG_DIRECTORY_ENTRY);
+
+  Nb10 = (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY*)(Dir + 1);
+  Nb10->Signature = CODEVIEW_SIGNATURE_NB10;
+  strcpy ((char *)(Nb10 + 1), mInImageName);
+
+
+  NtHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION *)(mCoffFile + mNtHdrOffset);
+  DataDir = &NtHdr->Pe32.OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG];
+  DataDir->VirtualAddress = DebugOffset;
+  DataDir->Size = mCoffOffset - DebugOffset;
+  if (DataDir->Size == 0) {
+    // If no debug, null out the directory entry and don't add the .debug section
+    DataDir->VirtualAddress = 0;
+    NtHdr->Pe32.FileHeader.NumberOfSections--;
+  } else {
+    DataDir->VirtualAddress = DebugOffset;
+    CreateSectionHeader (".debug", DebugOffset, mCoffOffset - DebugOffset,
+            EFI_IMAGE_SCN_CNT_INITIALIZED_DATA
+            | EFI_IMAGE_SCN_MEM_DISCARDABLE
+            | EFI_IMAGE_SCN_MEM_READ);
+
+  }
+}
+
+STATIC
+VOID
+SetImageSize32 (
+  VOID
+  )
+{
+  EFI_IMAGE_OPTIONAL_HEADER_UNION *NtHdr;
+  
+  //
+  // Set image size
+  //
+  NtHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION *)(mCoffFile + mNtHdrOffset);
+  NtHdr->Pe32.OptionalHeader.SizeOfImage = mCoffOffset;
+}
+
+STATIC
+VOID
+CleanUp32 (
+  VOID
+  )
+{
+  if (mCoffSectionsOffset != NULL) {
+    free (mCoffSectionsOffset);
+  }
+}
+
+
diff --git a/BaseTools/Source/C/GenFw/Elf32Convert.h b/BaseTools/Source/C/GenFw/Elf32Convert.h
new file mode 100644 (file)
index 0000000..2eafbec
--- /dev/null
@@ -0,0 +1,24 @@
+/** @file
+
+Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+
+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.
+
+**/
+
+#ifndef _ELF_32_CONVERT_
+#define _ELF_32_CONVERT_
+
+BOOLEAN
+InitializeElf32 (
+  UINT8               *FileBuffer,
+  ELF_FUNCTION_TABLE  *ElfFunctions
+  );
+
+#endif
diff --git a/BaseTools/Source/C/GenFw/Elf64Convert.c b/BaseTools/Source/C/GenFw/Elf64Convert.c
new file mode 100644 (file)
index 0000000..7c2e87e
--- /dev/null
@@ -0,0 +1,785 @@
+/** @file
+
+Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+
+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.
+
+**/
+
+#include "WinNtInclude.h"
+
+#ifndef __GNUC__
+#include <windows.h>
+#include <io.h>
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <ctype.h>
+
+#include <Common/UefiBaseTypes.h>
+#include <IndustryStandard/PeImage.h>
+
+#include "PeCoffLib.h"
+#include "EfiUtilityMsgs.h"
+
+#include "GenFw.h"
+#include "ElfConvert.h"
+#include "Elf64Convert.h"
+
+STATIC
+VOID
+ScanSections64 (
+  VOID
+  );
+
+STATIC
+BOOLEAN
+WriteSections64 (
+  SECTION_FILTER_TYPES  FilterType
+  );
+
+STATIC
+VOID
+WriteRelocations64 (
+  VOID
+  );
+
+STATIC
+VOID
+WriteDebug64 (
+  VOID
+  );
+
+STATIC
+VOID
+SetImageSize64 (
+  VOID
+  );
+
+STATIC
+VOID
+CleanUp64 (
+  VOID
+  );
+
+//
+// Rename ELF32 strucutres to common names to help when porting to ELF64.
+//
+typedef Elf64_Shdr Elf_Shdr;
+typedef Elf64_Ehdr Elf_Ehdr;
+typedef Elf64_Rel Elf_Rel;
+typedef Elf64_Rela Elf_Rela;
+typedef Elf64_Sym Elf_Sym;
+typedef Elf64_Phdr Elf_Phdr;
+typedef Elf64_Dyn Elf_Dyn;
+#define ELFCLASS ELFCLASS64
+#define ELF_R_TYPE(r) ELF64_R_TYPE(r)
+#define ELF_R_SYM(r) ELF64_R_SYM(r)
+
+//
+// Well known ELF structures.
+//
+STATIC Elf_Ehdr *mEhdr;
+STATIC Elf_Shdr *mShdrBase;
+STATIC Elf_Phdr *mPhdrBase;
+
+//
+// Coff information
+//
+STATIC const UINT32 mCoffAlignment = 0x20;
+
+//
+// PE section alignment.
+//
+STATIC const UINT16 mCoffNbrSections = 5;
+
+//
+// ELF sections to offset in Coff file.
+//
+STATIC UINT32 *mCoffSectionsOffset = NULL;
+
+//
+// Offsets in COFF file
+//
+STATIC UINT32 mNtHdrOffset;
+STATIC UINT32 mTextOffset;
+STATIC UINT32 mDataOffset;
+STATIC UINT32 mHiiRsrcOffset;
+STATIC UINT32 mRelocOffset;
+
+//
+// Initialization Function
+//
+BOOLEAN
+InitializeElf64 (
+  UINT8               *FileBuffer,
+  ELF_FUNCTION_TABLE  *ElfFunctions
+  )
+{
+  //
+  // Initialize data pointer and structures.
+  //
+  VerboseMsg ("Set EHDR");
+  mEhdr = (Elf_Ehdr*) FileBuffer;
+
+  //
+  // Check the ELF64 specific header information.
+  //
+  VerboseMsg ("Check ELF64 Header Information");
+  if (mEhdr->e_ident[EI_CLASS] != ELFCLASS64) {
+    Error (NULL, 0, 3000, "Unsupported", "ELF EI_DATA not ELFCLASS64");
+    return FALSE;
+  }
+  if (mEhdr->e_ident[EI_DATA] != ELFDATA2LSB) {
+    Error (NULL, 0, 3000, "Unsupported", "ELF EI_DATA not ELFDATA2LSB");
+    return FALSE;
+  }
+  if ((mEhdr->e_type != ET_EXEC) && (mEhdr->e_type != ET_DYN)) {
+    Error (NULL, 0, 3000, "Unsupported", "ELF e_type not ET_EXEC or ET_DYN");
+    return FALSE;
+  }
+  if (!((mEhdr->e_machine == EM_X86_64))) {
+    Error (NULL, 0, 3000, "Unsupported", "ELF e_machine not EM_X86_64");
+    return FALSE;
+  }
+  if (mEhdr->e_version != EV_CURRENT) {
+    Error (NULL, 0, 3000, "Unsupported", "ELF e_version (%u) not EV_CURRENT (%d)", (unsigned) mEhdr->e_version, EV_CURRENT);
+    return FALSE;
+  }
+
+  //
+  // Update section header pointers
+  //
+  VerboseMsg ("Update Header Pointers");
+  mShdrBase  = (Elf_Shdr *)((UINT8 *)mEhdr + mEhdr->e_shoff);
+  mPhdrBase = (Elf_Phdr *)((UINT8 *)mEhdr + mEhdr->e_phoff);
+
+  //
+  // Create COFF Section offset buffer and zero.
+  //
+  VerboseMsg ("Create COFF Section Offset Buffer");
+  mCoffSectionsOffset = (UINT32 *)malloc(mEhdr->e_shnum * sizeof (UINT32));
+  memset(mCoffSectionsOffset, 0, mEhdr->e_shnum * sizeof(UINT32));
+
+  //
+  // Fill in function pointers.
+  //
+  VerboseMsg ("Fill in Function Pointers");
+  ElfFunctions->ScanSections = ScanSections64;
+  ElfFunctions->WriteSections = WriteSections64;
+  ElfFunctions->WriteRelocations = WriteRelocations64;
+  ElfFunctions->WriteDebug = WriteDebug64;
+  ElfFunctions->SetImageSize = SetImageSize64;
+  ElfFunctions->CleanUp = CleanUp64;
+
+  return TRUE;
+}
+
+
+//
+// Header by Index functions
+//
+STATIC
+Elf_Shdr*
+GetShdrByIndex (
+  UINT32 Num
+  )
+{
+  if (Num >= mEhdr->e_shnum)
+    return NULL;
+  return (Elf_Shdr*)((UINT8*)mShdrBase + Num * mEhdr->e_shentsize);
+}
+
+STATIC
+UINT32
+CoffAlign (
+  UINT32 Offset
+  )
+{
+  return (Offset + mCoffAlignment - 1) & ~(mCoffAlignment - 1);
+}
+
+//
+// filter functions
+//
+STATIC
+BOOLEAN
+IsTextShdr (
+  Elf_Shdr *Shdr
+  )
+{
+  return (BOOLEAN) ((Shdr->sh_flags & (SHF_WRITE | SHF_ALLOC)) == SHF_ALLOC);
+}
+
+STATIC
+BOOLEAN
+IsHiiRsrcShdr (
+  Elf_Shdr *Shdr
+  )
+{
+  Elf_Shdr *Namedr = GetShdrByIndex(mEhdr->e_shstrndx);
+
+  return (BOOLEAN) (strcmp((CHAR8*)mEhdr + Namedr->sh_offset + Shdr->sh_name, ELF_HII_SECTION_NAME) == 0);
+}
+
+STATIC
+BOOLEAN
+IsDataShdr (
+  Elf_Shdr *Shdr
+  )
+{
+  if (IsHiiRsrcShdr(Shdr)) {
+    return FALSE;
+  }
+  return (BOOLEAN) (Shdr->sh_flags & (SHF_WRITE | SHF_ALLOC)) == (SHF_ALLOC | SHF_WRITE);
+}
+
+//
+// Elf functions interface implementation
+//
+
+STATIC
+VOID
+ScanSections64 (
+  VOID
+  )
+{
+  UINT32                          i;
+  EFI_IMAGE_DOS_HEADER            *DosHdr;
+  EFI_IMAGE_OPTIONAL_HEADER_UNION *NtHdr;
+  UINT32                          CoffEntry;
+
+  CoffEntry = 0;
+  mCoffOffset = 0;
+
+  //
+  // Coff file start with a DOS header.
+  //
+  mCoffOffset = sizeof(EFI_IMAGE_DOS_HEADER) + 0x40;
+  mNtHdrOffset = mCoffOffset;
+  switch (mEhdr->e_machine) {
+  case EM_X86_64:
+  case EM_IA_64:
+    mCoffOffset += sizeof (EFI_IMAGE_NT_HEADERS64);
+  break;
+  default:
+    VerboseMsg ("%s unknown e_machine type. Assume X64", (UINTN)mEhdr->e_machine);
+    mCoffOffset += sizeof (EFI_IMAGE_NT_HEADERS64);
+  break;
+  }
+
+  mTableOffset = mCoffOffset;
+  mCoffOffset += mCoffNbrSections * sizeof(EFI_IMAGE_SECTION_HEADER);
+
+  //
+  // First text sections.
+  //
+  mCoffOffset = CoffAlign(mCoffOffset);
+  mTextOffset = mCoffOffset;
+  for (i = 0; i < mEhdr->e_shnum; i++) {
+    Elf_Shdr *shdr = GetShdrByIndex(i);
+    if (IsTextShdr(shdr)) {
+      if ((shdr->sh_addralign != 0) && (shdr->sh_addralign != 1)) {
+        // the alignment field is valid
+        if ((shdr->sh_addr & (shdr->sh_addralign - 1)) == 0) {
+          // if the section address is aligned we must align PE/COFF
+          mCoffOffset = (UINT32) ((mCoffOffset + shdr->sh_addralign - 1) & ~(shdr->sh_addralign - 1));
+        } else if ((shdr->sh_addr % shdr->sh_addralign) != (mCoffOffset % shdr->sh_addralign)) {
+          // ARM RVCT tools have behavior outside of the ELF specification to try
+          // and make images smaller.  If sh_addr is not aligned to sh_addralign
+          // then the section needs to preserve sh_addr MOD sh_addralign.
+          // Normally doing nothing here works great.
+          Error (NULL, 0, 3000, "Invalid", "Unsupported section alignment.");
+        }
+      }
+
+      /* Relocate entry.  */
+      if ((mEhdr->e_entry >= shdr->sh_addr) &&
+          (mEhdr->e_entry < shdr->sh_addr + shdr->sh_size)) {
+        CoffEntry = (UINT32) (mCoffOffset + mEhdr->e_entry - shdr->sh_addr);
+      }
+      mCoffSectionsOffset[i] = mCoffOffset;
+      mCoffOffset += (UINT32) shdr->sh_size;
+    }
+  }
+
+  if (mEhdr->e_machine != EM_ARM) {
+    mCoffOffset = CoffAlign(mCoffOffset);
+  }
+
+  //
+  //  Then data sections.
+  //
+  mDataOffset = mCoffOffset;
+  for (i = 0; i < mEhdr->e_shnum; i++) {
+    Elf_Shdr *shdr = GetShdrByIndex(i);
+    if (IsDataShdr(shdr)) {
+      if ((shdr->sh_addralign != 0) && (shdr->sh_addralign != 1)) {
+        // the alignment field is valid
+        if ((shdr->sh_addr & (shdr->sh_addralign - 1)) == 0) {
+          // if the section address is aligned we must align PE/COFF
+          mCoffOffset = (UINT32) ((mCoffOffset + shdr->sh_addralign - 1) & ~(shdr->sh_addralign - 1));
+        } else if ((shdr->sh_addr % shdr->sh_addralign) != (mCoffOffset % shdr->sh_addralign)) {
+          // ARM RVCT tools have behavior outside of the ELF specification to try
+          // and make images smaller.  If sh_addr is not aligned to sh_addralign
+          // then the section needs to preserve sh_addr MOD sh_addralign.
+          // Normally doing nothing here works great.
+          Error (NULL, 0, 3000, "Invalid", "Unsupported section alignment.");
+        }
+      }
+      mCoffSectionsOffset[i] = mCoffOffset;
+      mCoffOffset += (UINT32) shdr->sh_size;
+    }
+  }
+  mCoffOffset = CoffAlign(mCoffOffset);
+
+  //
+  //  The HII resource sections.
+  //
+  mHiiRsrcOffset = mCoffOffset;
+  for (i = 0; i < mEhdr->e_shnum; i++) {
+    Elf_Shdr *shdr = GetShdrByIndex(i);
+    if (IsHiiRsrcShdr(shdr)) {
+      if ((shdr->sh_addralign != 0) && (shdr->sh_addralign != 1)) {
+        // the alignment field is valid
+        if ((shdr->sh_addr & (shdr->sh_addralign - 1)) == 0) {
+          // if the section address is aligned we must align PE/COFF
+          mCoffOffset = (UINT32) ((mCoffOffset + shdr->sh_addralign - 1) & ~(shdr->sh_addralign - 1));
+        } else if ((shdr->sh_addr % shdr->sh_addralign) != (mCoffOffset % shdr->sh_addralign)) {
+          // ARM RVCT tools have behavior outside of the ELF specification to try
+          // and make images smaller.  If sh_addr is not aligned to sh_addralign
+          // then the section needs to preserve sh_addr MOD sh_addralign.
+          // Normally doing nothing here works great.
+          Error (NULL, 0, 3000, "Invalid", "Unsupported section alignment.");
+        }
+      }
+      if (shdr->sh_size != 0) {
+        mCoffSectionsOffset[i] = mCoffOffset;
+        mCoffOffset += (UINT32) shdr->sh_size;
+        mCoffOffset = CoffAlign(mCoffOffset);
+        SetHiiResourceHeader ((UINT8*) mEhdr + shdr->sh_offset, mHiiRsrcOffset);
+      }
+      break;
+    }
+  }
+
+  mRelocOffset = mCoffOffset;
+
+  //
+  // Allocate base Coff file.  Will be expanded later for relocations.
+  //
+  mCoffFile = (UINT8 *)malloc(mCoffOffset);
+  memset(mCoffFile, 0, mCoffOffset);
+
+  //
+  // Fill headers.
+  //
+  DosHdr = (EFI_IMAGE_DOS_HEADER *)mCoffFile;
+  DosHdr->e_magic = EFI_IMAGE_DOS_SIGNATURE;
+  DosHdr->e_lfanew = mNtHdrOffset;
+
+  NtHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION*)(mCoffFile + mNtHdrOffset);
+
+  NtHdr->Pe32Plus.Signature = EFI_IMAGE_NT_SIGNATURE;
+
+  switch (mEhdr->e_machine) {
+  case EM_X86_64:
+    NtHdr->Pe32Plus.FileHeader.Machine = EFI_IMAGE_MACHINE_X64;
+    NtHdr->Pe32Plus.OptionalHeader.Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
+    break;
+  case EM_IA_64:
+    NtHdr->Pe32Plus.FileHeader.Machine = EFI_IMAGE_MACHINE_IPF;
+    NtHdr->Pe32Plus.OptionalHeader.Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
+    break;
+  default:
+    VerboseMsg ("%s unknown e_machine type. Assume X64", (UINTN)mEhdr->e_machine);
+    NtHdr->Pe32Plus.FileHeader.Machine = EFI_IMAGE_MACHINE_X64;
+    NtHdr->Pe32Plus.OptionalHeader.Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
+  }
+
+  NtHdr->Pe32Plus.FileHeader.NumberOfSections = mCoffNbrSections;
+  NtHdr->Pe32Plus.FileHeader.TimeDateStamp = (UINT32) time(NULL);
+  mImageTimeStamp = NtHdr->Pe32Plus.FileHeader.TimeDateStamp;
+  NtHdr->Pe32Plus.FileHeader.PointerToSymbolTable = 0;
+  NtHdr->Pe32Plus.FileHeader.NumberOfSymbols = 0;
+  NtHdr->Pe32Plus.FileHeader.SizeOfOptionalHeader = sizeof(NtHdr->Pe32Plus.OptionalHeader);
+  NtHdr->Pe32Plus.FileHeader.Characteristics = EFI_IMAGE_FILE_EXECUTABLE_IMAGE
+    | EFI_IMAGE_FILE_LINE_NUMS_STRIPPED
+    | EFI_IMAGE_FILE_LOCAL_SYMS_STRIPPED
+    | EFI_IMAGE_FILE_LARGE_ADDRESS_AWARE;
+
+  NtHdr->Pe32Plus.OptionalHeader.SizeOfCode = mDataOffset - mTextOffset;
+  NtHdr->Pe32Plus.OptionalHeader.SizeOfInitializedData = mRelocOffset - mDataOffset;
+  NtHdr->Pe32Plus.OptionalHeader.SizeOfUninitializedData = 0;
+  NtHdr->Pe32Plus.OptionalHeader.AddressOfEntryPoint = CoffEntry;
+
+  NtHdr->Pe32Plus.OptionalHeader.BaseOfCode = mTextOffset;
+
+  NtHdr->Pe32Plus.OptionalHeader.ImageBase = 0;
+  NtHdr->Pe32Plus.OptionalHeader.SectionAlignment = mCoffAlignment;
+  NtHdr->Pe32Plus.OptionalHeader.FileAlignment = mCoffAlignment;
+  NtHdr->Pe32Plus.OptionalHeader.SizeOfImage = 0;
+
+  NtHdr->Pe32Plus.OptionalHeader.SizeOfHeaders = mTextOffset;
+  NtHdr->Pe32Plus.OptionalHeader.NumberOfRvaAndSizes = EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES;
+
+  //
+  // Section headers.
+  //
+  if ((mDataOffset - mTextOffset) > 0) {
+    CreateSectionHeader (".text", mTextOffset, mDataOffset - mTextOffset,
+            EFI_IMAGE_SCN_CNT_CODE
+            | EFI_IMAGE_SCN_MEM_EXECUTE
+            | EFI_IMAGE_SCN_MEM_READ);
+  } else {
+    // Don't make a section of size 0.
+    NtHdr->Pe32Plus.FileHeader.NumberOfSections--;
+  }
+
+  if ((mHiiRsrcOffset - mDataOffset) > 0) {
+    CreateSectionHeader (".data", mDataOffset, mHiiRsrcOffset - mDataOffset,
+            EFI_IMAGE_SCN_CNT_INITIALIZED_DATA
+            | EFI_IMAGE_SCN_MEM_WRITE
+            | EFI_IMAGE_SCN_MEM_READ);
+  } else {
+    // Don't make a section of size 0.
+    NtHdr->Pe32Plus.FileHeader.NumberOfSections--;
+  }
+
+  if ((mRelocOffset - mHiiRsrcOffset) > 0) {
+    CreateSectionHeader (".rsrc", mHiiRsrcOffset, mRelocOffset - mHiiRsrcOffset,
+            EFI_IMAGE_SCN_CNT_INITIALIZED_DATA
+            | EFI_IMAGE_SCN_MEM_READ);
+
+    NtHdr->Pe32Plus.OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_RESOURCE].Size = mRelocOffset - mHiiRsrcOffset;
+    NtHdr->Pe32Plus.OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_RESOURCE].VirtualAddress = mHiiRsrcOffset;
+  } else {
+    // Don't make a section of size 0.
+    NtHdr->Pe32Plus.FileHeader.NumberOfSections--;
+  }
+
+}
+
+STATIC
+BOOLEAN
+WriteSections64 (
+  SECTION_FILTER_TYPES  FilterType
+  )
+{
+  UINT32      Idx;
+  Elf_Shdr    *SecShdr;
+  UINT32      SecOffset;
+  BOOLEAN     (*Filter)(Elf_Shdr *);
+
+  //
+  // Initialize filter pointer
+  //
+  switch (FilterType) {
+    case SECTION_TEXT:
+      Filter = IsTextShdr;
+      break;
+    case SECTION_HII:
+      Filter = IsHiiRsrcShdr;
+      break;
+    case SECTION_DATA:
+      Filter = IsDataShdr;
+      break;
+    default:
+      return FALSE;
+  }
+
+  //
+  // First: copy sections.
+  //
+  for (Idx = 0; Idx < mEhdr->e_shnum; Idx++) {
+    Elf_Shdr *Shdr = GetShdrByIndex(Idx);
+    if ((*Filter)(Shdr)) {
+      switch (Shdr->sh_type) {
+      case SHT_PROGBITS:
+        /* Copy.  */
+        memcpy(mCoffFile + mCoffSectionsOffset[Idx],
+              (UINT8*)mEhdr + Shdr->sh_offset,
+              (size_t) Shdr->sh_size);
+        break;
+
+      case SHT_NOBITS:
+        memset(mCoffFile + mCoffSectionsOffset[Idx], 0, (size_t) Shdr->sh_size);
+        break;
+
+      default:
+        //
+        //  Ignore for unkown section type.
+        //
+        VerboseMsg ("%s unknown section type %x. We directly copy this section into Coff file", mInImageName, (unsigned)Shdr->sh_type);
+        break;
+      }
+    }
+  }
+
+  //
+  // Second: apply relocations.
+  //
+  VerboseMsg ("Applying Relocations...");
+  for (Idx = 0; Idx < mEhdr->e_shnum; Idx++) {
+    Elf_Shdr *RelShdr = GetShdrByIndex(Idx);
+    if ((RelShdr->sh_type != SHT_REL) && (RelShdr->sh_type != SHT_RELA)) {
+      continue;
+    }
+    SecShdr = GetShdrByIndex(RelShdr->sh_info);
+    SecOffset = mCoffSectionsOffset[RelShdr->sh_info];
+    if (RelShdr->sh_type == SHT_RELA && (*Filter)(SecShdr)) {
+      UINT64 RelIdx;
+      Elf_Shdr *SymtabShdr = GetShdrByIndex(RelShdr->sh_link);
+      UINT8 *Symtab = (UINT8*)mEhdr + SymtabShdr->sh_offset;
+      for (RelIdx = 0; RelIdx < RelShdr->sh_size; RelIdx += (UINT32) RelShdr->sh_entsize) {
+        Elf_Rela *Rel = (Elf_Rela *)((UINT8*)mEhdr + RelShdr->sh_offset + RelIdx);
+        Elf_Sym  *Sym = (Elf_Sym *)(Symtab + ELF_R_SYM(Rel->r_info) * SymtabShdr->sh_entsize);
+        Elf_Shdr *SymShdr;
+        UINT8    *Targ;
+
+        if (Sym->st_shndx == SHN_UNDEF
+            || Sym->st_shndx == SHN_ABS
+            || Sym->st_shndx > mEhdr->e_shnum) {
+          Error (NULL, 0, 3000, "Invalid", "%s bad symbol definition.", mInImageName);
+        }
+        SymShdr = GetShdrByIndex(Sym->st_shndx);
+
+        //
+        // Note: r_offset in a memory address.
+        //  Convert it to a pointer in the coff file.
+        //
+        Targ = mCoffFile + SecOffset + (Rel->r_offset - SecShdr->sh_addr);
+
+        if (mEhdr->e_machine == EM_X86_64) {
+          switch (ELF_R_TYPE(Rel->r_info)) {
+          case R_X86_64_NONE:
+            break;
+          case R_X86_64_64:
+            //
+            // Absolute relocation.
+            //
+            VerboseMsg ("R_X86_64_64");
+            VerboseMsg ("Offset: 0x%08X, Addend: 0x%016LX", 
+              (UINT32)(SecOffset + (Rel->r_offset - SecShdr->sh_addr)), 
+              *(UINT64 *)Targ);
+            *(UINT64 *)Targ = *(UINT64 *)Targ - SymShdr->sh_addr + mCoffSectionsOffset[Sym->st_shndx];
+            VerboseMsg ("Relocation:  0x%016LX", *(UINT64*)Targ);
+            break;
+          case R_X86_64_32:
+            VerboseMsg ("R_X86_64_32");
+            VerboseMsg ("Offset: 0x%08X, Addend: 0x%08X", 
+              (UINT32)(SecOffset + (Rel->r_offset - SecShdr->sh_addr)), 
+              *(UINT32 *)Targ);
+            *(UINT32 *)Targ = (UINT32)((UINT64)(*(UINT32 *)Targ) - SymShdr->sh_addr + mCoffSectionsOffset[Sym->st_shndx]);
+            VerboseMsg ("Relocation:  0x%08X", *(UINT32*)Targ);
+            break;
+          case R_X86_64_32S:
+            VerboseMsg ("R_X86_64_32S");
+            VerboseMsg ("Offset: 0x%08X, Addend: 0x%08X", 
+              (UINT32)(SecOffset + (Rel->r_offset - SecShdr->sh_addr)), 
+              *(UINT32 *)Targ);
+            *(INT32 *)Targ = (INT32)((INT64)(*(INT32 *)Targ) - SymShdr->sh_addr + mCoffSectionsOffset[Sym->st_shndx]);
+            VerboseMsg ("Relocation:  0x%08X", *(UINT32*)Targ);
+            break;
+          case R_X86_64_PC32:
+            //
+            // Relative relocation: Symbol - Ip + Addend
+            //
+            VerboseMsg ("R_X86_64_PC32");
+            VerboseMsg ("Offset: 0x%08X, Addend: 0x%08X", 
+              (UINT32)(SecOffset + (Rel->r_offset - SecShdr->sh_addr)), 
+              *(UINT32 *)Targ);
+            *(UINT32 *)Targ = (UINT32) (*(UINT32 *)Targ
+              + (mCoffSectionsOffset[Sym->st_shndx] - SymShdr->sh_addr)
+              - (SecOffset - SecShdr->sh_addr));
+            VerboseMsg ("Relocation:  0x%08X", *(UINT32 *)Targ);
+            break;
+          default:
+            Error (NULL, 0, 3000, "Invalid", "%s unsupported ELF EM_X86_64 relocation 0x%x.", mInImageName, (unsigned) ELF_R_TYPE(Rel->r_info));
+          }
+        } else {
+          Error (NULL, 0, 3000, "Invalid", "Not EM_X86_X64");
+        }
+      }
+    }
+  }
+
+  return TRUE;
+}
+
+STATIC
+VOID
+WriteRelocations64 (
+  VOID
+  )
+{
+  UINT32                           Index;
+  EFI_IMAGE_OPTIONAL_HEADER_UNION  *NtHdr;
+  EFI_IMAGE_DATA_DIRECTORY         *Dir;
+  BOOLEAN                          FoundRelocations;
+  Elf_Sym                          *Sym;
+  Elf_Shdr                         *SymtabShdr;
+  UINT8                            *Symtab;
+
+
+  for (Index = 0, FoundRelocations = FALSE; Index < mEhdr->e_shnum; Index++) {
+    Elf_Shdr *RelShdr = GetShdrByIndex(Index);
+    if ((RelShdr->sh_type == SHT_REL) || (RelShdr->sh_type == SHT_RELA)) {
+      Elf_Shdr *SecShdr = GetShdrByIndex (RelShdr->sh_info);
+      if (IsTextShdr(SecShdr) || IsDataShdr(SecShdr)) {
+        UINT64 RelIdx;
+
+        SymtabShdr = GetShdrByIndex (RelShdr->sh_link);
+        Symtab = (UINT8*)mEhdr + SymtabShdr->sh_offset;
+        FoundRelocations = TRUE;
+        for (RelIdx = 0; RelIdx < RelShdr->sh_size; RelIdx += RelShdr->sh_entsize) {
+          Elf_Rela *Rel = (Elf_Rela *)((UINT8*)mEhdr + RelShdr->sh_offset + RelIdx);
+          Elf_Shdr *SymShdr;
+
+          Sym = (Elf_Sym *)(Symtab + ELF_R_SYM(Rel->r_info) * SymtabShdr->sh_entsize);
+          SymShdr = GetShdrByIndex (Sym->st_shndx);
+
+          if (mEhdr->e_machine == EM_X86_64) {
+            switch (ELF_R_TYPE(Rel->r_info)) {
+            case R_X86_64_NONE:
+            case R_X86_64_PC32:
+              break;
+            case R_X86_64_64:
+              VerboseMsg ("EFI_IMAGE_REL_BASED_DIR64 Offset: 0x%08X", 
+                mCoffSectionsOffset[RelShdr->sh_info] + (Rel->r_offset - SecShdr->sh_addr));
+              CoffAddFixup(
+                (UINT32) ((UINT64) mCoffSectionsOffset[RelShdr->sh_info]
+                + (Rel->r_offset - SecShdr->sh_addr)),
+                EFI_IMAGE_REL_BASED_DIR64);
+              break;
+            case R_X86_64_32S:
+            case R_X86_64_32:
+              VerboseMsg ("EFI_IMAGE_REL_BASED_HIGHLOW Offset: 0x%08X", 
+                mCoffSectionsOffset[RelShdr->sh_info] + (Rel->r_offset - SecShdr->sh_addr));
+              CoffAddFixup(
+                (UINT32) ((UINT64) mCoffSectionsOffset[RelShdr->sh_info]
+                + (Rel->r_offset - SecShdr->sh_addr)),
+                EFI_IMAGE_REL_BASED_HIGHLOW);
+              break;
+            default:
+              Error (NULL, 0, 3000, "Invalid", "%s unsupported ELF EM_X86_64 relocation 0x%x.", mInImageName, (unsigned) ELF_R_TYPE(Rel->r_info));
+            }
+          } else {
+            Error (NULL, 0, 3000, "Not Supported", "This tool does not support relocations for ELF with e_machine %u (processor type).", (unsigned) mEhdr->e_machine);
+          }
+        }
+      }
+    }
+  }
+
+  //
+  // Pad by adding empty entries.
+  //
+  while (mCoffOffset & (mCoffAlignment - 1)) {
+    CoffAddFixupEntry(0);
+  }
+
+  NtHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION *)(mCoffFile + mNtHdrOffset);
+  Dir = &NtHdr->Pe32Plus.OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC];
+  Dir->Size = mCoffOffset - mRelocOffset;
+  if (Dir->Size == 0) {
+    // If no relocations, null out the directory entry and don't add the .reloc section
+    Dir->VirtualAddress = 0;
+    NtHdr->Pe32Plus.FileHeader.NumberOfSections--;
+  } else {
+    Dir->VirtualAddress = mRelocOffset;
+    CreateSectionHeader (".reloc", mRelocOffset, mCoffOffset - mRelocOffset,
+            EFI_IMAGE_SCN_CNT_INITIALIZED_DATA
+            | EFI_IMAGE_SCN_MEM_DISCARDABLE
+            | EFI_IMAGE_SCN_MEM_READ);
+  }
+}
+
+STATIC
+VOID
+WriteDebug64 (
+  VOID
+  )
+{
+  UINT32                              Len;
+  UINT32                              DebugOffset;
+  EFI_IMAGE_OPTIONAL_HEADER_UNION     *NtHdr;
+  EFI_IMAGE_DATA_DIRECTORY            *DataDir;
+  EFI_IMAGE_DEBUG_DIRECTORY_ENTRY     *Dir;
+  EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY *Nb10;
+
+  Len = strlen(mInImageName) + 1;
+  DebugOffset = mCoffOffset;
+
+  mCoffOffset += sizeof(EFI_IMAGE_DEBUG_DIRECTORY_ENTRY)
+    + sizeof(EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY)
+    + Len;
+  mCoffOffset = CoffAlign(mCoffOffset);
+
+  mCoffFile = realloc(mCoffFile, mCoffOffset);
+  memset(mCoffFile + DebugOffset, 0, mCoffOffset - DebugOffset);
+
+  Dir = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY*)(mCoffFile + DebugOffset);
+  Dir->Type = EFI_IMAGE_DEBUG_TYPE_CODEVIEW;
+  Dir->SizeOfData = sizeof(EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY) + Len;
+  Dir->RVA = DebugOffset + sizeof(EFI_IMAGE_DEBUG_DIRECTORY_ENTRY);
+  Dir->FileOffset = DebugOffset + sizeof(EFI_IMAGE_DEBUG_DIRECTORY_ENTRY);
+
+  Nb10 = (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY*)(Dir + 1);
+  Nb10->Signature = CODEVIEW_SIGNATURE_NB10;
+  strcpy ((char *)(Nb10 + 1), mInImageName);
+
+
+  NtHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION *)(mCoffFile + mNtHdrOffset);
+  DataDir = &NtHdr->Pe32Plus.OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG];
+  DataDir->VirtualAddress = DebugOffset;
+  DataDir->Size = mCoffOffset - DebugOffset;
+  if (DataDir->Size == 0) {
+    // If no debug, null out the directory entry and don't add the .debug section
+    DataDir->VirtualAddress = 0;
+    NtHdr->Pe32Plus.FileHeader.NumberOfSections--;
+  } else {
+    DataDir->VirtualAddress = DebugOffset;
+    CreateSectionHeader (".debug", DebugOffset, mCoffOffset - DebugOffset,
+            EFI_IMAGE_SCN_CNT_INITIALIZED_DATA
+            | EFI_IMAGE_SCN_MEM_DISCARDABLE
+            | EFI_IMAGE_SCN_MEM_READ);
+
+  }
+}
+
+STATIC
+VOID
+SetImageSize64 (
+  VOID
+  )
+{
+  EFI_IMAGE_OPTIONAL_HEADER_UNION *NtHdr;
+
+  //
+  // Set image size
+  //
+  NtHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION *)(mCoffFile + mNtHdrOffset);
+  NtHdr->Pe32Plus.OptionalHeader.SizeOfImage = mCoffOffset;
+}
+
+STATIC
+VOID
+CleanUp64 (
+  VOID
+  )
+{
+  if (mCoffSectionsOffset != NULL) {
+    free (mCoffSectionsOffset);
+  }
+}
+
+
diff --git a/BaseTools/Source/C/GenFw/Elf64Convert.h b/BaseTools/Source/C/GenFw/Elf64Convert.h
new file mode 100644 (file)
index 0000000..1fb95a8
--- /dev/null
@@ -0,0 +1,24 @@
+/** @file
+
+Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+
+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.
+
+**/
+
+#ifndef _ELF_64_CONVERT_
+#define _ELF_64_CONVERT_
+
+BOOLEAN
+InitializeElf64 (
+  UINT8               *FileBuffer,
+  ELF_FUNCTION_TABLE  *ElfFunctions
+  );
+
+#endif
diff --git a/BaseTools/Source/C/GenFw/ElfConvert.c b/BaseTools/Source/C/GenFw/ElfConvert.c
new file mode 100644 (file)
index 0000000..135fa90
--- /dev/null
@@ -0,0 +1,233 @@
+/** @file
+
+Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+
+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.
+
+**/
+
+#include "WinNtInclude.h"
+
+#ifndef __GNUC__
+#include <windows.h>
+#include <io.h>
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <ctype.h>
+
+#include <Common/UefiBaseTypes.h>
+#include <IndustryStandard/PeImage.h>
+
+#include "EfiUtilityMsgs.h"
+
+#include "GenFw.h"
+#include "ElfConvert.h"
+#include "Elf32Convert.h"
+#include "Elf64Convert.h"
+
+//
+// Result Coff file in memory.
+//
+UINT8 *mCoffFile = NULL;
+
+//
+// COFF relocation data
+//
+EFI_IMAGE_BASE_RELOCATION *mCoffBaseRel;
+UINT16                    *mCoffEntryRel;
+
+//
+// Current offset in coff file.
+//
+UINT32 mCoffOffset;
+
+//
+// Offset in Coff file of headers and sections.
+//
+UINT32 mTableOffset;
+
+//
+//*****************************************************************************
+// Common ELF Functions
+//*****************************************************************************
+//
+
+VOID
+CoffAddFixupEntry(
+  UINT16 Val
+  )
+{
+  *mCoffEntryRel = Val;
+  mCoffEntryRel++;
+  mCoffBaseRel->SizeOfBlock += 2;
+  mCoffOffset += 2;
+}
+
+VOID
+CoffAddFixup(
+  UINT32 Offset,
+  UINT8  Type
+  )
+{
+  if (mCoffBaseRel == NULL
+      || mCoffBaseRel->VirtualAddress != (Offset & ~0xfff)) {
+    if (mCoffBaseRel != NULL) {
+      //
+      // Add a null entry (is it required ?)
+      //
+      CoffAddFixupEntry (0);
+      
+      //
+      // Pad for alignment.
+      //
+      if (mCoffOffset % 4 != 0)
+        CoffAddFixupEntry (0);
+    }
+
+    mCoffFile = realloc (
+      mCoffFile,
+      mCoffOffset + sizeof(EFI_IMAGE_BASE_RELOCATION) + 2*0x1000
+      );
+    memset (
+      mCoffFile + mCoffOffset, 0,
+      sizeof(EFI_IMAGE_BASE_RELOCATION) + 2*0x1000
+      );
+
+    mCoffBaseRel = (EFI_IMAGE_BASE_RELOCATION*)(mCoffFile + mCoffOffset);
+    mCoffBaseRel->VirtualAddress = Offset & ~0xfff;
+    mCoffBaseRel->SizeOfBlock = sizeof(EFI_IMAGE_BASE_RELOCATION);
+
+    mCoffEntryRel = (UINT16 *)(mCoffBaseRel + 1);
+    mCoffOffset += sizeof(EFI_IMAGE_BASE_RELOCATION);
+  }
+
+  //
+  // Fill the entry.
+  //
+  CoffAddFixupEntry((UINT16) ((Type << 12) | (Offset & 0xfff)));
+}
+
+VOID
+CreateSectionHeader (
+  const CHAR8 *Name,
+  UINT32      Offset,
+  UINT32      Size,
+  UINT32      Flags
+  )
+{
+  EFI_IMAGE_SECTION_HEADER *Hdr;
+  Hdr = (EFI_IMAGE_SECTION_HEADER*)(mCoffFile + mTableOffset);
+
+  strcpy((char *)Hdr->Name, Name);
+  Hdr->Misc.VirtualSize = Size;
+  Hdr->VirtualAddress = Offset;
+  Hdr->SizeOfRawData = Size;
+  Hdr->PointerToRawData = Offset;
+  Hdr->PointerToRelocations = 0;
+  Hdr->PointerToLinenumbers = 0;
+  Hdr->NumberOfRelocations = 0;
+  Hdr->NumberOfLinenumbers = 0;
+  Hdr->Characteristics = Flags;
+
+  mTableOffset += sizeof (EFI_IMAGE_SECTION_HEADER);
+}
+
+//
+//*****************************************************************************
+// Functions called from GenFw main code.
+//*****************************************************************************
+//
+
+INTN
+IsElfHeader (
+  UINT8  *FileBuffer
+)
+{
+  return (FileBuffer[EI_MAG0] == ELFMAG0 && 
+          FileBuffer[EI_MAG1] == ELFMAG1 &&
+          FileBuffer[EI_MAG2] == ELFMAG2 &&
+          FileBuffer[EI_MAG3] == ELFMAG3);
+}
+
+BOOLEAN
+ConvertElf (
+  UINT8  **FileBuffer,
+  UINT32 *FileLength
+  )
+{
+  ELF_FUNCTION_TABLE              ElfFunctions;
+  UINT8                           EiClass;
+
+  //
+  // Determine ELF type and set function table pointer correctly.
+  //
+  VerboseMsg ("Check Efl Image Header");
+  EiClass = (*FileBuffer)[EI_CLASS];
+  if (EiClass == ELFCLASS32) {
+    if (!InitializeElf32 (*FileBuffer, &ElfFunctions)) {
+      return FALSE;
+    }
+  } else if (EiClass == ELFCLASS64) {
+    if (!InitializeElf64 (*FileBuffer, &ElfFunctions)) {
+      return FALSE;
+    }
+  } else {
+    Error (NULL, 0, 3000, "Unsupported", "ELF EI_CLASS not supported.");
+    return FALSE;
+  }
+
+  //
+  // Compute sections new address.
+  //  
+  VerboseMsg ("Compute sections new address.");
+  ElfFunctions.ScanSections ();
+
+  //
+  // Write and relocate sections.
+  //
+  VerboseMsg ("Write and relocate sections.");
+  ElfFunctions.WriteSections (SECTION_TEXT);
+  ElfFunctions.WriteSections (SECTION_DATA);
+  ElfFunctions.WriteSections (SECTION_HII);
+
+  //
+  // Translate and write relocations.
+  //
+  VerboseMsg ("Translate and write relocations.");
+  ElfFunctions.WriteRelocations ();
+
+  //
+  // Write debug info.
+  //
+  VerboseMsg ("Write debug info.");
+  ElfFunctions.WriteDebug ();
+
+  //
+  // Make sure image size is correct before returning the new image.
+  //
+  VerboseMsg ("Set image size.");
+  ElfFunctions.SetImageSize ();
+
+  //
+  // Replace.
+  //
+  free (*FileBuffer);
+  *FileBuffer = mCoffFile;
+  *FileLength = mCoffOffset;
+
+  //
+  // Free resources used by ELF functions.
+  //
+  ElfFunctions.CleanUp ();
+  
+  return TRUE;
+}
diff --git a/BaseTools/Source/C/GenFw/ElfConvert.h b/BaseTools/Source/C/GenFw/ElfConvert.h
new file mode 100644 (file)
index 0000000..edd9d52
--- /dev/null
@@ -0,0 +1,82 @@
+/** @file
+
+Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+
+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.
+
+**/
+
+#ifndef _ELF_CONVERT_H_
+#define _ELF_CONVERT_H_
+
+#include "elf_common.h"
+#include "elf32.h"
+#include "elf64.h"
+
+//
+// Externally defined variables
+//
+extern UINT32 mCoffOffset;
+extern CHAR8  *mInImageName;
+extern UINT32 mImageTimeStamp;
+extern UINT8  *mCoffFile;
+extern UINT32 mTableOffset;
+
+//
+// Common EFI specific data.
+//
+#define ELF_HII_SECTION_NAME ".hii"
+
+//
+// Filter Types
+//
+typedef enum {
+  SECTION_TEXT,
+  SECTION_HII,
+  SECTION_DATA
+  
+} SECTION_FILTER_TYPES;
+
+//
+// FunctionTalbe
+//
+typedef struct {
+  VOID    (*ScanSections) ();
+  BOOLEAN (*WriteSections) (SECTION_FILTER_TYPES  FilterType);
+  VOID    (*WriteRelocations) ();
+  VOID    (*WriteDebug) ();
+  VOID    (*SetImageSize) ();
+  VOID    (*CleanUp) ();
+  
+} ELF_FUNCTION_TABLE;
+
+//
+// Common functions
+//
+VOID
+CoffAddFixup (
+  UINT32 Offset,
+  UINT8  Type
+  );
+
+VOID
+CoffAddFixupEntry (
+  UINT16 Val
+  );
+
+
+VOID
+CreateSectionHeader (
+  const CHAR8 *Name,
+  UINT32      Offset,
+  UINT32      Size,
+  UINT32      Flags
+  );
+
+#endif
index 25228eb5bb32171254c62b0652c8eb9cbbba3c42..2a0f058b86f8c0b7202e8b356671139932a8d267 100644 (file)
@@ -1,8 +1,8 @@
 ## @file\r
 # Windows makefile for 'GenFw' module build.\r
 #\r
-# Copyright (c) 2009 - 2010, Intel Corporation<BR>\r
-# All rights reserved. This program and the accompanying materials\r
+# Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
 # http://opensource.org/licenses/bsd-license.php\r
@@ -15,7 +15,7 @@ MAKEROOT ?= ..
 \r
 APPNAME = GenFw\r
 \r
-OBJECTS = GenFw.o\r
+OBJECTS = GenFw.o ElfConvert.o Elf32Convert.o Elf64Convert.o\r
 \r
 include $(MAKEROOT)/Makefiles/app.makefile\r
 \r
index ee02f851204a06e3ea02e2fba3bcf7e9488ed3d7..e41fe6e82ba78091124d654f7ad1d6ba104f822b 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 2004 - 2010, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 http://opensource.org/licenses/bsd-license.php\r
@@ -51,10 +51,7 @@ Abstract:
 #include "ParseInf.h"\r
 #include "EfiUtilityMsgs.h"\r
 \r
-#include "elf_common.h"\r
-#include "elf32.h"\r
-#include "elf64.h"\r
-\r
+#include "GenFw.h"\r
 \r
 //\r
 // Version of this utility\r
@@ -68,22 +65,22 @@ Abstract:
 //\r
 // Action for this tool.\r
 //\r
-#define FW_DUMMY_IMAGE       0\r
-#define FW_EFI_IMAGE         1\r
-#define FW_TE_IMAGE          2\r
-#define FW_ACPI_IMAGE        3\r
-#define FW_BIN_IMAGE         4\r
-#define FW_ZERO_DEBUG_IMAGE  5\r
-#define FW_SET_STAMP_IMAGE   6\r
-#define FW_MCI_IMAGE         7\r
-#define FW_MERGE_IMAGE       8\r
-#define FW_RELOC_STRIPEED_IMAGE 9\r
-#define FW_HII_PACKAGE_LIST_RCIMAGE 10\r
-#define FW_HII_PACKAGE_LIST_BINIMAGE 11\r
-#define FW_REBASE_IMAGE      12\r
-#define FW_SET_ADDRESS_IMAGE 13\r
-\r
-#define DUMP_TE_HEADER       0x11\r
+#define FW_DUMMY_IMAGE                0\r
+#define FW_EFI_IMAGE                  1\r
+#define FW_TE_IMAGE                   2\r
+#define FW_ACPI_IMAGE                 3\r
+#define FW_BIN_IMAGE                  4\r
+#define FW_ZERO_DEBUG_IMAGE           5\r
+#define FW_SET_STAMP_IMAGE            6\r
+#define FW_MCI_IMAGE                  7\r
+#define FW_MERGE_IMAGE                8\r
+#define FW_RELOC_STRIPEED_IMAGE       9\r
+#define FW_HII_PACKAGE_LIST_RCIMAGE   10\r
+#define FW_HII_PACKAGE_LIST_BINIMAGE  11\r
+#define FW_REBASE_IMAGE               12\r
+#define FW_SET_ADDRESS_IMAGE          13\r
+\r
+#define DUMP_TE_HEADER  0x11\r
 \r
 #define DEFAULT_MC_PAD_BYTE_VALUE  0xFF\r
 #define DEFAULT_MC_ALIGNMENT       16\r
@@ -92,7 +89,7 @@ Abstract:
 #define _MAX_PATH 500\r
 #endif\r
 \r
-#define STATUS_IGNORE        0xA\r
+#define STATUS_IGNORE 0xA\r
 //\r
 // Structure definition for a microcode header\r
 //\r
@@ -118,13 +115,13 @@ static const char *gHiiPackageRCFileHeader[] = {
   NULL\r
 };\r
 \r
-STATIC CHAR8 *mInImageName;\r
-\r
 //\r
 // Module image information\r
 //\r
-STATIC UINT32 mImageTimeStamp = 0;\r
-STATIC UINT32 mImageSize = 0;\r
+CHAR8  *mInImageName;\r
+UINT32 mImageTimeStamp = 0;\r
+UINT32 mImageSize = 0;\r
+\r
 \r
 STATIC\r
 EFI_STATUS\r
@@ -472,186 +469,6 @@ Returns:
   return STATUS_SUCCESS;\r
 }\r
 \r
-\r
-INTN\r
-IsElfHeader(\r
-  UINT8  *FileBuffer\r
-)\r
-{\r
-  return (FileBuffer[EI_MAG0] == ELFMAG0\r
-    && FileBuffer[EI_MAG1] == ELFMAG1\r
-    && FileBuffer[EI_MAG2] == ELFMAG2\r
-    && FileBuffer[EI_MAG3] == ELFMAG3);\r
-}\r
-\r
-typedef Elf32_Shdr Elf_Shdr;\r
-typedef Elf32_Ehdr Elf_Ehdr;\r
-typedef Elf32_Rel Elf_Rel;\r
-typedef Elf32_Sym Elf_Sym;\r
-typedef Elf32_Phdr Elf_Phdr;\r
-typedef Elf32_Dyn Elf_Dyn;\r
-\r
-#define ELFCLASS ELFCLASS32\r
-#define ELF_R_TYPE(r) ELF32_R_TYPE(r)\r
-#define ELF_R_SYM(r) ELF32_R_SYM(r)\r
-#define ELF_HII_SECTION_NAME ".hii"\r
-//\r
-// Well known ELF structures.\r
-//\r
-Elf_Ehdr *Ehdr;\r
-Elf_Shdr *ShdrBase;\r
-Elf_Phdr *gPhdrBase;\r
-\r
-//\r
-// PE section alignment.\r
-//\r
-const UINT32 CoffAlignment = 0x20;\r
-const UINT16 CoffNbrSections = 5;\r
-\r
-//\r
-// Current offset in coff file.\r
-//\r
-UINT32 CoffOffset;\r
-\r
-//\r
-// Result Coff file in memory.\r
-//\r
-UINT8 *CoffFile = NULL;\r
-//\r
-// ELF sections to offset in Coff file.\r
-//\r
-UINT32 *CoffSectionsOffset = NULL;\r
-\r
-//\r
-// Offset in Coff file of headers and sections.\r
-//\r
-UINT32 NtHdrOffset;\r
-UINT32 TableOffset;\r
-UINT32 TextOffset;\r
-UINT32 DataOffset;\r
-UINT32 HiiRsrcOffset;\r
-UINT32 RelocOffset;\r
-\r
-EFI_IMAGE_BASE_RELOCATION *CoffBaseRel;\r
-UINT16 *CoffEntryRel;\r
-\r
-UINT32\r
-CoffAlign(\r
-  UINT32 Offset\r
-  )\r
-{\r
-  return (Offset + CoffAlignment - 1) & ~(CoffAlignment - 1);\r
-}\r
-\r
-Elf_Shdr *\r
-GetShdrByIndex(\r
-  UINT32 Num\r
-  )\r
-{\r
-  if (Num >= Ehdr->e_shnum)\r
-    return NULL;\r
-  return (Elf_Shdr*)((UINT8*)ShdrBase + Num * Ehdr->e_shentsize);\r
-}\r
-\r
-INTN\r
-CheckElfHeader(\r
-  VOID\r
-  )\r
-{\r
-  //\r
-  // Note: Magic has already been tested.\r
-  //\r
-  if (Ehdr->e_ident[EI_CLASS] != ELFCLASS) {\r
-    Error (NULL, 0, 3000, "Unsupported", "%s needs to be ported for 64-bit ELF.", mInImageName);\r
-    return 0;\r
-  }\r
-  if (Ehdr->e_ident[EI_DATA] != ELFDATA2LSB) {\r
-    Error (NULL, 0, 3000, "Unsupported", "ELF EI_DATA not ELFDATA2LSB");\r
-    return 0;\r
-  }\r
-  if ((Ehdr->e_type != ET_EXEC) && (Ehdr->e_type != ET_DYN)) {\r
-    Error (NULL, 0, 3000, "Unsupported", "ELF e_type not ET_EXEC or ET_DYN");\r
-    return 0;\r
-  }\r
-  if (!((Ehdr->e_machine == EM_386) || (Ehdr->e_machine == EM_ARM))) { \r
-    Error (NULL, 0, 3000, "Unsupported", "ELF e_machine not EM_386 or EM_ARM");\r
-    return 0;\r
-  }\r
-  if (Ehdr->e_version != EV_CURRENT) {\r
-    Error (NULL, 0, 3000, "Unsupported", "ELF e_version (%u) not EV_CURRENT (%d)", (unsigned) Ehdr->e_version, EV_CURRENT);\r
-    return 0;\r
-  }\r
-\r
-  //\r
-  // Find the section header table\r
-  //\r
-  ShdrBase  = (Elf_Shdr *)((UINT8 *)Ehdr + Ehdr->e_shoff);\r
-  gPhdrBase = (Elf_Phdr *)((UINT8 *)Ehdr + Ehdr->e_phoff);\r
-\r
-  CoffSectionsOffset = (UINT32 *)malloc(Ehdr->e_shnum * sizeof (UINT32));\r
-\r
-  memset(CoffSectionsOffset, 0, Ehdr->e_shnum * sizeof(UINT32));\r
-  return 1;\r
-}\r
-\r
-int\r
-IsTextShdr(\r
-  Elf_Shdr *Shdr\r
-  )\r
-{\r
-  return (Shdr->sh_flags & (SHF_WRITE | SHF_ALLOC)) == SHF_ALLOC;\r
-}\r
-\r
-int\r
-IsHiiRsrcShdr(\r
-  Elf_Shdr *Shdr\r
-  )\r
-{\r
-  Elf_Shdr *Namedr = GetShdrByIndex(Ehdr->e_shstrndx);\r
-\r
-  if (strcmp((CHAR8*)Ehdr + Namedr->sh_offset + Shdr->sh_name, ELF_HII_SECTION_NAME) == 0) {\r
-    return 1;\r
-  }\r
-\r
-  return 0;\r
-}\r
-\r
-int\r
-IsDataShdr(\r
-  Elf_Shdr *Shdr\r
-  )\r
-{\r
-  if (IsHiiRsrcShdr(Shdr)) {\r
-    return 0;\r
-  }\r
-  return (Shdr->sh_flags & (SHF_WRITE | SHF_ALLOC)) == (SHF_ALLOC | SHF_WRITE);\r
-}\r
-\r
-VOID\r
-CreateSectionHeader(\r
-  const CHAR8 *Name,\r
-  UINT32      Offset,\r
-  UINT32      Size,\r
-  UINT32      Flags\r
-  )\r
-{\r
-  EFI_IMAGE_SECTION_HEADER *Hdr;\r
-  Hdr = (EFI_IMAGE_SECTION_HEADER*)(CoffFile + TableOffset);\r
-\r
-  strcpy((char *)Hdr->Name, Name);\r
-  Hdr->Misc.VirtualSize = Size;\r
-  Hdr->VirtualAddress = Offset;\r
-  Hdr->SizeOfRawData = Size;\r
-  Hdr->PointerToRawData = Offset;\r
-  Hdr->PointerToRelocations = 0;\r
-  Hdr->PointerToLinenumbers = 0;\r
-  Hdr->NumberOfRelocations = 0;\r
-  Hdr->NumberOfLinenumbers = 0;\r
-  Hdr->Characteristics = Flags;\r
-\r
-  TableOffset += sizeof (EFI_IMAGE_SECTION_HEADER);\r
-}\r
-\r
 VOID\r
 SetHiiResourceHeader (\r
   UINT8   *HiiBinData,\r
@@ -712,708 +529,6 @@ SetHiiResourceHeader (
   return;\r
 }\r
 \r
-VOID\r
-ScanSections(\r
-  VOID\r
-  )\r
-{\r
-  UINT32                          i;\r
-  EFI_IMAGE_DOS_HEADER            *DosHdr;\r
-  EFI_IMAGE_OPTIONAL_HEADER_UNION *NtHdr;\r
-  UINT32                          CoffEntry;\r
-\r
-  CoffEntry = 0;\r
-  CoffOffset = 0;\r
-\r
-  //\r
-  // Coff file start with a DOS header.\r
-  //\r
-  CoffOffset = sizeof(EFI_IMAGE_DOS_HEADER) + 0x40;\r
-  NtHdrOffset = CoffOffset;\r
-  switch (Ehdr->e_machine) {\r
-  case EM_386:\r
-  case EM_ARM:\r
-    CoffOffset += sizeof (EFI_IMAGE_NT_HEADERS32);\r
-       break;\r
-  case EM_X86_64:\r
-  case EM_IA_64:\r
-    CoffOffset += sizeof (EFI_IMAGE_NT_HEADERS64);\r
-       break;\r
-  default:\r
-    VerboseMsg ("%s unknown e_machine type. Assume IA-32", (UINTN)Ehdr->e_machine);\r
-    CoffOffset += sizeof (EFI_IMAGE_NT_HEADERS32);\r
-       break;\r
-  }\r
-\r
-  TableOffset = CoffOffset;\r
-  CoffOffset += CoffNbrSections * sizeof(EFI_IMAGE_SECTION_HEADER);\r
-\r
-  //\r
-  // First text sections.\r
-  //\r
-  CoffOffset = CoffAlign(CoffOffset);\r
-  TextOffset = CoffOffset;\r
-  for (i = 0; i < Ehdr->e_shnum; i++) {\r
-    Elf_Shdr *shdr = GetShdrByIndex(i);\r
-    if (IsTextShdr(shdr)) {\r
-      if ((shdr->sh_addralign != 0) && (shdr->sh_addralign != 1)) {\r
-        // the alignment field is valid\r
-        if ((shdr->sh_addr & (shdr->sh_addralign - 1)) == 0) {\r
-          // if the section address is aligned we must align PE/COFF \r
-          CoffOffset = (CoffOffset + shdr->sh_addralign - 1) & ~(shdr->sh_addralign - 1);\r
-        } else if ((shdr->sh_addr % shdr->sh_addralign) != (CoffOffset % shdr->sh_addralign)) {\r
-          // ARM RVCT tools have behavior outside of the ELF specification to try \r
-          // and make images smaller.  If sh_addr is not aligned to sh_addralign \r
-          // then the section needs to preserve sh_addr MOD sh_addralign. \r
-          // Normally doing nothing here works great.\r
-          Error (NULL, 0, 3000, "Invalid", "Unsupported section alignment.");\r
-        }\r
-      }\r
-      \r
-      /* Relocate entry.  */\r
-      if ((Ehdr->e_entry >= shdr->sh_addr) &&\r
-          (Ehdr->e_entry < shdr->sh_addr + shdr->sh_size)) {\r
-        CoffEntry = CoffOffset + Ehdr->e_entry - shdr->sh_addr;\r
-      }\r
-      CoffSectionsOffset[i] = CoffOffset;\r
-      CoffOffset += shdr->sh_size;\r
-    }\r
-  }\r
-\r
-  if (Ehdr->e_machine != EM_ARM) {\r
-    CoffOffset = CoffAlign(CoffOffset);\r
-  }\r
-\r
-  //\r
-  //  Then data sections.\r
-  //\r
-  DataOffset = CoffOffset;\r
-  for (i = 0; i < Ehdr->e_shnum; i++) {\r
-    Elf_Shdr *shdr = GetShdrByIndex(i);\r
-    if (IsDataShdr(shdr)) {\r
-      if ((shdr->sh_addralign != 0) && (shdr->sh_addralign != 1)) {\r
-        // the alignment field is valid\r
-        if ((shdr->sh_addr & (shdr->sh_addralign - 1)) == 0) {\r
-          // if the section address is aligned we must align PE/COFF \r
-          CoffOffset = (CoffOffset + shdr->sh_addralign - 1) & ~(shdr->sh_addralign - 1);\r
-        } else if ((shdr->sh_addr % shdr->sh_addralign) != (CoffOffset % shdr->sh_addralign)) {\r
-          // ARM RVCT tools have behavior outside of the ELF specification to try \r
-          // and make images smaller.  If sh_addr is not aligned to sh_addralign \r
-          // then the section needs to preserve sh_addr MOD sh_addralign. \r
-          // Normally doing nothing here works great.\r
-          Error (NULL, 0, 3000, "Invalid", "Unsupported section alignment.");\r
-        }\r
-      }\r
-      CoffSectionsOffset[i] = CoffOffset;\r
-      CoffOffset += shdr->sh_size;\r
-    }\r
-  }\r
-  CoffOffset = CoffAlign(CoffOffset);\r
-\r
-  //\r
-  //  The HII resource sections.\r
-  //\r
-  HiiRsrcOffset = CoffOffset;\r
-  for (i = 0; i < Ehdr->e_shnum; i++) {\r
-    Elf_Shdr *shdr = GetShdrByIndex(i);\r
-    if (IsHiiRsrcShdr(shdr)) {\r
-      if ((shdr->sh_addralign != 0) && (shdr->sh_addralign != 1)) {\r
-        // the alignment field is valid\r
-        if ((shdr->sh_addr & (shdr->sh_addralign - 1)) == 0) {\r
-          // if the section address is aligned we must align PE/COFF \r
-          CoffOffset = (CoffOffset + shdr->sh_addralign - 1) & ~(shdr->sh_addralign - 1);\r
-        } else if ((shdr->sh_addr % shdr->sh_addralign) != (CoffOffset % shdr->sh_addralign)) {\r
-          // ARM RVCT tools have behavior outside of the ELF specification to try \r
-          // and make images smaller.  If sh_addr is not aligned to sh_addralign \r
-          // then the section needs to preserve sh_addr MOD sh_addralign. \r
-          // Normally doing nothing here works great.\r
-          Error (NULL, 0, 3000, "Invalid", "Unsupported section alignment.");\r
-        }\r
-      }\r
-      if (shdr->sh_size != 0) {\r
-        CoffSectionsOffset[i] = CoffOffset;\r
-        CoffOffset += shdr->sh_size;\r
-        CoffOffset = CoffAlign(CoffOffset);\r
-        SetHiiResourceHeader ((UINT8*) Ehdr + shdr->sh_offset, HiiRsrcOffset);\r
-      }\r
-      break;\r
-    }\r
-  }\r
-\r
-  RelocOffset = CoffOffset;\r
-\r
-  //\r
-  // Allocate base Coff file.  Will be expanded later for relocations.\r
-  //\r
-  CoffFile = (UINT8 *)malloc(CoffOffset);\r
-  memset(CoffFile, 0, CoffOffset);\r
-\r
-  //\r
-  // Fill headers.\r
-  //\r
-  DosHdr = (EFI_IMAGE_DOS_HEADER *)CoffFile;\r
-  DosHdr->e_magic = EFI_IMAGE_DOS_SIGNATURE;\r
-  DosHdr->e_lfanew = NtHdrOffset;\r
-\r
-  NtHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION*)(CoffFile + NtHdrOffset);\r
-\r
-  NtHdr->Pe32.Signature = EFI_IMAGE_NT_SIGNATURE;\r
-\r
-  switch (Ehdr->e_machine) {\r
-  case EM_386:\r
-    NtHdr->Pe32.FileHeader.Machine = EFI_IMAGE_MACHINE_IA32;\r
-    NtHdr->Pe32.OptionalHeader.Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;\r
-    break;\r
-  case EM_X86_64:\r
-    NtHdr->Pe32.FileHeader.Machine = EFI_IMAGE_MACHINE_X64;\r
-    NtHdr->Pe32.OptionalHeader.Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;\r
-    break;\r
-  case EM_IA_64:\r
-    NtHdr->Pe32.FileHeader.Machine = EFI_IMAGE_MACHINE_IPF;\r
-    NtHdr->Pe32.OptionalHeader.Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;\r
-    break;\r
-  case EM_ARM:\r
-    NtHdr->Pe32.FileHeader.Machine = EFI_IMAGE_MACHINE_ARMT;\r
-    NtHdr->Pe32.OptionalHeader.Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;\r
-    break;\r
-  default:\r
-    VerboseMsg ("%s unknown e_machine type. Assume IA-32", (UINTN)Ehdr->e_machine);\r
-    NtHdr->Pe32.FileHeader.Machine = EFI_IMAGE_MACHINE_IA32;\r
-    NtHdr->Pe32.OptionalHeader.Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;\r
-  }\r
-\r
-  NtHdr->Pe32.FileHeader.NumberOfSections = CoffNbrSections;\r
-  NtHdr->Pe32.FileHeader.TimeDateStamp = (UINT32) time(NULL);\r
-  mImageTimeStamp = NtHdr->Pe32.FileHeader.TimeDateStamp;\r
-  NtHdr->Pe32.FileHeader.PointerToSymbolTable = 0;\r
-  NtHdr->Pe32.FileHeader.NumberOfSymbols = 0;\r
-  NtHdr->Pe32.FileHeader.SizeOfOptionalHeader = sizeof(NtHdr->Pe32.OptionalHeader);\r
-  NtHdr->Pe32.FileHeader.Characteristics = EFI_IMAGE_FILE_EXECUTABLE_IMAGE\r
-    | EFI_IMAGE_FILE_LINE_NUMS_STRIPPED\r
-    | EFI_IMAGE_FILE_LOCAL_SYMS_STRIPPED\r
-    | EFI_IMAGE_FILE_32BIT_MACHINE;\r
-\r
-  NtHdr->Pe32.OptionalHeader.SizeOfCode = DataOffset - TextOffset;\r
-  NtHdr->Pe32.OptionalHeader.SizeOfInitializedData = RelocOffset - DataOffset;\r
-  NtHdr->Pe32.OptionalHeader.SizeOfUninitializedData = 0;\r
-  NtHdr->Pe32.OptionalHeader.AddressOfEntryPoint = CoffEntry;\r
-\r
-  NtHdr->Pe32.OptionalHeader.BaseOfCode = TextOffset;\r
-\r
-  NtHdr->Pe32.OptionalHeader.BaseOfData = DataOffset;\r
-  NtHdr->Pe32.OptionalHeader.ImageBase = 0;\r
-  NtHdr->Pe32.OptionalHeader.SectionAlignment = CoffAlignment;\r
-  NtHdr->Pe32.OptionalHeader.FileAlignment = CoffAlignment;\r
-  NtHdr->Pe32.OptionalHeader.SizeOfImage = 0;\r
-\r
-  NtHdr->Pe32.OptionalHeader.SizeOfHeaders = TextOffset;\r
-  NtHdr->Pe32.OptionalHeader.NumberOfRvaAndSizes = EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES;\r
-\r
-  //\r
-  // Section headers.\r
-  //\r
-  if ((DataOffset - TextOffset) > 0) {\r
-    CreateSectionHeader (".text", TextOffset, DataOffset - TextOffset,\r
-            EFI_IMAGE_SCN_CNT_CODE\r
-            | EFI_IMAGE_SCN_MEM_EXECUTE\r
-            | EFI_IMAGE_SCN_MEM_READ);\r
-  } else {\r
-    // Don't make a section of size 0. \r
-    NtHdr->Pe32.FileHeader.NumberOfSections--;\r
-  }\r
-\r
-  if ((HiiRsrcOffset - DataOffset) > 0) {\r
-    CreateSectionHeader (".data", DataOffset, HiiRsrcOffset - DataOffset,\r
-            EFI_IMAGE_SCN_CNT_INITIALIZED_DATA\r
-            | EFI_IMAGE_SCN_MEM_WRITE\r
-            | EFI_IMAGE_SCN_MEM_READ);\r
-  } else {\r
-    // Don't make a section of size 0. \r
-    NtHdr->Pe32.FileHeader.NumberOfSections--;\r
-  }\r
-\r
-  if ((RelocOffset - HiiRsrcOffset) > 0) {\r
-    CreateSectionHeader (".rsrc", HiiRsrcOffset, RelocOffset - HiiRsrcOffset,\r
-            EFI_IMAGE_SCN_CNT_INITIALIZED_DATA\r
-            | EFI_IMAGE_SCN_MEM_READ);\r
-\r
-    NtHdr->Pe32.OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_RESOURCE].Size = RelocOffset - HiiRsrcOffset;\r
-    NtHdr->Pe32.OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_RESOURCE].VirtualAddress = HiiRsrcOffset;\r
-  } else {\r
-    // Don't make a section of size 0. \r
-    NtHdr->Pe32.FileHeader.NumberOfSections--;\r
-  }\r
-\r
-}\r
-\r
-VOID\r
-WriteSections(\r
-  int   (*Filter)(Elf_Shdr *)\r
-  )\r
-{\r
-  UINT32      Idx;\r
-  Elf_Shdr  *SecShdr;\r
-  UINT32      SecOffset;\r
-\r
-  //\r
-  // First: copy sections.\r
-  //\r
-  for (Idx = 0; Idx < Ehdr->e_shnum; Idx++) {\r
-    Elf_Shdr *Shdr = GetShdrByIndex(Idx);\r
-    if ((*Filter)(Shdr)) {\r
-      switch (Shdr->sh_type) {\r
-      case SHT_PROGBITS:\r
-        /* Copy.  */\r
-        memcpy(CoffFile + CoffSectionsOffset[Idx],\r
-              (UINT8*)Ehdr + Shdr->sh_offset,\r
-              Shdr->sh_size);\r
-        break;\r
-      \r
-      case SHT_NOBITS:\r
-        memset(CoffFile + CoffSectionsOffset[Idx], 0, Shdr->sh_size);\r
-        break;\r
-      \r
-      default:\r
-        //\r
-        //  Ignore for unkown section type.\r
-        //\r
-        VerboseMsg ("%s unknown section type %x. We directly copy this section into Coff file", mInImageName, (unsigned)Shdr->sh_type);\r
-        break;\r
-      }\r
-    }\r
-  }\r
-\r
-  //\r
-  // Second: apply relocations.\r
-  //\r
-  for (Idx = 0; Idx < Ehdr->e_shnum; Idx++) {\r
-    Elf_Shdr *RelShdr = GetShdrByIndex(Idx);\r
-    if (RelShdr->sh_type != SHT_REL)\r
-      continue;\r
-    SecShdr = GetShdrByIndex(RelShdr->sh_info);\r
-    SecOffset = CoffSectionsOffset[RelShdr->sh_info];\r
-    if (RelShdr->sh_type == SHT_REL && (*Filter)(SecShdr)) {\r
-      UINT32 RelIdx;\r
-      Elf_Shdr *SymtabShdr = GetShdrByIndex(RelShdr->sh_link);\r
-      UINT8 *Symtab = (UINT8*)Ehdr + SymtabShdr->sh_offset;\r
-\r
-      for (RelIdx = 0; RelIdx < RelShdr->sh_size; RelIdx += RelShdr->sh_entsize) {\r
-        Elf_Rel *Rel = (Elf_Rel *)((UINT8*)Ehdr + RelShdr->sh_offset + RelIdx);\r
-        Elf_Sym *Sym = (Elf_Sym *)(Symtab + ELF_R_SYM(Rel->r_info) * SymtabShdr->sh_entsize);\r
-        Elf_Shdr *SymShdr;\r
-        UINT8 *Targ;\r
-\r
-        if (Sym->st_shndx == SHN_UNDEF\r
-            || Sym->st_shndx == SHN_ABS\r
-            || Sym->st_shndx > Ehdr->e_shnum) {\r
-          Error (NULL, 0, 3000, "Invalid", "%s bad symbol definition.", mInImageName);\r
-        }\r
-        SymShdr = GetShdrByIndex(Sym->st_shndx);\r
-\r
-        //\r
-        // Note: r_offset in a memory address.\r
-        //  Convert it to a pointer in the coff file.\r
-        //\r
-        Targ = CoffFile + SecOffset + (Rel->r_offset - SecShdr->sh_addr);\r
-\r
-        if (Ehdr->e_machine == EM_386) {\r
-          switch (ELF_R_TYPE(Rel->r_info)) {\r
-          case R_386_NONE:\r
-            break;\r
-          case R_386_32:\r
-            //\r
-            // Absolute relocation.\r
-            //\r
-            *(UINT32 *)Targ = *(UINT32 *)Targ - SymShdr->sh_addr\r
-              + CoffSectionsOffset[Sym->st_shndx];\r
-            break;\r
-          case R_386_PC32:\r
-            //\r
-            // Relative relocation: Symbol - Ip + Addend\r
-            //\r
-            *(UINT32 *)Targ = *(UINT32 *)Targ\r
-              + (CoffSectionsOffset[Sym->st_shndx] - SymShdr->sh_addr)\r
-              - (SecOffset - SecShdr->sh_addr);\r
-            break;\r
-          default:\r
-            Error (NULL, 0, 3000, "Invalid", "%s unsupported ELF EM_386 relocation 0x%x.", mInImageName, (unsigned) ELF_R_TYPE(Rel->r_info));\r
-          }\r
-        } else if (Ehdr->e_machine == EM_ARM) {\r
-          switch (ELF32_R_TYPE(Rel->r_info)) {\r
-          case R_ARM_RBASE:   // No relocation - no action required\r
-          \r
-          // Thease are all PC-relative relocations and don't require modification\r
-          case R_ARM_PC24:    \r
-          case R_ARM_XPC25:   \r
-          case R_ARM_THM_PC22:\r
-          case R_ARM_THM_JUMP19:\r
-          case R_ARM_CALL:\r
-            break;\r
-\r
-          case R_ARM_ABS32:\r
-          case R_ARM_RABS32:\r
-            //\r
-            // Absolute relocation.\r
-            //\r
-            *(UINT32 *)Targ = *(UINT32 *)Targ - SymShdr->sh_addr + CoffSectionsOffset[Sym->st_shndx];\r
-            break;\r
-          default:\r
-            Error (NULL, 0, 3000, "Invalid", "WriteSections (): %s unsupported ELF EM_ARM relocation 0x%x.", mInImageName, (unsigned) ELF32_R_TYPE(Rel->r_info));\r
-          }\r
-        }\r
-      }\r
-    }\r
-  }\r
-}\r
-\r
-VOID\r
-CoffAddFixupEntry(\r
-  UINT16 Val\r
-  )\r
-{\r
-  *CoffEntryRel = Val;\r
-  CoffEntryRel++;\r
-  CoffBaseRel->SizeOfBlock += 2;\r
-  CoffOffset += 2;\r
-}\r
-\r
-VOID\r
-CoffAddFixup(\r
-  UINT32 Offset,\r
-  UINT8  Type\r
-  )\r
-{\r
-  if (CoffBaseRel == NULL\r
-      || CoffBaseRel->VirtualAddress != (Offset & ~0xfff)) {\r
-    if (CoffBaseRel != NULL) {\r
-      //\r
-      // Add a null entry (is it required ?)\r
-      //\r
-      CoffAddFixupEntry (0);\r
-      //\r
-      // Pad for alignment.\r
-      //\r
-      if (CoffOffset % 4 != 0)\r
-        CoffAddFixupEntry (0);\r
-    }\r
-\r
-    CoffFile = realloc\r
-      (CoffFile,\r
-       CoffOffset + sizeof(EFI_IMAGE_BASE_RELOCATION) + 2*0x1000);\r
-    memset(CoffFile + CoffOffset, 0,\r
-     sizeof(EFI_IMAGE_BASE_RELOCATION) + 2*0x1000);\r
-\r
-    CoffBaseRel = (EFI_IMAGE_BASE_RELOCATION*)(CoffFile + CoffOffset);\r
-    CoffBaseRel->VirtualAddress = Offset & ~0xfff;\r
-    CoffBaseRel->SizeOfBlock = sizeof(EFI_IMAGE_BASE_RELOCATION);\r
-\r
-    CoffEntryRel = (UINT16 *)(CoffBaseRel + 1);\r
-    CoffOffset += sizeof(EFI_IMAGE_BASE_RELOCATION);\r
-  }\r
-\r
-  //\r
-  // Fill the entry.\r
-  //\r
-  CoffAddFixupEntry((UINT16) ((Type << 12) | (Offset & 0xfff)));\r
-}\r
-\r
-\r
-Elf_Phdr *\r
-GetPhdrByIndex (\r
-  UINT32 num\r
-  )\r
-{\r
-  if (num >= Ehdr->e_phnum) {\r
-    return NULL;\r
-  }\r
-  \r
-  return (Elf32_Phdr *)((UINT8*)gPhdrBase + num * Ehdr->e_phentsize);\r
-}\r
-\r
-\r
-VOID\r
-WriteRelocations (\r
-  VOID\r
-  )\r
-{\r
-  UINT32                           Index;\r
-  EFI_IMAGE_OPTIONAL_HEADER_UNION  *NtHdr;\r
-  EFI_IMAGE_DATA_DIRECTORY         *Dir;\r
-  BOOLEAN                          FoundRelocations;\r
-  Elf_Dyn                          *Dyn;\r
-  Elf_Rel                          *Rel;\r
-  UINTN                            RelElementSize;\r
-  UINTN                            RelSize;\r
-  UINTN                            RelOffset;\r
-  UINTN                            K;\r
-  UINT8                            *Targ;\r
-  Elf32_Phdr                       *DynamicSegment;\r
-  Elf32_Phdr                       *TargetSegment;\r
-\r
-  for (Index = 0, FoundRelocations = FALSE; Index < Ehdr->e_shnum; Index++) {\r
-    Elf_Shdr *RelShdr = GetShdrByIndex(Index);\r
-    if (RelShdr->sh_type == SHT_REL) {\r
-      Elf_Shdr *SecShdr = GetShdrByIndex(RelShdr->sh_info);\r
-      if (IsTextShdr(SecShdr) || IsDataShdr(SecShdr)) {\r
-        UINT32 RelIdx;\r
-        FoundRelocations = TRUE;\r
-        for (RelIdx = 0; RelIdx < RelShdr->sh_size; RelIdx += RelShdr->sh_entsize) {\r
-          Elf_Rel *Rel = (Elf_Rel *)\r
-            ((UINT8*)Ehdr + RelShdr->sh_offset + RelIdx);\r
-          \r
-          if (Ehdr->e_machine == EM_386) { \r
-            switch (ELF_R_TYPE(Rel->r_info)) {\r
-            case R_386_NONE:\r
-            case R_386_PC32:\r
-              break;\r
-            case R_386_32:\r
-              CoffAddFixup(CoffSectionsOffset[RelShdr->sh_info]\r
-              + (Rel->r_offset - SecShdr->sh_addr),\r
-              EFI_IMAGE_REL_BASED_HIGHLOW);\r
-              break;\r
-            default:\r
-              Error (NULL, 0, 3000, "Invalid", "%s unsupported ELF EM_386 relocation 0x%x.", mInImageName, (unsigned) ELF_R_TYPE(Rel->r_info));\r
-            }\r
-          } else if (Ehdr->e_machine == EM_ARM) {\r
-            switch (ELF32_R_TYPE(Rel->r_info)) {\r
-            case R_ARM_RBASE: // No relocation - no action required\r
-          \r
-            // Thease are all PC-relative relocations and don't require modification\r
-            case R_ARM_PC24:\r
-            case R_ARM_XPC25:\r
-            case R_ARM_THM_PC22:\r
-            case R_ARM_THM_JUMP19:\r
-            case R_ARM_CALL:\r
-              break;\r
-            case R_ARM_ABS32:\r
-            case R_ARM_RABS32:\r
-              CoffAddFixup (\r
-                CoffSectionsOffset[RelShdr->sh_info]\r
-                + (Rel->r_offset - SecShdr->sh_addr),\r
-                EFI_IMAGE_REL_BASED_HIGHLOW\r
-                );\r
-              break;\r
-\r
-           default:\r
-              Error (NULL, 0, 3000, "Invalid", "WriteRelocations(): %s unsupported ELF EM_ARM relocation 0x%x.", mInImageName, (unsigned) ELF32_R_TYPE(Rel->r_info));\r
-            }\r
-          } else {\r
-            Error (NULL, 0, 3000, "Not Supported", "This tool does not support relocations for ELF with e_machine %u (processor type).", (unsigned) Ehdr->e_machine);\r
-          }\r
-        }\r
-      }\r
-    }\r
-  }\r
-\r
-  if (!FoundRelocations && (Ehdr->e_machine == EM_ARM)) {\r
-    /* Try again, but look for PT_DYNAMIC instead of SHT_REL */\r
-\r
-    for (Index = 0; Index < Ehdr->e_phnum; Index++) {\r
-      RelElementSize = 0;\r
-      RelSize = 0;\r
-      RelOffset = 0;\r
-\r
-      DynamicSegment = GetPhdrByIndex (Index);\r
-\r
-      if (DynamicSegment->p_type == PT_DYNAMIC) {\r
-        Dyn = (Elf32_Dyn *) ((UINT8 *)Ehdr + DynamicSegment->p_offset);\r
-\r
-        while (Dyn->d_tag != DT_NULL) {\r
-          switch (Dyn->d_tag) {\r
-            case  DT_REL:\r
-              RelOffset = Dyn->d_un.d_val;\r
-              break;\r
-\r
-            case  DT_RELSZ:\r
-              RelSize = Dyn->d_un.d_val;\r
-              break;\r
-\r
-            case  DT_RELENT:\r
-              RelElementSize = Dyn->d_un.d_val;\r
-              break;\r
-\r
-            default:\r
-              break;\r
-          }\r
-          Dyn++;\r
-        }\r
-        if (( RelOffset == 0 ) || ( RelSize == 0 ) || ( RelElementSize == 0 )) {\r
-          Error (NULL, 0, 3000, "Invalid", "%s bad ARM dynamic relocations.", mInImageName);\r
-        }\r
-\r
-        for (K = 0; K < RelSize; K += RelElementSize) {\r
-\r
-          if (DynamicSegment->p_paddr == 0) {\r
-            // This seems to be how it works on armcc???? Have the email in to find out?\r
-            Rel = (Elf32_Rel *) ((UINT8 *) Ehdr + DynamicSegment->p_offset + RelOffset + K);\r
-          } else {\r
-            // This is how it reads in the ELF specification\r
-            Rel = (Elf32_Rel *) ((UINT8 *) Ehdr + RelOffset + K);\r
-          }\r
-\r
-          switch (ELF32_R_TYPE (Rel->r_info)) {\r
-          case  R_ARM_RBASE:\r
-            break;\r
-          case  R_ARM_RABS32:\r
-            TargetSegment = GetPhdrByIndex (ELF32_R_SYM (Rel->r_info) - 1);\r
-\r
-            // Note: r_offset in a memory address.  Convert it to a pointer in the coff file.\r
-            Targ = CoffFile + CoffSectionsOffset[ ELF32_R_SYM( Rel->r_info ) ] + Rel->r_offset - TargetSegment->p_vaddr;\r
-\r
-            *(UINT32 *)Targ = *(UINT32 *)Targ + CoffSectionsOffset [ELF32_R_SYM( Rel->r_info )];\r
-\r
-            CoffAddFixup (CoffSectionsOffset[ELF32_R_SYM (Rel->r_info)] + (Rel->r_offset - TargetSegment->p_vaddr), EFI_IMAGE_REL_BASED_HIGHLOW);\r
-            break;\r
-          default:\r
-            Error (NULL, 0, 3000, "Invalid", "%s bad ARM dynamic relocations, unkown type %d.", mInImageName, ELF32_R_TYPE (Rel->r_info));\r
-            break;\r
-          }\r
-        }\r
-        break;\r
-      }\r
-    }\r
-  }\r
-\r
-  //\r
-  // Pad by adding empty entries.\r
-  //\r
-  while (CoffOffset & (CoffAlignment - 1)) {\r
-    CoffAddFixupEntry(0);\r
-  }\r
-\r
-\r
-  NtHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION *)(CoffFile + NtHdrOffset);\r
-  Dir = &NtHdr->Pe32.OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC];\r
-  Dir->Size = CoffOffset - RelocOffset;\r
-  if (Dir->Size == 0) {\r
-    // If no relocations, null out the directory entry and don't add the .reloc section\r
-    Dir->VirtualAddress = 0;\r
-    NtHdr->Pe32.FileHeader.NumberOfSections--;\r
-  } else {\r
-    Dir->VirtualAddress = RelocOffset;\r
-    CreateSectionHeader (".reloc", RelocOffset, CoffOffset - RelocOffset,\r
-            EFI_IMAGE_SCN_CNT_INITIALIZED_DATA\r
-            | EFI_IMAGE_SCN_MEM_DISCARDABLE\r
-            | EFI_IMAGE_SCN_MEM_READ);\r
-  }\r
-\r
-}\r
-\r
-VOID\r
-WriteDebug(\r
-  VOID\r
-  )\r
-{\r
-  UINT32                              Len;\r
-  UINT32                              DebugOffset;\r
-  EFI_IMAGE_OPTIONAL_HEADER_UNION     *NtHdr;\r
-  EFI_IMAGE_DATA_DIRECTORY            *DataDir;\r
-  EFI_IMAGE_DEBUG_DIRECTORY_ENTRY     *Dir;\r
-  EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY *Nb10;\r
-\r
-  Len = strlen(mInImageName) + 1;\r
-  DebugOffset = CoffOffset;\r
-\r
-  CoffOffset += sizeof(EFI_IMAGE_DEBUG_DIRECTORY_ENTRY)\r
-    + sizeof(EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY)\r
-    + Len;\r
-  CoffOffset = CoffAlign(CoffOffset);\r
-\r
-  CoffFile = realloc(CoffFile, CoffOffset);\r
-  memset(CoffFile + DebugOffset, 0, CoffOffset - DebugOffset);\r
-\r
-  Dir = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY*)(CoffFile + DebugOffset);\r
-  Dir->Type = EFI_IMAGE_DEBUG_TYPE_CODEVIEW;\r
-  Dir->SizeOfData = sizeof(EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY) + Len;\r
-  Dir->RVA = DebugOffset + sizeof(EFI_IMAGE_DEBUG_DIRECTORY_ENTRY);\r
-  Dir->FileOffset = DebugOffset + sizeof(EFI_IMAGE_DEBUG_DIRECTORY_ENTRY);\r
-\r
-  Nb10 = (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY*)(Dir + 1);\r
-  Nb10->Signature = CODEVIEW_SIGNATURE_NB10;\r
-  strcpy ((char *)(Nb10 + 1), mInImageName);\r
-\r
-\r
-  NtHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION *)(CoffFile + NtHdrOffset);\r
-  DataDir = &NtHdr->Pe32.OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG];\r
-  DataDir->VirtualAddress = DebugOffset;\r
-  DataDir->Size = CoffOffset - DebugOffset;\r
-  if (DataDir->Size == 0) {\r
-    // If no debug, null out the directory entry and don't add the .debug section\r
-    DataDir->VirtualAddress = 0;\r
-    NtHdr->Pe32.FileHeader.NumberOfSections--;\r
-  } else {\r
-    DataDir->VirtualAddress = DebugOffset;\r
-    CreateSectionHeader (".debug", DebugOffset, CoffOffset - DebugOffset,\r
-            EFI_IMAGE_SCN_CNT_INITIALIZED_DATA\r
-            | EFI_IMAGE_SCN_MEM_DISCARDABLE\r
-            | EFI_IMAGE_SCN_MEM_READ);\r
-\r
-  }\r
-}\r
-\r
-VOID\r
-ConvertElf (\r
-  UINT8  **FileBuffer,\r
-  UINT32 *FileLength\r
-  )\r
-{\r
-  EFI_IMAGE_OPTIONAL_HEADER_UNION *NtHdr;\r
-\r
-  //\r
-  // Check header, read section table.\r
-  //\r
-  Ehdr = (Elf32_Ehdr*)*FileBuffer;\r
-  if (!CheckElfHeader())\r
-    return;\r
-\r
-  VerboseMsg ("Check Efl Image Header");\r
-  //\r
-  // Compute sections new address.\r
-  //\r
-  \r
-  ScanSections();\r
-\r
-  VerboseMsg ("Compute sections new address.");\r
-\r
-  //\r
-  // Write and relocate sections.\r
-  //\r
-  WriteSections(IsTextShdr);\r
-  WriteSections(IsDataShdr);\r
-  WriteSections(IsHiiRsrcShdr);\r
-  VerboseMsg ("Write and relocate sections.");\r
-\r
-  //\r
-  // Translate and write relocations.\r
-  //\r
-  WriteRelocations();\r
-  VerboseMsg ("Translate and write relocations.");\r
-\r
-  //\r
-  // Write debug info.\r
-  //\r
-  WriteDebug();\r
-  VerboseMsg ("Write debug info.");\r
-\r
-  NtHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION *)(CoffFile + NtHdrOffset);\r
-  NtHdr->Pe32.OptionalHeader.SizeOfImage = CoffOffset;\r
-\r
-  //\r
-  // Replace.\r
-  //\r
-  free(*FileBuffer);\r
-  *FileBuffer = CoffFile;\r
-  *FileLength = CoffOffset;\r
-\r
-  //\r
-  // Free memory space\r
-  //\r
-  if (CoffSectionsOffset != NULL) {\r
-    free (CoffSectionsOffset);\r
-  }\r
-}\r
-\r
-\r
 EFI_IMAGE_OPTIONAL_HEADER_UNION *\r
 GetPeCoffHeader (\r
   void *Data\r
@@ -2935,8 +2050,11 @@ Returns:
   // Convert EFL image to PeImage\r
   //\r
   if (IsElfHeader(FileBuffer)) {\r
-    VerboseMsg ("Convert the input ELF Image to Pe Image");\r
-    ConvertElf(&FileBuffer, &FileLength);\r
+    VerboseMsg ("Convert %s from ELF to PE/COFF.", mInImageName);\r
+    if (!ConvertElf(&FileBuffer, &FileLength)) {\r
+      Error (NULL, 0, 3000, "Invalid", "Unable to convert %s from ELF to PE/COFF.", mInImageName);\r
+      goto Finish;\r
+    }\r
   }\r
 \r
   //\r
diff --git a/BaseTools/Source/C/GenFw/GenFw.h b/BaseTools/Source/C/GenFw/GenFw.h
new file mode 100644 (file)
index 0000000..11b3aa9
--- /dev/null
@@ -0,0 +1,35 @@