mirror of https://github.com/acidanthera/audk.git
BaseTools: Replaced GenFw with ImageTool and MicroTool.
This commit is contained in:
parent
a955e8811b
commit
7b10859b36
|
@ -16,7 +16,7 @@
|
||||||
[submodule "BaseTools/Source/C/BrotliCompress/brotli"]
|
[submodule "BaseTools/Source/C/BrotliCompress/brotli"]
|
||||||
path = BaseTools/Source/C/BrotliCompress/brotli
|
path = BaseTools/Source/C/BrotliCompress/brotli
|
||||||
url = https://github.com/google/brotli
|
url = https://github.com/google/brotli
|
||||||
ignore = untracked
|
ignore = untracked
|
||||||
[submodule "RedfishPkg/Library/JsonLib/jansson"]
|
[submodule "RedfishPkg/Library/JsonLib/jansson"]
|
||||||
path = RedfishPkg/Library/JsonLib/jansson
|
path = RedfishPkg/Library/JsonLib/jansson
|
||||||
url = https://github.com/akheron/jansson
|
url = https://github.com/akheron/jansson
|
||||||
|
@ -26,15 +26,18 @@
|
||||||
[submodule "UnitTestFrameworkPkg/Library/SubhookLib/subhook"]
|
[submodule "UnitTestFrameworkPkg/Library/SubhookLib/subhook"]
|
||||||
path = UnitTestFrameworkPkg/Library/SubhookLib/subhook
|
path = UnitTestFrameworkPkg/Library/SubhookLib/subhook
|
||||||
url = https://github.com/Zeex/subhook.git
|
url = https://github.com/Zeex/subhook.git
|
||||||
[submodule "MdePkg/Library/BaseFdtLib/libfdt"]
|
[submodule "MdePkg/Library/BaseFdtLib/libfdt"]
|
||||||
path = MdePkg/Library/BaseFdtLib/libfdt
|
path = MdePkg/Library/BaseFdtLib/libfdt
|
||||||
url = https://github.com/devicetree-org/pylibfdt.git
|
url = https://github.com/devicetree-org/pylibfdt.git
|
||||||
[submodule "MdePkg/Library/MipiSysTLib/mipisyst"]
|
[submodule "MdePkg/Library/MipiSysTLib/mipisyst"]
|
||||||
path = MdePkg/Library/MipiSysTLib/mipisyst
|
path = MdePkg/Library/MipiSysTLib/mipisyst
|
||||||
url = https://github.com/MIPI-Alliance/public-mipi-sys-t.git
|
url = https://github.com/MIPI-Alliance/public-mipi-sys-t.git
|
||||||
[submodule "CryptoPkg/Library/MbedTlsLib/mbedtls"]
|
[submodule "CryptoPkg/Library/MbedTlsLib/mbedtls"]
|
||||||
path = CryptoPkg/Library/MbedTlsLib/mbedtls
|
path = CryptoPkg/Library/MbedTlsLib/mbedtls
|
||||||
url = https://github.com/ARMmbed/mbedtls
|
url = https://github.com/ARMmbed/mbedtls
|
||||||
[submodule "SecurityPkg/DeviceSecurity/SpdmLib/libspdm"]
|
[submodule "SecurityPkg/DeviceSecurity/SpdmLib/libspdm"]
|
||||||
path = SecurityPkg/DeviceSecurity/SpdmLib/libspdm
|
path = SecurityPkg/DeviceSecurity/SpdmLib/libspdm
|
||||||
url = https://github.com/DMTF/libspdm.git
|
url = https://github.com/DMTF/libspdm.git
|
||||||
|
[submodule "OpenCorePkg"]
|
||||||
|
path = OpenCorePkg
|
||||||
|
url = https://github.com/acidanthera/OpenCorePkg.git
|
||||||
|
|
|
@ -106,7 +106,6 @@
|
||||||
"Trustzone",
|
"Trustzone",
|
||||||
"Fastboot",
|
"Fastboot",
|
||||||
"framebuffer",
|
"framebuffer",
|
||||||
"genfw",
|
|
||||||
"TTYTERM",
|
"TTYTERM",
|
||||||
"miniport",
|
"miniport",
|
||||||
"LFENCE",
|
"LFENCE",
|
||||||
|
|
|
@ -26,12 +26,9 @@
|
||||||
DEFINE FD_NUM_BLOCKS = 0x300
|
DEFINE FD_NUM_BLOCKS = 0x300
|
||||||
!endif
|
!endif
|
||||||
|
|
||||||
[BuildOptions.common.EDKII.DXE_CORE,BuildOptions.common.EDKII.DXE_DRIVER,BuildOptions.common.EDKII.UEFI_DRIVER,BuildOptions.common.EDKII.UEFI_APPLICATION]
|
|
||||||
GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
|
|
||||||
|
|
||||||
[BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
|
[BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
|
||||||
GCC:*_*_ARM_DLINK_FLAGS = -z common-page-size=0x1000
|
GCC:*_*_ARM_DLINK_FLAGS = -z max-page-size=0x1000
|
||||||
GCC:*_*_AARCH64_DLINK_FLAGS = -z common-page-size=0x10000
|
GCC:*_*_AARCH64_DLINK_FLAGS = -z max-page-size=0x10000
|
||||||
|
|
||||||
[LibraryClasses.common]
|
[LibraryClasses.common]
|
||||||
!if $(TARGET) == RELEASE
|
!if $(TARGET) == RELEASE
|
||||||
|
|
|
@ -18,4 +18,8 @@ Source/C/bin/
|
||||||
Source/C/libs/
|
Source/C/libs/
|
||||||
Bin/Win32
|
Bin/Win32
|
||||||
Lib
|
Lib
|
||||||
BaseToolsBuild/
|
BaseToolsBuild/
|
||||||
|
ImageTool/ImageTool
|
||||||
|
ImageTool/ImageTool32
|
||||||
|
ImageTool/ImageTool64
|
||||||
|
MicroTool/MicroTool
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Copyright (c) 2022, Mikhail Krichanov. All rights reserved.
|
||||||
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
#
|
||||||
|
full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here
|
||||||
|
dir=$(dirname "$full_cmd")
|
||||||
|
cmd=${full_cmd##*/}
|
||||||
|
|
||||||
|
if [ -n "$WORKSPACE" ] && [ -e "$EDK_TOOLS_PATH/ImageTool" ]
|
||||||
|
then
|
||||||
|
if [ ! -e "$EDK_TOOLS_PATH/ImageTool/ImageTool" ]
|
||||||
|
then
|
||||||
|
echo "BaseTools C Tool binary was not found (ImageTool)"
|
||||||
|
echo "You may need to run:"
|
||||||
|
echo " make -C $EDK_TOOLS_PATH/ImageTool"
|
||||||
|
else
|
||||||
|
exec "$EDK_TOOLS_PATH/ImageTool/ImageTool" "$@"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Unable to find the real '$cmd' to run"
|
||||||
|
echo "This message was printed by"
|
||||||
|
echo " $0"
|
||||||
|
exit 127
|
||||||
|
fi
|
|
@ -0,0 +1,25 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Copyright (c) 2022, Mikhail Krichanov. All rights reserved.
|
||||||
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
#
|
||||||
|
full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here
|
||||||
|
dir=$(dirname "$full_cmd")
|
||||||
|
cmd=${full_cmd##*/}
|
||||||
|
|
||||||
|
if [ -n "$WORKSPACE" ] && [ -e "$EDK_TOOLS_PATH/MicroTool" ]
|
||||||
|
then
|
||||||
|
if [ ! -e "$EDK_TOOLS_PATH/MicroTool/MicroTool" ]
|
||||||
|
then
|
||||||
|
echo "BaseTools C Tool binary was not found (MicroTool)"
|
||||||
|
echo "You may need to run:"
|
||||||
|
echo " make -C $EDK_TOOLS_PATH/MicroTool"
|
||||||
|
else
|
||||||
|
exec "$EDK_TOOLS_PATH/MicroTool/MicroTool" "$@"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Unable to find the real '$cmd' to run"
|
||||||
|
echo "This message was printed by"
|
||||||
|
echo " $0"
|
||||||
|
exit 127
|
||||||
|
fi
|
|
@ -0,0 +1,6 @@
|
||||||
|
::
|
||||||
|
:: Copyright (c) 2022, Mikhail Krichanov. All rights reserved.
|
||||||
|
:: SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
::
|
||||||
|
@echo off
|
||||||
|
call ImageTool.exe %*
|
|
@ -0,0 +1,6 @@
|
||||||
|
::
|
||||||
|
:: Copyright (c) 2022, Mikhail Krichanov. All rights reserved.
|
||||||
|
:: SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
::
|
||||||
|
@echo off
|
||||||
|
call MicroTool.exe %*
|
|
@ -272,7 +272,14 @@
|
||||||
<Command.GCC>
|
<Command.GCC>
|
||||||
$(RM) ${dst}
|
$(RM) ${dst}
|
||||||
"$(SLINK)" cr ${dst} $(SLINK_FLAGS) @$(OBJECT_FILES_LIST)
|
"$(SLINK)" cr ${dst} $(SLINK_FLAGS) @$(OBJECT_FILES_LIST)
|
||||||
|
|
||||||
|
<Command.RVCT>
|
||||||
|
"$(SLINK)" $(SLINK_FLAGS) ${dst} --via $(OBJECT_FILES_LIST)
|
||||||
|
|
||||||
|
<Command.RVCTCYGWIN>
|
||||||
|
# $(OBJECT_FILES_LIST) has wrong paths for cygwin
|
||||||
|
"$(SLINK)" $(SLINK_FLAGS) ${dst} $(OBJECT_FILES)
|
||||||
|
|
||||||
<Command.XCODE>
|
<Command.XCODE>
|
||||||
"$(SLINK)" $(SLINK_FLAGS) ${dst} -filelist $(OBJECT_FILES_LIST)
|
"$(SLINK)" $(SLINK_FLAGS) ${dst} -filelist $(OBJECT_FILES_LIST)
|
||||||
|
|
||||||
|
@ -295,12 +302,11 @@
|
||||||
|
|
||||||
<Command.GCC>
|
<Command.GCC>
|
||||||
"$(DLINK)" -o ${dst} $(DLINK_FLAGS) -Wl,--start-group,@$(STATIC_LIBRARY_FILES_LIST),--end-group $(CC_FLAGS) $(DLINK2_FLAGS)
|
"$(DLINK)" -o ${dst} $(DLINK_FLAGS) -Wl,--start-group,@$(STATIC_LIBRARY_FILES_LIST),--end-group $(CC_FLAGS) $(DLINK2_FLAGS)
|
||||||
"$(OBJCOPY)" $(OBJCOPY_FLAGS) ${dst}
|
|
||||||
|
|
||||||
<Command.XCODE>
|
<Command.XCODE>
|
||||||
"$(DLINK)" $(DLINK_FLAGS) -o ${dst} $(DLINK_SPATH) -filelist $(STATIC_LIBRARY_FILES_LIST) $(DLINK2_FLAGS)
|
"$(DLINK)" $(DLINK_FLAGS) -o ${dst} $(DLINK_SPATH) -filelist $(STATIC_LIBRARY_FILES_LIST) $(DLINK2_FLAGS)
|
||||||
|
|
||||||
|
|
||||||
[Static-Library-File.SEC.AARCH64, Static-Library-File.PEI_CORE.AARCH64, Static-Library-File.PEIM.AARCH64,Static-Library-File.SEC.ARM, Static-Library-File.PEI_CORE.ARM, Static-Library-File.PEIM.ARM]
|
[Static-Library-File.SEC.AARCH64, Static-Library-File.PEI_CORE.AARCH64, Static-Library-File.PEIM.AARCH64,Static-Library-File.SEC.ARM, Static-Library-File.PEI_CORE.ARM, Static-Library-File.PEIM.ARM]
|
||||||
<InputFile>
|
<InputFile>
|
||||||
*.lib
|
*.lib
|
||||||
|
@ -313,8 +319,6 @@
|
||||||
|
|
||||||
<Command.GCC>
|
<Command.GCC>
|
||||||
"$(DLINK)" -o ${dst} $(DLINK_FLAGS) $(DLINK_XIPFLAGS) -Wl,--start-group,@$(STATIC_LIBRARY_FILES_LIST),--end-group $(CC_FLAGS) $(CC_XIPFLAGS) $(DLINK2_FLAGS)
|
"$(DLINK)" -o ${dst} $(DLINK_FLAGS) $(DLINK_XIPFLAGS) -Wl,--start-group,@$(STATIC_LIBRARY_FILES_LIST),--end-group $(CC_FLAGS) $(CC_XIPFLAGS) $(DLINK2_FLAGS)
|
||||||
"$(OBJCOPY)" $(OBJCOPY_FLAGS) ${dst}
|
|
||||||
|
|
||||||
|
|
||||||
[Static-Library-File.USER_DEFINED, Static-Library-File.HOST_APPLICATION]
|
[Static-Library-File.USER_DEFINED, Static-Library-File.HOST_APPLICATION]
|
||||||
<InputFile>
|
<InputFile>
|
||||||
|
@ -334,8 +338,8 @@
|
||||||
|
|
||||||
<Command.XCODE>
|
<Command.XCODE>
|
||||||
"$(DLINK)" -o ${dst} $(DLINK_FLAGS) $(DLINK_SPATH) -filelist $(STATIC_LIBRARY_FILES_LIST) $(DLINK2_FLAGS)
|
"$(DLINK)" -o ${dst} $(DLINK_FLAGS) $(DLINK_SPATH) -filelist $(STATIC_LIBRARY_FILES_LIST) $(DLINK2_FLAGS)
|
||||||
|
|
||||||
|
|
||||||
[Dynamic-Library-File]
|
[Dynamic-Library-File]
|
||||||
<InputFile>
|
<InputFile>
|
||||||
?.dll
|
?.dll
|
||||||
|
@ -345,32 +349,67 @@
|
||||||
$(OUTPUT_DIR)(+)$(MODULE_NAME).map
|
$(OUTPUT_DIR)(+)$(MODULE_NAME).map
|
||||||
|
|
||||||
<Command.MSFT, Command.INTEL, Command.CLANGPDB>
|
<Command.MSFT, Command.INTEL, Command.CLANGPDB>
|
||||||
"$(GENFW)" -e $(MODULE_TYPE) -o ${dst} ${src} $(GENFW_FLAGS)
|
ImageTool GenImage -c PE -t $(MODULE_TYPE) -o ${dst} ${src}
|
||||||
$(CP) ${dst} $(DEBUG_DIR)
|
$(CP) ${dst} $(DEBUG_DIR)
|
||||||
$(CP) ${dst} $(BIN_DIR)(+)$(MODULE_NAME_GUID).efi
|
$(CP) ${dst} $(BIN_DIR)(+)$(MODULE_NAME_GUID).efi
|
||||||
-$(CP) $(DEBUG_DIR)(+)*.map $(OUTPUT_DIR)
|
-$(CP) $(DEBUG_DIR)(+)*.map $(OUTPUT_DIR)
|
||||||
-$(CP) $(DEBUG_DIR)(+)*.pdb $(OUTPUT_DIR)
|
-$(CP) $(DEBUG_DIR)(+)*.pdb $(OUTPUT_DIR)
|
||||||
<Command.GCC>
|
|
||||||
$(CP) ${src} $(DEBUG_DIR)(+)$(MODULE_NAME).debug
|
|
||||||
"$(OBJCOPY)" $(OBJCOPY_STRIPFLAG) ${src}
|
|
||||||
|
|
||||||
#
|
<Command.GCC, Command.CLANGGCC>
|
||||||
#The below 2 lines are only needed for UNIXGCC tool chain, which generates PE image directly
|
$(CP) ${src} $(DEBUG_DIR)(+)$(MODULE_NAME).strip
|
||||||
#
|
$(OBJCOPY) $(OBJCOPY_STRIPFLAG) $(DEBUG_DIR)(+)$(MODULE_NAME).strip
|
||||||
-"$(OBJCOPY)" $(OBJCOPY_ADDDEBUGFLAG) ${src}
|
|
||||||
-$(CP) $(DEBUG_DIR)(+)$(MODULE_NAME).debug $(BIN_DIR)(+)$(MODULE_NAME_GUID).debug
|
ImageTool GenImage -c PE -t $(MODULE_TYPE) -o ${dst} $(DEBUG_DIR)(+)$(MODULE_NAME).strip
|
||||||
|
|
||||||
"$(GENFW)" -e $(MODULE_TYPE) -o ${dst} ${src} $(GENFW_FLAGS)
|
|
||||||
$(CP) ${dst} $(DEBUG_DIR)
|
$(CP) ${dst} $(DEBUG_DIR)
|
||||||
$(CP) ${dst} $(BIN_DIR)(+)$(MODULE_NAME_GUID).efi
|
$(CP) ${dst} $(BIN_DIR)(+)$(MODULE_NAME_GUID).efi
|
||||||
-$(CP) $(DEBUG_DIR)(+)*.map $(OUTPUT_DIR)
|
-$(CP) $(DEBUG_DIR)(+)*.map $(OUTPUT_DIR)
|
||||||
|
|
||||||
<Command.XCODE>
|
<Command.XCODE>
|
||||||
# tool to convert Mach-O to PE/COFF
|
# tool to convert Mach-O to PE/COFF
|
||||||
"$(MTOC)" -subsystem $(MODULE_TYPE) $(MTOC_FLAGS) ${src} $(DEBUG_DIR)(+)$(MODULE_NAME).pecoff
|
"$(MTOC)" -subsystem $(MODULE_TYPE) $(MTOC_FLAGS) ${src} $(DEBUG_DIR)(+)$(MODULE_NAME).pecoff
|
||||||
# create symbol file for GDB debug
|
# create symbol file for GDB debug
|
||||||
-$(DSYMUTIL) ${src}
|
-$(DSYMUTIL) ${src}
|
||||||
"$(GENFW)" -e $(MODULE_TYPE) -o ${dst} $(DEBUG_DIR)(+)$(MODULE_NAME).pecoff $(GENFW_FLAGS)
|
ImageTool GenImage -c PE -t $(MODULE_TYPE) -o ${dst} $(DEBUG_DIR)(+)$(MODULE_NAME).pecoff
|
||||||
|
$(CP) ${dst} $(DEBUG_DIR)
|
||||||
|
$(CP) ${dst} $(BIN_DIR)(+)$(MODULE_NAME_GUID).efi
|
||||||
|
-$(CP) $(DEBUG_DIR)(+)*.map $(OUTPUT_DIR)
|
||||||
|
|
||||||
|
[Dynamic-Library-File.UEFI_HII]
|
||||||
|
<InputFile>
|
||||||
|
?.dll
|
||||||
|
|
||||||
|
<OutputFile>
|
||||||
|
$(OUTPUT_DIR)(+)$(MODULE_NAME).efi
|
||||||
|
$(DEBUG_DIR)(+)$(MODULE_NAME).efi
|
||||||
|
$(OUTPUT_DIR)(+)$(MODULE_NAME).map
|
||||||
|
|
||||||
|
<ExtraDependency>
|
||||||
|
$(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc
|
||||||
|
|
||||||
|
<Command.MSFT, Command.INTEL, Command.CLANGPDB>
|
||||||
|
ImageTool GenImage -c PE -t $(MODULE_TYPE) -h $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc -o ${dst} ${src}
|
||||||
|
$(CP) ${dst} $(DEBUG_DIR)
|
||||||
|
$(CP) ${dst} $(BIN_DIR)(+)$(MODULE_NAME_GUID).efi
|
||||||
|
-$(CP) $(DEBUG_DIR)(+)*.map $(OUTPUT_DIR)
|
||||||
|
-$(CP) $(DEBUG_DIR)(+)*.pdb $(OUTPUT_DIR)
|
||||||
|
|
||||||
|
<Command.GCC, Command.CLANGGCC>
|
||||||
|
$(CP) ${src} $(DEBUG_DIR)(+)$(MODULE_NAME).strip
|
||||||
|
$(OBJCOPY) $(OBJCOPY_STRIPFLAG) $(DEBUG_DIR)(+)$(MODULE_NAME).strip
|
||||||
|
|
||||||
|
ImageTool GenImage -c PE -t $(MODULE_TYPE) -h $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc -o ${dst} $(DEBUG_DIR)(+)$(MODULE_NAME).strip
|
||||||
|
|
||||||
|
$(CP) ${dst} $(DEBUG_DIR)
|
||||||
|
$(CP) ${dst} $(BIN_DIR)(+)$(MODULE_NAME_GUID).efi
|
||||||
|
-$(CP) $(DEBUG_DIR)(+)*.map $(OUTPUT_DIR)
|
||||||
|
|
||||||
|
<Command.XCODE>
|
||||||
|
# tool to convert Mach-O to PE/COFF
|
||||||
|
"$(MTOC)" -subsystem $(MODULE_TYPE) $(MTOC_FLAGS) ${src} $(DEBUG_DIR)(+)$(MODULE_NAME).pecoff
|
||||||
|
# create symbol file for GDB debug
|
||||||
|
-$(DSYMUTIL) ${src}
|
||||||
|
ImageTool GenImage -c PE -t $(MODULE_TYPE) -h $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc -o ${dst} $(DEBUG_DIR)(+)$(MODULE_NAME).pecoff
|
||||||
$(CP) ${dst} $(DEBUG_DIR)
|
$(CP) ${dst} $(DEBUG_DIR)
|
||||||
$(CP) ${dst} $(BIN_DIR)(+)$(MODULE_NAME_GUID).efi
|
$(CP) ${dst} $(BIN_DIR)(+)$(MODULE_NAME_GUID).efi
|
||||||
-$(CP) $(DEBUG_DIR)(+)*.map $(OUTPUT_DIR)
|
-$(CP) $(DEBUG_DIR)(+)*.map $(OUTPUT_DIR)
|
||||||
|
@ -404,14 +443,14 @@
|
||||||
<Command.MSFT, Command.INTEL>
|
<Command.MSFT, Command.INTEL>
|
||||||
Trim --asl-file --asl-deps -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i -i $(INC_LIST) ${src}
|
Trim --asl-file --asl-deps -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i -i $(INC_LIST) ${src}
|
||||||
"$(ASLPP)" $(DEPS_FLAGS) $(ASLPP_FLAGS) $(INC) /I${s_path} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i > $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii
|
"$(ASLPP)" $(DEPS_FLAGS) $(ASLPP_FLAGS) $(INC) /I${s_path} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i > $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii
|
||||||
Trim --source-code -l -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iiii $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii
|
Trim --source-code -l -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iiii $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii
|
||||||
"$(ASL)" $(ASL_FLAGS) $(ASL_OUTFLAGS)${dst} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iiii
|
"$(ASL)" $(ASL_FLAGS) $(ASL_OUTFLAGS)${dst} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iiii
|
||||||
$(CP) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.aml $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.amli
|
$(CP) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.aml $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.amli
|
||||||
|
|
||||||
<Command.GCC>
|
<Command.GCC>
|
||||||
Trim --asl-file --asl-deps -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i -i $(INC_LIST) ${src}
|
Trim --asl-file --asl-deps -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i -i $(INC_LIST) ${src}
|
||||||
"$(ASLPP)" $(DEPS_FLAGS) $(ASLPP_FLAGS) $(INC) -I${s_path} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i > $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii
|
"$(ASLPP)" $(DEPS_FLAGS) $(ASLPP_FLAGS) $(INC) -I${s_path} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i > $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii
|
||||||
Trim --source-code -l -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iiii $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii
|
Trim --source-code -l -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iiii $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii
|
||||||
"$(ASL)" $(ASL_FLAGS) $(ASL_OUTFLAGS)${dst} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iiii
|
"$(ASL)" $(ASL_FLAGS) $(ASL_OUTFLAGS)${dst} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iiii
|
||||||
$(CP) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.aml $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.amli
|
$(CP) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.aml $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.amli
|
||||||
|
|
||||||
|
@ -438,12 +477,12 @@
|
||||||
<Command.MSFT, Command.INTEL>
|
<Command.MSFT, Command.INTEL>
|
||||||
"$(ASLCC)" $(DEPS_FLAGS) /Fo$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(ASLCC_FLAGS) $(DEPS_FLAGS) $(INC) ${src}
|
"$(ASLCC)" $(DEPS_FLAGS) /Fo$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(ASLCC_FLAGS) $(DEPS_FLAGS) $(INC) ${src}
|
||||||
"$(ASLDLINK)" /OUT:$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
|
"$(ASLDLINK)" /OUT:$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
|
||||||
"$(GENFW)" -o ${dst} -c $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(GENFW_FLAGS)
|
ImageTool GetAcpi -o ${dst} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll
|
||||||
|
|
||||||
<Command.GCC>
|
<Command.GCC>
|
||||||
"$(ASLCC)" $(DEPS_FLAGS) -c -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(CC_FLAGS) $(ASLCC_FLAGS) $(DEPS_FLAGS) $(INC) ${src}
|
"$(ASLCC)" $(DEPS_FLAGS) -c -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(CC_FLAGS) $(ASLCC_FLAGS) $(DEPS_FLAGS) $(INC) ${src}
|
||||||
"$(ASLDLINK)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
|
"$(ASLDLINK)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
|
||||||
"$(GENFW)" -o ${dst} -c $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(GENFW_FLAGS)
|
ImageTool GetAcpi -o ${dst} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll
|
||||||
|
|
||||||
[Acpi-Table-Code-File]
|
[Acpi-Table-Code-File]
|
||||||
<InputFile>
|
<InputFile>
|
||||||
|
@ -458,25 +497,24 @@
|
||||||
<Command.MSFT, Command.INTEL>
|
<Command.MSFT, Command.INTEL>
|
||||||
"$(ASLCC)" $(DEPS_FLAGS) /Fo$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(ASLCC_FLAGS) $(DEPS_FLAGS) $(INC) ${src}
|
"$(ASLCC)" $(DEPS_FLAGS) /Fo$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(ASLCC_FLAGS) $(DEPS_FLAGS) $(INC) ${src}
|
||||||
"$(ASLDLINK)" /OUT:$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
|
"$(ASLDLINK)" /OUT:$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
|
||||||
"$(GENFW)" -o ${dst} -c $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(GENFW_FLAGS)
|
ImageTool GetAcpi -o ${dst} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll
|
||||||
|
|
||||||
<Command.GCC>
|
<Command.GCC>
|
||||||
"$(ASLCC)" $(DEPS_FLAGS) -c -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(CC_FLAGS) $(ASLCC_FLAGS) $(DEPS_FLAGS) $(INC) ${src}
|
"$(ASLCC)" $(DEPS_FLAGS) -c -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(CC_FLAGS) $(ASLCC_FLAGS) $(DEPS_FLAGS) $(INC) ${src}
|
||||||
"$(ASLDLINK)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
|
"$(ASLDLINK)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(CC_FLAGS) $(ASLCC_FLAGS)
|
||||||
"$(GENFW)" -o ${dst} -c $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(GENFW_FLAGS)
|
ImageTool GetAcpi -o ${dst} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll
|
||||||
|
|
||||||
<Command.CLANGPDB>
|
<Command.CLANGPDB>
|
||||||
"$(ASLCC)" $(DEPS_FLAGS) -c -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(CC_FLAGS) $(ASLCC_FLAGS) $(DEPS_FLAGS) $(INC) ${src}
|
"$(ASLCC)" $(DEPS_FLAGS) -c -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(CC_FLAGS) $(ASLCC_FLAGS) $(DEPS_FLAGS) $(INC) ${src}
|
||||||
"$(ASLDLINK)" /OUT:$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
|
"$(ASLDLINK)" /OUT:$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
|
||||||
"$(GENFW)" -o ${dst} -c $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(GENFW_FLAGS)
|
ImageTool GetAcpi -o ${dst} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll
|
||||||
|
|
||||||
<Command.XCODE>
|
<Command.XCODE>
|
||||||
"$(ASLCC)" $(DEPS_FLAGS) -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(ASLCC_FLAGS) $(DEPS_FLAGS) $(INC) ${src}
|
"$(ASLCC)" $(DEPS_FLAGS) -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(ASLCC_FLAGS) $(DEPS_FLAGS) $(INC) ${src}
|
||||||
"$(ASLDLINK)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
|
"$(ASLDLINK)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
|
||||||
"$(MTOC)" -subsystem $(MODULE_TYPE) $(MTOC_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.pecoff
|
"$(MTOC)" -subsystem $(MODULE_TYPE) $(MTOC_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.pecoff
|
||||||
"$(GENFW)" -o ${dst} -c $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.pecoff $(GENFW_FLAGS)
|
ImageTool GetAcpi -o ${dst} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.pecoff
|
||||||
|
|
||||||
|
|
||||||
[Masm16-Code-File]
|
[Masm16-Code-File]
|
||||||
<InputFile>
|
<InputFile>
|
||||||
?.asm16, ?.Asm16, ?.ASM16, ?.s16, ?.S16
|
?.asm16, ?.Asm16, ?.ASM16, ?.s16, ?.S16
|
||||||
|
@ -501,7 +539,7 @@
|
||||||
Trim --source-code -o ${d_path}(+)${s_base}.iii ${d_path}(+)${s_base}.ii
|
Trim --source-code -o ${d_path}(+)${s_base}.iii ${d_path}(+)${s_base}.ii
|
||||||
"$(ASM)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(ASM_FLAGS) $(INC) ${d_path}(+)${s_base}.iii
|
"$(ASM)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(ASM_FLAGS) $(INC) ${d_path}(+)${s_base}.iii
|
||||||
"$(DLINK)" -o ${dst} $(DLINK_FLAGS) --start-group $(DLINK_SPATH) $(LIBS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj --end-group
|
"$(DLINK)" -o ${dst} $(DLINK_FLAGS) --start-group $(DLINK_SPATH) $(LIBS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj --end-group
|
||||||
|
|
||||||
<Command.XCODE>
|
<Command.XCODE>
|
||||||
Trim --asm-file -o ${d_path}(+)${s_base}.i -i $(INC_LIST) ${src}
|
Trim --asm-file -o ${d_path}(+)${s_base}.i -i $(INC_LIST) ${src}
|
||||||
"$(PP)" $(DEPS_FLAGS) $(PP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.ii
|
"$(PP)" $(DEPS_FLAGS) $(PP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.ii
|
||||||
|
@ -509,7 +547,7 @@
|
||||||
"$(ASM)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(ASM_FLAGS) $(INC) ${d_path}(+)${s_base}.iii
|
"$(ASM)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(ASM_FLAGS) $(INC) ${d_path}(+)${s_base}.iii
|
||||||
"$(SLINK)" $(SLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.slib $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
|
"$(SLINK)" $(SLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.slib $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
|
||||||
otool -t $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.slib | hex2bin.py ${dst}
|
otool -t $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.slib | hex2bin.py ${dst}
|
||||||
|
|
||||||
|
|
||||||
[Nasm-to-Binary-Code-File]
|
[Nasm-to-Binary-Code-File]
|
||||||
<InputFile>
|
<InputFile>
|
||||||
|
@ -537,7 +575,7 @@
|
||||||
$(OUTPUT_DIR)(+)${s_base}.mcb
|
$(OUTPUT_DIR)(+)${s_base}.mcb
|
||||||
|
|
||||||
<Command>
|
<Command>
|
||||||
"$(GENFW)" -o ${dst} -m ${src} $(GENFW_FLAGS)
|
MicroTool TxtToBin ${src} ${dst}
|
||||||
|
|
||||||
[Microcode-Binary-File]
|
[Microcode-Binary-File]
|
||||||
<InputFile>
|
<InputFile>
|
||||||
|
@ -550,7 +588,7 @@
|
||||||
$(OUTPUT_DIR)(+)$(MODULE_NAME).bin
|
$(OUTPUT_DIR)(+)$(MODULE_NAME).bin
|
||||||
|
|
||||||
<Command>
|
<Command>
|
||||||
"$(GENFW)" -o ${dst} -j $(MICROCODE_BINARY_FILES) $(GENFW_FLAGS)
|
MicroTool Merge ${dst} $(MICROCODE_BINARY_FILES)
|
||||||
-$(CP) ${dst} $(BIN_DIR)(+)$(MODULE_NAME_GUID).bin
|
-$(CP) ${dst} $(BIN_DIR)(+)$(MODULE_NAME_GUID).bin
|
||||||
|
|
||||||
[EFI-Image-File]
|
[EFI-Image-File]
|
||||||
|
@ -633,19 +671,8 @@
|
||||||
<InputFile>
|
<InputFile>
|
||||||
*.hpk
|
*.hpk
|
||||||
|
|
||||||
<OutputFile.MSFT, OutputFile.INTEL, OutputFile.GCC, OutputFile.CLANGPDB, OutputFile.CLANGGCC>
|
<OutputFile>
|
||||||
$(OUTPUT_DIR)(+)$(MODULE_NAME)hii.lib
|
|
||||||
|
|
||||||
<OutputFile.XCODE>
|
|
||||||
$(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc
|
$(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc
|
||||||
|
|
||||||
<Command.MSFT, Command.INTEL, Command.CLANGPDB>
|
<Command>
|
||||||
"$(GENFW)" -o $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc -g $(MODULE_GUID) --hiipackage $(HII_BINARY_PACKAGES) $(GENFW_FLAGS)
|
ImageTool HiiBin $(MODULE_GUID) -o $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc $(HII_BINARY_PACKAGES)
|
||||||
"$(RC)" /Fo${dst} $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc
|
|
||||||
|
|
||||||
<Command.GCC, Command.CLANGGCC>
|
|
||||||
"$(GENFW)" -o $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc -g $(MODULE_GUID) --hiibinpackage $(HII_BINARY_PACKAGES) $(GENFW_FLAGS)
|
|
||||||
"$(RC)" $(RC_FLAGS) $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc ${dst}
|
|
||||||
|
|
||||||
<Command.XCODE>
|
|
||||||
"$(GENFW)" -o $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc -g $(MODULE_GUID) --hiibinpackage $(HII_BINARY_PACKAGES) $(GENFW_FLAGS)
|
|
||||||
|
|
|
@ -25,6 +25,28 @@
|
||||||
|
|
||||||
IDENTIFIER = Default TOOL_CHAIN_CONF
|
IDENTIFIER = Default TOOL_CHAIN_CONF
|
||||||
|
|
||||||
|
!ifdef $(EDK2_MERGE_RODATA_INTO_TEXT)
|
||||||
|
DEFINE DLINK_SCRIPT = -Wl,--script=$(EDK_TOOLS_PATH)/Scripts/Merge.lds
|
||||||
|
DEFINE MSFT_MERGE = /MERGE:.rdata=.text
|
||||||
|
DEFINE XCODE_MERGE = -rename_section __DATA_CONST __text_const __TEXT __const -rename_section __DATA_CONST __cstring __TEXT __cstring -rename_section __DATA_CONST __ustring __TEXT __ustring -rename_section __DATA_CONST __const __TEXT __data_const
|
||||||
|
!else
|
||||||
|
DEFINE DLINK_SCRIPT = -Wl,--script=$(EDK_TOOLS_PATH)/Scripts/Base.lds
|
||||||
|
DEFINE MSFT_MERGE =
|
||||||
|
DEFINE XCODE_MERGE =
|
||||||
|
!endif
|
||||||
|
|
||||||
|
!ifdef $(EDK2_REDUCE_FW_SIZE)
|
||||||
|
DEFINE GCC_ALIGN = -z max-page-size=0x20
|
||||||
|
DEFINE MSFT_ALIGN = /ALIGN:32 /FILEALIGN:32
|
||||||
|
DEFINE XCODE_ALIGN = 0x20
|
||||||
|
DEFINE XCODE_ADDR = 0x400
|
||||||
|
!else
|
||||||
|
DEFINE GCC_ALIGN = -z max-page-size=0x1000
|
||||||
|
DEFINE MSFT_ALIGN = /ALIGN:4096 /FILEALIGN:4096
|
||||||
|
DEFINE XCODE_ALIGN = 0x1000
|
||||||
|
DEFINE XCODE_ADDR = 0x1000
|
||||||
|
!endif
|
||||||
|
|
||||||
# common path macros
|
# common path macros
|
||||||
DEFINE VS2015_BIN = ENV(VS2015_PREFIX)Vc\bin
|
DEFINE VS2015_BIN = ENV(VS2015_PREFIX)Vc\bin
|
||||||
DEFINE VS2015_DLL = ENV(VS2015_PREFIX)Common7\IDE;DEF(VS2015_BIN)
|
DEFINE VS2015_DLL = ENV(VS2015_PREFIX)Common7\IDE;DEF(VS2015_BIN)
|
||||||
|
@ -107,6 +129,7 @@ DEFINE MSFT_DEPS_FLAGS = /showIncludes
|
||||||
DEFINE MSFT_ASLPP_FLAGS = /nologo /E /C /FIAutoGen.h
|
DEFINE MSFT_ASLPP_FLAGS = /nologo /E /C /FIAutoGen.h
|
||||||
DEFINE MSFT_ASLCC_FLAGS = /nologo /c /FIAutoGen.h /TC /Dmain=ReferenceAcpiTable
|
DEFINE MSFT_ASLCC_FLAGS = /nologo /c /FIAutoGen.h /TC /Dmain=ReferenceAcpiTable
|
||||||
DEFINE MSFT_ASLDLINK_FLAGS = /NODEFAULTLIB /ENTRY:ReferenceAcpiTable /SUBSYSTEM:CONSOLE
|
DEFINE MSFT_ASLDLINK_FLAGS = /NODEFAULTLIB /ENTRY:ReferenceAcpiTable /SUBSYSTEM:CONSOLE
|
||||||
|
DEFINE MSFT_DLINK_COMMON = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER DEF(MSFT_ALIGN) DEF(MSFT_MERGE)
|
||||||
|
|
||||||
DEFINE DTCPP_BIN = ENV(DTCPP_PREFIX)cpp
|
DEFINE DTCPP_BIN = ENV(DTCPP_PREFIX)cpp
|
||||||
DEFINE DTC_BIN = ENV(DTC_PREFIX)dtc
|
DEFINE DTC_BIN = ENV(DTC_PREFIX)dtc
|
||||||
|
@ -271,7 +294,7 @@ DEFINE DTC_BIN = ENV(DTC_PREFIX)dtc
|
||||||
*_VS2015_*_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
|
*_VS2015_*_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
|
||||||
*_VS2015_*_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
|
*_VS2015_*_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
|
||||||
*_VS2015_*_DLINK2_FLAGS =
|
*_VS2015_*_DLINK2_FLAGS =
|
||||||
*_VS2015_*_DEPS_FLAGS = DEF(MSFT_DEPS_FLAGS)
|
*_VS2015_*_DEPS_FLAGS = DEF(MSFT_DEPS_FLAGS)
|
||||||
*_VS2015_*_ASM16_PATH = DEF(VS2015_BIN)\ml.exe
|
*_VS2015_*_ASM16_PATH = DEF(VS2015_BIN)\ml.exe
|
||||||
|
|
||||||
##################
|
##################
|
||||||
|
@ -308,13 +331,13 @@ NOOPT_VS2015_IA32_CC_FLAGS = /nologo /arch:IA32 /c /WX /GS- /W4 /Gs32768
|
||||||
RELEASE_VS2015_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd
|
RELEASE_VS2015_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd
|
||||||
NOOPT_VS2015_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd /Zi
|
NOOPT_VS2015_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd /Zi
|
||||||
|
|
||||||
DEBUG_VS2015_IA32_NASM_FLAGS = -Ox -f win32 -g
|
DEBUG_VS2015_IA32_NASM_FLAGS = -Ox -f win32 -g -DRODATA_SECTION_NAME=.rdata
|
||||||
RELEASE_VS2015_IA32_NASM_FLAGS = -Ox -f win32
|
RELEASE_VS2015_IA32_NASM_FLAGS = -Ox -f win32 -DRODATA_SECTION_NAME=.rdata
|
||||||
NOOPT_VS2015_IA32_NASM_FLAGS = -O0 -f win32 -g
|
NOOPT_VS2015_IA32_NASM_FLAGS = -O0 -f win32 -g -DRODATA_SECTION_NAME=.rdata
|
||||||
|
|
||||||
DEBUG_VS2015_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:X86 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
|
DEBUG_VS2015_IA32_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /MACHINE:X86 /DEBUG
|
||||||
RELEASE_VS2015_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:X86 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data
|
RELEASE_VS2015_IA32_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /IGNORE:4254 /MACHINE:X86
|
||||||
NOOPT_VS2015_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:X86 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
|
NOOPT_VS2015_IA32_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /MACHINE:X86 /DEBUG
|
||||||
|
|
||||||
##################
|
##################
|
||||||
# X64 definitions
|
# X64 definitions
|
||||||
|
@ -338,15 +361,15 @@ NOOPT_VS2015_X64_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /G
|
||||||
|
|
||||||
DEBUG_VS2015_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi
|
DEBUG_VS2015_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi
|
||||||
RELEASE_VS2015_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd
|
RELEASE_VS2015_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd
|
||||||
NOOPT_VS2015_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi
|
NOOPT_VS2015_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi
|
||||||
|
|
||||||
DEBUG_VS2015_X64_NASM_FLAGS = -Ox -f win64 -g
|
DEBUG_VS2015_X64_NASM_FLAGS = -Ox -f win64 -g -DRODATA_SECTION_NAME=.rdata
|
||||||
RELEASE_VS2015_X64_NASM_FLAGS = -Ox -f win64
|
RELEASE_VS2015_X64_NASM_FLAGS = -Ox -f win64 -DRODATA_SECTION_NAME=.rdata
|
||||||
NOOPT_VS2015_X64_NASM_FLAGS = -O0 -f win64 -g
|
NOOPT_VS2015_X64_NASM_FLAGS = -O0 -f win64 -g -DRODATA_SECTION_NAME=.rdata
|
||||||
|
|
||||||
DEBUG_VS2015_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
|
DEBUG_VS2015_X64_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /MACHINE:X64 /DEBUG
|
||||||
RELEASE_VS2015_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data
|
RELEASE_VS2015_X64_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /IGNORE:4254 /MACHINE:X64
|
||||||
NOOPT_VS2015_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
|
NOOPT_VS2015_X64_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /MACHINE:X64 /DEBUG
|
||||||
|
|
||||||
####################################################################################
|
####################################################################################
|
||||||
# VS2015x86 - Microsoft Visual Studio 2015 (x86) professional with Intel ASL
|
# VS2015x86 - Microsoft Visual Studio 2015 (x86) professional with Intel ASL
|
||||||
|
@ -401,13 +424,13 @@ NOOPT_VS2015x86_IA32_CC_FLAGS = /nologo /arch:IA32 /c /WX /GS- /W4 /Gs32768
|
||||||
RELEASE_VS2015x86_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd
|
RELEASE_VS2015x86_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd
|
||||||
NOOPT_VS2015x86_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd /Zi
|
NOOPT_VS2015x86_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd /Zi
|
||||||
|
|
||||||
DEBUG_VS2015x86_IA32_NASM_FLAGS = -Ox -f win32 -g
|
DEBUG_VS2015x86_IA32_NASM_FLAGS = -Ox -f win32 -g -DRODATA_SECTION_NAME=.rdata
|
||||||
RELEASE_VS2015x86_IA32_NASM_FLAGS = -Ox -f win32
|
RELEASE_VS2015x86_IA32_NASM_FLAGS = -Ox -f win32 -DRODATA_SECTION_NAME=.rdata
|
||||||
NOOPT_VS2015x86_IA32_NASM_FLAGS = -O0 -f win32 -g
|
NOOPT_VS2015x86_IA32_NASM_FLAGS = -O0 -f win32 -g -DRODATA_SECTION_NAME=.rdata
|
||||||
|
|
||||||
DEBUG_VS2015x86_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:X86 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
|
DEBUG_VS2015x86_IA32_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /MACHINE:X86 /DEBUG
|
||||||
RELEASE_VS2015x86_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:X86 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data
|
RELEASE_VS2015x86_IA32_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /IGNORE:4254 /MACHINE:X86
|
||||||
NOOPT_VS2015x86_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:X86 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
|
NOOPT_VS2015x86_IA32_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /MACHINE:X86 /DEBUG
|
||||||
|
|
||||||
##################
|
##################
|
||||||
# X64 definitions
|
# X64 definitions
|
||||||
|
@ -433,13 +456,13 @@ NOOPT_VS2015x86_X64_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE
|
||||||
RELEASE_VS2015x86_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd
|
RELEASE_VS2015x86_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd
|
||||||
NOOPT_VS2015x86_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi
|
NOOPT_VS2015x86_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi
|
||||||
|
|
||||||
DEBUG_VS2015x86_X64_NASM_FLAGS = -Ox -f win64 -g
|
DEBUG_VS2015x86_X64_NASM_FLAGS = -Ox -f win64 -g -DRODATA_SECTION_NAME=.rdata
|
||||||
RELEASE_VS2015x86_X64_NASM_FLAGS = -Ox -f win64
|
RELEASE_VS2015x86_X64_NASM_FLAGS = -Ox -f win64 -DRODATA_SECTION_NAME=.rdata
|
||||||
NOOPT_VS2015x86_X64_NASM_FLAGS = -O0 -f win64 -g
|
NOOPT_VS2015x86_X64_NASM_FLAGS = -O0 -f win64 -g -DRODATA_SECTION_NAME=.rdata
|
||||||
|
|
||||||
DEBUG_VS2015x86_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
|
DEBUG_VS2015x86_X64_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /MACHINE:X64 /DEBUG
|
||||||
RELEASE_VS2015x86_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data
|
RELEASE_VS2015x86_X64_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /IGNORE:4254 /MACHINE:X64
|
||||||
NOOPT_VS2015x86_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
|
NOOPT_VS2015x86_X64_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /MACHINE:X64 /DEBUG
|
||||||
|
|
||||||
####################################################################################
|
####################################################################################
|
||||||
# VS2017 - Microsoft Visual Studio 2017 with Intel ASL
|
# VS2017 - Microsoft Visual Studio 2017 with Intel ASL
|
||||||
|
@ -492,13 +515,13 @@ NOOPT_VS2017_IA32_CC_FLAGS = /nologo /arch:IA32 /c /WX /GS- /W4 /Gs32768 /D
|
||||||
RELEASE_VS2017_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd
|
RELEASE_VS2017_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd
|
||||||
NOOPT_VS2017_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd /Zi
|
NOOPT_VS2017_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd /Zi
|
||||||
|
|
||||||
DEBUG_VS2017_IA32_NASM_FLAGS = -Ox -f win32 -g
|
DEBUG_VS2017_IA32_NASM_FLAGS = -Ox -f win32 -g -DRODATA_SECTION_NAME=.rdata
|
||||||
RELEASE_VS2017_IA32_NASM_FLAGS = -Ox -f win32
|
RELEASE_VS2017_IA32_NASM_FLAGS = -Ox -f win32 -DRODATA_SECTION_NAME=.rdata
|
||||||
NOOPT_VS2017_IA32_NASM_FLAGS = -O0 -f win32 -g
|
NOOPT_VS2017_IA32_NASM_FLAGS = -O0 -f win32 -g -DRODATA_SECTION_NAME=.rdata
|
||||||
|
|
||||||
DEBUG_VS2017_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:X86 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
|
DEBUG_VS2017_IA32_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /MACHINE:X86 /DEBUG
|
||||||
RELEASE_VS2017_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:X86 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data
|
RELEASE_VS2017_IA32_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /IGNORE:4254 /MACHINE:X86
|
||||||
NOOPT_VS2017_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:X86 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
|
NOOPT_VS2017_IA32_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /MACHINE:X86 /DEBUG
|
||||||
|
|
||||||
##################
|
##################
|
||||||
# X64 definitions
|
# X64 definitions
|
||||||
|
@ -522,13 +545,13 @@ NOOPT_VS2017_X64_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /G
|
||||||
RELEASE_VS2017_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd
|
RELEASE_VS2017_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd
|
||||||
NOOPT_VS2017_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi
|
NOOPT_VS2017_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi
|
||||||
|
|
||||||
DEBUG_VS2017_X64_NASM_FLAGS = -Ox -f win64 -g
|
DEBUG_VS2017_X64_NASM_FLAGS = -Ox -f win64 -g -DRODATA_SECTION_NAME=.rdata
|
||||||
RELEASE_VS2017_X64_NASM_FLAGS = -Ox -f win64
|
RELEASE_VS2017_X64_NASM_FLAGS = -Ox -f win64 -DRODATA_SECTION_NAME=.rdata
|
||||||
NOOPT_VS2017_X64_NASM_FLAGS = -O0 -f win64 -g
|
NOOPT_VS2017_X64_NASM_FLAGS = -O0 -f win64 -g -DRODATA_SECTION_NAME=.rdata
|
||||||
|
|
||||||
DEBUG_VS2017_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4281 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
|
DEBUG_VS2017_X64_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /IGNORE:4281 /MACHINE:X64 /DEBUG
|
||||||
RELEASE_VS2017_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4281 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data
|
RELEASE_VS2017_X64_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /IGNORE:4281 /IGNORE:4254 /MACHINE:X64
|
||||||
NOOPT_VS2017_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4281 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
|
NOOPT_VS2017_X64_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /IGNORE:4281 /MACHINE:X64 /DEBUG
|
||||||
|
|
||||||
#################
|
#################
|
||||||
# ARM definitions
|
# ARM definitions
|
||||||
|
@ -552,9 +575,9 @@ NOOPT_VS2017_ARM_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE
|
||||||
RELEASE_VS2017_ARM_ASM_FLAGS = /nologo
|
RELEASE_VS2017_ARM_ASM_FLAGS = /nologo
|
||||||
NOOPT_VS2017_ARM_ASM_FLAGS = /nologo
|
NOOPT_VS2017_ARM_ASM_FLAGS = /nologo
|
||||||
|
|
||||||
DEBUG_VS2017_ARM_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:ARM /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
|
DEBUG_VS2017_ARM_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /MACHINE:ARM /DEBUG
|
||||||
RELEASE_VS2017_ARM_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:ARM /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data
|
RELEASE_VS2017_ARM_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /IGNORE:4254 /MACHINE:ARM
|
||||||
NOOPT_VS2017_ARM_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:ARM /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
|
NOOPT_VS2017_ARM_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /MACHINE:ARM /DEBUG
|
||||||
|
|
||||||
#####################
|
#####################
|
||||||
# AARCH64 definitions
|
# AARCH64 definitions
|
||||||
|
@ -578,9 +601,9 @@ NOOPT_VS2017_AARCH64_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE
|
||||||
RELEASE_VS2017_AARCH64_ASM_FLAGS = /nologo
|
RELEASE_VS2017_AARCH64_ASM_FLAGS = /nologo
|
||||||
NOOPT_VS2017_AARCH64_ASM_FLAGS = /nologo
|
NOOPT_VS2017_AARCH64_ASM_FLAGS = /nologo
|
||||||
|
|
||||||
DEBUG_VS2017_AARCH64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:ARM64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /DRIVER /DEBUG
|
DEBUG_VS2017_AARCH64_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /MACHINE:ARM64 /DEBUG
|
||||||
RELEASE_VS2017_AARCH64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:ARM64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /DRIVER /MERGE:.rdata=.data
|
RELEASE_VS2017_AARCH64_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /IGNORE:4254 /MACHINE:ARM64
|
||||||
NOOPT_VS2017_AARCH64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:ARM64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /DRIVER /DEBUG
|
NOOPT_VS2017_AARCH64_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /MACHINE:ARM64 /DEBUG
|
||||||
|
|
||||||
####################################################################################
|
####################################################################################
|
||||||
# VS2019 - Microsoft Visual Studio 2019 with Intel ASL
|
# VS2019 - Microsoft Visual Studio 2019 with Intel ASL
|
||||||
|
@ -633,13 +656,13 @@ NOOPT_VS2019_IA32_CC_FLAGS = /nologo /arch:IA32 /c /WX /GS- /W4 /Gs32768 /D
|
||||||
RELEASE_VS2019_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd
|
RELEASE_VS2019_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd
|
||||||
NOOPT_VS2019_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd /Zi
|
NOOPT_VS2019_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd /Zi
|
||||||
|
|
||||||
DEBUG_VS2019_IA32_NASM_FLAGS = -Ox -f win32 -g
|
DEBUG_VS2019_IA32_NASM_FLAGS = -Ox -f win32 -g -DRODATA_SECTION_NAME=.rdata
|
||||||
RELEASE_VS2019_IA32_NASM_FLAGS = -Ox -f win32
|
RELEASE_VS2019_IA32_NASM_FLAGS = -Ox -f win32 -DRODATA_SECTION_NAME=.rdata
|
||||||
NOOPT_VS2019_IA32_NASM_FLAGS = -O0 -f win32 -g
|
NOOPT_VS2019_IA32_NASM_FLAGS = -O0 -f win32 -g -DRODATA_SECTION_NAME=.rdata
|
||||||
|
|
||||||
DEBUG_VS2019_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:X86 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
|
DEBUG_VS2019_IA32_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /MACHINE:X86 /DEBUG
|
||||||
RELEASE_VS2019_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:X86 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data
|
RELEASE_VS2019_IA32_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /IGNORE:4254 /MACHINE:X86
|
||||||
NOOPT_VS2019_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:X86 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
|
NOOPT_VS2019_IA32_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /MACHINE:X86 /DEBUG
|
||||||
|
|
||||||
##################
|
##################
|
||||||
# X64 definitions
|
# X64 definitions
|
||||||
|
@ -663,13 +686,13 @@ NOOPT_VS2019_X64_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /G
|
||||||
RELEASE_VS2019_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd
|
RELEASE_VS2019_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd
|
||||||
NOOPT_VS2019_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi
|
NOOPT_VS2019_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi
|
||||||
|
|
||||||
DEBUG_VS2019_X64_NASM_FLAGS = -Ox -f win64 -g
|
DEBUG_VS2019_X64_NASM_FLAGS = -Ox -f win64 -g -DRODATA_SECTION_NAME=.rdata
|
||||||
RELEASE_VS2019_X64_NASM_FLAGS = -Ox -f win64
|
RELEASE_VS2019_X64_NASM_FLAGS = -Ox -f win64 -DRODATA_SECTION_NAME=.rdata
|
||||||
NOOPT_VS2019_X64_NASM_FLAGS = -O0 -f win64 -g
|
NOOPT_VS2019_X64_NASM_FLAGS = -O0 -f win64 -g -DRODATA_SECTION_NAME=.rdata
|
||||||
|
|
||||||
DEBUG_VS2019_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4281 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
|
DEBUG_VS2019_X64_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /IGNORE:4281 /MACHINE:X64 /DEBUG
|
||||||
RELEASE_VS2019_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4281 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data
|
RELEASE_VS2019_X64_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /IGNORE:4281 /IGNORE:4254 /MACHINE:X64
|
||||||
NOOPT_VS2019_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4281 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
|
NOOPT_VS2019_X64_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /IGNORE:4281 /MACHINE:X64 /DEBUG
|
||||||
|
|
||||||
#################
|
#################
|
||||||
# ARM definitions
|
# ARM definitions
|
||||||
|
@ -693,9 +716,9 @@ NOOPT_VS2019_ARM_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE
|
||||||
RELEASE_VS2019_ARM_ASM_FLAGS = /nologo
|
RELEASE_VS2019_ARM_ASM_FLAGS = /nologo
|
||||||
NOOPT_VS2019_ARM_ASM_FLAGS = /nologo
|
NOOPT_VS2019_ARM_ASM_FLAGS = /nologo
|
||||||
|
|
||||||
DEBUG_VS2019_ARM_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:ARM /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
|
DEBUG_VS2019_ARM_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /MACHINE:ARM /DEBUG
|
||||||
RELEASE_VS2019_ARM_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:ARM /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data
|
RELEASE_VS2019_ARM_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /IGNORE:4254 /MACHINE:ARM
|
||||||
NOOPT_VS2019_ARM_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:ARM /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
|
NOOPT_VS2019_ARM_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /MACHINE:ARM /DEBUG
|
||||||
|
|
||||||
#####################
|
#####################
|
||||||
# AARCH64 definitions
|
# AARCH64 definitions
|
||||||
|
@ -719,42 +742,38 @@ NOOPT_VS2019_AARCH64_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE
|
||||||
RELEASE_VS2019_AARCH64_ASM_FLAGS = /nologo
|
RELEASE_VS2019_AARCH64_ASM_FLAGS = /nologo
|
||||||
NOOPT_VS2019_AARCH64_ASM_FLAGS = /nologo
|
NOOPT_VS2019_AARCH64_ASM_FLAGS = /nologo
|
||||||
|
|
||||||
DEBUG_VS2019_AARCH64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:ARM64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /DRIVER /DEBUG
|
DEBUG_VS2019_AARCH64_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /MACHINE:ARM64 /DEBUG
|
||||||
RELEASE_VS2019_AARCH64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:ARM64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /DRIVER /MERGE:.rdata=.data
|
RELEASE_VS2019_AARCH64_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /IGNORE:4254 /MACHINE:ARM64
|
||||||
NOOPT_VS2019_AARCH64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:ARM64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /DRIVER /DEBUG
|
NOOPT_VS2019_AARCH64_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /MACHINE:ARM64 /DEBUG
|
||||||
|
|
||||||
####################################################################################
|
####################################################################################
|
||||||
# GCC Common
|
# GCC Common
|
||||||
####################################################################################
|
####################################################################################
|
||||||
|
|
||||||
*_*_*_OBJCOPY_PATH = echo
|
*_*_*_OBJCOPY_PATH = echo
|
||||||
*_*_*_OBJCOPY_FLAGS = objcopy not needed for
|
|
||||||
*_*_*_SYMRENAME_PATH = echo
|
*_*_*_SYMRENAME_PATH = echo
|
||||||
*_*_*_SYMRENAME_FLAGS = Symbol renaming not needed for
|
*_*_*_SYMRENAME_FLAGS = Symbol renaming not needed for
|
||||||
DEBUG_*_*_OBJCOPY_ADDDEBUGFLAG = --add-gnu-debuglink="$(DEBUG_DIR)/$(MODULE_NAME).debug"
|
|
||||||
RELEASE_*_*_OBJCOPY_ADDDEBUGFLAG =
|
|
||||||
NOOPT_*_*_OBJCOPY_ADDDEBUGFLAG = --add-gnu-debuglink="$(DEBUG_DIR)/$(MODULE_NAME).debug"
|
|
||||||
*_*_*_OBJCOPY_STRIPFLAG = --strip-unneeded -R .eh_frame
|
*_*_*_OBJCOPY_STRIPFLAG = --strip-unneeded -R .eh_frame
|
||||||
*_*_*_DTC_FLAGS = -H epapr
|
*_*_*_DTC_FLAGS = -H epapr
|
||||||
*_*_*_DTCPP_PATH = DEF(DTCPP_BIN)
|
*_*_*_DTCPP_PATH = DEF(DTCPP_BIN)
|
||||||
*_*_*_DTC_PATH = DEF(DTC_BIN)
|
*_*_*_DTC_PATH = DEF(DTC_BIN)
|
||||||
|
|
||||||
DEFINE GCC_ALL_CC_FLAGS = -g -Os -fshort-wchar -fno-builtin -fno-strict-aliasing -Wall -Werror -Wno-array-bounds -include AutoGen.h -fno-common
|
DEFINE GCC_ALL_CC_FLAGS = -g -Os -fshort-wchar -fno-builtin -fno-strict-aliasing -Wall -Werror -Wno-array-bounds -include AutoGen.h -fno-common
|
||||||
DEFINE GCC_ARM_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS) -mlittle-endian -mabi=aapcs -fno-short-enums -funsigned-char -ffunction-sections -fdata-sections -fomit-frame-pointer -Wno-address -mthumb -fno-pic -fno-pie
|
DEFINE GCC_ARM_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS) -march=armv7-a -mthumb -mlittle-endian -mabi=aapcs -fno-short-enums -funsigned-char -ffunction-sections -fdata-sections -fomit-frame-pointer -Wno-address -mfloat-abi=soft -fno-pic -fno-pie
|
||||||
DEFINE GCC_LOONGARCH64_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS) -mabi=lp64d -fno-asynchronous-unwind-tables -fno-plt -Wno-address -fno-short-enums -fsigned-char -ffunction-sections -fdata-sections
|
DEFINE GCC_LOONGARCH64_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS) -mabi=lp64d -fno-asynchronous-unwind-tables -fno-plt -Wno-address -fno-short-enums -fsigned-char -ffunction-sections -fdata-sections
|
||||||
DEFINE GCC_ARM_CC_XIPFLAGS = -mno-unaligned-access
|
DEFINE GCC_ARM_CC_XIPFLAGS = -mno-unaligned-access
|
||||||
DEFINE GCC_AARCH64_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS) -mlittle-endian -fno-short-enums -fverbose-asm -funsigned-char -ffunction-sections -fdata-sections -Wno-address -fno-asynchronous-unwind-tables -fno-unwind-tables -fno-pic -fno-pie -ffixed-x18
|
DEFINE GCC_AARCH64_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS) -mlittle-endian -fno-short-enums -fverbose-asm -funsigned-char -ffunction-sections -fdata-sections -Wno-address -fno-asynchronous-unwind-tables -fno-unwind-tables -fno-pic -fno-pie -ffixed-x18
|
||||||
DEFINE GCC_AARCH64_CC_XIPFLAGS = -mstrict-align -mgeneral-regs-only
|
DEFINE GCC_AARCH64_CC_XIPFLAGS = -mstrict-align -mgeneral-regs-only
|
||||||
DEFINE GCC_RISCV64_CC_XIPFLAGS = -mstrict-align -mgeneral-regs-only
|
DEFINE GCC_RISCV64_CC_XIPFLAGS = -mstrict-align -mgeneral-regs-only
|
||||||
DEFINE GCC_DLINK_FLAGS_COMMON = -nostdlib --pie
|
DEFINE GCC_DLINK_FLAGS_COMMON = -nostdlib --pie
|
||||||
DEFINE GCC_DLINK2_FLAGS_COMMON = -Wl,--script=$(EDK_TOOLS_PATH)/Scripts/GccBase.lds
|
DEFINE GCC_DLINK2_FLAGS_COMMON = -Wl,--defsym=ALIGNED_PE_HEADER_SIZE=0x400 DEF(DLINK_SCRIPT)
|
||||||
DEFINE GCC_IA32_X64_DLINK_COMMON = DEF(GCC_DLINK_FLAGS_COMMON) --gc-sections
|
DEFINE GCC_IA32_X64_DLINK_COMMON = DEF(GCC_DLINK_FLAGS_COMMON) --gc-sections
|
||||||
DEFINE GCC_ARM_AARCH64_DLINK_COMMON= -Wl,--emit-relocs -nostdlib -Wl,--gc-sections -u $(IMAGE_ENTRY_POINT) -Wl,-e,$(IMAGE_ENTRY_POINT),-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map
|
DEFINE GCC_ARM_AARCH64_DLINK_COMMON= -Wl,--emit-relocs -nostdlib -Wl,--gc-sections -u $(IMAGE_ENTRY_POINT) -Wl,-e,$(IMAGE_ENTRY_POINT),-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map -no-pie
|
||||||
DEFINE GCC_LOONGARCH64_DLINK_COMMON= -Wl,--emit-relocs -nostdlib -Wl,--gc-sections -u $(IMAGE_ENTRY_POINT) -Wl,-e,$(IMAGE_ENTRY_POINT),-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map
|
DEFINE GCC_LOONGARCH64_DLINK_COMMON= -Wl,--emit-relocs -nostdlib -Wl,--gc-sections -u $(IMAGE_ENTRY_POINT) -Wl,-e,$(IMAGE_ENTRY_POINT),-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map
|
||||||
DEFINE GCC_ARM_DLINK_FLAGS = DEF(GCC_ARM_AARCH64_DLINK_COMMON) -z common-page-size=0x20 -Wl,--pic-veneer
|
DEFINE GCC_ARM_DLINK_FLAGS = DEF(GCC_ARM_AARCH64_DLINK_COMMON) DEF(GCC_ALIGN) -Wl,--pic-veneer
|
||||||
DEFINE GCC_AARCH64_DLINK_FLAGS = DEF(GCC_ARM_AARCH64_DLINK_COMMON) -z common-page-size=0x20
|
DEFINE GCC_AARCH64_DLINK_FLAGS = DEF(GCC_ARM_AARCH64_DLINK_COMMON) DEF(GCC_ALIGN)
|
||||||
DEFINE GCC_LOONGARCH64_DLINK_FLAGS = DEF(GCC_LOONGARCH64_DLINK_COMMON) -z common-page-size=0x20
|
DEFINE GCC_LOONGARCH64_DLINK_FLAGS = DEF(GCC_LOONGARCH64_DLINK_COMMON) DEF(GCC_ALIGN)
|
||||||
DEFINE GCC_ARM_AARCH64_ASLDLINK_FLAGS = -Wl,--defsym=PECOFF_HEADER_SIZE=0 DEF(GCC_DLINK2_FLAGS_COMMON) -z common-page-size=0x20
|
DEFINE GCC_ARM_AARCH64_ASLDLINK_FLAGS = DEF(GCC_DLINK2_FLAGS_COMMON) DEF(GCC_ALIGN)
|
||||||
DEFINE GCC_IA32_X64_ASLDLINK_FLAGS = DEF(GCC_IA32_X64_DLINK_COMMON) --entry _ReferenceAcpiTable -u $(IMAGE_ENTRY_POINT)
|
DEFINE GCC_IA32_X64_ASLDLINK_FLAGS = DEF(GCC_IA32_X64_DLINK_COMMON) --entry _ReferenceAcpiTable -u $(IMAGE_ENTRY_POINT)
|
||||||
DEFINE GCC_ARM_ASLDLINK_FLAGS = DEF(GCC_ARM_DLINK_FLAGS) -Wl,--entry,ReferenceAcpiTable -u $(IMAGE_ENTRY_POINT) DEF(GCC_ARM_AARCH64_ASLDLINK_FLAGS)
|
DEFINE GCC_ARM_ASLDLINK_FLAGS = DEF(GCC_ARM_DLINK_FLAGS) -Wl,--entry,ReferenceAcpiTable -u $(IMAGE_ENTRY_POINT) DEF(GCC_ARM_AARCH64_ASLDLINK_FLAGS)
|
||||||
DEFINE GCC_AARCH64_ASLDLINK_FLAGS = DEF(GCC_AARCH64_DLINK_FLAGS) -Wl,--entry,ReferenceAcpiTable -u $(IMAGE_ENTRY_POINT) DEF(GCC_ARM_AARCH64_ASLDLINK_FLAGS)
|
DEFINE GCC_AARCH64_ASLDLINK_FLAGS = DEF(GCC_AARCH64_DLINK_FLAGS) -Wl,--entry,ReferenceAcpiTable -u $(IMAGE_ENTRY_POINT) DEF(GCC_ARM_AARCH64_ASLDLINK_FLAGS)
|
||||||
|
@ -767,45 +786,38 @@ DEFINE GCC_ASLPP_FLAGS = -x c -E -include AutoGen.h
|
||||||
DEFINE GCC_ASLCC_FLAGS = -x c
|
DEFINE GCC_ASLCC_FLAGS = -x c
|
||||||
DEFINE GCC_WINDRES_FLAGS = -J rc -O coff
|
DEFINE GCC_WINDRES_FLAGS = -J rc -O coff
|
||||||
DEFINE GCC_DTCPP_FLAGS = -E -x assembler-with-cpp -imacros AutoGen.h -nostdinc -undef
|
DEFINE GCC_DTCPP_FLAGS = -E -x assembler-with-cpp -imacros AutoGen.h -nostdinc -undef
|
||||||
DEFINE GCC_IA32_RC_FLAGS = -I binary -O elf32-i386 -B i386 --rename-section .data=.hii
|
|
||||||
DEFINE GCC_X64_RC_FLAGS = -I binary -O elf64-x86-64 -B i386 --rename-section .data=.hii
|
|
||||||
DEFINE GCC_ARM_RC_FLAGS = -I binary -O elf32-littlearm -B arm --rename-section .data=.hii
|
|
||||||
DEFINE GCC_AARCH64_RC_FLAGS = -I binary -O elf64-littleaarch64 -B aarch64 --rename-section .data=.hii
|
|
||||||
DEFINE GCC_AARCH64_RC_BTI_FLAGS = --add-section .note.gnu.property=$(WORKSPACE)/ArmPkg/Library/GnuNoteBti.bin --set-section-flags .note.gnu.property=alloc,readonly
|
|
||||||
DEFINE GCC_RISCV64_RC_FLAGS = -I binary -O elf64-littleriscv -B riscv --rename-section .data=.hii
|
|
||||||
DEFINE GCC_LOONGARCH64_RC_FLAGS = -I binary -O elf64-loongarch -B loongarch64 --rename-section .data=.hii
|
|
||||||
|
|
||||||
# GCC Build Flag for included header file list generation
|
# GCC Build Flag for included header file list generation
|
||||||
DEFINE GCC_DEPS_FLAGS = -MMD -MF $@.deps
|
DEFINE GCC_DEPS_FLAGS = -MMD -MF $@.deps
|
||||||
|
|
||||||
DEFINE GCC48_ALL_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS) -ffunction-sections -fdata-sections -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings
|
DEFINE GCC48_ALL_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS) -ffunction-sections -fdata-sections -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings
|
||||||
DEFINE GCC48_IA32_X64_DLINK_COMMON = -nostdlib -Wl,-n,-q,--gc-sections -z common-page-size=0x20
|
DEFINE GCC48_IA32_X64_DLINK_COMMON = -nostdlib -Wl,-n,-q,--gc-sections DEF(GCC_ALIGN)
|
||||||
DEFINE GCC48_IA32_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) -m32 -march=i586 -malign-double -fno-stack-protector -D EFI32 -fno-asynchronous-unwind-tables -Wno-address -fno-omit-frame-pointer
|
DEFINE GCC48_IA32_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) -m32 -march=i586 -malign-double -fno-stack-protector -D EFI32 -fno-asynchronous-unwind-tables -Wno-address -fno-omit-frame-pointer
|
||||||
DEFINE GCC48_X64_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) -m64 -fno-stack-protector "-DEFIAPI=__attribute__((ms_abi))" -maccumulate-outgoing-args -mno-red-zone -Wno-address -mcmodel=small -fpie -fno-asynchronous-unwind-tables -Wno-address -fno-omit-frame-pointer
|
DEFINE GCC48_X64_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) -m64 -fno-stack-protector "-DEFIAPI=__attribute__((ms_abi))" -maccumulate-outgoing-args -mno-red-zone -Wno-address -mcmodel=small -fpie -fno-asynchronous-unwind-tables -Wno-address -fno-omit-frame-pointer
|
||||||
DEFINE GCC48_IA32_X64_ASLDLINK_FLAGS = DEF(GCC48_IA32_X64_DLINK_COMMON) -Wl,--entry,ReferenceAcpiTable -u ReferenceAcpiTable
|
DEFINE GCC48_IA32_X64_ASLDLINK_FLAGS = DEF(GCC48_IA32_X64_DLINK_COMMON) -Wl,--entry,ReferenceAcpiTable -u ReferenceAcpiTable
|
||||||
DEFINE GCC48_IA32_X64_DLINK_FLAGS = DEF(GCC48_IA32_X64_DLINK_COMMON) -Wl,--entry,$(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT) -Wl,-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map,--whole-archive
|
DEFINE GCC48_IA32_X64_DLINK_FLAGS = DEF(GCC48_IA32_X64_DLINK_COMMON) -Wl,--entry,$(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT) -Wl,-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map,--whole-archive
|
||||||
DEFINE GCC48_IA32_DLINK2_FLAGS = -Wl,--defsym=PECOFF_HEADER_SIZE=0x220 DEF(GCC_DLINK2_FLAGS_COMMON)
|
DEFINE GCC48_IA32_DLINK2_FLAGS = DEF(GCC_DLINK2_FLAGS_COMMON)
|
||||||
DEFINE GCC48_X64_DLINK_FLAGS = DEF(GCC48_IA32_X64_DLINK_FLAGS) -Wl,-melf_x86_64,--oformat=elf64-x86-64,-pie
|
DEFINE GCC48_X64_DLINK_FLAGS = DEF(GCC48_IA32_X64_DLINK_FLAGS) -Wl,-melf_x86_64,--oformat=elf64-x86-64,-pie
|
||||||
DEFINE GCC48_X64_DLINK2_FLAGS = -Wl,--defsym=PECOFF_HEADER_SIZE=0x228 DEF(GCC_DLINK2_FLAGS_COMMON)
|
DEFINE GCC48_X64_DLINK2_FLAGS = DEF(GCC_DLINK2_FLAGS_COMMON)
|
||||||
DEFINE GCC48_ASM_FLAGS = DEF(GCC_ASM_FLAGS)
|
DEFINE GCC48_ASM_FLAGS = DEF(GCC_ASM_FLAGS)
|
||||||
DEFINE GCC48_ARM_ASM_FLAGS = $(PLATFORM_FLAGS) DEF(GCC_ASM_FLAGS) -mlittle-endian
|
DEFINE GCC48_ARM_ASM_FLAGS = DEF(GCC_ASM_FLAGS) -mlittle-endian -march=armv7-a
|
||||||
DEFINE GCC48_AARCH64_ASM_FLAGS = $(PLATFORM_FLAGS) DEF(GCC_ASM_FLAGS) -mlittle-endian
|
DEFINE GCC48_AARCH64_ASM_FLAGS = DEF(GCC_ASM_FLAGS) -mlittle-endian
|
||||||
DEFINE GCC48_ARM_CC_FLAGS = $(PLATFORM_FLAGS) DEF(GCC_ARM_CC_FLAGS) -fstack-protector -mword-relocations
|
DEFINE GCC48_ARM_CC_FLAGS = DEF(GCC_ARM_CC_FLAGS) -fstack-protector -mword-relocations
|
||||||
DEFINE GCC48_ARM_CC_XIPFLAGS = DEF(GCC_ARM_CC_XIPFLAGS)
|
DEFINE GCC48_ARM_CC_XIPFLAGS = DEF(GCC_ARM_CC_XIPFLAGS)
|
||||||
DEFINE GCC48_AARCH64_CC_FLAGS = $(PLATFORM_FLAGS) -mcmodel=large DEF(GCC_AARCH64_CC_FLAGS)
|
DEFINE GCC48_AARCH64_CC_FLAGS = -mcmodel=large DEF(GCC_AARCH64_CC_FLAGS)
|
||||||
DEFINE GCC48_AARCH64_CC_XIPFLAGS = DEF(GCC_AARCH64_CC_XIPFLAGS)
|
DEFINE GCC48_AARCH64_CC_XIPFLAGS = DEF(GCC_AARCH64_CC_XIPFLAGS)
|
||||||
DEFINE GCC48_ARM_DLINK_FLAGS = DEF(GCC_ARM_DLINK_FLAGS) -Wl,--oformat=elf32-littlearm
|
DEFINE GCC48_ARM_DLINK_FLAGS = DEF(GCC_ARM_DLINK_FLAGS) -Wl,--oformat=elf32-littlearm
|
||||||
DEFINE GCC48_ARM_DLINK2_FLAGS = DEF(GCC_DLINK2_FLAGS_COMMON) -Wl,--defsym=PECOFF_HEADER_SIZE=0x220
|
DEFINE GCC48_ARM_DLINK2_FLAGS = DEF(GCC_DLINK2_FLAGS_COMMON)
|
||||||
DEFINE GCC48_AARCH64_DLINK_FLAGS = DEF(GCC_AARCH64_DLINK_FLAGS)
|
DEFINE GCC48_AARCH64_DLINK_FLAGS = DEF(GCC_AARCH64_DLINK_FLAGS)
|
||||||
DEFINE GCC48_AARCH64_DLINK2_FLAGS = DEF(GCC_DLINK2_FLAGS_COMMON) -Wl,--defsym=PECOFF_HEADER_SIZE=0x228
|
DEFINE GCC48_AARCH64_DLINK2_FLAGS = DEF(GCC_DLINK2_FLAGS_COMMON)
|
||||||
DEFINE GCC48_ARM_ASLDLINK_FLAGS = DEF(GCC_ARM_ASLDLINK_FLAGS) -Wl,--oformat=elf32-littlearm
|
DEFINE GCC48_ARM_ASLDLINK_FLAGS = DEF(GCC_ARM_ASLDLINK_FLAGS) -Wl,--oformat=elf32-littlearm
|
||||||
DEFINE GCC48_AARCH64_ASLDLINK_FLAGS = DEF(GCC_AARCH64_ASLDLINK_FLAGS)
|
DEFINE GCC48_AARCH64_ASLDLINK_FLAGS = DEF(GCC_AARCH64_ASLDLINK_FLAGS)
|
||||||
DEFINE GCC48_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS)
|
DEFINE GCC48_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS)
|
||||||
|
|
||||||
DEFINE GCC49_IA32_CC_FLAGS = DEF(GCC48_IA32_CC_FLAGS) -fno-pic -fno-pie
|
DEFINE GCC49_IA32_CC_FLAGS = DEF(GCC48_IA32_CC_FLAGS) -fno-pic -fno-pie
|
||||||
DEFINE GCC49_X64_CC_FLAGS = DEF(GCC48_X64_CC_FLAGS)
|
DEFINE GCC49_X64_CC_FLAGS = DEF(GCC48_X64_CC_FLAGS)
|
||||||
DEFINE GCC49_IA32_X64_DLINK_COMMON = -nostdlib -Wl,-n,-q,--gc-sections -z common-page-size=0x40
|
DEFINE GCC49_IA32_X64_DLINK_COMMON = -nostdlib -Wl,-n,-q,--gc-sections DEF(GCC_ALIGN)
|
||||||
DEFINE GCC49_IA32_X64_ASLDLINK_FLAGS = DEF(GCC49_IA32_X64_DLINK_COMMON) -Wl,--defsym=PECOFF_HEADER_SIZE=0 DEF(GCC_DLINK2_FLAGS_COMMON) -Wl,--entry,ReferenceAcpiTable -u ReferenceAcpiTable
|
DEFINE GCC49_IA32_X64_ASLDLINK_FLAGS = DEF(GCC49_IA32_X64_DLINK_COMMON) DEF(GCC_DLINK2_FLAGS_COMMON) -Wl,--entry,ReferenceAcpiTable -u ReferenceAcpiTable
|
||||||
DEFINE GCC49_IA32_X64_DLINK_FLAGS = DEF(GCC49_IA32_X64_DLINK_COMMON) -Wl,--entry,$(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT) -Wl,-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map,--whole-archive
|
DEFINE GCC49_IA32_X64_DLINK_FLAGS = DEF(GCC49_IA32_X64_DLINK_COMMON) -Wl,--entry,$(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT) -Wl,-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map,--whole-archive
|
||||||
DEFINE GCC49_IA32_DLINK2_FLAGS = DEF(GCC48_IA32_DLINK2_FLAGS)
|
DEFINE GCC49_IA32_DLINK2_FLAGS = DEF(GCC48_IA32_DLINK2_FLAGS)
|
||||||
DEFINE GCC49_X64_DLINK_FLAGS = DEF(GCC49_IA32_X64_DLINK_FLAGS) -Wl,-melf_x86_64,--oformat=elf64-x86-64,-pie
|
DEFINE GCC49_X64_DLINK_FLAGS = DEF(GCC49_IA32_X64_DLINK_FLAGS) -Wl,-melf_x86_64,--oformat=elf64-x86-64,-pie
|
||||||
|
@ -815,11 +827,11 @@ DEFINE GCC49_ARM_ASM_FLAGS = DEF(GCC48_ARM_ASM_FLAGS)
|
||||||
DEFINE GCC49_AARCH64_ASM_FLAGS = DEF(GCC48_AARCH64_ASM_FLAGS)
|
DEFINE GCC49_AARCH64_ASM_FLAGS = DEF(GCC48_AARCH64_ASM_FLAGS)
|
||||||
DEFINE GCC49_ARM_CC_FLAGS = DEF(GCC48_ARM_CC_FLAGS)
|
DEFINE GCC49_ARM_CC_FLAGS = DEF(GCC48_ARM_CC_FLAGS)
|
||||||
DEFINE GCC49_ARM_CC_XIPFLAGS = DEF(GCC48_ARM_CC_XIPFLAGS)
|
DEFINE GCC49_ARM_CC_XIPFLAGS = DEF(GCC48_ARM_CC_XIPFLAGS)
|
||||||
DEFINE GCC49_AARCH64_CC_FLAGS = $(PLATFORM_FLAGS) DEF(GCC48_ALL_CC_FLAGS) DEF(GCC_AARCH64_CC_FLAGS) -mcmodel=small
|
DEFINE GCC49_AARCH64_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) DEF(GCC_AARCH64_CC_FLAGS) -mcmodel=small
|
||||||
DEFINE GCC49_AARCH64_CC_XIPFLAGS = DEF(GCC48_AARCH64_CC_XIPFLAGS)
|
DEFINE GCC49_AARCH64_CC_XIPFLAGS = DEF(GCC48_AARCH64_CC_XIPFLAGS)
|
||||||
DEFINE GCC49_ARM_DLINK_FLAGS = DEF(GCC48_ARM_DLINK_FLAGS)
|
DEFINE GCC49_ARM_DLINK_FLAGS = DEF(GCC48_ARM_DLINK_FLAGS)
|
||||||
DEFINE GCC49_ARM_DLINK2_FLAGS = DEF(GCC48_ARM_DLINK2_FLAGS)
|
DEFINE GCC49_ARM_DLINK2_FLAGS = DEF(GCC48_ARM_DLINK2_FLAGS)
|
||||||
DEFINE GCC49_AARCH64_DLINK_FLAGS = DEF(GCC48_AARCH64_DLINK_FLAGS) -z common-page-size=0x1000
|
DEFINE GCC49_AARCH64_DLINK_FLAGS = DEF(GCC48_AARCH64_DLINK_FLAGS) DEF(GCC_ALIGN)
|
||||||
DEFINE GCC49_AARCH64_DLINK2_FLAGS = DEF(GCC48_AARCH64_DLINK2_FLAGS)
|
DEFINE GCC49_AARCH64_DLINK2_FLAGS = DEF(GCC48_AARCH64_DLINK2_FLAGS)
|
||||||
DEFINE GCC49_ARM_ASLDLINK_FLAGS = DEF(GCC48_ARM_ASLDLINK_FLAGS)
|
DEFINE GCC49_ARM_ASLDLINK_FLAGS = DEF(GCC48_ARM_ASLDLINK_FLAGS)
|
||||||
DEFINE GCC49_AARCH64_ASLDLINK_FLAGS = DEF(GCC48_AARCH64_ASLDLINK_FLAGS)
|
DEFINE GCC49_AARCH64_ASLDLINK_FLAGS = DEF(GCC48_AARCH64_ASLDLINK_FLAGS)
|
||||||
|
@ -849,9 +861,9 @@ DEFINE GCC5_AARCH64_ASLDLINK_FLAGS = DEF(GCC49_AARCH64_ASLDLINK_FLAGS)
|
||||||
DEFINE GCC5_ASLCC_FLAGS = DEF(GCC49_ASLCC_FLAGS) -fno-lto
|
DEFINE GCC5_ASLCC_FLAGS = DEF(GCC49_ASLCC_FLAGS) -fno-lto
|
||||||
|
|
||||||
DEFINE GCC5_RISCV_ALL_CC_FLAGS = -g -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-array-bounds -ffunction-sections -fdata-sections -include AutoGen.h -fno-common -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings -msmall-data-limit=0
|
DEFINE GCC5_RISCV_ALL_CC_FLAGS = -g -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-array-bounds -ffunction-sections -fdata-sections -include AutoGen.h -fno-common -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings -msmall-data-limit=0
|
||||||
DEFINE GCC5_RISCV_ALL_DLINK_COMMON = -nostdlib -Wl,-n,-q,--gc-sections -z common-page-size=0x40
|
DEFINE GCC5_RISCV_ALL_DLINK_COMMON = -nostdlib -Wl,-n,-q,--gc-sections DEF(GCC_ALIGN)
|
||||||
DEFINE GCC5_RISCV_ALL_DLINK_FLAGS = DEF(GCC5_RISCV_ALL_DLINK_COMMON) -Wl,--entry,$(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT) -Wl,-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map
|
DEFINE GCC5_RISCV_ALL_DLINK_FLAGS = DEF(GCC5_RISCV_ALL_DLINK_COMMON) -Wl,--entry,$(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT) -Wl,-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map
|
||||||
DEFINE GCC5_RISCV_ALL_DLINK2_FLAGS = -Wl,--defsym=PECOFF_HEADER_SIZE=0x220,--script=$(EDK_TOOLS_PATH)/Scripts/GccBase.lds
|
DEFINE GCC5_RISCV_ALL_DLINK2_FLAGS = -Wl,--defsym=ALIGNED_PE_HEADER_SIZE=0x400 DEF(DLINK_SCRIPT)
|
||||||
DEFINE GCC5_RISCV_ALL_ASM_FLAGS = -c -x assembler -imacros $(DEST_DIR_DEBUG)/AutoGen.h
|
DEFINE GCC5_RISCV_ALL_ASM_FLAGS = -c -x assembler -imacros $(DEST_DIR_DEBUG)/AutoGen.h
|
||||||
DEFINE GCC5_RISCV_ALL_CC_FLAGS_WARNING_DISABLE = -Wno-tautological-compare -Wno-pointer-compare
|
DEFINE GCC5_RISCV_ALL_CC_FLAGS_WARNING_DISABLE = -Wno-tautological-compare -Wno-pointer-compare
|
||||||
|
|
||||||
|
@ -866,7 +878,7 @@ DEFINE GCC5_RISCV64_ASM_FLAGS = DEF(GCC5_RISCV_ALL_ASM_FLAGS) -marc
|
||||||
|
|
||||||
DEFINE GCC5_LOONGARCH64_CC_FLAGS = DEF(GCC_LOONGARCH64_CC_FLAGS) -march=loongarch64 -mno-memcpy -Werror -Wno-maybe-uninitialized -Wno-stringop-overflow -Wno-pointer-to-int-cast -no-pie -fno-stack-protector -mno-explicit-relocs
|
DEFINE GCC5_LOONGARCH64_CC_FLAGS = DEF(GCC_LOONGARCH64_CC_FLAGS) -march=loongarch64 -mno-memcpy -Werror -Wno-maybe-uninitialized -Wno-stringop-overflow -Wno-pointer-to-int-cast -no-pie -fno-stack-protector -mno-explicit-relocs
|
||||||
DEFINE GCC5_LOONGARCH64_DLINK_FLAGS = DEF(GCC_LOONGARCH64_DLINK_FLAGS)
|
DEFINE GCC5_LOONGARCH64_DLINK_FLAGS = DEF(GCC_LOONGARCH64_DLINK_FLAGS)
|
||||||
DEFINE GCC5_LOONGARCH64_DLINK2_FLAGS = DEF(GCC_DLINK2_FLAGS_COMMON) -Wl,--defsym=PECOFF_HEADER_SIZE=0x228
|
DEFINE GCC5_LOONGARCH64_DLINK2_FLAGS = DEF(GCC_DLINK2_FLAGS_COMMON)
|
||||||
DEFINE GCC5_LOONGARCH64_ASLDLINK_FLAGS = DEF(GCC_LOONGARCH64_ASLDLINK_FLAGS) DEF(GCC5_LOONGARCH64_DLINK2_FLAGS)
|
DEFINE GCC5_LOONGARCH64_ASLDLINK_FLAGS = DEF(GCC_LOONGARCH64_ASLDLINK_FLAGS) DEF(GCC5_LOONGARCH64_DLINK2_FLAGS)
|
||||||
DEFINE GCC5_LOONGARCH64_ASM_FLAGS = -x assembler-with-cpp -mabi=lp64d -march=loongarch64 -fno-builtin -c -Wall -mno-explicit-relocs
|
DEFINE GCC5_LOONGARCH64_ASM_FLAGS = -x assembler-with-cpp -mabi=lp64d -march=loongarch64 -fno-builtin -c -Wall -mno-explicit-relocs
|
||||||
DEFINE GCC5_LOONGARCH64_PP_FLAGS = -mabi=lp64d -march=loongarch64 DEF(GCC_PP_FLAGS)
|
DEFINE GCC5_LOONGARCH64_PP_FLAGS = -mabi=lp64d -march=loongarch64 DEF(GCC_PP_FLAGS)
|
||||||
|
@ -913,8 +925,7 @@ DEFINE GCC5_LOONGARCH64_PP_FLAGS = -mabi=lp64d -march=loongarch64 DEF(
|
||||||
*_GCC48_IA32_DLINK_FLAGS = DEF(GCC48_IA32_X64_DLINK_FLAGS) -Wl,-m,elf_i386,--oformat=elf32-i386
|
*_GCC48_IA32_DLINK_FLAGS = DEF(GCC48_IA32_X64_DLINK_FLAGS) -Wl,-m,elf_i386,--oformat=elf32-i386
|
||||||
*_GCC48_IA32_DLINK2_FLAGS = DEF(GCC48_IA32_DLINK2_FLAGS)
|
*_GCC48_IA32_DLINK2_FLAGS = DEF(GCC48_IA32_DLINK2_FLAGS)
|
||||||
*_GCC48_IA32_RC_FLAGS = DEF(GCC_IA32_RC_FLAGS)
|
*_GCC48_IA32_RC_FLAGS = DEF(GCC_IA32_RC_FLAGS)
|
||||||
*_GCC48_IA32_OBJCOPY_FLAGS =
|
*_GCC48_IA32_NASM_FLAGS = -f elf32 -DRODATA_SECTION_NAME=.rodata
|
||||||
*_GCC48_IA32_NASM_FLAGS = -f elf32
|
|
||||||
|
|
||||||
DEBUG_GCC48_IA32_CC_FLAGS = DEF(GCC48_IA32_CC_FLAGS)
|
DEBUG_GCC48_IA32_CC_FLAGS = DEF(GCC48_IA32_CC_FLAGS)
|
||||||
RELEASE_GCC48_IA32_CC_FLAGS = DEF(GCC48_IA32_CC_FLAGS) -Wno-unused-but-set-variable
|
RELEASE_GCC48_IA32_CC_FLAGS = DEF(GCC48_IA32_CC_FLAGS) -Wno-unused-but-set-variable
|
||||||
|
@ -941,8 +952,7 @@ RELEASE_GCC48_IA32_CC_FLAGS = DEF(GCC48_IA32_CC_FLAGS) -Wno-unused-but-set
|
||||||
*_GCC48_X64_DLINK_FLAGS = DEF(GCC48_X64_DLINK_FLAGS)
|
*_GCC48_X64_DLINK_FLAGS = DEF(GCC48_X64_DLINK_FLAGS)
|
||||||
*_GCC48_X64_DLINK2_FLAGS = DEF(GCC48_X64_DLINK2_FLAGS)
|
*_GCC48_X64_DLINK2_FLAGS = DEF(GCC48_X64_DLINK2_FLAGS)
|
||||||
*_GCC48_X64_RC_FLAGS = DEF(GCC_X64_RC_FLAGS)
|
*_GCC48_X64_RC_FLAGS = DEF(GCC_X64_RC_FLAGS)
|
||||||
*_GCC48_X64_OBJCOPY_FLAGS =
|
*_GCC48_X64_NASM_FLAGS = -f elf64 -DRODATA_SECTION_NAME=.rodata
|
||||||
*_GCC48_X64_NASM_FLAGS = -f elf64
|
|
||||||
|
|
||||||
DEBUG_GCC48_X64_CC_FLAGS = DEF(GCC48_X64_CC_FLAGS)
|
DEBUG_GCC48_X64_CC_FLAGS = DEF(GCC48_X64_CC_FLAGS)
|
||||||
RELEASE_GCC48_X64_CC_FLAGS = DEF(GCC48_X64_CC_FLAGS) -Wno-unused-but-set-variable
|
RELEASE_GCC48_X64_CC_FLAGS = DEF(GCC48_X64_CC_FLAGS) -Wno-unused-but-set-variable
|
||||||
|
@ -968,10 +978,9 @@ RELEASE_GCC48_X64_CC_FLAGS = DEF(GCC48_X64_CC_FLAGS) -Wno-unused-but-set-v
|
||||||
*_GCC48_ARM_DLINK_FLAGS = DEF(GCC48_ARM_DLINK_FLAGS)
|
*_GCC48_ARM_DLINK_FLAGS = DEF(GCC48_ARM_DLINK_FLAGS)
|
||||||
*_GCC48_ARM_DLINK2_FLAGS = DEF(GCC48_ARM_DLINK2_FLAGS)
|
*_GCC48_ARM_DLINK2_FLAGS = DEF(GCC48_ARM_DLINK2_FLAGS)
|
||||||
*_GCC48_ARM_DTCPP_FLAGS = DEF(GCC_DTCPP_FLAGS)
|
*_GCC48_ARM_DTCPP_FLAGS = DEF(GCC_DTCPP_FLAGS)
|
||||||
*_GCC48_ARM_PLATFORM_FLAGS = -march=armv7-a
|
*_GCC48_ARM_PP_FLAGS = DEF(GCC_PP_FLAGS) -mthumb -march=armv7-a
|
||||||
*_GCC48_ARM_PP_FLAGS = $(PLATFORM_FLAGS) DEF(GCC_PP_FLAGS)
|
|
||||||
*_GCC48_ARM_RC_FLAGS = DEF(GCC_ARM_RC_FLAGS)
|
*_GCC48_ARM_RC_FLAGS = DEF(GCC_ARM_RC_FLAGS)
|
||||||
*_GCC48_ARM_VFRPP_FLAGS = $(PLATFORM_FLAGS) DEF(GCC_VFRPP_FLAGS)
|
*_GCC48_ARM_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS) -mthumb -march=armv7-a
|
||||||
*_GCC48_ARM_CC_XIPFLAGS = DEF(GCC48_ARM_CC_XIPFLAGS)
|
*_GCC48_ARM_CC_XIPFLAGS = DEF(GCC48_ARM_CC_XIPFLAGS)
|
||||||
|
|
||||||
DEBUG_GCC48_ARM_CC_FLAGS = DEF(GCC48_ARM_CC_FLAGS) -O0
|
DEBUG_GCC48_ARM_CC_FLAGS = DEF(GCC48_ARM_CC_FLAGS) -O0
|
||||||
|
@ -998,10 +1007,9 @@ RELEASE_GCC48_ARM_CC_FLAGS = DEF(GCC48_ARM_CC_FLAGS) -Wno-unused-but-set-v
|
||||||
*_GCC48_AARCH64_DLINK_FLAGS = DEF(GCC48_AARCH64_DLINK_FLAGS)
|
*_GCC48_AARCH64_DLINK_FLAGS = DEF(GCC48_AARCH64_DLINK_FLAGS)
|
||||||
*_GCC48_AARCH64_DLINK2_FLAGS = DEF(GCC48_AARCH64_DLINK2_FLAGS)
|
*_GCC48_AARCH64_DLINK2_FLAGS = DEF(GCC48_AARCH64_DLINK2_FLAGS)
|
||||||
*_GCC48_AARCH64_DTCPP_FLAGS = DEF(GCC_DTCPP_FLAGS)
|
*_GCC48_AARCH64_DTCPP_FLAGS = DEF(GCC_DTCPP_FLAGS)
|
||||||
*_GCC48_AARCH64_PLATFORM_FLAGS =
|
*_GCC48_AARCH64_PP_FLAGS = DEF(GCC_PP_FLAGS)
|
||||||
*_GCC48_AARCH64_PP_FLAGS = $(PLATFORM_FLAGS) DEF(GCC_PP_FLAGS)
|
|
||||||
*_GCC48_AARCH64_RC_FLAGS = DEF(GCC_AARCH64_RC_FLAGS)
|
*_GCC48_AARCH64_RC_FLAGS = DEF(GCC_AARCH64_RC_FLAGS)
|
||||||
*_GCC48_AARCH64_VFRPP_FLAGS = $(PLATFORM_FLAGS) DEF(GCC_VFRPP_FLAGS)
|
*_GCC48_AARCH64_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS)
|
||||||
*_GCC48_AARCH64_CC_XIPFLAGS = DEF(GCC48_AARCH64_CC_XIPFLAGS)
|
*_GCC48_AARCH64_CC_XIPFLAGS = DEF(GCC48_AARCH64_CC_XIPFLAGS)
|
||||||
|
|
||||||
DEBUG_GCC48_AARCH64_CC_FLAGS = DEF(GCC48_AARCH64_CC_FLAGS) -O0
|
DEBUG_GCC48_AARCH64_CC_FLAGS = DEF(GCC48_AARCH64_CC_FLAGS) -O0
|
||||||
|
@ -1050,8 +1058,7 @@ RELEASE_GCC48_AARCH64_CC_FLAGS = DEF(GCC48_AARCH64_CC_FLAGS) -Wno-unused-but-s
|
||||||
*_GCC49_IA32_DLINK_FLAGS = DEF(GCC49_IA32_X64_DLINK_FLAGS) -Wl,-m,elf_i386,--oformat=elf32-i386
|
*_GCC49_IA32_DLINK_FLAGS = DEF(GCC49_IA32_X64_DLINK_FLAGS) -Wl,-m,elf_i386,--oformat=elf32-i386
|
||||||
*_GCC49_IA32_DLINK2_FLAGS = DEF(GCC49_IA32_DLINK2_FLAGS)
|
*_GCC49_IA32_DLINK2_FLAGS = DEF(GCC49_IA32_DLINK2_FLAGS)
|
||||||
*_GCC49_IA32_RC_FLAGS = DEF(GCC_IA32_RC_FLAGS)
|
*_GCC49_IA32_RC_FLAGS = DEF(GCC_IA32_RC_FLAGS)
|
||||||
*_GCC49_IA32_OBJCOPY_FLAGS =
|
*_GCC49_IA32_NASM_FLAGS = -f elf32 -DRODATA_SECTION_NAME=.rodata
|
||||||
*_GCC49_IA32_NASM_FLAGS = -f elf32
|
|
||||||
|
|
||||||
DEBUG_GCC49_IA32_CC_FLAGS = DEF(GCC49_IA32_CC_FLAGS)
|
DEBUG_GCC49_IA32_CC_FLAGS = DEF(GCC49_IA32_CC_FLAGS)
|
||||||
RELEASE_GCC49_IA32_CC_FLAGS = DEF(GCC49_IA32_CC_FLAGS) -Wno-unused-but-set-variable -Wno-unused-const-variable
|
RELEASE_GCC49_IA32_CC_FLAGS = DEF(GCC49_IA32_CC_FLAGS) -Wno-unused-but-set-variable -Wno-unused-const-variable
|
||||||
|
@ -1078,8 +1085,7 @@ RELEASE_GCC49_IA32_CC_FLAGS = DEF(GCC49_IA32_CC_FLAGS) -Wno-unused-but-set
|
||||||
*_GCC49_X64_DLINK_FLAGS = DEF(GCC49_X64_DLINK_FLAGS)
|
*_GCC49_X64_DLINK_FLAGS = DEF(GCC49_X64_DLINK_FLAGS)
|
||||||
*_GCC49_X64_DLINK2_FLAGS = DEF(GCC49_X64_DLINK2_FLAGS)
|
*_GCC49_X64_DLINK2_FLAGS = DEF(GCC49_X64_DLINK2_FLAGS)
|
||||||
*_GCC49_X64_RC_FLAGS = DEF(GCC_X64_RC_FLAGS)
|
*_GCC49_X64_RC_FLAGS = DEF(GCC_X64_RC_FLAGS)
|
||||||
*_GCC49_X64_OBJCOPY_FLAGS =
|
*_GCC49_X64_NASM_FLAGS = -f elf64 -DRODATA_SECTION_NAME=.rodata
|
||||||
*_GCC49_X64_NASM_FLAGS = -f elf64
|
|
||||||
|
|
||||||
DEBUG_GCC49_X64_CC_FLAGS = DEF(GCC49_X64_CC_FLAGS)
|
DEBUG_GCC49_X64_CC_FLAGS = DEF(GCC49_X64_CC_FLAGS)
|
||||||
RELEASE_GCC49_X64_CC_FLAGS = DEF(GCC49_X64_CC_FLAGS) -Wno-unused-but-set-variable -Wno-unused-const-variable
|
RELEASE_GCC49_X64_CC_FLAGS = DEF(GCC49_X64_CC_FLAGS) -Wno-unused-but-set-variable -Wno-unused-const-variable
|
||||||
|
@ -1105,10 +1111,9 @@ RELEASE_GCC49_X64_CC_FLAGS = DEF(GCC49_X64_CC_FLAGS) -Wno-unused-but-set-v
|
||||||
*_GCC49_ARM_DLINK_FLAGS = DEF(GCC49_ARM_DLINK_FLAGS)
|
*_GCC49_ARM_DLINK_FLAGS = DEF(GCC49_ARM_DLINK_FLAGS)
|
||||||
*_GCC49_ARM_DLINK2_FLAGS = DEF(GCC49_ARM_DLINK2_FLAGS)
|
*_GCC49_ARM_DLINK2_FLAGS = DEF(GCC49_ARM_DLINK2_FLAGS)
|
||||||
*_GCC49_ARM_DTCPP_FLAGS = DEF(GCC_DTCPP_FLAGS)
|
*_GCC49_ARM_DTCPP_FLAGS = DEF(GCC_DTCPP_FLAGS)
|
||||||
*_GCC49_ARM_PLATFORM_FLAGS = -march=armv7-a
|
*_GCC49_ARM_PP_FLAGS = DEF(GCC_PP_FLAGS) -mthumb -march=armv7-a
|
||||||
*_GCC49_ARM_PP_FLAGS = $(PLATFORM_FLAGS) DEF(GCC_PP_FLAGS)
|
|
||||||
*_GCC49_ARM_RC_FLAGS = DEF(GCC_ARM_RC_FLAGS)
|
*_GCC49_ARM_RC_FLAGS = DEF(GCC_ARM_RC_FLAGS)
|
||||||
*_GCC49_ARM_VFRPP_FLAGS = $(PLATFORM_FLAGS) DEF(GCC_VFRPP_FLAGS)
|
*_GCC49_ARM_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS) -mthumb -march=armv7-a
|
||||||
*_GCC49_ARM_CC_XIPFLAGS = DEF(GCC49_ARM_CC_XIPFLAGS)
|
*_GCC49_ARM_CC_XIPFLAGS = DEF(GCC49_ARM_CC_XIPFLAGS)
|
||||||
|
|
||||||
DEBUG_GCC49_ARM_CC_FLAGS = DEF(GCC49_ARM_CC_FLAGS) -O0
|
DEBUG_GCC49_ARM_CC_FLAGS = DEF(GCC49_ARM_CC_FLAGS) -O0
|
||||||
|
@ -1134,23 +1139,22 @@ RELEASE_GCC49_ARM_CC_FLAGS = DEF(GCC49_ARM_CC_FLAGS) -Wno-unused-but-set-v
|
||||||
*_GCC49_AARCH64_ASM_FLAGS = DEF(GCC49_AARCH64_ASM_FLAGS)
|
*_GCC49_AARCH64_ASM_FLAGS = DEF(GCC49_AARCH64_ASM_FLAGS)
|
||||||
*_GCC49_AARCH64_DLINK2_FLAGS = DEF(GCC49_AARCH64_DLINK2_FLAGS)
|
*_GCC49_AARCH64_DLINK2_FLAGS = DEF(GCC49_AARCH64_DLINK2_FLAGS)
|
||||||
*_GCC49_AARCH64_DTCPP_FLAGS = DEF(GCC_DTCPP_FLAGS)
|
*_GCC49_AARCH64_DTCPP_FLAGS = DEF(GCC_DTCPP_FLAGS)
|
||||||
*_GCC49_AARCH64_PLATFORM_FLAGS =
|
*_GCC49_AARCH64_PP_FLAGS = DEF(GCC_PP_FLAGS)
|
||||||
*_GCC49_AARCH64_PP_FLAGS = $(PLATFORM_FLAGS) DEF(GCC_PP_FLAGS)
|
|
||||||
*_GCC49_AARCH64_RC_FLAGS = DEF(GCC_AARCH64_RC_FLAGS)
|
*_GCC49_AARCH64_RC_FLAGS = DEF(GCC_AARCH64_RC_FLAGS)
|
||||||
*_GCC49_AARCH64_VFRPP_FLAGS = $(PLATFORM_FLAGS) DEF(GCC_VFRPP_FLAGS)
|
*_GCC49_AARCH64_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS)
|
||||||
*_GCC49_AARCH64_CC_XIPFLAGS = DEF(GCC49_AARCH64_CC_XIPFLAGS)
|
*_GCC49_AARCH64_CC_XIPFLAGS = DEF(GCC49_AARCH64_CC_XIPFLAGS)
|
||||||
|
|
||||||
DEBUG_GCC49_AARCH64_CC_FLAGS = DEF(GCC49_AARCH64_CC_FLAGS) -O0
|
DEBUG_GCC49_AARCH64_CC_FLAGS = DEF(GCC49_AARCH64_CC_FLAGS) -O0
|
||||||
DEBUG_GCC49_AARCH64_DLINK_FLAGS = DEF(GCC49_AARCH64_DLINK_FLAGS)
|
DEBUG_GCC49_AARCH64_DLINK_FLAGS = DEF(GCC49_AARCH64_DLINK_FLAGS)
|
||||||
DEBUG_GCC49_AARCH64_DLINK_XIPFLAGS = -z common-page-size=0x20
|
DEBUG_GCC49_AARCH64_DLINK_XIPFLAGS = DEF(GCC_ALIGN)
|
||||||
|
|
||||||
RELEASE_GCC49_AARCH64_CC_FLAGS = DEF(GCC49_AARCH64_CC_FLAGS) -Wno-unused-but-set-variable -Wno-unused-const-variable
|
RELEASE_GCC49_AARCH64_CC_FLAGS = DEF(GCC49_AARCH64_CC_FLAGS) -Wno-unused-but-set-variable -Wno-unused-const-variable
|
||||||
RELEASE_GCC49_AARCH64_DLINK_FLAGS = DEF(GCC49_AARCH64_DLINK_FLAGS)
|
RELEASE_GCC49_AARCH64_DLINK_FLAGS = DEF(GCC49_AARCH64_DLINK_FLAGS)
|
||||||
RELEASE_GCC49_AARCH64_DLINK_XIPFLAGS = -z common-page-size=0x20
|
RELEASE_GCC49_AARCH64_DLINK_XIPFLAGS = DEF(GCC_ALIGN)
|
||||||
|
|
||||||
NOOPT_GCC49_AARCH64_CC_FLAGS = DEF(GCC49_AARCH64_CC_FLAGS) -O0
|
NOOPT_GCC49_AARCH64_CC_FLAGS = DEF(GCC49_AARCH64_CC_FLAGS) -O0
|
||||||
NOOPT_GCC49_AARCH64_DLINK_FLAGS = DEF(GCC49_AARCH64_DLINK_FLAGS) -O0
|
NOOPT_GCC49_AARCH64_DLINK_FLAGS = DEF(GCC49_AARCH64_DLINK_FLAGS) -O0
|
||||||
NOOPT_GCC49_AARCH64_DLINK_XIPFLAGS = -z common-page-size=0x20 -O0
|
NOOPT_GCC49_AARCH64_DLINK_XIPFLAGS = DEF(GCC_ALIGN) -O0
|
||||||
|
|
||||||
####################################################################################
|
####################################################################################
|
||||||
#
|
#
|
||||||
|
@ -1336,9 +1340,7 @@ RELEASE_GCCNOLTO_AARCH64_DLINK_XIPFLAGS = -z common-page-size=0x20
|
||||||
*_GCC5_IA32_ASLDLINK_FLAGS = DEF(GCC5_IA32_X64_ASLDLINK_FLAGS) -Wl,-m,elf_i386 -no-pie
|
*_GCC5_IA32_ASLDLINK_FLAGS = DEF(GCC5_IA32_X64_ASLDLINK_FLAGS) -Wl,-m,elf_i386 -no-pie
|
||||||
*_GCC5_IA32_ASM_FLAGS = DEF(GCC5_ASM_FLAGS) -m32 -march=i386
|
*_GCC5_IA32_ASM_FLAGS = DEF(GCC5_ASM_FLAGS) -m32 -march=i386
|
||||||
*_GCC5_IA32_DLINK2_FLAGS = DEF(GCC5_IA32_DLINK2_FLAGS) -no-pie
|
*_GCC5_IA32_DLINK2_FLAGS = DEF(GCC5_IA32_DLINK2_FLAGS) -no-pie
|
||||||
*_GCC5_IA32_RC_FLAGS = DEF(GCC_IA32_RC_FLAGS)
|
*_GCC5_IA32_NASM_FLAGS = -f elf32 -DRODATA_SECTION_NAME=.rodata
|
||||||
*_GCC5_IA32_OBJCOPY_FLAGS =
|
|
||||||
*_GCC5_IA32_NASM_FLAGS = -f elf32
|
|
||||||
|
|
||||||
DEBUG_GCC5_IA32_CC_FLAGS = DEF(GCC5_IA32_CC_FLAGS) -flto
|
DEBUG_GCC5_IA32_CC_FLAGS = DEF(GCC5_IA32_CC_FLAGS) -flto
|
||||||
DEBUG_GCC5_IA32_DLINK_FLAGS = DEF(GCC5_IA32_X64_DLINK_FLAGS) -flto -Os -Wl,-m,elf_i386,--oformat=elf32-i386
|
DEBUG_GCC5_IA32_DLINK_FLAGS = DEF(GCC5_IA32_X64_DLINK_FLAGS) -flto -Os -Wl,-m,elf_i386,--oformat=elf32-i386
|
||||||
|
@ -1368,9 +1370,7 @@ RELEASE_GCC5_IA32_DLINK_FLAGS = DEF(GCC5_IA32_X64_DLINK_FLAGS) -flto -Os -Wl,
|
||||||
*_GCC5_X64_ASLDLINK_FLAGS = DEF(GCC5_IA32_X64_ASLDLINK_FLAGS) -Wl,-m,elf_x86_64
|
*_GCC5_X64_ASLDLINK_FLAGS = DEF(GCC5_IA32_X64_ASLDLINK_FLAGS) -Wl,-m,elf_x86_64
|
||||||
*_GCC5_X64_ASM_FLAGS = DEF(GCC5_ASM_FLAGS) -m64
|
*_GCC5_X64_ASM_FLAGS = DEF(GCC5_ASM_FLAGS) -m64
|
||||||
*_GCC5_X64_DLINK2_FLAGS = DEF(GCC5_X64_DLINK2_FLAGS)
|
*_GCC5_X64_DLINK2_FLAGS = DEF(GCC5_X64_DLINK2_FLAGS)
|
||||||
*_GCC5_X64_RC_FLAGS = DEF(GCC_X64_RC_FLAGS)
|
*_GCC5_X64_NASM_FLAGS = -f elf64 -DRODATA_SECTION_NAME=.rodata
|
||||||
*_GCC5_X64_OBJCOPY_FLAGS =
|
|
||||||
*_GCC5_X64_NASM_FLAGS = -f elf64
|
|
||||||
|
|
||||||
DEBUG_GCC5_X64_CC_FLAGS = DEF(GCC5_X64_CC_FLAGS) -flto -DUSING_LTO
|
DEBUG_GCC5_X64_CC_FLAGS = DEF(GCC5_X64_CC_FLAGS) -flto -DUSING_LTO
|
||||||
DEBUG_GCC5_X64_DLINK_FLAGS = DEF(GCC5_X64_DLINK_FLAGS) -flto -Os
|
DEBUG_GCC5_X64_DLINK_FLAGS = DEF(GCC5_X64_DLINK_FLAGS) -flto -Os
|
||||||
|
@ -1384,6 +1384,7 @@ RELEASE_GCC5_X64_DLINK_FLAGS = DEF(GCC5_X64_DLINK_FLAGS) -flto -Os
|
||||||
##################
|
##################
|
||||||
# GCC5 ARM definitions
|
# GCC5 ARM definitions
|
||||||
##################
|
##################
|
||||||
|
*_GCC5_ARM_OBJCOPY_PATH = ENV(GCC5_ARM_PREFIX)objcopy
|
||||||
*_GCC5_ARM_CC_PATH = ENV(GCC5_ARM_PREFIX)gcc
|
*_GCC5_ARM_CC_PATH = ENV(GCC5_ARM_PREFIX)gcc
|
||||||
*_GCC5_ARM_SLINK_PATH = ENV(GCC5_ARM_PREFIX)gcc-ar
|
*_GCC5_ARM_SLINK_PATH = ENV(GCC5_ARM_PREFIX)gcc-ar
|
||||||
*_GCC5_ARM_DLINK_PATH = ENV(GCC5_ARM_PREFIX)gcc
|
*_GCC5_ARM_DLINK_PATH = ENV(GCC5_ARM_PREFIX)gcc
|
||||||
|
@ -1400,10 +1401,8 @@ RELEASE_GCC5_X64_DLINK_FLAGS = DEF(GCC5_X64_DLINK_FLAGS) -flto -Os
|
||||||
*_GCC5_ARM_ASM_FLAGS = DEF(GCC5_ARM_ASM_FLAGS)
|
*_GCC5_ARM_ASM_FLAGS = DEF(GCC5_ARM_ASM_FLAGS)
|
||||||
*_GCC5_ARM_DLINK2_FLAGS = DEF(GCC5_ARM_DLINK2_FLAGS)
|
*_GCC5_ARM_DLINK2_FLAGS = DEF(GCC5_ARM_DLINK2_FLAGS)
|
||||||
*_GCC5_ARM_DTCPP_FLAGS = DEF(GCC_DTCPP_FLAGS)
|
*_GCC5_ARM_DTCPP_FLAGS = DEF(GCC_DTCPP_FLAGS)
|
||||||
*_GCC5_ARM_PLATFORM_FLAGS = -march=armv7-a -mfloat-abi=soft
|
*_GCC5_ARM_PP_FLAGS = DEF(GCC_PP_FLAGS) -mthumb -march=armv7-a
|
||||||
*_GCC5_ARM_PP_FLAGS = $(PLATFORM_FLAGS) DEF(GCC_PP_FLAGS)
|
*_GCC5_ARM_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS) -mthumb -march=armv7-a
|
||||||
*_GCC5_ARM_RC_FLAGS = DEF(GCC_ARM_RC_FLAGS)
|
|
||||||
*_GCC5_ARM_VFRPP_FLAGS = $(PLATFORM_FLAGS) DEF(GCC_VFRPP_FLAGS)
|
|
||||||
*_GCC5_ARM_CC_XIPFLAGS = DEF(GCC5_ARM_CC_XIPFLAGS)
|
*_GCC5_ARM_CC_XIPFLAGS = DEF(GCC5_ARM_CC_XIPFLAGS)
|
||||||
|
|
||||||
DEBUG_GCC5_ARM_CC_FLAGS = DEF(GCC5_ARM_CC_FLAGS) -flto -Wno-unused-but-set-variable -Wno-unused-const-variable
|
DEBUG_GCC5_ARM_CC_FLAGS = DEF(GCC5_ARM_CC_FLAGS) -flto -Wno-unused-but-set-variable -Wno-unused-const-variable
|
||||||
|
@ -1418,6 +1417,7 @@ RELEASE_GCC5_ARM_DLINK_FLAGS = DEF(GCC5_ARM_DLINK_FLAGS) -flto -Os -L$(WORKS
|
||||||
##################
|
##################
|
||||||
# GCC5 AARCH64 definitions
|
# GCC5 AARCH64 definitions
|
||||||
##################
|
##################
|
||||||
|
*_GCC5_AARCH64_OBJCOPY_PATH = ENV(GCC5_AARCH64_PREFIX)objcopy
|
||||||
*_GCC5_AARCH64_CC_PATH = ENV(GCC5_AARCH64_PREFIX)gcc
|
*_GCC5_AARCH64_CC_PATH = ENV(GCC5_AARCH64_PREFIX)gcc
|
||||||
*_GCC5_AARCH64_SLINK_PATH = ENV(GCC5_AARCH64_PREFIX)gcc-ar
|
*_GCC5_AARCH64_SLINK_PATH = ENV(GCC5_AARCH64_PREFIX)gcc-ar
|
||||||
*_GCC5_AARCH64_DLINK_PATH = ENV(GCC5_AARCH64_PREFIX)gcc
|
*_GCC5_AARCH64_DLINK_PATH = ENV(GCC5_AARCH64_PREFIX)gcc
|
||||||
|
@ -1434,23 +1434,21 @@ RELEASE_GCC5_ARM_DLINK_FLAGS = DEF(GCC5_ARM_DLINK_FLAGS) -flto -Os -L$(WORKS
|
||||||
*_GCC5_AARCH64_ASM_FLAGS = DEF(GCC5_AARCH64_ASM_FLAGS)
|
*_GCC5_AARCH64_ASM_FLAGS = DEF(GCC5_AARCH64_ASM_FLAGS)
|
||||||
*_GCC5_AARCH64_DLINK2_FLAGS = DEF(GCC5_AARCH64_DLINK2_FLAGS)
|
*_GCC5_AARCH64_DLINK2_FLAGS = DEF(GCC5_AARCH64_DLINK2_FLAGS)
|
||||||
*_GCC5_AARCH64_DTCPP_FLAGS = DEF(GCC_DTCPP_FLAGS)
|
*_GCC5_AARCH64_DTCPP_FLAGS = DEF(GCC_DTCPP_FLAGS)
|
||||||
*_GCC5_AARCH64_PLATFORM_FLAGS =
|
*_GCC5_AARCH64_PP_FLAGS = DEF(GCC_PP_FLAGS)
|
||||||
*_GCC5_AARCH64_PP_FLAGS = $(PLATFORM_FLAGS) DEF(GCC_PP_FLAGS)
|
*_GCC5_AARCH64_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS)
|
||||||
*_GCC5_AARCH64_RC_FLAGS = DEF(GCC_AARCH64_RC_FLAGS) DEF(GCC_AARCH64_RC_BTI_FLAGS)
|
|
||||||
*_GCC5_AARCH64_VFRPP_FLAGS = $(PLATFORM_FLAGS) DEF(GCC_VFRPP_FLAGS)
|
|
||||||
*_GCC5_AARCH64_CC_XIPFLAGS = DEF(GCC5_AARCH64_CC_XIPFLAGS)
|
*_GCC5_AARCH64_CC_XIPFLAGS = DEF(GCC5_AARCH64_CC_XIPFLAGS)
|
||||||
|
|
||||||
DEBUG_GCC5_AARCH64_CC_FLAGS = DEF(GCC5_AARCH64_CC_FLAGS) -flto -Wno-unused-but-set-variable -Wno-unused-const-variable
|
DEBUG_GCC5_AARCH64_CC_FLAGS = DEF(GCC5_AARCH64_CC_FLAGS) -flto -Wno-unused-but-set-variable -Wno-unused-const-variable
|
||||||
DEBUG_GCC5_AARCH64_DLINK_FLAGS = DEF(GCC5_AARCH64_DLINK_FLAGS) -flto -Os -L$(WORKSPACE)/ArmPkg/Library/GccLto -llto-aarch64 -Wl,-plugin-opt=-pass-through=-llto-aarch64 -Wno-lto-type-mismatch
|
DEBUG_GCC5_AARCH64_DLINK_FLAGS = DEF(GCC5_AARCH64_DLINK_FLAGS) -flto -Os -L$(WORKSPACE)/ArmPkg/Library/GccLto -llto-aarch64 -Wl,-plugin-opt=-pass-through=-llto-aarch64 -Wno-lto-type-mismatch
|
||||||
DEBUG_GCC5_AARCH64_DLINK_XIPFLAGS = -z common-page-size=0x20
|
DEBUG_GCC5_AARCH64_DLINK_XIPFLAGS = DEF(GCC_ALIGN)
|
||||||
|
|
||||||
RELEASE_GCC5_AARCH64_CC_FLAGS = DEF(GCC5_AARCH64_CC_FLAGS) -flto -Wno-unused-but-set-variable -Wno-unused-const-variable
|
RELEASE_GCC5_AARCH64_CC_FLAGS = DEF(GCC5_AARCH64_CC_FLAGS) -flto -Wno-unused-but-set-variable -Wno-unused-const-variable
|
||||||
RELEASE_GCC5_AARCH64_DLINK_FLAGS = DEF(GCC5_AARCH64_DLINK_FLAGS) -flto -Os -L$(WORKSPACE)/ArmPkg/Library/GccLto -llto-aarch64 -Wl,-plugin-opt=-pass-through=-llto-aarch64 -Wno-lto-type-mismatch
|
RELEASE_GCC5_AARCH64_DLINK_FLAGS = DEF(GCC5_AARCH64_DLINK_FLAGS) -flto -Os -L$(WORKSPACE)/ArmPkg/Library/GccLto -llto-aarch64 -Wl,-plugin-opt=-pass-through=-llto-aarch64 -Wno-lto-type-mismatch
|
||||||
RELEASE_GCC5_AARCH64_DLINK_XIPFLAGS = -z common-page-size=0x20
|
RELEASE_GCC5_AARCH64_DLINK_XIPFLAGS = DEF(GCC_ALIGN)
|
||||||
|
|
||||||
NOOPT_GCC5_AARCH64_CC_FLAGS = DEF(GCC5_AARCH64_CC_FLAGS) -O0
|
NOOPT_GCC5_AARCH64_CC_FLAGS = DEF(GCC5_AARCH64_CC_FLAGS) -O0
|
||||||
NOOPT_GCC5_AARCH64_DLINK_FLAGS = DEF(GCC5_AARCH64_DLINK_FLAGS) -O0
|
NOOPT_GCC5_AARCH64_DLINK_FLAGS = DEF(GCC5_AARCH64_DLINK_FLAGS) -O0
|
||||||
NOOPT_GCC5_AARCH64_DLINK_XIPFLAGS = -z common-page-size=0x20 -O0
|
NOOPT_GCC5_AARCH64_DLINK_XIPFLAGS = DEF(GCC_ALIGN) -O0
|
||||||
|
|
||||||
####################################################################################
|
####################################################################################
|
||||||
#
|
#
|
||||||
|
@ -1480,8 +1478,6 @@ RELEASE_GCC5_AARCH64_DLINK_XIPFLAGS = -z common-page-size=0x20
|
||||||
*_GCC5_RISCV64_CC_FLAGS = DEF(GCC5_RISCV64_CC_FLAGS) -save-temps
|
*_GCC5_RISCV64_CC_FLAGS = DEF(GCC5_RISCV64_CC_FLAGS) -save-temps
|
||||||
*_GCC5_RISCV64_DLINK_FLAGS = DEF(GCC5_RISCV64_DLINK_FLAGS)
|
*_GCC5_RISCV64_DLINK_FLAGS = DEF(GCC5_RISCV64_DLINK_FLAGS)
|
||||||
*_GCC5_RISCV64_DLINK2_FLAGS = DEF(GCC5_RISCV64_DLINK2_FLAGS)
|
*_GCC5_RISCV64_DLINK2_FLAGS = DEF(GCC5_RISCV64_DLINK2_FLAGS)
|
||||||
*_GCC5_RISCV64_RC_FLAGS = DEF(GCC_RISCV64_RC_FLAGS)
|
|
||||||
*_GCC5_RISCV64_OBJCOPY_FLAGS =
|
|
||||||
*_GCC5_RISCV64_DTCPP_FLAGS = DEF(GCC_DTCPP_FLAGS)
|
*_GCC5_RISCV64_DTCPP_FLAGS = DEF(GCC_DTCPP_FLAGS)
|
||||||
*_GCC5_RISCV64_PP_FLAGS = DEF(GCC_PP_FLAGS) DEF(GCC5_RISCV_OPENSBI_TYPES)
|
*_GCC5_RISCV64_PP_FLAGS = DEF(GCC_PP_FLAGS) DEF(GCC5_RISCV_OPENSBI_TYPES)
|
||||||
|
|
||||||
|
@ -1505,8 +1501,6 @@ RELEASE_GCC5_AARCH64_DLINK_XIPFLAGS = -z common-page-size=0x20
|
||||||
*_GCC5_LOONGARCH64_ASM_FLAGS = DEF(GCC5_LOONGARCH64_ASM_FLAGS)
|
*_GCC5_LOONGARCH64_ASM_FLAGS = DEF(GCC5_LOONGARCH64_ASM_FLAGS)
|
||||||
*_GCC5_LOONGARCH64_DLINK_FLAGS = DEF(GCC5_LOONGARCH64_DLINK_FLAGS)
|
*_GCC5_LOONGARCH64_DLINK_FLAGS = DEF(GCC5_LOONGARCH64_DLINK_FLAGS)
|
||||||
*_GCC5_LOONGARCH64_DLINK2_FLAGS = DEF(GCC5_LOONGARCH64_DLINK2_FLAGS)
|
*_GCC5_LOONGARCH64_DLINK2_FLAGS = DEF(GCC5_LOONGARCH64_DLINK2_FLAGS)
|
||||||
*_GCC5_LOONGARCH64_RC_FLAGS = DEF(GCC_LOONGARCH64_RC_FLAGS)
|
|
||||||
*_GCC5_LOONGARCH64_OBJCOPY_FLAGS =
|
|
||||||
*_GCC5_LOONGARCH64_NASM_FLAGS = -f elf32
|
*_GCC5_LOONGARCH64_NASM_FLAGS = -f elf32
|
||||||
*_GCC5_LOONGARCH64_PP_FLAGS = DEF(GCC5_LOONGARCH64_PP_FLAGS)
|
*_GCC5_LOONGARCH64_PP_FLAGS = DEF(GCC5_LOONGARCH64_PP_FLAGS)
|
||||||
|
|
||||||
|
@ -1553,7 +1547,6 @@ RELEASE_GCC5_LOONGARCH64_CC_FLAGS = DEF(GCC5_LOONGARCH64_CC_FLAGS) -Wno-un
|
||||||
*_GCC_IA32_ASLDLINK_FLAGS = DEF(GCC5_IA32_X64_ASLDLINK_FLAGS) -Wl,-m,elf_i386 -no-pie
|
*_GCC_IA32_ASLDLINK_FLAGS = DEF(GCC5_IA32_X64_ASLDLINK_FLAGS) -Wl,-m,elf_i386 -no-pie
|
||||||
*_GCC_IA32_ASM_FLAGS = DEF(GCC5_ASM_FLAGS) -m32 -march=i386
|
*_GCC_IA32_ASM_FLAGS = DEF(GCC5_ASM_FLAGS) -m32 -march=i386
|
||||||
*_GCC_IA32_DLINK2_FLAGS = DEF(GCC5_IA32_DLINK2_FLAGS) -no-pie
|
*_GCC_IA32_DLINK2_FLAGS = DEF(GCC5_IA32_DLINK2_FLAGS) -no-pie
|
||||||
*_GCC_IA32_RC_FLAGS = DEF(GCC_IA32_RC_FLAGS)
|
|
||||||
*_GCC_IA32_OBJCOPY_FLAGS =
|
*_GCC_IA32_OBJCOPY_FLAGS =
|
||||||
*_GCC_IA32_NASM_FLAGS = -f elf32
|
*_GCC_IA32_NASM_FLAGS = -f elf32
|
||||||
|
|
||||||
|
@ -1585,7 +1578,6 @@ RELEASE_GCC_IA32_DLINK_FLAGS = DEF(GCC5_IA32_X64_DLINK_FLAGS) -flto -Os -Wl,-
|
||||||
*_GCC_X64_ASLDLINK_FLAGS = DEF(GCC5_IA32_X64_ASLDLINK_FLAGS) -Wl,-m,elf_x86_64
|
*_GCC_X64_ASLDLINK_FLAGS = DEF(GCC5_IA32_X64_ASLDLINK_FLAGS) -Wl,-m,elf_x86_64
|
||||||
*_GCC_X64_ASM_FLAGS = DEF(GCC5_ASM_FLAGS) -m64
|
*_GCC_X64_ASM_FLAGS = DEF(GCC5_ASM_FLAGS) -m64
|
||||||
*_GCC_X64_DLINK2_FLAGS = DEF(GCC5_X64_DLINK2_FLAGS)
|
*_GCC_X64_DLINK2_FLAGS = DEF(GCC5_X64_DLINK2_FLAGS)
|
||||||
*_GCC_X64_RC_FLAGS = DEF(GCC_X64_RC_FLAGS)
|
|
||||||
*_GCC_X64_OBJCOPY_FLAGS =
|
*_GCC_X64_OBJCOPY_FLAGS =
|
||||||
*_GCC_X64_NASM_FLAGS = -f elf64
|
*_GCC_X64_NASM_FLAGS = -f elf64
|
||||||
|
|
||||||
|
@ -1619,7 +1611,6 @@ RELEASE_GCC_X64_DLINK_FLAGS = DEF(GCC5_X64_DLINK_FLAGS) -flto -Os
|
||||||
*_GCC_ARM_DTCPP_FLAGS = DEF(GCC_DTCPP_FLAGS)
|
*_GCC_ARM_DTCPP_FLAGS = DEF(GCC_DTCPP_FLAGS)
|
||||||
*_GCC_ARM_PLATFORM_FLAGS = -march=armv7-a -mfloat-abi=soft
|
*_GCC_ARM_PLATFORM_FLAGS = -march=armv7-a -mfloat-abi=soft
|
||||||
*_GCC_ARM_PP_FLAGS = $(PLATFORM_FLAGS) DEF(GCC_PP_FLAGS)
|
*_GCC_ARM_PP_FLAGS = $(PLATFORM_FLAGS) DEF(GCC_PP_FLAGS)
|
||||||
*_GCC_ARM_RC_FLAGS = DEF(GCC_ARM_RC_FLAGS)
|
|
||||||
*_GCC_ARM_VFRPP_FLAGS = $(PLATFORM_FLAGS) DEF(GCC_VFRPP_FLAGS)
|
*_GCC_ARM_VFRPP_FLAGS = $(PLATFORM_FLAGS) DEF(GCC_VFRPP_FLAGS)
|
||||||
*_GCC_ARM_CC_XIPFLAGS = DEF(GCC5_ARM_CC_XIPFLAGS)
|
*_GCC_ARM_CC_XIPFLAGS = DEF(GCC5_ARM_CC_XIPFLAGS)
|
||||||
|
|
||||||
|
@ -1653,7 +1644,6 @@ RELEASE_GCC_ARM_DLINK_FLAGS = DEF(GCC5_ARM_DLINK_FLAGS) -flto -Os -L$(WORKSP
|
||||||
*_GCC_AARCH64_DTCPP_FLAGS = DEF(GCC_DTCPP_FLAGS)
|
*_GCC_AARCH64_DTCPP_FLAGS = DEF(GCC_DTCPP_FLAGS)
|
||||||
*_GCC_AARCH64_PLATFORM_FLAGS =
|
*_GCC_AARCH64_PLATFORM_FLAGS =
|
||||||
*_GCC_AARCH64_PP_FLAGS = $(PLATFORM_FLAGS) DEF(GCC_PP_FLAGS)
|
*_GCC_AARCH64_PP_FLAGS = $(PLATFORM_FLAGS) DEF(GCC_PP_FLAGS)
|
||||||
*_GCC_AARCH64_RC_FLAGS = DEF(GCC_AARCH64_RC_FLAGS) DEF(GCC_AARCH64_RC_BTI_FLAGS)
|
|
||||||
*_GCC_AARCH64_VFRPP_FLAGS = $(PLATFORM_FLAGS) DEF(GCC_VFRPP_FLAGS)
|
*_GCC_AARCH64_VFRPP_FLAGS = $(PLATFORM_FLAGS) DEF(GCC_VFRPP_FLAGS)
|
||||||
*_GCC_AARCH64_CC_XIPFLAGS = DEF(GCC5_AARCH64_CC_XIPFLAGS)
|
*_GCC_AARCH64_CC_XIPFLAGS = DEF(GCC5_AARCH64_CC_XIPFLAGS)
|
||||||
|
|
||||||
|
@ -1697,7 +1687,6 @@ RELEASE_GCC_AARCH64_DLINK_XIPFLAGS = -z common-page-size=0x20
|
||||||
*_GCC_RISCV64_CC_FLAGS = DEF(GCC5_RISCV64_CC_FLAGS) -save-temps
|
*_GCC_RISCV64_CC_FLAGS = DEF(GCC5_RISCV64_CC_FLAGS) -save-temps
|
||||||
*_GCC_RISCV64_DLINK_FLAGS = DEF(GCC5_RISCV64_DLINK_FLAGS)
|
*_GCC_RISCV64_DLINK_FLAGS = DEF(GCC5_RISCV64_DLINK_FLAGS)
|
||||||
*_GCC_RISCV64_DLINK2_FLAGS = DEF(GCC5_RISCV64_DLINK2_FLAGS)
|
*_GCC_RISCV64_DLINK2_FLAGS = DEF(GCC5_RISCV64_DLINK2_FLAGS)
|
||||||
*_GCC_RISCV64_RC_FLAGS = DEF(GCC_RISCV64_RC_FLAGS)
|
|
||||||
*_GCC_RISCV64_OBJCOPY_FLAGS =
|
*_GCC_RISCV64_OBJCOPY_FLAGS =
|
||||||
*_GCC_RISCV64_DTCPP_FLAGS = DEF(GCC_DTCPP_FLAGS)
|
*_GCC_RISCV64_DTCPP_FLAGS = DEF(GCC_DTCPP_FLAGS)
|
||||||
*_GCC_RISCV64_PP_FLAGS = DEF(GCC_PP_FLAGS) DEF(GCC5_RISCV_OPENSBI_TYPES)
|
*_GCC_RISCV64_PP_FLAGS = DEF(GCC_PP_FLAGS) DEF(GCC5_RISCV_OPENSBI_TYPES)
|
||||||
|
@ -1722,7 +1711,6 @@ RELEASE_GCC_AARCH64_DLINK_XIPFLAGS = -z common-page-size=0x20
|
||||||
*_GCC_LOONGARCH64_ASM_FLAGS = DEF(GCC5_LOONGARCH64_ASM_FLAGS)
|
*_GCC_LOONGARCH64_ASM_FLAGS = DEF(GCC5_LOONGARCH64_ASM_FLAGS)
|
||||||
*_GCC_LOONGARCH64_DLINK_FLAGS = DEF(GCC5_LOONGARCH64_DLINK_FLAGS)
|
*_GCC_LOONGARCH64_DLINK_FLAGS = DEF(GCC5_LOONGARCH64_DLINK_FLAGS)
|
||||||
*_GCC_LOONGARCH64_DLINK2_FLAGS = DEF(GCC5_LOONGARCH64_DLINK2_FLAGS)
|
*_GCC_LOONGARCH64_DLINK2_FLAGS = DEF(GCC5_LOONGARCH64_DLINK2_FLAGS)
|
||||||
*_GCC_LOONGARCH64_RC_FLAGS = DEF(GCC_LOONGARCH64_RC_FLAGS)
|
|
||||||
*_GCC_LOONGARCH64_OBJCOPY_FLAGS =
|
*_GCC_LOONGARCH64_OBJCOPY_FLAGS =
|
||||||
*_GCC_LOONGARCH64_NASM_FLAGS = -f elf32
|
*_GCC_LOONGARCH64_NASM_FLAGS = -f elf32
|
||||||
*_GCC_LOONGARCH64_PP_FLAGS = DEF(GCC5_LOONGARCH64_PP_FLAGS)
|
*_GCC_LOONGARCH64_PP_FLAGS = DEF(GCC5_LOONGARCH64_PP_FLAGS)
|
||||||
|
@ -1773,22 +1761,21 @@ DEFINE CLANGPDB_ALL_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) DEF(CLANGPDB_WARN
|
||||||
|
|
||||||
*_CLANGPDB_IA32_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS) -m32 -fno-lto DEF(CLANGPDB_IA32_TARGET)
|
*_CLANGPDB_IA32_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS) -m32 -fno-lto DEF(CLANGPDB_IA32_TARGET)
|
||||||
*_CLANGPDB_IA32_ASM_FLAGS = DEF(GCC_ASM_FLAGS) -m32 -march=i386 DEF(CLANGPDB_IA32_TARGET)
|
*_CLANGPDB_IA32_ASM_FLAGS = DEF(GCC_ASM_FLAGS) -m32 -march=i386 DEF(CLANGPDB_IA32_TARGET)
|
||||||
*_CLANGPDB_IA32_OBJCOPY_FLAGS =
|
*_CLANGPDB_IA32_NASM_FLAGS = -f win32 -DRODATA_SECTION_NAME=.rdata
|
||||||
*_CLANGPDB_IA32_NASM_FLAGS = -f win32
|
|
||||||
*_CLANGPDB_IA32_PP_FLAGS = DEF(GCC_PP_FLAGS) DEF(CLANGPDB_IA32_TARGET)
|
*_CLANGPDB_IA32_PP_FLAGS = DEF(GCC_PP_FLAGS) DEF(CLANGPDB_IA32_TARGET)
|
||||||
*_CLANGPDB_IA32_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS) DEF(CLANGPDB_IA32_TARGET)
|
*_CLANGPDB_IA32_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS) DEF(CLANGPDB_IA32_TARGET)
|
||||||
*_CLANGPDB_IA32_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS) DEF(CLANGPDB_IA32_TARGET)
|
*_CLANGPDB_IA32_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS) DEF(CLANGPDB_IA32_TARGET)
|
||||||
|
|
||||||
DEBUG_CLANGPDB_IA32_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS) -m32 -Oz -flto -march=i586 DEF(CLANGPDB_IA32_TARGET) -gcodeview -malign-double
|
DEBUG_CLANGPDB_IA32_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS) -m32 -Oz -flto -march=i586 DEF(CLANGPDB_IA32_TARGET) -gcodeview -malign-double
|
||||||
DEBUG_CLANGPDB_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /ALIGN:32 /FILEALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:X86 /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DEBUG:GHASH /MLLVM:-exception-model=wineh /lldmap
|
DEBUG_CLANGPDB_IA32_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /MACHINE:X86 /DEBUG:GHASH /MLLVM:-exception-model=wineh /lldmap
|
||||||
DEBUG_CLANGPDB_IA32_DLINK2_FLAGS =
|
DEBUG_CLANGPDB_IA32_DLINK2_FLAGS =
|
||||||
|
|
||||||
RELEASE_CLANGPDB_IA32_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS) -m32 -Oz -flto -march=i586 DEF(CLANGPDB_IA32_TARGET) -malign-double
|
RELEASE_CLANGPDB_IA32_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS) -m32 -Oz -flto -march=i586 DEF(CLANGPDB_IA32_TARGET) -malign-double
|
||||||
RELEASE_CLANGPDB_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /ALIGN:32 /FILEALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:X86 /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /MERGE:.rdata=.data /MLLVM:-exception-model=wineh /lldmap
|
RELEASE_CLANGPDB_IA32_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /IGNORE:4254 /MACHINE:X86 /MLLVM:-exception-model=wineh /lldmap
|
||||||
RELEASE_CLANGPDB_IA32_DLINK2_FLAGS =
|
RELEASE_CLANGPDB_IA32_DLINK2_FLAGS =
|
||||||
|
|
||||||
NOOPT_CLANGPDB_IA32_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS) -m32 -O0 -march=i586 DEF(CLANGPDB_IA32_TARGET) -gcodeview -malign-double
|
NOOPT_CLANGPDB_IA32_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS) -m32 -O0 -march=i586 DEF(CLANGPDB_IA32_TARGET) -gcodeview -malign-double
|
||||||
NOOPT_CLANGPDB_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /ALIGN:32 /FILEALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:X86 /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DEBUG:GHASH /MLLVM:-exception-model=wineh /lldmap
|
NOOPT_CLANGPDB_IA32_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /MACHINE:X86 /DEBUG:GHASH /MLLVM:-exception-model=wineh /lldmap
|
||||||
NOOPT_CLANGPDB_IA32_DLINK2_FLAGS =
|
NOOPT_CLANGPDB_IA32_DLINK2_FLAGS =
|
||||||
|
|
||||||
##########################
|
##########################
|
||||||
|
@ -1807,26 +1794,22 @@ NOOPT_CLANGPDB_IA32_DLINK2_FLAGS =
|
||||||
|
|
||||||
*_CLANGPDB_X64_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS) -m64 -fno-lto DEF(CLANGPDB_X64_TARGET)
|
*_CLANGPDB_X64_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS) -m64 -fno-lto DEF(CLANGPDB_X64_TARGET)
|
||||||
*_CLANGPDB_X64_ASM_FLAGS = DEF(GCC_ASM_FLAGS) -m64 DEF(CLANGPDB_X64_TARGET)
|
*_CLANGPDB_X64_ASM_FLAGS = DEF(GCC_ASM_FLAGS) -m64 DEF(CLANGPDB_X64_TARGET)
|
||||||
*_CLANGPDB_X64_OBJCOPY_FLAGS =
|
*_CLANGPDB_X64_NASM_FLAGS = -f win64 -DRODATA_SECTION_NAME=.rdata
|
||||||
*_CLANGPDB_X64_NASM_FLAGS = -f win64
|
|
||||||
*_CLANGPDB_X64_PP_FLAGS = DEF(GCC_PP_FLAGS) DEF(CLANGPDB_X64_TARGET)
|
*_CLANGPDB_X64_PP_FLAGS = DEF(GCC_PP_FLAGS) DEF(CLANGPDB_X64_TARGET)
|
||||||
*_CLANGPDB_X64_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS) DEF(CLANGPDB_X64_TARGET)
|
*_CLANGPDB_X64_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS) DEF(CLANGPDB_X64_TARGET)
|
||||||
*_CLANGPDB_X64_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS) DEF(CLANGPDB_X64_TARGET)
|
*_CLANGPDB_X64_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS) DEF(CLANGPDB_X64_TARGET)
|
||||||
|
|
||||||
DEBUG_CLANGPDB_X64_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -Oz -flto DEF(CLANGPDB_X64_TARGET) -gcodeview -funwind-tables
|
DEBUG_CLANGPDB_X64_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -Oz -flto DEF(CLANGPDB_X64_TARGET) -gcodeview -funwind-tables
|
||||||
DEBUG_CLANGPDB_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /ALIGN:32 /FILEALIGN:32 /Machine:X64 /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DEBUG:GHASH /MLLVM:-exception-model=wineh /lldmap
|
DEBUG_CLANGPDB_X64_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /MACHINE:X64 /DEBUG:GHASH /MLLVM:-exception-model=wineh /lldmap
|
||||||
DEBUG_CLANGPDB_X64_DLINK2_FLAGS =
|
DEBUG_CLANGPDB_X64_DLINK2_FLAGS =
|
||||||
DEBUG_CLANGPDB_X64_GENFW_FLAGS = --keepexceptiontable
|
|
||||||
|
|
||||||
RELEASE_CLANGPDB_X64_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -Oz -flto DEF(CLANGPDB_X64_TARGET) -fno-unwind-tables
|
RELEASE_CLANGPDB_X64_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -Oz -flto DEF(CLANGPDB_X64_TARGET) -fno-unwind-tables
|
||||||
RELEASE_CLANGPDB_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /ALIGN:32 /FILEALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /MERGE:.rdata=.data /MLLVM:-exception-model=wineh /lldmap
|
RELEASE_CLANGPDB_X64_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /IGNORE:4254 /MACHINE:X64 /MLLVM:-exception-model=wineh /lldmap
|
||||||
RELEASE_CLANGPDB_X64_DLINK2_FLAGS =
|
RELEASE_CLANGPDB_X64_DLINK2_FLAGS =
|
||||||
RELEASE_CLANGPDB_X64_GENFW_FLAGS =
|
|
||||||
|
|
||||||
NOOPT_CLANGPDB_X64_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -O0 DEF(CLANGPDB_X64_TARGET) -gcodeview -funwind-tables
|
NOOPT_CLANGPDB_X64_CC_FLAGS = DEF(CLANGPDB_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -O0 DEF(CLANGPDB_X64_TARGET) -gcodeview -funwind-tables
|
||||||
NOOPT_CLANGPDB_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /ALIGN:32 /FILEALIGN:32 /Machine:X64 /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DEBUG:GHASH /MLLVM:-exception-model=wineh /lldmap
|
NOOPT_CLANGPDB_X64_DLINK_FLAGS = DEF(MSFT_DLINK_COMMON) /MACHINE:X64 /DEBUG:GHASH /MLLVM:-exception-model=wineh /lldmap
|
||||||
NOOPT_CLANGPDB_X64_DLINK2_FLAGS =
|
NOOPT_CLANGPDB_X64_DLINK2_FLAGS =
|
||||||
NOOPT_CLANGPDB_X64_GENFW_FLAGS = --keepexceptiontable
|
|
||||||
|
|
||||||
####################################################################################
|
####################################################################################
|
||||||
#
|
#
|
||||||
|
@ -1846,15 +1829,14 @@ NOOPT_CLANGPDB_X64_GENFW_FLAGS = --keepexceptiontable
|
||||||
|
|
||||||
DEFINE CLANGDWARF_IA32_PREFIX = ENV(CLANG_BIN)
|
DEFINE CLANGDWARF_IA32_PREFIX = ENV(CLANG_BIN)
|
||||||
DEFINE CLANGDWARF_X64_PREFIX = ENV(CLANG_BIN)
|
DEFINE CLANGDWARF_X64_PREFIX = ENV(CLANG_BIN)
|
||||||
|
DEFINE CLANGDWARF_ARM_PREFIX = ENV(CLANG_BIN)
|
||||||
|
DEFINE CLANGDWARF_AARCH64_PREFIX = ENV(CLANG_BIN)
|
||||||
|
|
||||||
# LLVM/CLANG doesn't support -n link option. So, it can't share the same IA32_X64_DLINK_COMMON flag.
|
# LLVM/CLANG doesn't support -n link option. So, it can't share the same IA32_X64_DLINK_COMMON flag.
|
||||||
# LLVM/CLANG doesn't support common page size. So, it can't share the same GccBase.lds script.
|
DEFINE CLANGDWARF_IA32_X64_DLINK_COMMON = -nostdlib -Wl,-q,--gc-sections DEF(GCC_ALIGN) -Wl,-z,notext,--defsym=ALIGNED_PE_HEADER_SIZE=0x400 DEF(DLINK_SCRIPT)
|
||||||
DEFINE CLANGDWARF_IA32_X64_DLINK_COMMON = -nostdlib -Wl,-q,--gc-sections -z max-page-size=0x40 -Wl,-z,notext
|
DEFINE CLANGDWARF_IA32_X64_ASLDLINK_FLAGS = DEF(CLANGDWARF_IA32_X64_DLINK_COMMON) -Wl,--entry,ReferenceAcpiTable -u ReferenceAcpiTable
|
||||||
DEFINE CLANGDWARF_DLINK2_FLAGS_COMMON = -Wl,--script=$(EDK_TOOLS_PATH)/Scripts/ClangBase.lds
|
DEFINE CLANGDWARF_IA32_X64_DLINK_FLAGS = DEF(CLANGDWARF_IA32_X64_DLINK_COMMON) -Wl,--entry,$(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT) -Wl,-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map,--whole-archive
|
||||||
DEFINE CLANGDWARF_IA32_X64_ASLDLINK_FLAGS = DEF(CLANGDWARF_IA32_X64_DLINK_COMMON) -Wl,--defsym=PECOFF_HEADER_SIZE=0 DEF(CLANGDWARF_DLINK2_FLAGS_COMMON) -Wl,--entry,ReferenceAcpiTable -u ReferenceAcpiTable
|
DEFINE CLANGDWARF_IA32_DLINK2_FLAGS = -no-pie
|
||||||
DEFINE CLANGDWARF_IA32_X64_DLINK_FLAGS = DEF(CLANGDWARF_IA32_X64_DLINK_COMMON) -Wl,--entry,$(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT) -Wl,-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map,--whole-archive -Wl,-z,notext
|
|
||||||
DEFINE CLANGDWARF_IA32_DLINK2_FLAGS = -Wl,--defsym=PECOFF_HEADER_SIZE=0x220 DEF(CLANGDWARF_DLINK2_FLAGS_COMMON)
|
|
||||||
DEFINE CLANGDWARF_X64_DLINK2_FLAGS = -Wl,--defsym=PECOFF_HEADER_SIZE=0x228 DEF(CLANGDWARF_DLINK2_FLAGS_COMMON)
|
|
||||||
|
|
||||||
DEFINE CLANGDWARF_IA32_TARGET = -target i686-pc-linux-gnu
|
DEFINE CLANGDWARF_IA32_TARGET = -target i686-pc-linux-gnu
|
||||||
DEFINE CLANGDWARF_X64_TARGET = -target x86_64-pc-linux-gnu
|
DEFINE CLANGDWARF_X64_TARGET = -target x86_64-pc-linux-gnu
|
||||||
|
@ -1865,6 +1847,7 @@ DEFINE CLANGDWARF_ALL_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) DEF(CLANGDWARF_
|
||||||
###########################
|
###########################
|
||||||
# CLANGDWARF IA32 definitions
|
# CLANGDWARF IA32 definitions
|
||||||
###########################
|
###########################
|
||||||
|
*_CLANGDWARF_IA32_OBJCOPY_PATH = DEF(CLANGDWARF_IA32_PREFIX)llvm-objcopy
|
||||||
*_CLANGDWARF_IA32_CC_PATH = DEF(CLANGDWARF_IA32_PREFIX)clang
|
*_CLANGDWARF_IA32_CC_PATH = DEF(CLANGDWARF_IA32_PREFIX)clang
|
||||||
*_CLANGDWARF_IA32_SLINK_PATH = DEF(CLANGDWARF_IA32_PREFIX)llvm-ar
|
*_CLANGDWARF_IA32_SLINK_PATH = DEF(CLANGDWARF_IA32_PREFIX)llvm-ar
|
||||||
*_CLANGDWARF_IA32_DLINK_PATH = DEF(CLANGDWARF_IA32_PREFIX)clang
|
*_CLANGDWARF_IA32_DLINK_PATH = DEF(CLANGDWARF_IA32_PREFIX)clang
|
||||||
|
@ -1879,28 +1862,27 @@ DEFINE CLANGDWARF_ALL_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) DEF(CLANGDWARF_
|
||||||
*_CLANGDWARF_IA32_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS) -m32 -fno-lto DEF(CLANGDWARF_IA32_TARGET)
|
*_CLANGDWARF_IA32_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS) -m32 -fno-lto DEF(CLANGDWARF_IA32_TARGET)
|
||||||
*_CLANGDWARF_IA32_ASLDLINK_FLAGS = DEF(CLANGDWARF_IA32_X64_ASLDLINK_FLAGS) -Wl,-m,elf_i386 -fuse-ld=lld -no-pie
|
*_CLANGDWARF_IA32_ASLDLINK_FLAGS = DEF(CLANGDWARF_IA32_X64_ASLDLINK_FLAGS) -Wl,-m,elf_i386 -fuse-ld=lld -no-pie
|
||||||
*_CLANGDWARF_IA32_ASM_FLAGS = DEF(GCC5_ASM_FLAGS) -m32 -march=i386 DEF(CLANGDWARF_IA32_TARGET)
|
*_CLANGDWARF_IA32_ASM_FLAGS = DEF(GCC5_ASM_FLAGS) -m32 -march=i386 DEF(CLANGDWARF_IA32_TARGET)
|
||||||
*_CLANGDWARF_IA32_RC_FLAGS = DEF(GCC_IA32_RC_FLAGS)
|
*_CLANGDWARF_IA32_NASM_FLAGS = -f elf32 -DRODATA_SECTION_NAME=.rodata
|
||||||
*_CLANGDWARF_IA32_OBJCOPY_FLAGS =
|
|
||||||
*_CLANGDWARF_IA32_NASM_FLAGS = -f elf32
|
|
||||||
*_CLANGDWARF_IA32_PP_FLAGS = DEF(GCC_PP_FLAGS) DEF(CLANGDWARF_IA32_TARGET)
|
*_CLANGDWARF_IA32_PP_FLAGS = DEF(GCC_PP_FLAGS) DEF(CLANGDWARF_IA32_TARGET)
|
||||||
*_CLANGDWARF_IA32_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS) DEF(CLANGDWARF_IA32_TARGET)
|
*_CLANGDWARF_IA32_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS) DEF(CLANGDWARF_IA32_TARGET)
|
||||||
*_CLANGDWARF_IA32_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS) DEF(CLANGDWARF_IA32_TARGET)
|
*_CLANGDWARF_IA32_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS) DEF(CLANGDWARF_IA32_TARGET)
|
||||||
|
|
||||||
DEBUG_CLANGDWARF_IA32_CC_FLAGS = DEF(CLANGDWARF_ALL_CC_FLAGS) -fno-pic -fno-pie -m32 -Oz -flto -march=i586 DEF(CLANGDWARF_IA32_TARGET) -g -malign-double
|
DEBUG_CLANGDWARF_IA32_CC_FLAGS = DEF(CLANGDWARF_ALL_CC_FLAGS) -m32 -malign-double -Oz -flto -march=i586 DEF(CLANGDWARF_IA32_TARGET) -g -fno-pic -fno-pie
|
||||||
DEBUG_CLANGDWARF_IA32_DLINK_FLAGS = DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -flto -Wl,-O3 -Wl,-melf_i386 -Wl,--oformat,elf32-i386
|
DEBUG_CLANGDWARF_IA32_DLINK_FLAGS = DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -flto -Wl,-O3 -Wl,-melf_i386 -Wl,--oformat,elf32-i386
|
||||||
DEBUG_CLANGDWARF_IA32_DLINK2_FLAGS = DEF(CLANGDWARF_IA32_DLINK2_FLAGS) -O3 -fuse-ld=lld -no-pie
|
DEBUG_CLANGDWARF_IA32_DLINK2_FLAGS = DEF(CLANGDWARF_IA32_DLINK2_FLAGS) -O3 -fuse-ld=lld -no-pie
|
||||||
|
|
||||||
RELEASE_CLANGDWARF_IA32_CC_FLAGS = DEF(CLANGDWARF_ALL_CC_FLAGS) -fno-pic -fno-pie -m32 -Oz -flto -march=i586 DEF(CLANGDWARF_IA32_TARGET) -malign-double
|
RELEASE_CLANGDWARF_IA32_CC_FLAGS = DEF(CLANGDWARF_ALL_CC_FLAGS) -m32 -malign-double -Oz -flto -march=i586 DEF(CLANGDWARF_IA32_TARGET) -fno-pic -fno-pie
|
||||||
RELEASE_CLANGDWARF_IA32_DLINK_FLAGS = DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -flto -Wl,-O3 -Wl,-melf_i386 -Wl,--oformat,elf32-i386
|
RELEASE_CLANGDWARF_IA32_DLINK_FLAGS = DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -flto -Wl,-O3 -Wl,-melf_i386 -Wl,--oformat,elf32-i386
|
||||||
RELEASE_CLANGDWARF_IA32_DLINK2_FLAGS = DEF(CLANGDWARF_IA32_DLINK2_FLAGS) -O3 -fuse-ld=lld -no-pie
|
RELEASE_CLANGDWARF_IA32_DLINK2_FLAGS = DEF(CLANGDWARF_IA32_DLINK2_FLAGS) -O3 -fuse-ld=lld -no-pie
|
||||||
|
|
||||||
NOOPT_CLANGDWARF_IA32_CC_FLAGS = DEF(CLANGDWARF_ALL_CC_FLAGS) -fno-pic -fno-pie -m32 -O0 -march=i586 DEF(CLANGDWARF_IA32_TARGET) -g -malign-double
|
NOOPT_CLANGDWARF_IA32_CC_FLAGS = DEF(CLANGDWARF_ALL_CC_FLAGS) -m32 -malign-double -O0 -march=i586 DEF(CLANGDWARF_IA32_TARGET) -g -fno-pic -fno-pie
|
||||||
NOOPT_CLANGDWARF_IA32_DLINK_FLAGS = DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -Wl,-O0 -Wl,-melf_i386 -Wl,--oformat,elf32-i386
|
NOOPT_CLANGDWARF_IA32_DLINK_FLAGS = DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -Wl,-O0 -Wl,-melf_i386 -Wl,--oformat,elf32-i386
|
||||||
NOOPT_CLANGDWARF_IA32_DLINK2_FLAGS = DEF(CLANGDWARF_IA32_DLINK2_FLAGS) -O0 -fuse-ld=lld -no-pie
|
NOOPT_CLANGDWARF_IA32_DLINK2_FLAGS = DEF(CLANGDWARF_IA32_DLINK2_FLAGS) -O0 -fuse-ld=lld -no-pie
|
||||||
|
|
||||||
##########################
|
##########################
|
||||||
# CLANGDWARF X64 definitions
|
# CLANGDWARF X64 definitions
|
||||||
##########################
|
##########################
|
||||||
|
*_CLANGDWARF_X64_OBJCOPY_PATH = DEF(CLANGDWARF_X64_PREFIX)llvm-objcopy
|
||||||
*_CLANGDWARF_X64_CC_PATH = DEF(CLANGDWARF_X64_PREFIX)clang
|
*_CLANGDWARF_X64_CC_PATH = DEF(CLANGDWARF_X64_PREFIX)clang
|
||||||
*_CLANGDWARF_X64_SLINK_PATH = DEF(CLANGDWARF_X64_PREFIX)llvm-ar
|
*_CLANGDWARF_X64_SLINK_PATH = DEF(CLANGDWARF_X64_PREFIX)llvm-ar
|
||||||
*_CLANGDWARF_X64_DLINK_PATH = DEF(CLANGDWARF_X64_PREFIX)clang
|
*_CLANGDWARF_X64_DLINK_PATH = DEF(CLANGDWARF_X64_PREFIX)clang
|
||||||
|
@ -1915,31 +1897,29 @@ NOOPT_CLANGDWARF_IA32_DLINK2_FLAGS = DEF(CLANGDWARF_IA32_DLINK2_FLAGS) -O0 -
|
||||||
*_CLANGDWARF_X64_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS) -m64 -fno-lto DEF(CLANGDWARF_X64_TARGET)
|
*_CLANGDWARF_X64_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS) -m64 -fno-lto DEF(CLANGDWARF_X64_TARGET)
|
||||||
*_CLANGDWARF_X64_ASLDLINK_FLAGS = DEF(CLANGDWARF_IA32_X64_ASLDLINK_FLAGS) -Wl,-m,elf_x86_64 -fuse-ld=lld
|
*_CLANGDWARF_X64_ASLDLINK_FLAGS = DEF(CLANGDWARF_IA32_X64_ASLDLINK_FLAGS) -Wl,-m,elf_x86_64 -fuse-ld=lld
|
||||||
*_CLANGDWARF_X64_ASM_FLAGS = DEF(GCC5_ASM_FLAGS) -m64 DEF(CLANGDWARF_X64_TARGET)
|
*_CLANGDWARF_X64_ASM_FLAGS = DEF(GCC5_ASM_FLAGS) -m64 DEF(CLANGDWARF_X64_TARGET)
|
||||||
*_CLANGDWARF_X64_RC_FLAGS = DEF(GCC_X64_RC_FLAGS)
|
*_CLANGDWARF_X64_NASM_FLAGS = -f elf64 -DRODATA_SECTION_NAME=.rodata
|
||||||
*_CLANGDWARF_X64_OBJCOPY_FLAGS =
|
|
||||||
*_CLANGDWARF_X64_NASM_FLAGS = -f elf64
|
|
||||||
*_CLANGDWARF_X64_PP_FLAGS = DEF(GCC_PP_FLAGS) DEF(CLANGDWARF_X64_TARGET)
|
*_CLANGDWARF_X64_PP_FLAGS = DEF(GCC_PP_FLAGS) DEF(CLANGDWARF_X64_TARGET)
|
||||||
*_CLANGDWARF_X64_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS) DEF(CLANGDWARF_X64_TARGET)
|
*_CLANGDWARF_X64_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS) DEF(CLANGDWARF_X64_TARGET)
|
||||||
*_CLANGDWARF_X64_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS) DEF(CLANGDWARF_X64_TARGET)
|
*_CLANGDWARF_X64_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS) DEF(CLANGDWARF_X64_TARGET)
|
||||||
|
|
||||||
DEBUG_CLANGDWARF_X64_CC_FLAGS = DEF(CLANGDWARF_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -fdirect-access-external-data -Oz -flto DEF(CLANGDWARF_X64_TARGET) -g
|
DEBUG_CLANGDWARF_X64_CC_FLAGS = DEF(CLANGDWARF_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -fdirect-access-external-data -Oz -flto DEF(CLANGDWARF_X64_TARGET) -g
|
||||||
DEBUG_CLANGDWARF_X64_DLINK_FLAGS = DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -flto -Wl,-O3 -Wl,-melf_x86_64 -Wl,--oformat,elf64-x86-64 -Wl,-pie -mcmodel=small -Wl,--apply-dynamic-relocs
|
DEBUG_CLANGDWARF_X64_DLINK_FLAGS = DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -flto -Wl,-O3 -Wl,-melf_x86_64 -Wl,--oformat,elf64-x86-64 -Wl,-pie -mcmodel=small -Wl,--apply-dynamic-relocs
|
||||||
DEBUG_CLANGDWARF_X64_DLINK2_FLAGS = DEF(CLANGDWARF_X64_DLINK2_FLAGS) -O3 -fuse-ld=lld
|
DEBUG_CLANGDWARF_X64_DLINK2_FLAGS = -O3 -fuse-ld=lld
|
||||||
|
|
||||||
RELEASE_CLANGDWARF_X64_CC_FLAGS = DEF(CLANGDWARF_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -fdirect-access-external-data -Oz -flto DEF(CLANGDWARF_X64_TARGET)
|
RELEASE_CLANGDWARF_X64_CC_FLAGS = DEF(CLANGDWARF_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -fdirect-access-external-data -Oz -flto DEF(CLANGDWARF_X64_TARGET)
|
||||||
RELEASE_CLANGDWARF_X64_DLINK_FLAGS = DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -flto -Wl,-O3 -Wl,-melf_x86_64 -Wl,--oformat,elf64-x86-64 -Wl,-pie -mcmodel=small -Wl,--apply-dynamic-relocs
|
RELEASE_CLANGDWARF_X64_DLINK_FLAGS = DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -flto -Wl,-O3 -Wl,-melf_x86_64 -Wl,--oformat,elf64-x86-64 -Wl,-pie -mcmodel=small -Wl,--apply-dynamic-relocs
|
||||||
RELEASE_CLANGDWARF_X64_DLINK2_FLAGS = DEF(CLANGDWARF_X64_DLINK2_FLAGS) -O3 -fuse-ld=lld
|
RELEASE_CLANGDWARF_X64_DLINK2_FLAGS = -O3 -fuse-ld=lld
|
||||||
|
|
||||||
NOOPT_CLANGDWARF_X64_CC_FLAGS = DEF(CLANGDWARF_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -fdirect-access-external-data -O0 DEF(CLANGDWARF_X64_TARGET) -g
|
NOOPT_CLANGDWARF_X64_CC_FLAGS = DEF(CLANGDWARF_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -fdirect-access-external-data -O0 DEF(CLANGDWARF_X64_TARGET) -g
|
||||||
NOOPT_CLANGDWARF_X64_DLINK_FLAGS = DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -Wl,-O0 -Wl,-melf_x86_64 -Wl,--oformat,elf64-x86-64 -Wl,-pie -mcmodel=small -Wl,--apply-dynamic-relocs
|
NOOPT_CLANGDWARF_X64_DLINK_FLAGS = DEF(CLANGDWARF_IA32_X64_DLINK_FLAGS) -Wl,-O0 -Wl,-melf_x86_64 -Wl,--oformat,elf64-x86-64 -Wl,-pie -mcmodel=small -Wl,--apply-dynamic-relocs
|
||||||
NOOPT_CLANGDWARF_X64_DLINK2_FLAGS = DEF(CLANGDWARF_X64_DLINK2_FLAGS) -O0 -fuse-ld=lld
|
NOOPT_CLANGDWARF_X64_DLINK2_FLAGS = -O0 -fuse-ld=lld
|
||||||
|
|
||||||
##################
|
##################
|
||||||
# CLANGDWARF ARM definitions
|
# CLANGDWARF ARM definitions
|
||||||
##################
|
##################
|
||||||
DEFINE CLANGDWARF_ARM_TARGET = -target arm-linux-gnueabi
|
DEFINE CLANGDWARF_ARM_TARGET = -target arm-linux-gnueabi
|
||||||
DEFINE CLANGDWARF_ARM_CC_FLAGS = DEF(GCC_ARM_CC_FLAGS) DEF(CLANGDWARF_ARM_TARGET) DEF(CLANGDWARF_WARNING_OVERRIDES) -mno-movt
|
DEFINE CLANGDWARF_ARM_CC_FLAGS = DEF(GCC_ARM_CC_FLAGS) DEF(CLANGDWARF_ARM_TARGET) DEF(CLANGDWARF_WARNING_OVERRIDES) -mno-movt
|
||||||
DEFINE CLANGDWARF_ARM_DLINK_FLAGS = DEF(CLANGDWARF_ARM_TARGET) DEF(GCC_ARM_DLINK_FLAGS)
|
DEFINE CLANGDWARF_ARM_DLINK_FLAGS = DEF(CLANGDWARF_ARM_TARGET) DEF(GCC_ARM_DLINK_FLAGS) -fuse-ld=lld -Wl,--apply-dynamic-relocs,--no-pie,--no-relax
|
||||||
|
|
||||||
*_CLANGDWARF_ARM_PP_FLAGS = DEF(GCC_PP_FLAGS)
|
*_CLANGDWARF_ARM_PP_FLAGS = DEF(GCC_PP_FLAGS)
|
||||||
*_CLANGDWARF_ARM_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS)
|
*_CLANGDWARF_ARM_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS)
|
||||||
|
@ -1948,42 +1928,40 @@ DEFINE CLANGDWARF_ARM_DLINK_FLAGS = DEF(CLANGDWARF_ARM_TARGET) DEF(GCC_ARM_DLI
|
||||||
*_CLANGDWARF_ARM_ASL_OUTFLAGS = DEF(IASL_OUTFLAGS)
|
*_CLANGDWARF_ARM_ASL_OUTFLAGS = DEF(IASL_OUTFLAGS)
|
||||||
*_CLANGDWARF_ARM_DTCPP_FLAGS = DEF(GCC_DTCPP_FLAGS)
|
*_CLANGDWARF_ARM_DTCPP_FLAGS = DEF(GCC_DTCPP_FLAGS)
|
||||||
|
|
||||||
*_CLANGDWARF_ARM_CC_PATH = ENV(CLANGDWARF_BIN)clang
|
*_CLANGDWARF_ARM_OBJCOPY_PATH = DEF(CLANGDWARF_ARM_PREFIX)llvm-objcopy
|
||||||
*_CLANGDWARF_ARM_ASM_PATH = ENV(CLANGDWARF_BIN)clang
|
*_CLANGDWARF_ARM_CC_PATH = DEF(CLANGDWARF_ARM_PREFIX)clang
|
||||||
*_CLANGDWARF_ARM_PP_PATH = ENV(CLANGDWARF_BIN)clang
|
*_CLANGDWARF_ARM_ASM_PATH = DEF(CLANGDWARF_ARM_PREFIX)clang
|
||||||
*_CLANGDWARF_ARM_VFRPP_PATH = ENV(CLANGDWARF_BIN)clang
|
*_CLANGDWARF_ARM_PP_PATH = DEF(CLANGDWARF_ARM_PREFIX)clang
|
||||||
*_CLANGDWARF_ARM_ASLCC_PATH = ENV(CLANGDWARF_BIN)clang
|
*_CLANGDWARF_ARM_VFRPP_PATH = DEF(CLANGDWARF_ARM_PREFIX)clang
|
||||||
*_CLANGDWARF_ARM_ASLPP_PATH = ENV(CLANGDWARF_BIN)clang
|
*_CLANGDWARF_ARM_ASLCC_PATH = DEF(CLANGDWARF_ARM_PREFIX)clang
|
||||||
*_CLANGDWARF_ARM_DLINK_PATH = ENV(CLANGDWARF_BIN)clang
|
*_CLANGDWARF_ARM_ASLPP_PATH = DEF(CLANGDWARF_ARM_PREFIX)clang
|
||||||
*_CLANGDWARF_ARM_ASLDLINK_PATH = ENV(CLANGDWARF_BIN)clang
|
*_CLANGDWARF_ARM_DLINK_PATH = DEF(CLANGDWARF_ARM_PREFIX)clang
|
||||||
|
*_CLANGDWARF_ARM_ASLDLINK_PATH = DEF(CLANGDWARF_ARM_PREFIX)clang
|
||||||
*_CLANGDWARF_ARM_SLINK_PATH = ENV(CLANGDWARF_BIN)llvm-ar
|
*_CLANGDWARF_ARM_SLINK_PATH = DEF(CLANGDWARF_ARM_PREFIX)llvm-ar
|
||||||
*_CLANGDWARF_ARM_RC_PATH = ENV(CLANGDWARF_BIN)llvm-objcopy
|
*_CLANGDWARF_ARM_RC_PATH = DEF(CLANGDWARF_ARM_PREFIX)llvm-objcopy
|
||||||
|
|
||||||
*_CLANGDWARF_ARM_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS) -fno-lto
|
*_CLANGDWARF_ARM_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS) -fno-lto
|
||||||
*_CLANGDWARF_ARM_ASLDLINK_FLAGS = DEF(CLANGDWARF_ARM_TARGET) DEF(GCC_ARM_ASLDLINK_FLAGS)
|
*_CLANGDWARF_ARM_ASLDLINK_FLAGS = DEF(CLANGDWARF_ARM_TARGET) DEF(GCC_ARM_ASLDLINK_FLAGS) -fuse-ld=lld
|
||||||
*_CLANGDWARF_ARM_ASM_FLAGS = DEF(GCC_ASM_FLAGS) DEF(CLANGDWARF_ARM_TARGET) $(PLATFORM_FLAGS) -Qunused-arguments
|
*_CLANGDWARF_ARM_ASM_FLAGS = DEF(GCC_ASM_FLAGS) DEF(CLANGDWARF_ARM_TARGET) -march=armv7-a -Qunused-arguments
|
||||||
*_CLANGDWARF_ARM_DLINK2_FLAGS = DEF(GCC_DLINK2_FLAGS_COMMON) -Wl,--defsym=PECOFF_HEADER_SIZE=0x220
|
*_CLANGDWARF_ARM_DLINK2_FLAGS = DEF(GCC_DLINK2_FLAGS_COMMON)
|
||||||
*_CLANGDWARF_ARM_PLATFORM_FLAGS = -march=armv7-a
|
*_CLANGDWARF_ARM_PP_FLAGS = DEF(GCC_PP_FLAGS) DEF(CLANGDWARF_ARM_TARGET) -march=armv7-a
|
||||||
*_CLANGDWARF_ARM_PP_FLAGS = DEF(GCC_PP_FLAGS) DEF(CLANGDWARF_ARM_TARGET) $(PLATFORM_FLAGS)
|
*_CLANGDWARF_ARM_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS) DEF(CLANGDWARF_ARM_TARGET) -march=armv7-a
|
||||||
*_CLANGDWARF_ARM_RC_FLAGS = DEF(GCC_ARM_RC_FLAGS)
|
|
||||||
*_CLANGDWARF_ARM_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS) DEF(CLANGDWARF_ARM_TARGET) $(PLATFORM_FLAGS)
|
|
||||||
*_CLANGDWARF_ARM_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS) DEF(CLANGDWARF_ARM_TARGET)
|
*_CLANGDWARF_ARM_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS) DEF(CLANGDWARF_ARM_TARGET)
|
||||||
*_CLANGDWARF_ARM_CC_XIPFLAGS = DEF(GCC_ARM_CC_XIPFLAGS)
|
*_CLANGDWARF_ARM_CC_XIPFLAGS = DEF(GCC_ARM_CC_XIPFLAGS)
|
||||||
|
|
||||||
DEBUG_CLANGDWARF_ARM_CC_FLAGS = DEF(CLANGDWARF_ARM_CC_FLAGS) $(PLATFORM_FLAGS) -flto -O1
|
DEBUG_CLANGDWARF_ARM_CC_FLAGS = DEF(CLANGDWARF_ARM_CC_FLAGS) -flto -O1
|
||||||
DEBUG_CLANGDWARF_ARM_DLINK_FLAGS = DEF(CLANGDWARF_ARM_DLINK_FLAGS) -flto -Wl,-O1 -fuse-ld=lld -L$(WORKSPACE)/ArmPkg/Library/GccLto -llto-arm -Wl,-plugin-opt=-pass-through=-llto-arm -Wl,--no-pie,--no-relax
|
DEBUG_CLANGDWARF_ARM_DLINK_FLAGS = DEF(CLANGDWARF_ARM_DLINK_FLAGS) -flto -Wl,-O1 -L$(WORKSPACE)/ArmPkg/Library/GccLto -llto-arm -Wl,-plugin-opt=-pass-through=-llto-arm
|
||||||
NOOPT_CLANGDWARF_ARM_CC_FLAGS = DEF(CLANGDWARF_ARM_CC_FLAGS) $(PLATFORM_FLAGS) -O0
|
NOOPT_CLANGDWARF_ARM_CC_FLAGS = DEF(CLANGDWARF_ARM_CC_FLAGS) -O0
|
||||||
NOOPT_CLANGDWARF_ARM_DLINK_FLAGS = DEF(CLANGDWARF_ARM_DLINK_FLAGS) -fuse-ld=lld -Wl,--no-pie,--no-relax
|
NOOPT_CLANGDWARF_ARM_DLINK_FLAGS = DEF(CLANGDWARF_ARM_DLINK_FLAGS)
|
||||||
RELEASE_CLANGDWARF_ARM_CC_FLAGS = DEF(CLANGDWARF_ARM_CC_FLAGS) $(PLATFORM_FLAGS) -flto -O3
|
RELEASE_CLANGDWARF_ARM_CC_FLAGS = DEF(CLANGDWARF_ARM_CC_FLAGS) -flto -O3
|
||||||
RELEASE_CLANGDWARF_ARM_DLINK_FLAGS = DEF(CLANGDWARF_ARM_DLINK_FLAGS) -flto -Wl,-O3 -fuse-ld=lld -L$(WORKSPACE)/ArmPkg/Library/GccLto -llto-arm -Wl,-plugin-opt=-pass-through=-llto-arm -Wl,--no-pie,--no-relax
|
RELEASE_CLANGDWARF_ARM_DLINK_FLAGS = DEF(CLANGDWARF_ARM_DLINK_FLAGS) -flto -Wl,-O3 -L$(WORKSPACE)/ArmPkg/Library/GccLto -llto-arm -Wl,-plugin-opt=-pass-through=-llto-arm
|
||||||
|
|
||||||
##################
|
##################
|
||||||
# CLANGDWARF AARCH64 definitions
|
# CLANGDWARF AARCH64 definitions
|
||||||
##################
|
##################
|
||||||
DEFINE CLANGDWARF_AARCH64_TARGET = -target aarch64-linux-gnu
|
DEFINE CLANGDWARF_AARCH64_TARGET = -target aarch64-linux-gnu
|
||||||
DEFINE CLANGDWARF_AARCH64_CC_FLAGS = DEF(GCC_AARCH64_CC_FLAGS) DEF(CLANGDWARF_AARCH64_TARGET) -mcmodel=small DEF(CLANGDWARF_WARNING_OVERRIDES)
|
DEFINE CLANGDWARF_AARCH64_CC_FLAGS = DEF(GCC_AARCH64_CC_FLAGS) DEF(CLANGDWARF_AARCH64_TARGET) -mcmodel=small DEF(CLANGDWARF_WARNING_OVERRIDES)
|
||||||
DEFINE CLANGDWARF_AARCH64_DLINK_FLAGS = DEF(CLANGDWARF_AARCH64_TARGET) DEF(GCC_AARCH64_DLINK_FLAGS) -z common-page-size=0x1000
|
DEFINE CLANGDWARF_AARCH64_DLINK_FLAGS = DEF(CLANGDWARF_AARCH64_TARGET) DEF(GCC_AARCH64_DLINK_FLAGS) DEF(GCC_ALIGN) -fuse-ld=lld -Wl,--apply-dynamic-relocs,--no-pie,--no-relax
|
||||||
|
|
||||||
*_CLANGDWARF_AARCH64_PP_FLAGS = DEF(GCC_PP_FLAGS)
|
*_CLANGDWARF_AARCH64_PP_FLAGS = DEF(GCC_PP_FLAGS)
|
||||||
*_CLANGDWARF_AARCH64_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS)
|
*_CLANGDWARF_AARCH64_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS)
|
||||||
|
@ -1992,37 +1970,35 @@ DEFINE CLANGDWARF_AARCH64_DLINK_FLAGS = DEF(CLANGDWARF_AARCH64_TARGET) DEF(GCC_
|
||||||
*_CLANGDWARF_AARCH64_ASL_OUTFLAGS = DEF(IASL_OUTFLAGS)
|
*_CLANGDWARF_AARCH64_ASL_OUTFLAGS = DEF(IASL_OUTFLAGS)
|
||||||
*_CLANGDWARF_AARCH64_DTCPP_FLAGS = DEF(GCC_DTCPP_FLAGS)
|
*_CLANGDWARF_AARCH64_DTCPP_FLAGS = DEF(GCC_DTCPP_FLAGS)
|
||||||
|
|
||||||
*_CLANGDWARF_AARCH64_CC_PATH = ENV(CLANGDWARF_BIN)clang
|
*_CLANGDWARF_AARCH64_OBJCOPY_PATH = DEF(CLANGDWARF_AARCH64_PREFIX)llvm-objcopy
|
||||||
*_CLANGDWARF_AARCH64_ASM_PATH = ENV(CLANGDWARF_BIN)clang
|
*_CLANGDWARF_AARCH64_CC_PATH = DEF(CLANGDWARF_AARCH64_PREFIX)clang
|
||||||
*_CLANGDWARF_AARCH64_PP_PATH = ENV(CLANGDWARF_BIN)clang
|
*_CLANGDWARF_AARCH64_ASM_PATH = DEF(CLANGDWARF_AARCH64_PREFIX)clang
|
||||||
*_CLANGDWARF_AARCH64_VFRPP_PATH = ENV(CLANGDWARF_BIN)clang
|
*_CLANGDWARF_AARCH64_PP_PATH = DEF(CLANGDWARF_AARCH64_PREFIX)clang
|
||||||
*_CLANGDWARF_AARCH64_ASLCC_PATH = ENV(CLANGDWARF_BIN)clang
|
*_CLANGDWARF_AARCH64_VFRPP_PATH = DEF(CLANGDWARF_AARCH64_PREFIX)clang
|
||||||
*_CLANGDWARF_AARCH64_ASLPP_PATH = ENV(CLANGDWARF_BIN)clang
|
*_CLANGDWARF_AARCH64_ASLCC_PATH = DEF(CLANGDWARF_AARCH64_PREFIX)clang
|
||||||
*_CLANGDWARF_AARCH64_DLINK_PATH = ENV(CLANGDWARF_BIN)clang
|
*_CLANGDWARF_AARCH64_ASLPP_PATH = DEF(CLANGDWARF_AARCH64_PREFIX)clang
|
||||||
*_CLANGDWARF_AARCH64_ASLDLINK_PATH = ENV(CLANGDWARF_BIN)clang
|
*_CLANGDWARF_AARCH64_DLINK_PATH = DEF(CLANGDWARF_AARCH64_PREFIX)clang
|
||||||
|
*_CLANGDWARF_AARCH64_ASLDLINK_PATH = DEF(CLANGDWARF_AARCH64_PREFIX)clang
|
||||||
*_CLANGDWARF_AARCH64_SLINK_PATH = ENV(CLANGDWARF_BIN)llvm-ar
|
*_CLANGDWARF_AARCH64_SLINK_PATH = DEF(CLANGDWARF_AARCH64_PREFIX)llvm-ar
|
||||||
*_CLANGDWARF_AARCH64_RC_PATH = ENV(CLANGDWARF_BIN)llvm-objcopy
|
*_CLANGDWARF_AARCH64_RC_PATH = DEF(CLANGDWARF_AARCH64_PREFIX)llvm-objcopy
|
||||||
|
|
||||||
*_CLANGDWARF_AARCH64_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS) -fno-lto
|
*_CLANGDWARF_AARCH64_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS) -fno-lto
|
||||||
*_CLANGDWARF_AARCH64_ASLDLINK_FLAGS = DEF(CLANGDWARF_AARCH64_TARGET) DEF(GCC_AARCH64_ASLDLINK_FLAGS)
|
*_CLANGDWARF_AARCH64_ASLDLINK_FLAGS = DEF(CLANGDWARF_AARCH64_TARGET) DEF(GCC_AARCH64_ASLDLINK_FLAGS) -fuse-ld=lld
|
||||||
*_CLANGDWARF_AARCH64_ASM_FLAGS = DEF(GCC_ASM_FLAGS) DEF(CLANGDWARF_AARCH64_TARGET) $(PLATFORM_FLAGS) -Qunused-arguments
|
*_CLANGDWARF_AARCH64_ASM_FLAGS = DEF(GCC_ASM_FLAGS) DEF(CLANGDWARF_AARCH64_TARGET) -Qunused-arguments
|
||||||
*_CLANGDWARF_AARCH64_DLINK_FLAGS = DEF(CLANGDWARF_AARCH64_TARGET) DEF(GCC_AARCH64_DLINK_FLAGS) -z common-page-size=0x1000
|
*_CLANGDWARF_AARCH64_DLINK_FLAGS = DEF(CLANGDWARF_AARCH64_TARGET) DEF(GCC_AARCH64_DLINK_FLAGS) DEF(GCC_ALIGN)
|
||||||
*_CLANGDWARF_AARCH64_DLINK_XIPFLAGS = -z common-page-size=0x20
|
*_CLANGDWARF_AARCH64_DLINK_XIPFLAGS = DEF(GCC_ALIGN)
|
||||||
*_CLANGDWARF_AARCH64_DLINK2_FLAGS = DEF(GCC_DLINK2_FLAGS_COMMON) -Wl,--defsym=PECOFF_HEADER_SIZE=0x228
|
*_CLANGDWARF_AARCH64_DLINK2_FLAGS = DEF(GCC_DLINK2_FLAGS_COMMON)
|
||||||
*_CLANGDWARF_AARCH64_PLATFORM_FLAGS =
|
*_CLANGDWARF_AARCH64_PP_FLAGS = DEF(GCC_PP_FLAGS) DEF(CLANGDWARF_AARCH64_TARGET)
|
||||||
*_CLANGDWARF_AARCH64_PP_FLAGS = DEF(GCC_PP_FLAGS) DEF(CLANGDWARF_AARCH64_TARGET) $(PLATFORM_FLAGS)
|
*_CLANGDWARF_AARCH64_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS) DEF(CLANGDWARF_AARCH64_TARGET)
|
||||||
*_CLANGDWARF_AARCH64_RC_FLAGS = DEF(GCC_AARCH64_RC_FLAGS) DEF(GCC_AARCH64_RC_BTI_FLAGS)
|
|
||||||
*_CLANGDWARF_AARCH64_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS) DEF(CLANGDWARF_AARCH64_TARGET) $(PLATFORM_FLAGS)
|
|
||||||
*_CLANGDWARF_AARCH64_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS) DEF(CLANGDWARF_AARCH64_TARGET)
|
*_CLANGDWARF_AARCH64_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS) DEF(CLANGDWARF_AARCH64_TARGET)
|
||||||
*_CLANGDWARF_AARCH64_CC_XIPFLAGS = -mstrict-align
|
*_CLANGDWARF_AARCH64_CC_XIPFLAGS = -mstrict-align
|
||||||
|
|
||||||
DEBUG_CLANGDWARF_AARCH64_CC_FLAGS = DEF(CLANGDWARF_AARCH64_CC_FLAGS) $(PLATFORM_FLAGS) -flto -O1
|
DEBUG_CLANGDWARF_AARCH64_CC_FLAGS = DEF(CLANGDWARF_AARCH64_CC_FLAGS) -flto -O1
|
||||||
DEBUG_CLANGDWARF_AARCH64_DLINK_FLAGS = DEF(CLANGDWARF_AARCH64_DLINK_FLAGS) -flto -Wl,-O1 -fuse-ld=lld -L$(WORKSPACE)/ArmPkg/Library/GccLto -llto-aarch64 -Wl,-plugin-opt=-pass-through=-llto-aarch64 -Wl,--no-pie,--no-relax
|
DEBUG_CLANGDWARF_AARCH64_DLINK_FLAGS = DEF(CLANGDWARF_AARCH64_DLINK_FLAGS) -flto -Wl,-O1 -L$(WORKSPACE)/ArmPkg/Library/GccLto -llto-aarch64 -Wl,-plugin-opt=-pass-through=-llto-aarch64
|
||||||
NOOPT_CLANGDWARF_AARCH64_CC_FLAGS = DEF(CLANGDWARF_AARCH64_CC_FLAGS) $(PLATFORM_FLAGS) -O0
|
NOOPT_CLANGDWARF_AARCH64_CC_FLAGS = DEF(CLANGDWARF_AARCH64_CC_FLAGS) -O0
|
||||||
NOOPT_CLANGDWARF_AARCH64_DLINK_FLAGS = DEF(CLANGDWARF_AARCH64_DLINK_FLAGS) -fuse-ld=lld -Wl,--no-pie,--no-relax
|
NOOPT_CLANGDWARF_AARCH64_DLINK_FLAGS = DEF(CLANGDWARF_AARCH64_DLINK_FLAGS)
|
||||||
RELEASE_CLANGDWARF_AARCH64_CC_FLAGS = DEF(CLANGDWARF_AARCH64_CC_FLAGS) $(PLATFORM_FLAGS) -flto -O3
|
RELEASE_CLANGDWARF_AARCH64_CC_FLAGS = DEF(CLANGDWARF_AARCH64_CC_FLAGS) -flto -O3
|
||||||
RELEASE_CLANGDWARF_AARCH64_DLINK_FLAGS = DEF(CLANGDWARF_AARCH64_DLINK_FLAGS) -flto -Wl,-O3 -fuse-ld=lld -L$(WORKSPACE)/ArmPkg/Library/GccLto -llto-aarch64 -Wl,-plugin-opt=-pass-through=-llto-aarch64 -Wl,--no-pie,--no-relax
|
RELEASE_CLANGDWARF_AARCH64_DLINK_FLAGS = DEF(CLANGDWARF_AARCH64_DLINK_FLAGS) -flto -Wl,-O3 -L$(WORKSPACE)/ArmPkg/Library/GccLto -llto-aarch64 -Wl,-plugin-opt=-pass-through=-llto-aarch64
|
||||||
|
|
||||||
##################
|
##################
|
||||||
# CLANGDWARF RISCV64 definitions
|
# CLANGDWARF RISCV64 definitions
|
||||||
|
@ -2099,14 +2075,28 @@ RELEASE_CLANGDWARF_RISCV64_DLINK_FLAGS = DEF(CLANGDWARF_RISCV64_DLINK_FLAGS) -fl
|
||||||
*_XCODE5_*_ASLPP_PATH = clang
|
*_XCODE5_*_ASLPP_PATH = clang
|
||||||
*_XCODE5_*_ASLDLINK_PATH = ld
|
*_XCODE5_*_ASLDLINK_PATH = ld
|
||||||
*_XCODE5_*_DSYMUTIL_PATH = /usr/bin/dsymutil
|
*_XCODE5_*_DSYMUTIL_PATH = /usr/bin/dsymutil
|
||||||
*_XCODE5_*_MTOC_PATH = /usr/local/bin/mtoc
|
*_XCODE5_*_MTOC_PATH = ENV(MTOC_PREFIX)mtoc
|
||||||
*_XCODE5_*_DEPS_FLAGS = DEF(GCC_DEPS_FLAGS)
|
*_XCODE5_*_DEPS_FLAGS = DEF(GCC_DEPS_FLAGS)
|
||||||
|
|
||||||
|
#
|
||||||
|
# x86_64 Preload Mach-O files index relocations relative to the first writable
|
||||||
|
# section, usually in __DATA. Merging __DATA,__const, which may have relocations
|
||||||
|
# targeting it, into __TEXT moves it in front of __DATA, yielding negative
|
||||||
|
# offsets to the relocation base address. These cannot be represented by the
|
||||||
|
# Mach-O relocation offsets, resulting in a broken binary.
|
||||||
|
# To work around this, introduce a new 0-sized segment __RO_RELOCS segment with
|
||||||
|
# RW permissions, which will make all relocations relative to the beginning of
|
||||||
|
# image. This also makes the usage of "-read_only_relocs suppress" safe, as
|
||||||
|
# relocations can now target __TEXT without triggering the same issue.
|
||||||
|
#
|
||||||
|
DEFINE XCODE5_RORELOCS_ARGS = -segprot __RO_RELOCS rw- rw- -segment_order __RO_RELOCS:__TEXT:__DATA_CONST:__DATA -rename_section __TEXT __text __RO_RELOCS __text -rename_section __RO_RELOCS __text __TEXT __text
|
||||||
|
DEFINE XCODE5_RODATA_ARGS = DEF(XCODE5_RORELOCS_ARGS) -segprot __DATA_CONST r-- r-- -rename_section __DATA __const __DATA_CONST __const -rename_section __TEXT __const __DATA_CONST __text_const -rename_section __TEXT __cstring __DATA_CONST __cstring -rename_section __TEXT __ustring __DATA_CONST __ustring
|
||||||
|
|
||||||
##################
|
##################
|
||||||
# ASL definitions
|
# ASL definitions
|
||||||
##################
|
##################
|
||||||
*_XCODE5_*_ASLCC_FLAGS = -x c -save-temps -g -O0 -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-missing-braces -c -include AutoGen.h
|
*_XCODE5_*_ASLCC_FLAGS = -x c -save-temps -g -O0 -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-missing-braces -c -include AutoGen.h
|
||||||
*_XCODE5_*_ASLDLINK_FLAGS = -e _ReferenceAcpiTable -preload -segalign 0x20 -pie -seg1addr 0x240 -read_only_relocs suppress -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map
|
*_XCODE5_*_ASLDLINK_FLAGS = DEF(XCODE5_RODATA_ARGS) -e _ReferenceAcpiTable -preload -segalign DEF(XCODE_ALIGN) -pie -seg1addr DEF(XCODE_ADDR) -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map
|
||||||
*_XCODE5_*_ASLPP_FLAGS = -x c -E -include AutoGen.h
|
*_XCODE5_*_ASLPP_FLAGS = -x c -E -include AutoGen.h
|
||||||
*_XCODE5_*_ASL_FLAGS =
|
*_XCODE5_*_ASL_FLAGS =
|
||||||
*_XCODE5_*_ASL_OUTFLAGS = DEF(IASL_OUTFLAGS)
|
*_XCODE5_*_ASL_OUTFLAGS = DEF(IASL_OUTFLAGS)
|
||||||
|
@ -2115,46 +2105,46 @@ RELEASE_CLANGDWARF_RISCV64_DLINK_FLAGS = DEF(CLANGDWARF_RISCV64_DLINK_FLAGS) -fl
|
||||||
# MTOC definitions
|
# MTOC definitions
|
||||||
##################
|
##################
|
||||||
|
|
||||||
DEBUG_XCODE5_*_MTOC_FLAGS = -align 0x20 -d $(DEBUG_DIR)/$(MODULE_NAME).dll
|
DEBUG_XCODE5_*_MTOC_FLAGS = -align DEF(XCODE_ALIGN) -d $(DEBUG_DIR)/$(MODULE_NAME).dll -require_read_only_relocs
|
||||||
NOOPT_XCODE5_*_MTOC_FLAGS = -align 0x20 -d $(DEBUG_DIR)/$(MODULE_NAME).dll
|
NOOPT_XCODE5_*_MTOC_FLAGS = -align DEF(XCODE_ALIGN) -d $(DEBUG_DIR)/$(MODULE_NAME).dll -require_read_only_relocs
|
||||||
RELEASE_XCODE5_*_MTOC_FLAGS = -align 0x20
|
RELEASE_XCODE5_*_MTOC_FLAGS = -align DEF(XCODE_ALIGN) -require_read_only_relocs
|
||||||
|
|
||||||
####################
|
####################
|
||||||
# IA-32 definitions
|
# IA-32 definitions
|
||||||
####################
|
####################
|
||||||
DEBUG_XCODE5_IA32_DLINK_FLAGS = -arch i386 -u _$(IMAGE_ENTRY_POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign 0x20 -pie -all_load -dead_strip -seg1addr 0x240 -read_only_relocs suppress -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map
|
DEBUG_XCODE5_IA32_DLINK_FLAGS = DEF(XCODE5_RODATA_ARGS) -arch i386 -u _$(IMAGE_ENTRY_POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign DEF(XCODE_ALIGN) -pie -all_load -dead_strip -seg1addr DEF(XCODE_ADDR) -read_only_relocs suppress -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map DEF(XCODE_MERGE)
|
||||||
NOOPT_XCODE5_IA32_DLINK_FLAGS = -arch i386 -u _$(IMAGE_ENTRY_POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign 0x20 -pie -all_load -dead_strip -seg1addr 0x240 -read_only_relocs suppress -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map
|
NOOPT_XCODE5_IA32_DLINK_FLAGS = DEF(XCODE5_RODATA_ARGS) -arch i386 -u _$(IMAGE_ENTRY_POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign DEF(XCODE_ALIGN) -pie -all_load -dead_strip -seg1addr DEF(XCODE_ADDR) -read_only_relocs suppress -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map DEF(XCODE_MERGE)
|
||||||
RELEASE_XCODE5_IA32_DLINK_FLAGS = -arch i386 -u _$(IMAGE_ENTRY_POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign 0x20 -pie -all_load -dead_strip -seg1addr 0x240 -read_only_relocs suppress -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map
|
RELEASE_XCODE5_IA32_DLINK_FLAGS = DEF(XCODE5_RODATA_ARGS) -arch i386 -u _$(IMAGE_ENTRY_POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign DEF(XCODE_ALIGN) -pie -all_load -dead_strip -seg1addr DEF(XCODE_ADDR) -read_only_relocs suppress -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map DEF(XCODE_MERGE)
|
||||||
|
|
||||||
*_XCODE5_IA32_SLINK_FLAGS = -static -o
|
*_XCODE5_IA32_SLINK_FLAGS = -static -o
|
||||||
DEBUG_XCODE5_IA32_ASM_FLAGS = -arch i386 -g
|
DEBUG_XCODE5_IA32_ASM_FLAGS = -arch i386 -g
|
||||||
NOOPT_XCODE5_IA32_ASM_FLAGS = -arch i386 -g
|
NOOPT_XCODE5_IA32_ASM_FLAGS = -arch i386 -g
|
||||||
RELEASE_XCODE5_IA32_ASM_FLAGS = -arch i386
|
RELEASE_XCODE5_IA32_ASM_FLAGS = -arch i386
|
||||||
*_XCODE5_IA32_NASM_FLAGS = -f macho32
|
*_XCODE5_IA32_NASM_FLAGS = -f macho32 -DRODATA_SECTION_NAME=.rodata
|
||||||
|
|
||||||
|
|
||||||
DEBUG_XCODE5_IA32_CC_FLAGS = -arch i386 -c -g -Os -Wall -Werror -include AutoGen.h -funsigned-char -fno-stack-protector -fno-builtin -fshort-wchar -fasm-blocks -mdynamic-no-pic -mno-implicit-float -mms-bitfields -msoft-float -Wno-unused-parameter -Wno-missing-braces -Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare -Wno-varargs -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang $(PLATFORM_FLAGS)
|
DEBUG_XCODE5_IA32_CC_FLAGS = -arch i386 -c -g -Os -Wall -Werror -include AutoGen.h -funsigned-char -fno-stack-protector -fno-builtin -fshort-wchar -fasm-blocks -mdynamic-no-pic -mno-implicit-float -mms-bitfields -msoft-float -Wno-unused-parameter -Wno-missing-braces -Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare -Wno-varargs -Wno-unknown-warning-option -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang
|
||||||
RELEASE_XCODE5_IA32_CC_FLAGS = -arch i386 -c -Os -Wall -Werror -include AutoGen.h -funsigned-char -fno-stack-protector -fno-builtin -fshort-wchar -fasm-blocks -mdynamic-no-pic -mno-implicit-float -mms-bitfields -msoft-float -Wno-unused-parameter -Wno-missing-braces -Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare -Wno-varargs -Wno-unused-const-variable -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang $(PLATFORM_FLAGS)
|
RELEASE_XCODE5_IA32_CC_FLAGS = -arch i386 -c -Os -Wall -Werror -include AutoGen.h -funsigned-char -fno-stack-protector -fno-builtin -fshort-wchar -fasm-blocks -mdynamic-no-pic -mno-implicit-float -mms-bitfields -msoft-float -Wno-unused-parameter -Wno-missing-braces -Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare -Wno-varargs -Wno-unknown-warning-option -Wno-unused-const-variable -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang
|
||||||
NOOPT_XCODE5_IA32_CC_FLAGS = -arch i386 -c -g -O0 -Wall -Werror -include AutoGen.h -funsigned-char -fno-stack-protector -fno-builtin -fshort-wchar -fasm-blocks -mdynamic-no-pic -mno-implicit-float -mms-bitfields -msoft-float -Wno-unused-parameter -Wno-missing-braces -Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare -Wno-varargs -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang $(PLATFORM_FLAGS)
|
NOOPT_XCODE5_IA32_CC_FLAGS = -arch i386 -c -g -O0 -Wall -Werror -include AutoGen.h -funsigned-char -fno-stack-protector -fno-builtin -fshort-wchar -fasm-blocks -mdynamic-no-pic -mno-implicit-float -mms-bitfields -msoft-float -Wno-unused-parameter -Wno-missing-braces -Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare -Wno-varargs -Wno-unknown-warning-option -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang
|
||||||
|
|
||||||
##################
|
##################
|
||||||
# X64 definitions
|
# X64 definitions
|
||||||
##################
|
##################
|
||||||
DEBUG_XCODE5_X64_DLINK_FLAGS = -arch x86_64 -u _$(IMAGE_ENTRY_POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign 0x20 -pie -all_load -dead_strip -seg1addr 0x240 -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map
|
DEBUG_XCODE5_X64_DLINK_FLAGS = DEF(XCODE5_RODATA_ARGS) -arch x86_64 -u _$(IMAGE_ENTRY_POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign DEF(XCODE_ALIGN) -pie -all_load -dead_strip -seg1addr DEF(XCODE_ADDR) -read_only_relocs suppress -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map DEF(XCODE_MERGE)
|
||||||
NOOPT_XCODE5_X64_DLINK_FLAGS = -arch x86_64 -u _$(IMAGE_ENTRY_POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign 0x20 -pie -all_load -dead_strip -seg1addr 0x240 -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map
|
NOOPT_XCODE5_X64_DLINK_FLAGS = DEF(XCODE5_RODATA_ARGS) -arch x86_64 -u _$(IMAGE_ENTRY_POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign DEF(XCODE_ALIGN) -pie -all_load -dead_strip -seg1addr DEF(XCODE_ADDR) -read_only_relocs suppress -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map DEF(XCODE_MERGE)
|
||||||
RELEASE_XCODE5_X64_DLINK_FLAGS = -arch x86_64 -u _$(IMAGE_ENTRY_POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign 0x20 -pie -all_load -dead_strip -seg1addr 0x240 -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map
|
RELEASE_XCODE5_X64_DLINK_FLAGS = DEF(XCODE5_RODATA_ARGS) -arch x86_64 -u _$(IMAGE_ENTRY_POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign DEF(XCODE_ALIGN) -pie -all_load -dead_strip -seg1addr DEF(XCODE_ADDR) -read_only_relocs suppress -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map DEF(XCODE_MERGE)
|
||||||
|
|
||||||
*_XCODE5_X64_SLINK_FLAGS = -static -o
|
*_XCODE5_X64_SLINK_FLAGS = -static -o
|
||||||
DEBUG_XCODE5_X64_ASM_FLAGS = -arch x86_64 -g
|
DEBUG_XCODE5_X64_ASM_FLAGS = -arch x86_64 -g
|
||||||
NOOPT_XCODE5_X64_ASM_FLAGS = -arch x86_64 -g
|
NOOPT_XCODE5_X64_ASM_FLAGS = -arch x86_64 -g
|
||||||
RELEASE_XCODE5_X64_ASM_FLAGS = -arch x86_64
|
RELEASE_XCODE5_X64_ASM_FLAGS = -arch x86_64
|
||||||
*_XCODE5_X64_NASM_FLAGS = -f macho64
|
*_XCODE5_X64_NASM_FLAGS = -f macho64 -DRODATA_SECTION_NAME=.rodata
|
||||||
*_XCODE5_*_PP_FLAGS = -E -x assembler-with-cpp -include AutoGen.h
|
*_XCODE5_*_PP_FLAGS = -E -x assembler-with-cpp -include AutoGen.h
|
||||||
*_XCODE5_*_VFRPP_FLAGS = -x c -E -P -DVFRCOMPILE -include $(MODULE_NAME)StrDefs.h
|
*_XCODE5_*_VFRPP_FLAGS = -x c -E -P -DVFRCOMPILE -include $(MODULE_NAME)StrDefs.h
|
||||||
|
|
||||||
DEBUG_XCODE5_X64_CC_FLAGS = -target x86_64-pc-win32-macho -c -g -gdwarf -Os -Wall -Werror -Wextra -include AutoGen.h -funsigned-char -fno-ms-extensions -fno-stack-protector -fno-builtin -fshort-wchar -mno-implicit-float -mms-bitfields -Wno-unused-parameter -Wno-missing-braces -Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare -Wno-varargs -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang -D NO_MSABI_VA_FUNCS $(PLATFORM_FLAGS)
|
DEBUG_XCODE5_X64_CC_FLAGS = -target x86_64-pc-win32-macho -c -g -gdwarf -Os -Wall -Werror -Wextra -include AutoGen.h -funsigned-char -fno-ms-extensions -fno-stack-protector -fno-builtin -fshort-wchar -mno-implicit-float -mms-bitfields -Wno-unused-parameter -Wno-missing-braces -Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare -Wno-varargs -Wno-unknown-warning-option -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang -D NO_MSABI_VA_FUNCS
|
||||||
NOOPT_XCODE5_X64_CC_FLAGS = -target x86_64-pc-win32-macho -c -g -gdwarf -O0 -Wall -Werror -Wextra -include AutoGen.h -funsigned-char -fno-ms-extensions -fno-stack-protector -fno-builtin -fshort-wchar -mno-implicit-float -mms-bitfields -Wno-unused-parameter -Wno-missing-braces -Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare -Wno-varargs -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang -D NO_MSABI_VA_FUNCS $(PLATFORM_FLAGS)
|
NOOPT_XCODE5_X64_CC_FLAGS = -target x86_64-pc-win32-macho -c -g -gdwarf -O0 -Wall -Werror -Wextra -include AutoGen.h -funsigned-char -fno-ms-extensions -fno-stack-protector -fno-builtin -fshort-wchar -mno-implicit-float -mms-bitfields -Wno-unused-parameter -Wno-missing-braces -Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare -Wno-varargs -Wno-unknown-warning-option -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang -D NO_MSABI_VA_FUNCS
|
||||||
RELEASE_XCODE5_X64_CC_FLAGS = -target x86_64-pc-win32-macho -c -Os -Wall -Werror -Wextra -include AutoGen.h -funsigned-char -fno-ms-extensions -fno-stack-protector -fno-builtin -fshort-wchar -mno-implicit-float -mms-bitfields -Wno-unused-parameter -Wno-missing-braces -Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare -Wno-varargs -Wno-unused-const-variable -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang -D NO_MSABI_VA_FUNCS $(PLATFORM_FLAGS)
|
RELEASE_XCODE5_X64_CC_FLAGS = -target x86_64-pc-win32-macho -c -Os -Wall -Werror -Wextra -include AutoGen.h -funsigned-char -fno-ms-extensions -fno-stack-protector -fno-builtin -fshort-wchar -mno-implicit-float -mms-bitfields -Wno-unused-parameter -Wno-missing-braces -Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare -Wno-varargs -Wno-unused-const-variable -Wno-unknown-warning-option -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang -D NO_MSABI_VA_FUNCS
|
||||||
|
|
||||||
#################
|
#################
|
||||||
# ASM 16 linker definitions
|
# ASM 16 linker definitions
|
||||||
|
@ -2174,12 +2164,6 @@ RELEASE_XCODE5_X64_CC_FLAGS = -target x86_64-pc-win32-macho -c -Os -W
|
||||||
*_*_*_OPTROM_PATH = EfiRom
|
*_*_*_OPTROM_PATH = EfiRom
|
||||||
*_*_*_OPTROM_FLAGS = -e
|
*_*_*_OPTROM_FLAGS = -e
|
||||||
|
|
||||||
##################
|
|
||||||
# GenFw tool definitions
|
|
||||||
##################
|
|
||||||
*_*_*_GENFW_PATH = GenFw
|
|
||||||
*_*_*_GENFW_FLAGS =
|
|
||||||
|
|
||||||
##################
|
##################
|
||||||
# Asl Compiler definitions
|
# Asl Compiler definitions
|
||||||
##################
|
##################
|
||||||
|
|
|
@ -10,7 +10,7 @@ all: subdirs
|
||||||
LANGUAGES = C Python
|
LANGUAGES = C Python
|
||||||
|
|
||||||
SOURCE_SUBDIRS := $(patsubst %,Source/%,$(sort $(LANGUAGES)))
|
SOURCE_SUBDIRS := $(patsubst %,Source/%,$(sort $(LANGUAGES)))
|
||||||
SUBDIRS := $(SOURCE_SUBDIRS) Tests
|
SUBDIRS := $(SOURCE_SUBDIRS) Tests ImageTool MicroTool
|
||||||
CLEAN_SUBDIRS := $(patsubst %,%-clean,$(sort $(SUBDIRS)))
|
CLEAN_SUBDIRS := $(patsubst %,%-clean,$(sort $(SUBDIRS)))
|
||||||
|
|
||||||
.PHONY: subdirs $(SUBDIRS)
|
.PHONY: subdirs $(SUBDIRS)
|
||||||
|
|
|
@ -0,0 +1,200 @@
|
||||||
|
/** @file
|
||||||
|
Copyright (c) 2022, Mikhail Krichanov. All rights reserved.
|
||||||
|
SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include "ImageTool.h"
|
||||||
|
|
||||||
|
static
|
||||||
|
EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *
|
||||||
|
CreateEntry (
|
||||||
|
IN UINT8 *HiiSectionHeader,
|
||||||
|
IN OUT UINT32 *HiiSectionOffset,
|
||||||
|
IN BOOLEAN DataIsDirectory
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_IMAGE_RESOURCE_DIRECTORY *RDir;
|
||||||
|
EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *Entry;
|
||||||
|
|
||||||
|
assert (HiiSectionHeader != NULL);
|
||||||
|
assert (HiiSectionOffset != NULL);
|
||||||
|
|
||||||
|
RDir = (EFI_IMAGE_RESOURCE_DIRECTORY *)(HiiSectionHeader + *HiiSectionOffset);
|
||||||
|
*HiiSectionOffset += sizeof (EFI_IMAGE_RESOURCE_DIRECTORY);
|
||||||
|
RDir->NumberOfNamedEntries = 1;
|
||||||
|
|
||||||
|
Entry = (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *)(HiiSectionHeader + *HiiSectionOffset);
|
||||||
|
*HiiSectionOffset += sizeof (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY);
|
||||||
|
Entry->u1.s.NameIsString = 1;
|
||||||
|
|
||||||
|
if (DataIsDirectory) {
|
||||||
|
Entry->u2.s.DataIsDirectory = 1;
|
||||||
|
Entry->u2.s.OffsetToDirectory = *HiiSectionOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
void
|
||||||
|
CreateStringEntry (
|
||||||
|
IN OUT EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *Entry,
|
||||||
|
IN UINT8 *HiiSectionHeader,
|
||||||
|
IN OUT UINT32 *HiiSectionOffset,
|
||||||
|
IN CHAR16 *String
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_IMAGE_RESOURCE_DIRECTORY_STRING *RDStr;
|
||||||
|
|
||||||
|
assert (Entry != NULL);
|
||||||
|
assert (HiiSectionHeader != NULL);
|
||||||
|
assert (HiiSectionOffset != NULL);
|
||||||
|
assert (String != NULL);
|
||||||
|
|
||||||
|
Entry->u1.s.NameOffset = *HiiSectionOffset;
|
||||||
|
RDStr = (EFI_IMAGE_RESOURCE_DIRECTORY_STRING *)(HiiSectionHeader + *HiiSectionOffset);
|
||||||
|
RDStr->Length = (UINT16)StrLen (String);
|
||||||
|
memcpy (RDStr->String, String, RDStr->Length * sizeof (RDStr->String[0]));
|
||||||
|
*HiiSectionOffset += sizeof (*RDStr) + RDStr->Length * sizeof (RDStr->String[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 mHiiResourceSectionHeaderSize =
|
||||||
|
3 * (sizeof (EFI_IMAGE_RESOURCE_DIRECTORY) + sizeof (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY)
|
||||||
|
+ sizeof (EFI_IMAGE_RESOURCE_DIRECTORY_STRING) + 3 * sizeof (CHAR16)) + sizeof (EFI_IMAGE_RESOURCE_DATA_ENTRY);
|
||||||
|
|
||||||
|
VOID
|
||||||
|
InitializeHiiResouceSectionHeader (
|
||||||
|
OUT UINT8 *HiiSectionHeader,
|
||||||
|
IN UINT32 HiiDataAddress,
|
||||||
|
IN UINT32 HiiDataSize
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINT32 HiiSectionOffset;
|
||||||
|
EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *TypeRDirEntry;
|
||||||
|
EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *NameRDirEntry;
|
||||||
|
EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *LangRDirEntry;
|
||||||
|
EFI_IMAGE_RESOURCE_DATA_ENTRY *ResourceDataEntry;
|
||||||
|
|
||||||
|
assert (HiiSectionHeader != NULL);
|
||||||
|
|
||||||
|
HiiSectionOffset = 0;
|
||||||
|
//
|
||||||
|
// Create Type, Name, Language entries
|
||||||
|
//
|
||||||
|
TypeRDirEntry = CreateEntry (HiiSectionHeader, &HiiSectionOffset, TRUE);
|
||||||
|
NameRDirEntry = CreateEntry (HiiSectionHeader, &HiiSectionOffset, TRUE);
|
||||||
|
LangRDirEntry = CreateEntry (HiiSectionHeader, &HiiSectionOffset, FALSE);
|
||||||
|
//
|
||||||
|
// Create string entry for Type, Name, Language
|
||||||
|
//
|
||||||
|
CreateStringEntry (TypeRDirEntry, HiiSectionHeader, &HiiSectionOffset, L"HII");
|
||||||
|
CreateStringEntry (NameRDirEntry, HiiSectionHeader, &HiiSectionOffset, L"EFI");
|
||||||
|
CreateStringEntry (LangRDirEntry, HiiSectionHeader, &HiiSectionOffset, L"BIN");
|
||||||
|
//
|
||||||
|
// Create Leaf data
|
||||||
|
//
|
||||||
|
LangRDirEntry->u2.OffsetToData = HiiSectionOffset;
|
||||||
|
ResourceDataEntry = (EFI_IMAGE_RESOURCE_DATA_ENTRY *)(HiiSectionHeader + HiiSectionOffset);
|
||||||
|
HiiSectionOffset += sizeof (EFI_IMAGE_RESOURCE_DATA_ENTRY);
|
||||||
|
ResourceDataEntry->OffsetToData = HiiDataAddress + HiiSectionOffset;
|
||||||
|
ResourceDataEntry->Size = HiiDataSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
RETURN_STATUS
|
||||||
|
ConstructHii (
|
||||||
|
IN const char *FileNames[],
|
||||||
|
IN UINT32 NumOfFiles,
|
||||||
|
IN GUID *HiiGuid,
|
||||||
|
OUT void **Hii,
|
||||||
|
OUT UINT32 *HiiSize
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINT8 *HiiPackageData;
|
||||||
|
UINT8 *HiiPackageDataPointer;
|
||||||
|
EFI_HII_PACKAGE_LIST_HEADER HiiPackageListHeader;
|
||||||
|
EFI_HII_PACKAGE_HEADER *HiiPackageHeader;
|
||||||
|
EFI_IFR_FORM_SET *IfrFormSet;
|
||||||
|
EFI_HII_PACKAGE_HEADER EndPackage;
|
||||||
|
UINT32 Index;
|
||||||
|
void *File;
|
||||||
|
UINT32 FileSize;
|
||||||
|
UINT8 NumberOfFormPackages;
|
||||||
|
|
||||||
|
assert (Hii != NULL);
|
||||||
|
assert (HiiGuid != NULL);
|
||||||
|
assert (FileNames != NULL);
|
||||||
|
|
||||||
|
NumberOfFormPackages = 0;
|
||||||
|
|
||||||
|
EndPackage.Length = sizeof (EFI_HII_PACKAGE_HEADER);
|
||||||
|
EndPackage.Type = EFI_HII_PACKAGE_END;
|
||||||
|
|
||||||
|
HiiPackageListHeader.PackageLength = sizeof (EFI_HII_PACKAGE_LIST_HEADER) + sizeof (EndPackage);
|
||||||
|
|
||||||
|
for (Index = 0; Index < NumOfFiles; ++Index) {
|
||||||
|
File = UserReadFile (FileNames[Index], &FileSize);
|
||||||
|
if (File == NULL) {
|
||||||
|
fprintf (stderr, "ImageTool: Could not open %s: %s\n", FileNames[Index], strerror (errno));
|
||||||
|
return RETURN_ABORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
HiiPackageHeader = (EFI_HII_PACKAGE_HEADER *)File;
|
||||||
|
if (HiiPackageHeader->Type == EFI_HII_PACKAGE_FORMS) {
|
||||||
|
if (HiiPackageHeader->Length != FileSize) {
|
||||||
|
fprintf (stderr, "ImageTool: Wrong package size in HII package file %s\n", FileNames[Index]);
|
||||||
|
free (File);
|
||||||
|
return RETURN_ABORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsZeroGuid (HiiGuid)) {
|
||||||
|
IfrFormSet = (EFI_IFR_FORM_SET *)(HiiPackageHeader + 1);
|
||||||
|
CopyGuid (HiiGuid, &IfrFormSet->Guid);
|
||||||
|
}
|
||||||
|
|
||||||
|
++NumberOfFormPackages;
|
||||||
|
}
|
||||||
|
|
||||||
|
HiiPackageListHeader.PackageLength += FileSize;
|
||||||
|
free (File);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NumberOfFormPackages > 1) {
|
||||||
|
fprintf (stderr, "ImageTool: The input HII packages contain more than one HII Form package\n");
|
||||||
|
return RETURN_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsZeroGuid (HiiGuid)) {
|
||||||
|
fprintf (stderr, "ImageTool: HII package list guid is not specified\n");
|
||||||
|
return RETURN_ABORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
CopyGuid (&HiiPackageListHeader.PackageListGuid, HiiGuid);
|
||||||
|
|
||||||
|
HiiPackageData = calloc (1, HiiPackageListHeader.PackageLength);
|
||||||
|
if (HiiPackageData == NULL) {
|
||||||
|
return RETURN_OUT_OF_RESOURCES;
|
||||||
|
}
|
||||||
|
|
||||||
|
memmove (HiiPackageData, &HiiPackageListHeader, sizeof (HiiPackageListHeader));
|
||||||
|
|
||||||
|
HiiPackageDataPointer = HiiPackageData + sizeof (HiiPackageListHeader);
|
||||||
|
for (Index = 0; Index < NumOfFiles; ++Index) {
|
||||||
|
File = UserReadFile (FileNames[Index], &FileSize);
|
||||||
|
if (File == NULL) {
|
||||||
|
fprintf (stderr, "ImageTool: Could not open %s: %s\n", FileNames[Index], strerror (errno));
|
||||||
|
return RETURN_ABORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
memmove (HiiPackageDataPointer, File, FileSize);
|
||||||
|
HiiPackageDataPointer += FileSize;
|
||||||
|
|
||||||
|
free (File);
|
||||||
|
}
|
||||||
|
|
||||||
|
memmove (HiiPackageDataPointer, &EndPackage, sizeof (EndPackage));
|
||||||
|
|
||||||
|
*Hii = HiiPackageData;
|
||||||
|
*HiiSize = HiiPackageListHeader.PackageLength;
|
||||||
|
|
||||||
|
return RETURN_SUCCESS;
|
||||||
|
}
|
|
@ -0,0 +1,731 @@
|
||||||
|
/** @file
|
||||||
|
Copyright (c) 2022, Mikhail Krichanov. All rights reserved.
|
||||||
|
SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include "ImageTool.h"
|
||||||
|
|
||||||
|
#include "ElfScanCommon.h"
|
||||||
|
|
||||||
|
#include "../../UefiPayloadPkg/PayloadLoaderPeim/ElfLib/ElfCommon.h"
|
||||||
|
|
||||||
|
#if ELF_ARCH == 32
|
||||||
|
|
||||||
|
#include "../../UefiPayloadPkg/PayloadLoaderPeim/ElfLib/Elf32.h"
|
||||||
|
|
||||||
|
#define ELFCLASS ELFCLASS32
|
||||||
|
#define Elf_Ehdr Elf32_Ehdr
|
||||||
|
#define Elf_Shdr Elf32_Shdr
|
||||||
|
#define Elf_Sym Elf32_Sym
|
||||||
|
#define Elf_Rel Elf32_Rel
|
||||||
|
#define Elf_Rela Elf32_Rela
|
||||||
|
#define Elf_Size Elf32_Size
|
||||||
|
#define Elf_Addr Elf32_Addr
|
||||||
|
#define ELF_R_TYPE ELF32_R_TYPE
|
||||||
|
#define ELF_R_SYM ELF32_R_SYM
|
||||||
|
|
||||||
|
#elif ELF_ARCH == 64
|
||||||
|
|
||||||
|
#include "../../UefiPayloadPkg/PayloadLoaderPeim/ElfLib/Elf64.h"
|
||||||
|
|
||||||
|
#define ELFCLASS ELFCLASS64
|
||||||
|
#define Elf_Ehdr Elf64_Ehdr
|
||||||
|
#define Elf_Shdr Elf64_Shdr
|
||||||
|
#define Elf_Sym Elf64_Sym
|
||||||
|
#define Elf_Rel Elf64_Rel
|
||||||
|
#define Elf_Rela Elf64_Rela
|
||||||
|
#define Elf_Size Elf64_Size
|
||||||
|
#define Elf_Addr Elf64_Addr
|
||||||
|
#define ELF_R_TYPE ELF64_R_TYPE
|
||||||
|
#define ELF_R_SYM ELF64_R_SYM
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define ELF_SUFFIX__(Name, Arch) Name##Arch
|
||||||
|
#define ELF_SUFFIX_(Name, Arch) ELF_SUFFIX__ (Name, Arch)
|
||||||
|
#define ELF_SUFFIX(Name) ELF_SUFFIX_ (Name, ELF_ARCH)
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const Elf_Ehdr *Ehdr;
|
||||||
|
uint32_t Alignment;
|
||||||
|
Elf_Addr BaseAddress;
|
||||||
|
bool HasPieRelocs;
|
||||||
|
} tool_elf_scan_context;
|
||||||
|
|
||||||
|
#if defined (_MSC_EXTENSIONS)
|
||||||
|
#define EFI_IMAGE_MACHINE_IA32 0x014C
|
||||||
|
#define EFI_IMAGE_MACHINE_X64 0x8664
|
||||||
|
#define EFI_IMAGE_MACHINE_ARMTHUMB_MIXED 0x01C2
|
||||||
|
#define EFI_IMAGE_MACHINE_AARCH64 0xAA64
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define GetShrbyIndex ELF_SUFFIX(GetShrbyIndex)
|
||||||
|
static
|
||||||
|
Elf_Shdr *
|
||||||
|
GetShdrByIndex (
|
||||||
|
IN const Elf_Ehdr *Ehdr,
|
||||||
|
IN UINT32 Index
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINTN Offset;
|
||||||
|
|
||||||
|
assert (Index < Ehdr->e_shnum);
|
||||||
|
|
||||||
|
Offset = (UINTN)Ehdr->e_shoff + Index * Ehdr->e_shentsize;
|
||||||
|
|
||||||
|
return (Elf_Shdr *)((UINT8 *)Ehdr + Offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define GetString ELF_SUFFIX(GetString)
|
||||||
|
static
|
||||||
|
const char *
|
||||||
|
GetString (
|
||||||
|
IN const Elf_Ehdr *Ehdr,
|
||||||
|
IN UINT32 Offset,
|
||||||
|
IN UINT32 Index
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const Elf_Shdr *Shdr;
|
||||||
|
|
||||||
|
if (Index == 0) {
|
||||||
|
Shdr = GetShdrByIndex (Ehdr, Ehdr->e_shstrndx);
|
||||||
|
} else {
|
||||||
|
Shdr = GetShdrByIndex (Ehdr, Index);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Offset >= Shdr->sh_size) {
|
||||||
|
fprintf (stderr, "ImageTool: Invalid ELF string offset\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (const char *)Ehdr + Shdr->sh_offset + Offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define IsShdrLoadable ELF_SUFFIX(IsShdrLoadable)
|
||||||
|
static
|
||||||
|
BOOLEAN
|
||||||
|
IsShdrLoadable (
|
||||||
|
IN const Elf_Ehdr *Ehdr,
|
||||||
|
IN const Elf_Shdr *Shdr
|
||||||
|
)
|
||||||
|
{
|
||||||
|
assert (Shdr != NULL);
|
||||||
|
|
||||||
|
return (Shdr->sh_flags & SHF_ALLOC) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define ParseElfFile ELF_SUFFIX(ParseElfFile)
|
||||||
|
static
|
||||||
|
RETURN_STATUS
|
||||||
|
ParseElfFile (
|
||||||
|
OUT tool_elf_scan_context *Context,
|
||||||
|
IN const void *File,
|
||||||
|
IN uint32_t FileSize
|
||||||
|
)
|
||||||
|
{
|
||||||
|
static const unsigned char Ident[] = {
|
||||||
|
ELFMAG0, ELFMAG1, ELFMAG2, ELFMAG3, ELFCLASS, ELFDATA2LSB
|
||||||
|
};
|
||||||
|
const Elf_Ehdr *Ehdr;
|
||||||
|
bool AlignmentSet;
|
||||||
|
Elf_Size Alignment;
|
||||||
|
bool BaseAddressSet;
|
||||||
|
Elf_Addr BaseAddress;
|
||||||
|
bool HasPieRelocs;
|
||||||
|
const Elf_Shdr *Shdr;
|
||||||
|
UINTN Offset;
|
||||||
|
UINT32 Index;
|
||||||
|
char *Last;
|
||||||
|
|
||||||
|
assert (File != NULL || FileSize == 0);
|
||||||
|
|
||||||
|
Ehdr = (const Elf_Ehdr *)File;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check header
|
||||||
|
//
|
||||||
|
if ((FileSize < sizeof (*Ehdr))
|
||||||
|
|| (memcmp (Ident, Ehdr->e_ident, sizeof (Ident)) != 0)) {
|
||||||
|
return RETURN_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((Ehdr->e_type != ET_EXEC) && (Ehdr->e_type != ET_DYN)) {
|
||||||
|
fprintf (stderr, "ImageTool: ELF e_type not ET_EXEC or ET_DYN\n");
|
||||||
|
return RETURN_INCOMPATIBLE_VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check section headers
|
||||||
|
//
|
||||||
|
BaseAddressSet = false;
|
||||||
|
BaseAddress = 0;
|
||||||
|
Alignment = 0;
|
||||||
|
AlignmentSet = false;
|
||||||
|
HasPieRelocs = false;
|
||||||
|
for (Index = 0; Index < Ehdr->e_shnum; ++Index) {
|
||||||
|
Offset = (UINTN)Ehdr->e_shoff + Index * Ehdr->e_shentsize;
|
||||||
|
|
||||||
|
if (FileSize < (Offset + sizeof (*Shdr))) {
|
||||||
|
fprintf (stderr, "ImageTool: ELF section header is outside file\n");
|
||||||
|
return RETURN_VOLUME_CORRUPTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
Shdr = (const Elf_Shdr *)((const char *)Ehdr + Offset);
|
||||||
|
|
||||||
|
if ((Shdr->sh_type != SHT_NOBITS)
|
||||||
|
&& ((FileSize < Shdr->sh_offset) || ((FileSize - Shdr->sh_offset) < Shdr->sh_size))) {
|
||||||
|
fprintf (stderr, "ImageTool: ELF section %d points outside file\n", Index);
|
||||||
|
return RETURN_VOLUME_CORRUPTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Shdr->sh_link >= Ehdr->e_shnum) {
|
||||||
|
fprintf (stderr, "ImageTool: ELF %d-th section's sh_link is out of range\n", Index);
|
||||||
|
return RETURN_VOLUME_CORRUPTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((Shdr->sh_type == SHT_RELA) || (Shdr->sh_type == SHT_REL)) {
|
||||||
|
if (Shdr->sh_info >= Ehdr->e_shnum) {
|
||||||
|
fprintf (stderr, "ImageTool: ELF %d-th section's sh_info is out of range\n", Index);
|
||||||
|
return RETURN_VOLUME_CORRUPTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Shdr->sh_info == 0) {
|
||||||
|
HasPieRelocs = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!BaseAddressSet || Shdr->sh_addr < BaseAddress) {
|
||||||
|
BaseAddressSet = TRUE;
|
||||||
|
BaseAddress = Shdr->sh_addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IsShdrLoadable (Ehdr, Shdr)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!AlignmentSet || Alignment < Shdr->sh_addralign) {
|
||||||
|
AlignmentSet = TRUE;
|
||||||
|
Alignment = Shdr->sh_addralign;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Ehdr->e_shstrndx >= Ehdr->e_shnum) {
|
||||||
|
fprintf (stderr, "ImageTool: Invalid section name string table\n");
|
||||||
|
return RETURN_VOLUME_CORRUPTED;
|
||||||
|
}
|
||||||
|
Shdr = GetShdrByIndex (Ehdr, Ehdr->e_shstrndx);
|
||||||
|
|
||||||
|
if (Shdr->sh_type != SHT_STRTAB) {
|
||||||
|
fprintf (stderr, "ImageTool: ELF string table section has wrong type\n");
|
||||||
|
return RETURN_VOLUME_CORRUPTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
Last = (char *)((UINT8 *)Ehdr + Shdr->sh_offset + Shdr->sh_size - 1);
|
||||||
|
if (*Last != '\0') {
|
||||||
|
fprintf (stderr, "ImageTool: ELF string table section is not NUL-terminated\n");
|
||||||
|
return RETURN_VOLUME_CORRUPTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!AlignmentSet || (!IS_POW2(Alignment)) || (Alignment > MAX_PE_ALIGNMENT)) {
|
||||||
|
fprintf (stderr, "ImageTool: Invalid section alignment\n");
|
||||||
|
return RETURN_VOLUME_CORRUPTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!BaseAddressSet || !IS_ALIGNED (BaseAddress, Alignment)) {
|
||||||
|
fprintf (stderr, "ImageTool: Invalid base address %llx\n", (unsigned long long)BaseAddress);
|
||||||
|
return RETURN_VOLUME_CORRUPTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset (Context, 0, sizeof (*Context));
|
||||||
|
|
||||||
|
Context->Ehdr = Ehdr;
|
||||||
|
Context->Alignment = (uint32_t)Alignment;
|
||||||
|
Context->BaseAddress = BaseAddress;
|
||||||
|
Context->HasPieRelocs = HasPieRelocs;
|
||||||
|
|
||||||
|
return RETURN_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define ProcessRelocSection ELF_SUFFIX(ProcessRelocSection)
|
||||||
|
static
|
||||||
|
bool
|
||||||
|
ProcessRelocSection (
|
||||||
|
const tool_elf_scan_context *Context,
|
||||||
|
const Elf_Shdr *Shdr
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const Elf_Ehdr *Ehdr;
|
||||||
|
bool HasPieRelocs;
|
||||||
|
const Elf_Shdr *SecShdr;
|
||||||
|
|
||||||
|
Ehdr = Context->Ehdr;
|
||||||
|
HasPieRelocs = Context->HasPieRelocs;
|
||||||
|
//
|
||||||
|
// PIE relocations will target dummy section 0.
|
||||||
|
//
|
||||||
|
if (Shdr->sh_info != 0) {
|
||||||
|
//
|
||||||
|
// If PIE relocations exist, prefer them.
|
||||||
|
//
|
||||||
|
if (HasPieRelocs) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Only translate relocations targetting sections that are translated.
|
||||||
|
//
|
||||||
|
SecShdr = GetShdrByIndex (Ehdr, Shdr->sh_info);
|
||||||
|
|
||||||
|
if (!IsShdrLoadable (Ehdr, SecShdr)) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
assert (HasPieRelocs);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define SetRelocs ELF_SUFFIX(SetRelocs)
|
||||||
|
static
|
||||||
|
RETURN_STATUS
|
||||||
|
SetRelocs (
|
||||||
|
OUT image_tool_image_info_t *ImageInfo,
|
||||||
|
IN const tool_elf_scan_context *Context
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const Elf_Ehdr *Ehdr;
|
||||||
|
Elf_Addr BaseAddress;
|
||||||
|
UINT32 Index;
|
||||||
|
const Elf_Shdr *RelShdr;
|
||||||
|
UINTN RelIdx;
|
||||||
|
const Elf_Rela *Rel;
|
||||||
|
UINT32 RelNum;
|
||||||
|
|
||||||
|
Ehdr = Context->Ehdr;
|
||||||
|
BaseAddress = Context->BaseAddress;
|
||||||
|
|
||||||
|
RelNum = 0;
|
||||||
|
|
||||||
|
for (Index = 0; Index < Ehdr->e_shnum; Index++) {
|
||||||
|
RelShdr = GetShdrByIndex (Ehdr, Index);
|
||||||
|
|
||||||
|
if ((RelShdr->sh_type != SHT_REL) && (RelShdr->sh_type != SHT_RELA)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ProcessRelocSection (Context, RelShdr)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (RelIdx = 0; RelIdx < RelShdr->sh_size; RelIdx += (UINTN)RelShdr->sh_entsize) {
|
||||||
|
Rel = (const Elf_Rela *)((const char *)Ehdr + RelShdr->sh_offset + RelIdx);
|
||||||
|
//
|
||||||
|
// Assume ELF virtual addresses match corresponding PE virtual adresses one to one,
|
||||||
|
// so we don't need to recalculate relocations computed by the linker at all r_offset's.
|
||||||
|
// We only need to transform ELF relocations' format into PE one.
|
||||||
|
//
|
||||||
|
#if ELF_ARCH == 64
|
||||||
|
if (Ehdr->e_machine == EM_X86_64) {
|
||||||
|
switch (ELF_R_TYPE(Rel->r_info)) {
|
||||||
|
case R_X86_64_NONE:
|
||||||
|
break;
|
||||||
|
case R_X86_64_RELATIVE:
|
||||||
|
case R_X86_64_64:
|
||||||
|
ImageInfo->RelocInfo.Relocs[RelNum].Type = EFI_IMAGE_REL_BASED_DIR64;
|
||||||
|
ImageInfo->RelocInfo.Relocs[RelNum].Target = (uint32_t)(Rel->r_offset - BaseAddress);
|
||||||
|
++RelNum;
|
||||||
|
|
||||||
|
break;
|
||||||
|
case R_X86_64_32:
|
||||||
|
|
||||||
|
ImageInfo->RelocInfo.Relocs[RelNum].Type = EFI_IMAGE_REL_BASED_HIGHLOW;
|
||||||
|
ImageInfo->RelocInfo.Relocs[RelNum].Target = (uint32_t)(Rel->r_offset - BaseAddress);
|
||||||
|
++RelNum;
|
||||||
|
|
||||||
|
break;
|
||||||
|
case R_X86_64_32S:
|
||||||
|
case R_X86_64_PLT32:
|
||||||
|
case R_X86_64_PC32:
|
||||||
|
break;
|
||||||
|
case R_X86_64_GOTPCREL:
|
||||||
|
case R_X86_64_GOTPCRELX:
|
||||||
|
case R_X86_64_REX_GOTPCRELX:
|
||||||
|
//
|
||||||
|
// Relocations of these types point to instructions' arguments containing
|
||||||
|
// offsets relative to RIP leading to .got entries. As sections' virtual
|
||||||
|
// addresses do not change during ELF->PE transform, we don't need to
|
||||||
|
// add them to relocations' list. But .got entries contain virtual
|
||||||
|
// addresses which must be updated.
|
||||||
|
//
|
||||||
|
// At r_offset the following value is stored: G + GOT + A - P.
|
||||||
|
// To derive .got entry address (G + GOT) compute: value - A + P.
|
||||||
|
//
|
||||||
|
// Such a method of finding relocatable .got entries can not be used,
|
||||||
|
// due to a BUG in clang compiler, which sometimes generates
|
||||||
|
// R_X86_64_REX_GOTPCRELX relocations instead of R_X86_64_PC32.
|
||||||
|
//
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf (stderr, "ImageTool: Unsupported ELF EM_X86_64 relocation 0x%llx in %s\n", ELF_R_TYPE(Rel->r_info), ImageInfo->DebugInfo.SymbolsPath);
|
||||||
|
return RETURN_INCOMPATIBLE_VERSION;
|
||||||
|
}
|
||||||
|
} else if (Ehdr->e_machine == EM_AARCH64) {
|
||||||
|
switch (ELF_R_TYPE(Rel->r_info)) {
|
||||||
|
case R_AARCH64_NONE0:
|
||||||
|
case R_AARCH64_NONE:
|
||||||
|
case R_AARCH64_LD64_GOTOFF_LO15:
|
||||||
|
case R_AARCH64_LD64_GOTPAGE_LO15:
|
||||||
|
case R_AARCH64_LD64_GOT_LO12_NC:
|
||||||
|
case R_AARCH64_ADR_GOT_PAGE:
|
||||||
|
case R_AARCH64_ADR_PREL_PG_HI21:
|
||||||
|
case R_AARCH64_ADD_ABS_LO12_NC:
|
||||||
|
case R_AARCH64_LDST8_ABS_LO12_NC:
|
||||||
|
case R_AARCH64_LDST16_ABS_LO12_NC:
|
||||||
|
case R_AARCH64_LDST32_ABS_LO12_NC:
|
||||||
|
case R_AARCH64_LDST64_ABS_LO12_NC:
|
||||||
|
case R_AARCH64_LDST128_ABS_LO12_NC:
|
||||||
|
case R_AARCH64_ADR_PREL_LO21:
|
||||||
|
case R_AARCH64_CONDBR19:
|
||||||
|
case R_AARCH64_LD_PREL_LO19:
|
||||||
|
case R_AARCH64_CALL26:
|
||||||
|
case R_AARCH64_JUMP26:
|
||||||
|
case R_AARCH64_PREL64:
|
||||||
|
case R_AARCH64_PREL32:
|
||||||
|
case R_AARCH64_PREL16:
|
||||||
|
break;
|
||||||
|
case R_AARCH64_ABS64:
|
||||||
|
case R_AARCH64_RELATIVE:
|
||||||
|
ImageInfo->RelocInfo.Relocs[RelNum].Type = EFI_IMAGE_REL_BASED_DIR64;
|
||||||
|
ImageInfo->RelocInfo.Relocs[RelNum].Target = (uint32_t)(Rel->r_offset - BaseAddress);
|
||||||
|
++RelNum;
|
||||||
|
|
||||||
|
break;
|
||||||
|
case R_AARCH64_ABS32:
|
||||||
|
|
||||||
|
ImageInfo->RelocInfo.Relocs[RelNum].Type = EFI_IMAGE_REL_BASED_HIGHLOW;
|
||||||
|
ImageInfo->RelocInfo.Relocs[RelNum].Target = (uint32_t)(Rel->r_offset - BaseAddress);
|
||||||
|
++RelNum;
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf (stderr, "ImageTool: Unsupported ELF EM_AARCH64 relocation 0x%llx in %s\n", ELF_R_TYPE(Rel->r_info), ImageInfo->DebugInfo.SymbolsPath);
|
||||||
|
return RETURN_INCOMPATIBLE_VERSION;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#elif ELF_ARCH == 32
|
||||||
|
if (Ehdr->e_machine == EM_386) {
|
||||||
|
switch (ELF_R_TYPE(Rel->r_info)) {
|
||||||
|
case R_386_NONE:
|
||||||
|
break;
|
||||||
|
case R_386_32:
|
||||||
|
|
||||||
|
ImageInfo->RelocInfo.Relocs[RelNum].Type = EFI_IMAGE_REL_BASED_HIGHLOW;
|
||||||
|
ImageInfo->RelocInfo.Relocs[RelNum].Target = (Rel->r_offset - BaseAddress);
|
||||||
|
++RelNum;
|
||||||
|
|
||||||
|
break;
|
||||||
|
case R_386_PLT32:
|
||||||
|
case R_386_PC32:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf (stderr, "ImageTool: Unsupported ELF EM_386 relocation 0x%x in %s\n", ELF_R_TYPE(Rel->r_info), ImageInfo->DebugInfo.SymbolsPath);
|
||||||
|
return RETURN_INCOMPATIBLE_VERSION;
|
||||||
|
}
|
||||||
|
} else if (Ehdr->e_machine == EM_ARM) {
|
||||||
|
switch (ELF32_R_TYPE(Rel->r_info)) {
|
||||||
|
case R_ARM_NONE:
|
||||||
|
case R_ARM_PC24:
|
||||||
|
case R_ARM_REL32:
|
||||||
|
case R_ARM_XPC25:
|
||||||
|
case R_ARM_THM_PC22:
|
||||||
|
case R_ARM_THM_JUMP19:
|
||||||
|
case R_ARM_CALL:
|
||||||
|
case R_ARM_JMP24:
|
||||||
|
case R_ARM_THM_JUMP24:
|
||||||
|
case R_ARM_PREL31:
|
||||||
|
case R_ARM_MOVW_PREL_NC:
|
||||||
|
case R_ARM_MOVT_PREL:
|
||||||
|
case R_ARM_THM_MOVW_PREL_NC:
|
||||||
|
case R_ARM_THM_MOVT_PREL:
|
||||||
|
case R_ARM_THM_JMP6:
|
||||||
|
case R_ARM_THM_ALU_PREL_11_0:
|
||||||
|
case R_ARM_THM_PC12:
|
||||||
|
case R_ARM_REL32_NOI:
|
||||||
|
case R_ARM_ALU_PC_G0_NC:
|
||||||
|
case R_ARM_ALU_PC_G0:
|
||||||
|
case R_ARM_ALU_PC_G1_NC:
|
||||||
|
case R_ARM_ALU_PC_G1:
|
||||||
|
case R_ARM_ALU_PC_G2:
|
||||||
|
case R_ARM_LDR_PC_G1:
|
||||||
|
case R_ARM_LDR_PC_G2:
|
||||||
|
case R_ARM_LDRS_PC_G0:
|
||||||
|
case R_ARM_LDRS_PC_G1:
|
||||||
|
case R_ARM_LDRS_PC_G2:
|
||||||
|
case R_ARM_LDC_PC_G0:
|
||||||
|
case R_ARM_LDC_PC_G1:
|
||||||
|
case R_ARM_LDC_PC_G2:
|
||||||
|
case R_ARM_THM_JUMP11:
|
||||||
|
case R_ARM_THM_JUMP8:
|
||||||
|
case R_ARM_TLS_GD32:
|
||||||
|
case R_ARM_TLS_LDM32:
|
||||||
|
case R_ARM_TLS_IE32:
|
||||||
|
break;
|
||||||
|
case R_ARM_ABS32:
|
||||||
|
|
||||||
|
ImageInfo->RelocInfo.Relocs[RelNum].Type = EFI_IMAGE_REL_BASED_HIGHLOW;
|
||||||
|
ImageInfo->RelocInfo.Relocs[RelNum].Target = (Rel->r_offset - BaseAddress);
|
||||||
|
++RelNum;
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf (stderr, "ImageTool: Unsupported ELF EM_ARM relocation 0x%x in %s\n", ELF_R_TYPE(Rel->r_info), ImageInfo->DebugInfo.SymbolsPath);
|
||||||
|
return RETURN_INCOMPATIBLE_VERSION;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImageInfo->RelocInfo.NumRelocs = RelNum;
|
||||||
|
|
||||||
|
return RETURN_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define CreateIntermediate ELF_SUFFIX(CreateIntermediate)
|
||||||
|
static
|
||||||
|
RETURN_STATUS
|
||||||
|
CreateIntermediate (
|
||||||
|
OUT image_tool_image_info_t *ImageInfo,
|
||||||
|
IN const tool_elf_scan_context *Context
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const Elf_Ehdr *Ehdr;
|
||||||
|
Elf_Addr BaseAddress;
|
||||||
|
const Elf_Shdr *Shdr;
|
||||||
|
UINT32 Index;
|
||||||
|
image_tool_segment_t *Segments;
|
||||||
|
image_tool_reloc_t *Relocs;
|
||||||
|
UINT32 SIndex;
|
||||||
|
const Elf_Rel *Rel;
|
||||||
|
UINTN RIndex;
|
||||||
|
const char *Name;
|
||||||
|
UINT32 NumRelocs;
|
||||||
|
|
||||||
|
Ehdr = Context->Ehdr;
|
||||||
|
BaseAddress = Context->BaseAddress;
|
||||||
|
|
||||||
|
Segments = NULL;
|
||||||
|
SIndex = 0;
|
||||||
|
Relocs = NULL;
|
||||||
|
NumRelocs = 0;
|
||||||
|
|
||||||
|
for (Index = 0; Index < Ehdr->e_shnum; ++Index) {
|
||||||
|
Shdr = GetShdrByIndex (Ehdr, Index);
|
||||||
|
|
||||||
|
if ((Shdr->sh_type == SHT_REL) || (Shdr->sh_type == SHT_RELA)) {
|
||||||
|
if ((Shdr->sh_flags & SHF_ALLOC) != 0) {
|
||||||
|
fprintf (stderr, "ImageTool: Loadable reloc sections are unsupported\n");
|
||||||
|
return RETURN_VOLUME_CORRUPTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ProcessRelocSection (Context, Shdr)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (RIndex = 0; RIndex < Shdr->sh_size; RIndex += (UINTN)Shdr->sh_entsize) {
|
||||||
|
Rel = (Elf_Rel *)((UINT8 *)Ehdr + Shdr->sh_offset + RIndex);
|
||||||
|
#if ELF_ARCH == 64
|
||||||
|
if (Ehdr->e_machine == EM_X86_64) {
|
||||||
|
if ((ELF_R_TYPE(Rel->r_info) == R_X86_64_RELATIVE)
|
||||||
|
|| (ELF_R_TYPE(Rel->r_info) == R_X86_64_64)
|
||||||
|
|| (ELF_R_TYPE(Rel->r_info) == R_X86_64_32)
|
||||||
|
|| (ELF_R_TYPE(Rel->r_info) == R_X86_64_GOTPCREL)
|
||||||
|
|| (ELF_R_TYPE(Rel->r_info) == R_X86_64_GOTPCRELX)
|
||||||
|
|| (ELF_R_TYPE(Rel->r_info) == R_X86_64_REX_GOTPCRELX)) {
|
||||||
|
++NumRelocs;
|
||||||
|
}
|
||||||
|
} else if (Ehdr->e_machine == EM_AARCH64) {
|
||||||
|
if ((ELF_R_TYPE(Rel->r_info) == R_AARCH64_ABS64)
|
||||||
|
|| (ELF_R_TYPE(Rel->r_info) == R_AARCH64_RELATIVE)
|
||||||
|
|| (ELF_R_TYPE(Rel->r_info) == R_AARCH64_ABS32)) {
|
||||||
|
++NumRelocs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#elif ELF_ARCH == 32
|
||||||
|
if (Ehdr->e_machine == EM_386) {
|
||||||
|
if (ELF_R_TYPE(Rel->r_info) == R_386_32) {
|
||||||
|
++NumRelocs;
|
||||||
|
}
|
||||||
|
} else if (Ehdr->e_machine == EM_ARM) {
|
||||||
|
if (ELF_R_TYPE(Rel->r_info) == R_ARM_ABS32) {
|
||||||
|
++NumRelocs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IsShdrLoadable (Ehdr, Shdr)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
++ImageInfo->SegmentInfo.NumSegments;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImageInfo->SegmentInfo.NumSegments == 0) {
|
||||||
|
fprintf (stderr, "ImageTool: No loadable sections\n");
|
||||||
|
return RETURN_VOLUME_CORRUPTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
Segments = calloc (1, sizeof (*Segments) * ImageInfo->SegmentInfo.NumSegments);
|
||||||
|
if (Segments == NULL) {
|
||||||
|
fprintf (stderr, "ImageTool: Could not allocate memory for Segments\n");
|
||||||
|
return RETURN_OUT_OF_RESOURCES;
|
||||||
|
};
|
||||||
|
|
||||||
|
ImageInfo->SegmentInfo.Segments = Segments;
|
||||||
|
|
||||||
|
if (NumRelocs != 0) {
|
||||||
|
Relocs = calloc (1, sizeof (*Relocs) * NumRelocs);
|
||||||
|
if (Relocs == NULL) {
|
||||||
|
fprintf (stderr, "ImageTool: Could not allocate memory for Relocs\n");
|
||||||
|
return RETURN_OUT_OF_RESOURCES;
|
||||||
|
};
|
||||||
|
|
||||||
|
ImageInfo->RelocInfo.Relocs = Relocs;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Index = 0; Index < Ehdr->e_shnum; ++Index) {
|
||||||
|
Shdr = GetShdrByIndex (Ehdr, Index);
|
||||||
|
|
||||||
|
if ((Shdr->sh_flags & SHF_ALLOC) == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Shdr->sh_type != SHT_PROGBITS && Shdr->sh_type != SHT_NOBITS) {
|
||||||
|
fprintf (stderr, "ImageTool: Segment #%d type %x unsupported\n", Index, Shdr->sh_type);
|
||||||
|
return RETURN_VOLUME_CORRUPTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
Name = GetString (Ehdr, Shdr->sh_name, 0);
|
||||||
|
if (Name == NULL) {
|
||||||
|
return RETURN_VOLUME_CORRUPTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
Segments[SIndex].Name = calloc (1, strlen (Name) + 1);
|
||||||
|
if (Segments[SIndex].Name == NULL) {
|
||||||
|
fprintf (stderr, "ImageTool: Could not allocate memory for Segment #%d Name\n", Index);
|
||||||
|
return RETURN_OUT_OF_RESOURCES;
|
||||||
|
};
|
||||||
|
|
||||||
|
memcpy (Segments[SIndex].Name, Name, strlen (Name));
|
||||||
|
|
||||||
|
Segments[SIndex].ImageAddress = (uint32_t)(Shdr->sh_addr - BaseAddress);
|
||||||
|
Segments[SIndex].ImageSize = ALIGN_VALUE ((uint32_t)Shdr->sh_size, Context->Alignment);
|
||||||
|
Segments[SIndex].Read = true;
|
||||||
|
Segments[SIndex].Write = (Shdr->sh_flags & SHF_WRITE) != 0;
|
||||||
|
Segments[SIndex].Execute = (Shdr->sh_flags & SHF_EXECINSTR) != 0;
|
||||||
|
|
||||||
|
Segments[SIndex].Data = calloc (1, Segments[SIndex].ImageSize);
|
||||||
|
if (Segments[SIndex].Data == NULL) {
|
||||||
|
fprintf (stderr, "ImageTool: Could not allocate memory for Segment #%d Data\n", Index);
|
||||||
|
return RETURN_OUT_OF_RESOURCES;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (Shdr->sh_type == SHT_PROGBITS) {
|
||||||
|
memcpy (Segments[SIndex].Data, (const char *)Ehdr + Shdr->sh_offset, (size_t)Shdr->sh_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
++SIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert (SIndex == ImageInfo->SegmentInfo.NumSegments);
|
||||||
|
|
||||||
|
return SetRelocs (ImageInfo, Context);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define ScanElf ELF_SUFFIX(ScanElf)
|
||||||
|
RETURN_STATUS
|
||||||
|
ScanElf (
|
||||||
|
OUT image_tool_image_info_t *ImageInfo,
|
||||||
|
IN const void *File,
|
||||||
|
IN uint32_t FileSize,
|
||||||
|
IN const char *SymbolsPath OPTIONAL
|
||||||
|
)
|
||||||
|
{
|
||||||
|
RETURN_STATUS Status;
|
||||||
|
tool_elf_scan_context Context;
|
||||||
|
const Elf_Ehdr *Ehdr;
|
||||||
|
Elf_Addr BaseAddress;
|
||||||
|
|
||||||
|
assert (ImageInfo != NULL);
|
||||||
|
assert (File != NULL || FileSize == 0);
|
||||||
|
|
||||||
|
Status = ParseElfFile (&Context, File, FileSize);
|
||||||
|
if (RETURN_ERROR (Status)) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ehdr = Context.Ehdr;
|
||||||
|
BaseAddress = Context.BaseAddress;
|
||||||
|
|
||||||
|
memset (ImageInfo, 0, sizeof (*ImageInfo));
|
||||||
|
|
||||||
|
ImageInfo->HeaderInfo.BaseAddress = BaseAddress;
|
||||||
|
ImageInfo->HeaderInfo.EntryPointAddress = (uint32_t)(Ehdr->e_entry - BaseAddress);
|
||||||
|
ImageInfo->HeaderInfo.IsXip = true;
|
||||||
|
ImageInfo->SegmentInfo.SegmentAlignment = (uint32_t)Context.Alignment;
|
||||||
|
ImageInfo->RelocInfo.RelocsStripped = false;
|
||||||
|
|
||||||
|
if (SymbolsPath != NULL) {
|
||||||
|
ImageInfo->DebugInfo.SymbolsPathLen = strlen (SymbolsPath);
|
||||||
|
} else {
|
||||||
|
assert (ImageInfo->DebugInfo.SymbolsPathLen == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (Ehdr->e_machine) {
|
||||||
|
#if ELF_ARCH == 64
|
||||||
|
case EM_X86_64:
|
||||||
|
ImageInfo->HeaderInfo.Machine = EFI_IMAGE_MACHINE_X64;
|
||||||
|
break;
|
||||||
|
case EM_AARCH64:
|
||||||
|
ImageInfo->HeaderInfo.Machine = EFI_IMAGE_MACHINE_AARCH64;
|
||||||
|
break;
|
||||||
|
#elif ELF_ARCH == 32
|
||||||
|
case EM_386:
|
||||||
|
ImageInfo->HeaderInfo.Machine = EFI_IMAGE_MACHINE_IA32;
|
||||||
|
break;
|
||||||
|
case EM_ARM:
|
||||||
|
ImageInfo->HeaderInfo.Machine = EFI_IMAGE_MACHINE_ARMTHUMB_MIXED;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
default:
|
||||||
|
fprintf (stderr, "ImageTool: Unknown ELF architecture %d\n", Ehdr->e_machine);
|
||||||
|
return RETURN_INCOMPATIBLE_VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImageInfo->DebugInfo.SymbolsPath = malloc (ImageInfo->DebugInfo.SymbolsPathLen + 1);
|
||||||
|
if (ImageInfo->DebugInfo.SymbolsPath == NULL) {
|
||||||
|
fprintf (stderr, "ImageTool: Could not allocate memory for Debug Data\n");
|
||||||
|
return RETURN_OUT_OF_RESOURCES;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (SymbolsPath != NULL) {
|
||||||
|
memmove (ImageInfo->DebugInfo.SymbolsPath, SymbolsPath, ImageInfo->DebugInfo.SymbolsPathLen + 1);
|
||||||
|
} else {
|
||||||
|
*ImageInfo->DebugInfo.SymbolsPath = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// There is no corresponding ELF property.
|
||||||
|
//
|
||||||
|
ImageInfo->HeaderInfo.Subsystem = 0;
|
||||||
|
|
||||||
|
Status = CreateIntermediate (ImageInfo, &Context);
|
||||||
|
if (RETURN_ERROR (Status)) {
|
||||||
|
ToolImageDestruct (ImageInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
/** @file
|
||||||
|
Copyright (c) 2023, Marvin Häuser. All rights reserved.
|
||||||
|
SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
**/
|
||||||
|
|
||||||
|
#define ELF_ARCH 32
|
||||||
|
#include "ElfScan.c"
|
|
@ -0,0 +1,7 @@
|
||||||
|
/** @file
|
||||||
|
Copyright (c) 2023, Marvin Häuser. All rights reserved.
|
||||||
|
SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
**/
|
||||||
|
|
||||||
|
#define ELF_ARCH 64
|
||||||
|
#include "ElfScan.c"
|
|
@ -0,0 +1,24 @@
|
||||||
|
/** @file
|
||||||
|
Copyright (c) 2023, Marvin Häuser. All rights reserved.
|
||||||
|
SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include "ElfScanCommon.h"
|
||||||
|
|
||||||
|
RETURN_STATUS
|
||||||
|
ScanElf (
|
||||||
|
OUT image_tool_image_info_t *ImageInfo,
|
||||||
|
IN const void *File,
|
||||||
|
IN uint32_t FileSize,
|
||||||
|
IN const char *SymbolsPath OPTIONAL
|
||||||
|
)
|
||||||
|
{
|
||||||
|
RETURN_STATUS Status;
|
||||||
|
|
||||||
|
Status = ScanElf64 (ImageInfo, File, FileSize, SymbolsPath);
|
||||||
|
if (Status == RETURN_UNSUPPORTED) {
|
||||||
|
Status = ScanElf32 (ImageInfo, File, FileSize, SymbolsPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
/** @file
|
||||||
|
Copyright (c) 2023, Marvin Häuser. All rights reserved.
|
||||||
|
SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
**/
|
||||||
|
|
||||||
|
#ifndef ELF_SCAN_COMMON_H
|
||||||
|
#define ELF_SCAN_COMMON_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "ImageTool.h"
|
||||||
|
|
||||||
|
RETURN_STATUS
|
||||||
|
ScanElf32 (
|
||||||
|
OUT image_tool_image_info_t *ImageInfo,
|
||||||
|
IN const void *File,
|
||||||
|
IN uint32_t FileSize,
|
||||||
|
IN const char *SymbolsPath OPTIONAL
|
||||||
|
);
|
||||||
|
|
||||||
|
RETURN_STATUS
|
||||||
|
ScanElf64 (
|
||||||
|
OUT image_tool_image_info_t *ImageInfo,
|
||||||
|
IN const void *File,
|
||||||
|
IN uint32_t FileSize,
|
||||||
|
IN const char *SymbolsPath OPTIONAL
|
||||||
|
);
|
||||||
|
|
||||||
|
#endif // ELF_SCAN_COMMON_H
|
|
@ -0,0 +1,25 @@
|
||||||
|
## @file
|
||||||
|
# Copyright (c) 2021, Marvin Häuser. All rights reserved.
|
||||||
|
# Copyright (c) 2022, Mikhail Krichanov. All rights reserved.
|
||||||
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
##
|
||||||
|
|
||||||
|
PROJECT = ImageTool
|
||||||
|
PRODUCT = $(PROJECT)$(INFIX)$(SUFFIX)
|
||||||
|
OBJS = $(PROJECT).o
|
||||||
|
OBJS += Image.o UefiImageScan.o PeEmit32.o PeEmit64.o PeEmitCommon.o PeScan.o ElfScan32.o ElfScan64.o ElfScanCommon.o BinEmit.o ImageToolEmit.o
|
||||||
|
OBJS += UefiImageExtraActionLib.o
|
||||||
|
OBJS += PeCoffInit.o PeCoffInfo.o PeCoffLoad.o PeCoffRelocate.o PeCoffHii.o PeCoffDebug.o PeCoffHash.o
|
||||||
|
OBJS += UefiImageLibPeCoff.o PeCoffSupport.o CommonSupport.o
|
||||||
|
|
||||||
|
WERROR = 1
|
||||||
|
DEBUG = 1
|
||||||
|
SANITIZE = 0
|
||||||
|
OC_USER = ../../OpenCorePkg
|
||||||
|
UDK_PATH = ../..
|
||||||
|
|
||||||
|
VPATH += ../../MdePkg/Library/BasePeCoffLib2:$\
|
||||||
|
../../MdePkg/Library/BaseUefiImageExtraActionLibNull:$\
|
||||||
|
../../MdePkg/Library/BaseUefiImageLib
|
||||||
|
|
||||||
|
include $(OC_USER)/User/Makefile
|
|
@ -0,0 +1,649 @@
|
||||||
|
/** @file
|
||||||
|
Copyright (c) 2021, Marvin Häuser. All rights reserved.
|
||||||
|
Copyright (c) 2022, Mikhail Krichanov. All rights reserved.
|
||||||
|
SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include "ImageTool.h"
|
||||||
|
|
||||||
|
static
|
||||||
|
bool
|
||||||
|
CheckToolImageSegment (
|
||||||
|
const image_tool_segment_info_t *SegmentInfo,
|
||||||
|
const image_tool_segment_t *Segment,
|
||||||
|
uint32_t *PreviousEndAddress
|
||||||
|
)
|
||||||
|
{
|
||||||
|
bool Overflow;
|
||||||
|
|
||||||
|
assert (Segment != NULL);
|
||||||
|
assert (PreviousEndAddress != NULL);
|
||||||
|
|
||||||
|
if (!IS_ALIGNED (Segment->ImageSize, SegmentInfo->SegmentAlignment)) {
|
||||||
|
raise ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Segment->Write && Segment->Execute) {
|
||||||
|
raise ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: Expand prior segment
|
||||||
|
if (Segment->ImageAddress != *PreviousEndAddress) {
|
||||||
|
raise ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Overflow = BaseOverflowAddU32 (
|
||||||
|
Segment->ImageAddress,
|
||||||
|
Segment->ImageSize,
|
||||||
|
PreviousEndAddress
|
||||||
|
);
|
||||||
|
if (Overflow) {
|
||||||
|
raise ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
bool
|
||||||
|
CheckToolImageSegmentInfo (
|
||||||
|
const image_tool_segment_info_t *SegmentInfo,
|
||||||
|
uint32_t *ImageSize
|
||||||
|
)
|
||||||
|
{
|
||||||
|
uint32_t Index;
|
||||||
|
bool Result;
|
||||||
|
|
||||||
|
assert (SegmentInfo != NULL);
|
||||||
|
assert (ImageSize != NULL);
|
||||||
|
|
||||||
|
if (!IS_POW2 (SegmentInfo->SegmentAlignment)) {
|
||||||
|
raise ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SegmentInfo->NumSegments == 0) {
|
||||||
|
raise ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IS_ALIGNED (SegmentInfo->Segments[0].ImageAddress, SegmentInfo->SegmentAlignment)) {
|
||||||
|
raise ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
*ImageSize = SegmentInfo->Segments[0].ImageAddress;
|
||||||
|
for (Index = 0; Index < SegmentInfo->NumSegments; ++Index) {
|
||||||
|
Result = CheckToolImageSegment (
|
||||||
|
SegmentInfo,
|
||||||
|
&SegmentInfo->Segments[Index],
|
||||||
|
ImageSize
|
||||||
|
);
|
||||||
|
if (!Result) {
|
||||||
|
raise ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
const image_tool_segment_t *
|
||||||
|
ImageGetSegmentByAddress (
|
||||||
|
uint32_t *Address,
|
||||||
|
uint32_t *RemainingSize,
|
||||||
|
const image_tool_segment_info_t *SegmentInfo
|
||||||
|
)
|
||||||
|
{
|
||||||
|
uint32_t Index;
|
||||||
|
|
||||||
|
assert (Address != NULL);
|
||||||
|
assert (SegmentInfo != NULL);
|
||||||
|
|
||||||
|
for (Index = 0; Index < SegmentInfo->NumSegments; ++Index) {
|
||||||
|
if ((SegmentInfo->Segments[Index].ImageAddress <= *Address)
|
||||||
|
&& (*Address < SegmentInfo->Segments[Index].ImageAddress + SegmentInfo->Segments[Index].ImageSize)) {
|
||||||
|
*Address -= SegmentInfo->Segments[Index].ImageAddress;
|
||||||
|
*RemainingSize = SegmentInfo->Segments[Index].ImageSize - *Address;
|
||||||
|
return &SegmentInfo->Segments[Index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
bool
|
||||||
|
CheckToolImageReloc (
|
||||||
|
const image_tool_image_info_t *Image,
|
||||||
|
uint32_t ImageSize,
|
||||||
|
const image_tool_reloc_t *Reloc
|
||||||
|
)
|
||||||
|
{
|
||||||
|
uint32_t RelocOffset;
|
||||||
|
uint32_t RemainingSize;
|
||||||
|
const image_tool_segment_t *Segment;
|
||||||
|
uint16_t MovHigh;
|
||||||
|
uint16_t MovLow;
|
||||||
|
|
||||||
|
assert (Image != NULL);
|
||||||
|
assert (Reloc != NULL);
|
||||||
|
|
||||||
|
RelocOffset = Reloc->Target;
|
||||||
|
Segment = ImageGetSegmentByAddress (
|
||||||
|
&RelocOffset,
|
||||||
|
&RemainingSize,
|
||||||
|
&Image->SegmentInfo
|
||||||
|
);
|
||||||
|
if (Segment == NULL) {
|
||||||
|
raise ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (Reloc->Type) {
|
||||||
|
case EFI_IMAGE_REL_BASED_HIGHLOW:
|
||||||
|
{
|
||||||
|
if (RemainingSize < sizeof (UINT32)) {
|
||||||
|
raise ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case EFI_IMAGE_REL_BASED_DIR64:
|
||||||
|
{
|
||||||
|
if (RemainingSize < sizeof (UINT64)) {
|
||||||
|
raise ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case EFI_IMAGE_REL_BASED_ARM_MOV32T:
|
||||||
|
{
|
||||||
|
if (RemainingSize < sizeof (UINT32)) {
|
||||||
|
raise ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IS_ALIGNED (Reloc->Target, ALIGNOF (UINT16))) {
|
||||||
|
raise ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
MovHigh = *(const uint16_t *)&Segment->Data[RelocOffset];
|
||||||
|
MovLow = *(const uint16_t *)&Segment->Data[RelocOffset + 2];
|
||||||
|
if (((MovHigh & 0xFBF0U) != 0xF200U && (MovHigh & 0xFBF0U) != 0xF2C0U) ||
|
||||||
|
(MovLow & 0x8000U) != 0) {
|
||||||
|
raise ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
raise ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*if (Segment->Write) {
|
||||||
|
printf("!!! writable reloc at %x !!!\n", Reloc->Target);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
bool
|
||||||
|
CheckToolImageRelocInfo (
|
||||||
|
const image_tool_image_info_t *Image,
|
||||||
|
uint32_t ImageSize
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const image_tool_reloc_info_t *RelocInfo;
|
||||||
|
uint32_t Index;
|
||||||
|
bool Result;
|
||||||
|
|
||||||
|
assert (Image != NULL);
|
||||||
|
|
||||||
|
RelocInfo = &Image->RelocInfo;
|
||||||
|
|
||||||
|
if (RelocInfo->NumRelocs == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (RelocInfo->RelocsStripped && (RelocInfo->NumRelocs > 0)) {
|
||||||
|
raise ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (RelocInfo->NumRelocs > (MAX_UINT32 / sizeof (UINT16))) {
|
||||||
|
raise ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Result = CheckToolImageReloc (Image, ImageSize, &RelocInfo->Relocs[0]);
|
||||||
|
if (!Result) {
|
||||||
|
raise ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Index = 1; Index < RelocInfo->NumRelocs; ++Index) {
|
||||||
|
if (RelocInfo->Relocs[Index].Target < RelocInfo->Relocs[Index - 1].Target) {
|
||||||
|
assert (false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Result = CheckToolImageReloc (Image, ImageSize, &RelocInfo->Relocs[Index]);
|
||||||
|
if (!Result) {
|
||||||
|
raise ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
bool
|
||||||
|
CheckToolImageDebugInfo (
|
||||||
|
const image_tool_debug_info_t *DebugInfo
|
||||||
|
)
|
||||||
|
{
|
||||||
|
assert (DebugInfo != NULL);
|
||||||
|
|
||||||
|
if (DebugInfo->SymbolsPath != NULL) {
|
||||||
|
// FIXME: UE-only?
|
||||||
|
if (DebugInfo->SymbolsPathLen > MAX_UINT8) {
|
||||||
|
raise ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
CheckToolImage (
|
||||||
|
const image_tool_image_info_t *Image
|
||||||
|
)
|
||||||
|
{
|
||||||
|
bool Result;
|
||||||
|
uint32_t ImageSize;
|
||||||
|
|
||||||
|
assert (Image != NULL);
|
||||||
|
|
||||||
|
Result = CheckToolImageSegmentInfo (&Image->SegmentInfo, &ImageSize);
|
||||||
|
if (!Result) {
|
||||||
|
raise ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Result = CheckToolImageRelocInfo (Image, ImageSize);
|
||||||
|
if (!Result) {
|
||||||
|
raise ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Result = CheckToolImageDebugInfo (&Image->DebugInfo);
|
||||||
|
if (!Result) {
|
||||||
|
raise ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ImageInitUnpaddedSize (
|
||||||
|
const image_tool_image_info_t *Image
|
||||||
|
)
|
||||||
|
{
|
||||||
|
uint32_t Index;
|
||||||
|
image_tool_segment_t *Segment;
|
||||||
|
|
||||||
|
for (Index = 0; Index < Image->SegmentInfo.NumSegments; ++Index) {
|
||||||
|
Segment = &Image->SegmentInfo.Segments[Index];
|
||||||
|
Segment->UnpaddedSize = Segment->ImageSize;
|
||||||
|
|
||||||
|
if (Image->HeaderInfo.IsXip) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (; Segment->UnpaddedSize > 0; --Segment->UnpaddedSize) {
|
||||||
|
if (Segment->Data[Segment->UnpaddedSize - 1] != 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ToolImageDestruct (
|
||||||
|
image_tool_image_info_t *Image
|
||||||
|
)
|
||||||
|
{
|
||||||
|
uint8_t Index;
|
||||||
|
|
||||||
|
assert (Image != NULL);
|
||||||
|
|
||||||
|
if (Image->SegmentInfo.Segments != NULL) {
|
||||||
|
for (Index = 0; Index < Image->SegmentInfo.NumSegments; ++Index) {
|
||||||
|
free (Image->SegmentInfo.Segments[Index].Name);
|
||||||
|
free (Image->SegmentInfo.Segments[Index].Data);
|
||||||
|
}
|
||||||
|
|
||||||
|
free (Image->SegmentInfo.Segments);
|
||||||
|
}
|
||||||
|
|
||||||
|
free (Image->HiiInfo.Data);
|
||||||
|
free (Image->RelocInfo.Relocs);
|
||||||
|
free (Image->DebugInfo.SymbolsPath);
|
||||||
|
|
||||||
|
memset (Image, 0, sizeof (*Image));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
ToolImageRelocate (
|
||||||
|
image_tool_image_info_t *Image,
|
||||||
|
uint64_t BaseAddress
|
||||||
|
)
|
||||||
|
{
|
||||||
|
uint64_t Adjust;
|
||||||
|
const image_tool_reloc_t *Reloc;
|
||||||
|
uint32_t RelocOffset;
|
||||||
|
uint32_t RemainingSize;
|
||||||
|
const image_tool_segment_t *Segment;
|
||||||
|
uint32_t Index;
|
||||||
|
uint32_t RelocTarget32;
|
||||||
|
uint64_t RelocTarget64;
|
||||||
|
|
||||||
|
Adjust = BaseAddress - Image->HeaderInfo.BaseAddress;
|
||||||
|
|
||||||
|
if (Adjust == 0) {
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Index = 0; Index < Image->RelocInfo.NumRelocs; ++Index) {
|
||||||
|
Reloc = &Image->RelocInfo.Relocs[Index];
|
||||||
|
|
||||||
|
RelocOffset = Reloc->Target;
|
||||||
|
Segment = ImageGetSegmentByAddress (
|
||||||
|
&RelocOffset,
|
||||||
|
&RemainingSize,
|
||||||
|
&Image->SegmentInfo
|
||||||
|
);
|
||||||
|
if (Segment == NULL) {
|
||||||
|
raise ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (Reloc->Type) {
|
||||||
|
case EFI_IMAGE_REL_BASED_HIGHLOW:
|
||||||
|
{
|
||||||
|
assert (RemainingSize >= sizeof (UINT32));
|
||||||
|
|
||||||
|
RelocTarget32 = ReadUnaligned32 ((CONST VOID *)&Segment->Data[RelocOffset]);
|
||||||
|
RelocTarget32 += (uint32_t)Adjust;
|
||||||
|
WriteUnaligned32 ((VOID *)&Segment->Data[RelocOffset], RelocTarget32);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case EFI_IMAGE_REL_BASED_DIR64:
|
||||||
|
{
|
||||||
|
assert (RemainingSize >= sizeof (UINT64));
|
||||||
|
|
||||||
|
RelocTarget64 = ReadUnaligned64 ((CONST VOID *)&Segment->Data[RelocOffset]);
|
||||||
|
RelocTarget64 += Adjust;
|
||||||
|
WriteUnaligned64 ((VOID *)&Segment->Data[RelocOffset], RelocTarget64);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case EFI_IMAGE_REL_BASED_ARM_MOV32T:
|
||||||
|
{
|
||||||
|
assert (RemainingSize >= sizeof (UINT32));
|
||||||
|
assert (IS_ALIGNED (Reloc->Target, ALIGNOF (UINT16)));
|
||||||
|
|
||||||
|
PeCoffThumbMovwMovtImmediateFixup (&Segment->Data[RelocOffset], Adjust);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
raise ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Image->HeaderInfo.BaseAddress = BaseAddress;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
int
|
||||||
|
ToolImageRelocCompare (
|
||||||
|
IN const void *Buffer1,
|
||||||
|
IN const void *Buffer2
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const image_tool_reloc_t *Reloc1;
|
||||||
|
const image_tool_reloc_t *Reloc2;
|
||||||
|
|
||||||
|
Reloc1 = (const image_tool_reloc_t *)Buffer1;
|
||||||
|
Reloc2 = (const image_tool_reloc_t *)Buffer2;
|
||||||
|
|
||||||
|
if (Reloc1->Target < Reloc2->Target) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Reloc1->Target > Reloc2->Target) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ToolImageSortRelocs (
|
||||||
|
image_tool_image_info_t *Image
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (Image->RelocInfo.Relocs == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
qsort (
|
||||||
|
Image->RelocInfo.Relocs,
|
||||||
|
Image->RelocInfo.NumRelocs,
|
||||||
|
sizeof (*Image->RelocInfo.Relocs),
|
||||||
|
ToolImageRelocCompare
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
ToolImageCompare (
|
||||||
|
const image_tool_image_info_t *Image1,
|
||||||
|
const image_tool_image_info_t *Image2
|
||||||
|
)
|
||||||
|
{
|
||||||
|
int CmpResult;
|
||||||
|
uint32_t SegIndex;
|
||||||
|
const char *Name1;
|
||||||
|
const char *Name2;
|
||||||
|
uint32_t NameIndex;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Compare HeaderInfo.
|
||||||
|
//
|
||||||
|
|
||||||
|
CmpResult = memcmp (
|
||||||
|
&Image1->HeaderInfo,
|
||||||
|
&Image2->HeaderInfo,
|
||||||
|
sizeof (Image1->HeaderInfo)
|
||||||
|
);
|
||||||
|
if (CmpResult != 0) {
|
||||||
|
raise ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Compare SegmentInfo.
|
||||||
|
// UnpaddedSize is deliberately omitted, as it's implicit by the equality of
|
||||||
|
// ImageSize and Data.
|
||||||
|
//
|
||||||
|
|
||||||
|
CmpResult = memcmp (
|
||||||
|
&Image1->SegmentInfo,
|
||||||
|
&Image2->SegmentInfo,
|
||||||
|
OFFSET_OF (image_tool_segment_info_t, Segments)
|
||||||
|
);
|
||||||
|
if (CmpResult != 0) {
|
||||||
|
raise ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (SegIndex = 0; SegIndex < Image1->SegmentInfo.NumSegments; ++SegIndex) {
|
||||||
|
CmpResult = memcmp (
|
||||||
|
&Image1->SegmentInfo.Segments[SegIndex],
|
||||||
|
&Image2->SegmentInfo.Segments[SegIndex],
|
||||||
|
OFFSET_OF (image_tool_segment_t, Name)
|
||||||
|
);
|
||||||
|
if (CmpResult != 0) {
|
||||||
|
raise ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Don't assume images generally support arbitrarily long names or names in
|
||||||
|
// general. Check prefix equiality as a best effort.
|
||||||
|
//
|
||||||
|
Name1 = Image1->SegmentInfo.Segments[SegIndex].Name;
|
||||||
|
Name2 = Image2->SegmentInfo.Segments[SegIndex].Name;
|
||||||
|
if (Name1 != NULL && Name2 != NULL) {
|
||||||
|
for (
|
||||||
|
NameIndex = 0;
|
||||||
|
Name1[NameIndex] != '\0' && Name2[NameIndex] != '\0';
|
||||||
|
++NameIndex
|
||||||
|
) {
|
||||||
|
if (Name1[NameIndex] != Name2[NameIndex]) {
|
||||||
|
raise ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CmpResult = memcmp (
|
||||||
|
Image1->SegmentInfo.Segments[SegIndex].Data,
|
||||||
|
Image2->SegmentInfo.Segments[SegIndex].Data,
|
||||||
|
Image1->SegmentInfo.Segments[SegIndex].ImageSize
|
||||||
|
);
|
||||||
|
if (CmpResult != 0) {
|
||||||
|
raise ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Compare RelocInfo.
|
||||||
|
//
|
||||||
|
|
||||||
|
CmpResult = memcmp (
|
||||||
|
&Image1->RelocInfo,
|
||||||
|
&Image2->RelocInfo,
|
||||||
|
OFFSET_OF (image_tool_reloc_info_t, Relocs)
|
||||||
|
);
|
||||||
|
if (CmpResult != 0) {
|
||||||
|
raise ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CmpResult = memcmp (
|
||||||
|
Image1->RelocInfo.Relocs,
|
||||||
|
Image2->RelocInfo.Relocs,
|
||||||
|
Image1->RelocInfo.NumRelocs * sizeof (*Image1->RelocInfo.Relocs)
|
||||||
|
);
|
||||||
|
if (CmpResult != 0) {
|
||||||
|
raise ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Compare HiiInfo.
|
||||||
|
//
|
||||||
|
|
||||||
|
CmpResult = memcmp (
|
||||||
|
&Image1->HiiInfo,
|
||||||
|
&Image2->HiiInfo,
|
||||||
|
OFFSET_OF (image_tool_hii_info_t, Data)
|
||||||
|
);
|
||||||
|
if (CmpResult != 0) {
|
||||||
|
raise ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CmpResult = memcmp (
|
||||||
|
Image1->HiiInfo.Data,
|
||||||
|
Image2->HiiInfo.Data,
|
||||||
|
Image1->HiiInfo.DataSize
|
||||||
|
);
|
||||||
|
if (CmpResult != 0) {
|
||||||
|
raise ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Compare DebugInfo.
|
||||||
|
//
|
||||||
|
|
||||||
|
CmpResult = memcmp (
|
||||||
|
&Image1->DebugInfo,
|
||||||
|
&Image2->DebugInfo,
|
||||||
|
OFFSET_OF (image_tool_debug_info_t, SymbolsPath)
|
||||||
|
);
|
||||||
|
if (CmpResult != 0) {
|
||||||
|
raise ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((Image1->DebugInfo.SymbolsPath != NULL) != (Image2->DebugInfo.SymbolsPath != NULL)) {
|
||||||
|
raise ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Image1->DebugInfo.SymbolsPath != NULL) {
|
||||||
|
CmpResult = strcmp (
|
||||||
|
Image1->DebugInfo.SymbolsPath,
|
||||||
|
Image2->DebugInfo.SymbolsPath
|
||||||
|
);
|
||||||
|
if (CmpResult != 0) {
|
||||||
|
raise ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ToolImageStripRelocs (
|
||||||
|
image_tool_image_info_t *Image
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Image->RelocInfo.NumRelocs = 0;
|
||||||
|
free (Image->RelocInfo.Relocs);
|
||||||
|
Image->RelocInfo.Relocs = NULL;
|
||||||
|
|
||||||
|
Image->RelocInfo.RelocsStripped = TRUE;
|
||||||
|
}
|
|
@ -0,0 +1,530 @@
|
||||||
|
/** @file
|
||||||
|
Copyright (c) 2021, Marvin Häuser. All rights reserved.
|
||||||
|
Copyright (c) 2022, Mikhail Krichanov. All rights reserved.
|
||||||
|
SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include "ImageTool.h"
|
||||||
|
#include <IndustryStandard/Acpi10.h>
|
||||||
|
#include <IndustryStandard/Acpi30.h>
|
||||||
|
#include <IndustryStandard/MemoryMappedConfigurationSpaceAccessTable.h>
|
||||||
|
|
||||||
|
#include <Library/UefiImageLib.h>
|
||||||
|
|
||||||
|
#include "ImageToolEmit.h"
|
||||||
|
|
||||||
|
#define EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_VERSION 0x0
|
||||||
|
|
||||||
|
|
||||||
|
static
|
||||||
|
RETURN_STATUS
|
||||||
|
HiiBin (
|
||||||
|
IN const char *HiiName,
|
||||||
|
IN const char *Guid,
|
||||||
|
IN const char *FileNames[],
|
||||||
|
IN UINT32 NumOfFiles
|
||||||
|
)
|
||||||
|
{
|
||||||
|
RETURN_STATUS Status;
|
||||||
|
void *Hii;
|
||||||
|
UINT32 HiiSize;
|
||||||
|
GUID HiiGuid;
|
||||||
|
|
||||||
|
assert (FileNames != NULL);
|
||||||
|
assert (HiiName != NULL);
|
||||||
|
assert (Guid != NULL);
|
||||||
|
|
||||||
|
Status = AsciiStrToGuid (Guid, &HiiGuid);
|
||||||
|
if (RETURN_ERROR (Status)) {
|
||||||
|
fprintf (stderr, "ImageTool: Invalid GUID - %s\n", Guid);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = ConstructHii (FileNames, NumOfFiles, &HiiGuid, &Hii, &HiiSize);
|
||||||
|
if (RETURN_ERROR (Status)) {
|
||||||
|
fprintf (stderr, "ImageTool: Could not construct HiiBin\n");
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
UserWriteFile (HiiName, Hii, HiiSize);
|
||||||
|
|
||||||
|
free (Hii);
|
||||||
|
|
||||||
|
return RETURN_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
RETURN_STATUS
|
||||||
|
CheckAcpiTable (
|
||||||
|
IN const void *AcpiTable,
|
||||||
|
IN UINT32 Length
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const EFI_ACPI_DESCRIPTION_HEADER *AcpiHeader;
|
||||||
|
const EFI_ACPI_3_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *Facs;
|
||||||
|
UINT32 ExpectedLength;
|
||||||
|
|
||||||
|
AcpiHeader = (const EFI_ACPI_DESCRIPTION_HEADER *)AcpiTable;
|
||||||
|
|
||||||
|
if (AcpiHeader->Length > Length) {
|
||||||
|
fprintf (stderr, "ImageTool: AcpiTable length section size\n");
|
||||||
|
return RETURN_VOLUME_CORRUPTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (AcpiHeader->Signature) {
|
||||||
|
case EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE:
|
||||||
|
switch (AcpiHeader->Revision) {
|
||||||
|
case EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE_REVISION:
|
||||||
|
ExpectedLength = sizeof(EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE);
|
||||||
|
break;
|
||||||
|
case EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_REVISION:
|
||||||
|
ExpectedLength = sizeof(EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE);
|
||||||
|
break;
|
||||||
|
case EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE_REVISION:
|
||||||
|
ExpectedLength = sizeof(EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (AcpiHeader->Revision > EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE_REVISION) {
|
||||||
|
ExpectedLength = AcpiHeader->Length;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
fprintf (stderr, "ImageTool: FACP revision check failed\n");
|
||||||
|
return RETURN_VOLUME_CORRUPTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ExpectedLength != AcpiHeader->Length) {
|
||||||
|
fprintf (stderr, "ImageTool: FACP length check failed\n");
|
||||||
|
return RETURN_VOLUME_CORRUPTED;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case EFI_ACPI_3_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE:
|
||||||
|
Facs = (const EFI_ACPI_3_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *)AcpiTable;
|
||||||
|
if (Facs->Version > EFI_ACPI_3_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_VERSION) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((Facs->Version != EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_VERSION)
|
||||||
|
&& (Facs->Version != EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_VERSION)
|
||||||
|
&& (Facs->Version != EFI_ACPI_3_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_VERSION)) {
|
||||||
|
fprintf (stderr, "ImageTool: FACS version check failed\n");
|
||||||
|
return RETURN_VOLUME_CORRUPTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((Facs->Length != sizeof(EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE))
|
||||||
|
&& (Facs->Length != sizeof(EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE))
|
||||||
|
&& (Facs->Length != sizeof(EFI_ACPI_3_0_FIRMWARE_ACPI_CONTROL_STRUCTURE))) {
|
||||||
|
fprintf (stderr, "ImageTool: FACS length check failed\n");
|
||||||
|
return RETURN_VOLUME_CORRUPTED;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case EFI_ACPI_3_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE:
|
||||||
|
if (AcpiHeader->Revision > EFI_ACPI_3_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_REVISION) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (AcpiHeader->Length <= sizeof(EFI_ACPI_DESCRIPTION_HEADER)) {
|
||||||
|
fprintf (stderr, "ImageTool: DSDT length check failed\n");
|
||||||
|
return RETURN_VOLUME_CORRUPTED;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case EFI_ACPI_3_0_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE:
|
||||||
|
if (AcpiHeader->Revision > EFI_ACPI_3_0_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((AcpiHeader->Revision != EFI_ACPI_1_0_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION)
|
||||||
|
&& (AcpiHeader->Revision != EFI_ACPI_2_0_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION)
|
||||||
|
&& (AcpiHeader->Revision != EFI_ACPI_3_0_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION)) {
|
||||||
|
fprintf (stderr, "ImageTool: APIC revision check failed\n");
|
||||||
|
return RETURN_VOLUME_CORRUPTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (AcpiHeader->Length <= (sizeof(EFI_ACPI_DESCRIPTION_HEADER) + sizeof(UINT32) + sizeof(UINT32))) {
|
||||||
|
fprintf (stderr, "ImageTool: APIC length check failed\n");
|
||||||
|
return RETURN_VOLUME_CORRUPTED;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case EFI_ACPI_3_0_PCI_EXPRESS_MEMORY_MAPPED_CONFIGURATION_SPACE_BASE_ADDRESS_DESCRIPTION_TABLE_SIGNATURE:
|
||||||
|
if (AcpiHeader->Revision > EFI_ACPI_MEMORY_MAPPED_CONFIGURATION_SPACE_ACCESS_TABLE_REVISION) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (AcpiHeader->Revision != EFI_ACPI_MEMORY_MAPPED_CONFIGURATION_SPACE_ACCESS_TABLE_REVISION) {
|
||||||
|
fprintf (stderr, "ImageTool: MCFG revision check failed\n");
|
||||||
|
return RETURN_VOLUME_CORRUPTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (AcpiHeader->Length <= (sizeof(EFI_ACPI_DESCRIPTION_HEADER) + sizeof(UINT64))) {
|
||||||
|
fprintf (stderr, "ImageTool: MCFG length check failed\n");
|
||||||
|
return RETURN_VOLUME_CORRUPTED;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return RETURN_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
RETURN_STATUS
|
||||||
|
GetAcpi (
|
||||||
|
IN const char *PeName,
|
||||||
|
IN const char *AcpiName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
RETURN_STATUS Status;
|
||||||
|
void *Pe;
|
||||||
|
uint32_t PeSize;
|
||||||
|
PE_COFF_LOADER_IMAGE_CONTEXT Context;
|
||||||
|
UINT16 NumberOfSections;
|
||||||
|
const EFI_IMAGE_SECTION_HEADER *Sections;
|
||||||
|
UINT16 Index;
|
||||||
|
UINT32 FileLength;
|
||||||
|
|
||||||
|
assert (PeName != NULL);
|
||||||
|
assert (AcpiName != NULL);
|
||||||
|
|
||||||
|
Pe = UserReadFile (PeName, &PeSize);
|
||||||
|
if (Pe == NULL) {
|
||||||
|
fprintf (stderr, "ImageTool: Could not open %s: %s\n", PeName, strerror (errno));
|
||||||
|
return RETURN_ABORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = PeCoffInitializeContext (&Context, Pe, (UINT32)PeSize);
|
||||||
|
if (RETURN_ERROR (Status)) {
|
||||||
|
fprintf (stderr, "ImageTool: Could not initialise Context\n");
|
||||||
|
free (Pe);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
NumberOfSections = PeCoffGetSectionTable (&Context, &Sections);
|
||||||
|
for (Index = 0; Index < NumberOfSections; ++Index) {
|
||||||
|
if ((strcmp ((char *)Sections[Index].Name, ".data") == 0)
|
||||||
|
|| (strcmp ((char *)Sections[Index].Name, ".sdata") == 0)
|
||||||
|
|| (strcmp ((char *)Sections[Index].Name, ".rdata") == 0)) {
|
||||||
|
|
||||||
|
if (Sections[Index].VirtualSize < Sections[Index].SizeOfRawData) {
|
||||||
|
FileLength = Sections[Index].VirtualSize;
|
||||||
|
} else {
|
||||||
|
FileLength = Sections[Index].SizeOfRawData;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = CheckAcpiTable ((char *)Context.FileBuffer + Sections[Index].PointerToRawData, FileLength);
|
||||||
|
if (RETURN_ERROR (Status)) {
|
||||||
|
free (Pe);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
UserWriteFile (AcpiName, (char *)Context.FileBuffer + Sections[Index].PointerToRawData, FileLength);
|
||||||
|
|
||||||
|
free (Pe);
|
||||||
|
|
||||||
|
return RETURN_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return RETURN_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
int32_t
|
||||||
|
NameToType (
|
||||||
|
IN const char *TypeName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if ((strcmp (TypeName, "BASE") == 0)
|
||||||
|
|| (strcmp (TypeName, "SEC") == 0)
|
||||||
|
|| (strcmp (TypeName, "SECURITY_CORE") == 0)
|
||||||
|
|| (strcmp (TypeName, "PEI_CORE") == 0)
|
||||||
|
|| (strcmp (TypeName, "PEIM") == 0)
|
||||||
|
|| (strcmp (TypeName, "COMBINED_PEIM_DRIVER") == 0)
|
||||||
|
|| (strcmp (TypeName, "PIC_PEIM") == 0)
|
||||||
|
|| (strcmp (TypeName, "RELOCATABLE_PEIM") == 0)
|
||||||
|
|| (strcmp (TypeName, "DXE_CORE") == 0)
|
||||||
|
|| (strcmp (TypeName, "BS_DRIVER") == 0)
|
||||||
|
|| (strcmp (TypeName, "DXE_DRIVER") == 0)
|
||||||
|
|| (strcmp (TypeName, "DXE_SMM_DRIVER") == 0)
|
||||||
|
|| (strcmp (TypeName, "UEFI_DRIVER") == 0)
|
||||||
|
|| (strcmp (TypeName, "SMM_CORE") == 0)
|
||||||
|
|| (strcmp (TypeName, "MM_STANDALONE") == 0)
|
||||||
|
|| (strcmp (TypeName, "MM_CORE_STANDALONE") == 0)) {
|
||||||
|
return EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((strcmp (TypeName, "UEFI_APPLICATION") == 0)
|
||||||
|
|| (strcmp (TypeName, "APPLICATION") == 0)) {
|
||||||
|
return EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((strcmp (TypeName, "DXE_RUNTIME_DRIVER") == 0)
|
||||||
|
|| (strcmp (TypeName, "RT_DRIVER") == 0)) {
|
||||||
|
return EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((strcmp (TypeName, "DXE_SAL_DRIVER") == 0)
|
||||||
|
|| (strcmp (TypeName, "SAL_RT_DRIVER") == 0)) {
|
||||||
|
return EFI_IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
int8_t
|
||||||
|
NameToFormat (
|
||||||
|
IN const char *FormatName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (strcmp (FormatName, "PE") == 0) {
|
||||||
|
return UefiImageFormatPe;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
RETURN_STATUS
|
||||||
|
GenExecutable (
|
||||||
|
IN const char *OutputFileName,
|
||||||
|
IN const char *InputFileName,
|
||||||
|
IN const char *FormatName,
|
||||||
|
IN const char *TypeName,
|
||||||
|
IN const char *HiiFileName,
|
||||||
|
IN const char *BaseAddress,
|
||||||
|
IN bool Strip,
|
||||||
|
IN bool FixedAddress
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINT32 InputFileSize;
|
||||||
|
VOID *InputFile;
|
||||||
|
int8_t Format;
|
||||||
|
int32_t Type;
|
||||||
|
UINT32 HiiFileSize;
|
||||||
|
VOID *HiiFile;
|
||||||
|
RETURN_STATUS Status;
|
||||||
|
UINT64 NewBaseAddress;
|
||||||
|
void *OutputFile;
|
||||||
|
uint32_t OutputFileSize;
|
||||||
|
|
||||||
|
Format = -1;
|
||||||
|
if (FormatName != NULL) {
|
||||||
|
Format = NameToFormat (FormatName);
|
||||||
|
if (Format == -1) {
|
||||||
|
fprintf (stderr, "ImageTool: Unknown output format %s\n", FormatName);
|
||||||
|
return RETURN_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Type = -1;
|
||||||
|
if (TypeName != NULL) {
|
||||||
|
Type = NameToType (TypeName);
|
||||||
|
if (Type == -1) {
|
||||||
|
fprintf (stderr, "ImageTool: Unknown EFI_FILETYPE = %s\n", TypeName);
|
||||||
|
return RETURN_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NewBaseAddress = 0;
|
||||||
|
if (BaseAddress != NULL) {
|
||||||
|
Status = AsciiStrHexToUint64S (BaseAddress, NULL, &NewBaseAddress);
|
||||||
|
if (RETURN_ERROR (Status)) {
|
||||||
|
fprintf (stderr, "ImageTool: Could not convert ASCII string to UINT64\n");
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
InputFile = UserReadFile (InputFileName, &InputFileSize);
|
||||||
|
if (InputFile == NULL) {
|
||||||
|
fprintf (stderr, "ImageTool: Could not open %s: %s\n", InputFileName, strerror (errno));
|
||||||
|
return RETURN_ABORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
HiiFile = NULL;
|
||||||
|
HiiFileSize = 0;
|
||||||
|
if (HiiFileName != NULL) {
|
||||||
|
HiiFile = UserReadFile (HiiFileName, &HiiFileSize);
|
||||||
|
if (HiiFile == NULL) {
|
||||||
|
fprintf (stderr, "ImageTool: Could not open %s: %s\n", HiiFileName, strerror (errno));
|
||||||
|
return RETURN_ABORTED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
OutputFile = ToolImageEmit (
|
||||||
|
&OutputFileSize,
|
||||||
|
InputFile,
|
||||||
|
InputFileSize,
|
||||||
|
Format,
|
||||||
|
Type,
|
||||||
|
HiiFile,
|
||||||
|
HiiFileSize,
|
||||||
|
BaseAddress != NULL,
|
||||||
|
NewBaseAddress,
|
||||||
|
InputFileName,
|
||||||
|
Strip,
|
||||||
|
FixedAddress
|
||||||
|
);
|
||||||
|
|
||||||
|
if (OutputFile == NULL) {
|
||||||
|
free (HiiFile);
|
||||||
|
return RETURN_ABORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
UserWriteFile (OutputFileName, OutputFile, OutputFileSize);
|
||||||
|
|
||||||
|
free (OutputFile);
|
||||||
|
|
||||||
|
return RETURN_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main (int argc, const char *argv[])
|
||||||
|
{
|
||||||
|
RETURN_STATUS Status;
|
||||||
|
UINT32 NumOfFiles;
|
||||||
|
const char *OutputName;
|
||||||
|
const char *InputName;
|
||||||
|
const char *FormatName;
|
||||||
|
const char *TypeName;
|
||||||
|
const char *HiiFileName;
|
||||||
|
const char *BaseAddress;
|
||||||
|
bool Strip;
|
||||||
|
bool FixedAddress;
|
||||||
|
int ArgIndex;
|
||||||
|
|
||||||
|
if (argc < 2) {
|
||||||
|
fprintf (stderr, "ImageTool: No command is specified\n");
|
||||||
|
raise ();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// The command structure must prefix all output files with "-o" and all
|
||||||
|
// following dash-less parameters must be input files due to scanning for
|
||||||
|
// these arguments by BaseTools/GenMake.
|
||||||
|
//
|
||||||
|
if (strcmp (argv[1], "GenImage") == 0) {
|
||||||
|
if (argc < 5) {
|
||||||
|
fprintf (stderr, "ImageTool: Command arguments are missing\n");
|
||||||
|
fprintf (stderr, " Usage: ImageTool GenImage [-c Format] [-t ModuleType] [-h HiiRc] [-b BaseAddress] [-s] [-f] -o OutputFile InputFile\n");
|
||||||
|
raise ();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
OutputName = NULL;
|
||||||
|
InputName = NULL;
|
||||||
|
FormatName = NULL;
|
||||||
|
TypeName = NULL;
|
||||||
|
HiiFileName = NULL;
|
||||||
|
BaseAddress = NULL;
|
||||||
|
Strip = false;
|
||||||
|
FixedAddress = false;
|
||||||
|
for (ArgIndex = 2; ArgIndex < argc; ++ArgIndex) {
|
||||||
|
if (strcmp (argv[ArgIndex], "-o") == 0) {
|
||||||
|
++ArgIndex;
|
||||||
|
if (ArgIndex == argc) {
|
||||||
|
fprintf (stderr, "Must specify an argument to -o\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
OutputName = argv[ArgIndex];
|
||||||
|
} else if (strcmp (argv[ArgIndex], "-c") == 0) {
|
||||||
|
++ArgIndex;
|
||||||
|
if (ArgIndex == argc) {
|
||||||
|
fprintf (stderr, "Must specify an argument to -c\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
FormatName = argv[ArgIndex];
|
||||||
|
} else if (strcmp (argv[ArgIndex], "-t") == 0) {
|
||||||
|
++ArgIndex;
|
||||||
|
if (ArgIndex == argc) {
|
||||||
|
fprintf (stderr, "Must specify an argument to -t\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
TypeName = argv[ArgIndex];
|
||||||
|
} else if (strcmp (argv[ArgIndex], "-h") == 0) {
|
||||||
|
++ArgIndex;
|
||||||
|
if (ArgIndex == argc) {
|
||||||
|
fprintf (stderr, "Must specify an argument to -h\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
HiiFileName = argv[ArgIndex];
|
||||||
|
} else if (strcmp (argv[ArgIndex], "-b") == 0) {
|
||||||
|
++ArgIndex;
|
||||||
|
if (ArgIndex == argc) {
|
||||||
|
fprintf (stderr, "Must specify an argument to -b\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
BaseAddress = argv[ArgIndex];
|
||||||
|
} else if (strcmp (argv[ArgIndex], "-s") == 0) {
|
||||||
|
Strip = true;
|
||||||
|
} else if (strcmp (argv[ArgIndex], "-f") == 0) {
|
||||||
|
FixedAddress = true;
|
||||||
|
} else if (argv[ArgIndex][0] == '-') {
|
||||||
|
fprintf (stderr, "Unknown parameter %s\n", argv[ArgIndex]);
|
||||||
|
} else if (InputName == NULL) {
|
||||||
|
InputName = argv[ArgIndex];
|
||||||
|
} else {
|
||||||
|
fprintf (stderr, "GenImage only supports one input file.\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (OutputName == NULL) {
|
||||||
|
fprintf (stderr, "Must provide an output file.\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (InputName == NULL) {
|
||||||
|
fprintf (stderr, "Must provide an input file.\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = GenExecutable (
|
||||||
|
OutputName,
|
||||||
|
InputName,
|
||||||
|
FormatName,
|
||||||
|
TypeName,
|
||||||
|
HiiFileName,
|
||||||
|
BaseAddress,
|
||||||
|
Strip,
|
||||||
|
FixedAddress
|
||||||
|
);
|
||||||
|
if (RETURN_ERROR (Status)) {
|
||||||
|
raise ();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else if (strcmp (argv[1], "HiiBin") == 0) {
|
||||||
|
if (argc < 5 || strcmp (argv[3], "-o") != 0) {
|
||||||
|
fprintf (stderr, "ImageTool: Command arguments are missing\n");
|
||||||
|
fprintf (stderr, " Usage: ImageTool HiiBin GUID -o OutputFile InputFile1 InputFile2 ...\n");
|
||||||
|
raise ();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
NumOfFiles = (UINT32)argc - 5U;
|
||||||
|
|
||||||
|
Status = HiiBin (argv[4], argv[2], &argv[5], NumOfFiles);
|
||||||
|
if (RETURN_ERROR (Status)) {
|
||||||
|
raise ();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else if (strcmp (argv[1], "GetAcpi") == 0) {
|
||||||
|
if (argc != 5 || strcmp (argv[2], "-o") != 0) {
|
||||||
|
fprintf (stderr, "ImageTool: Command arguments are missing\n");
|
||||||
|
fprintf (stderr, " Usage: ImageTool GetAcpi -o OutputFile InputFile\n");
|
||||||
|
raise ();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = GetAcpi (argv[4], argv[3]);
|
||||||
|
if (RETURN_ERROR (Status)) {
|
||||||
|
raise ();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,185 @@
|
||||||
|
/** @file
|
||||||
|
Copyright (c) 2021, Marvin Häuser. All rights reserved.
|
||||||
|
Copyright (c) 2022, Mikhail Krichanov. All rights reserved.
|
||||||
|
SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
**/
|
||||||
|
|
||||||
|
#ifndef IMAGE_TOOL_H
|
||||||
|
#define IMAGE_TOOL_H
|
||||||
|
|
||||||
|
#include <Base.h>
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include <IndustryStandard/PeImage2.h>
|
||||||
|
#include <Library/PeCoffLib2.h>
|
||||||
|
#include <Library/BaseLib.h>
|
||||||
|
#include <Library/BaseMemoryLib.h>
|
||||||
|
#include <Library/BaseOverflowLib.h>
|
||||||
|
#include <Library/MemoryAllocationLib.h>
|
||||||
|
#include <UserFile.h>
|
||||||
|
|
||||||
|
#define MAX_PE_ALIGNMENT 0x10000
|
||||||
|
|
||||||
|
#define raise() assert(false)
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
EFI_IMAGE_DEBUG_DIRECTORY_ENTRY Dir;
|
||||||
|
EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY Nb10;
|
||||||
|
char Name[];
|
||||||
|
} DebugData;
|
||||||
|
|
||||||
|
#define PAGE(x) ((x) & ~4095U)
|
||||||
|
#define PAGE_OFF(x) ((x) & 4095U)
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint64_t BaseAddress;
|
||||||
|
uint32_t EntryPointAddress;
|
||||||
|
uint16_t Machine;
|
||||||
|
uint16_t Subsystem;
|
||||||
|
uint8_t IsXip;
|
||||||
|
uint8_t FixedAddress;
|
||||||
|
uint8_t Reserved[6];
|
||||||
|
} image_tool_header_info_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint32_t ImageAddress;
|
||||||
|
uint32_t ImageSize;
|
||||||
|
uint8_t Read;
|
||||||
|
uint8_t Write;
|
||||||
|
uint8_t Execute;
|
||||||
|
uint8_t Reserved[1];
|
||||||
|
|
||||||
|
char *Name;
|
||||||
|
uint8_t *Data;
|
||||||
|
|
||||||
|
uint32_t UnpaddedSize;
|
||||||
|
} image_tool_segment_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint32_t SegmentAlignment;
|
||||||
|
uint32_t NumSegments;
|
||||||
|
|
||||||
|
image_tool_segment_t *Segments;
|
||||||
|
} image_tool_segment_info_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint8_t Type;
|
||||||
|
uint8_t Reserved[3];
|
||||||
|
uint32_t Target;
|
||||||
|
} image_tool_reloc_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint32_t NumRelocs;
|
||||||
|
uint8_t RelocsStripped;
|
||||||
|
uint8_t Reserved[3];
|
||||||
|
|
||||||
|
image_tool_reloc_t *Relocs;
|
||||||
|
} image_tool_reloc_info_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint32_t SymbolsPathLen;
|
||||||
|
|
||||||
|
char *SymbolsPath;
|
||||||
|
} image_tool_debug_info_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint32_t DebugDirAddress;
|
||||||
|
uint32_t DebugDirSize;
|
||||||
|
} image_tool_pe_datadir_info_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint32_t DataSize;
|
||||||
|
|
||||||
|
void *Data;
|
||||||
|
} image_tool_hii_info_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
image_tool_header_info_t HeaderInfo;
|
||||||
|
image_tool_segment_info_t SegmentInfo;
|
||||||
|
image_tool_reloc_info_t RelocInfo;
|
||||||
|
image_tool_hii_info_t HiiInfo;
|
||||||
|
image_tool_debug_info_t DebugInfo;
|
||||||
|
} image_tool_image_info_t;
|
||||||
|
|
||||||
|
void
|
||||||
|
ToolImageDestruct (
|
||||||
|
image_tool_image_info_t *Image
|
||||||
|
);
|
||||||
|
|
||||||
|
void
|
||||||
|
ImageInitUnpaddedSize (
|
||||||
|
const image_tool_image_info_t *Image
|
||||||
|
);
|
||||||
|
|
||||||
|
bool
|
||||||
|
ToolImageRelocate (
|
||||||
|
image_tool_image_info_t *Image,
|
||||||
|
uint64_t BaseAddress
|
||||||
|
);
|
||||||
|
|
||||||
|
void
|
||||||
|
ToolImageSortRelocs (
|
||||||
|
image_tool_image_info_t *Image
|
||||||
|
);
|
||||||
|
|
||||||
|
bool
|
||||||
|
ToolImageCompare (
|
||||||
|
const image_tool_image_info_t *Image1,
|
||||||
|
const image_tool_image_info_t *Image2
|
||||||
|
);
|
||||||
|
|
||||||
|
void
|
||||||
|
ToolImageStripRelocs (
|
||||||
|
image_tool_image_info_t *Image
|
||||||
|
);
|
||||||
|
|
||||||
|
RETURN_STATUS
|
||||||
|
ToolContextConstructUefiImage (
|
||||||
|
OUT image_tool_image_info_t *Image,
|
||||||
|
OUT INT8 *Format,
|
||||||
|
IN const void *File,
|
||||||
|
IN size_t FileSize
|
||||||
|
);
|
||||||
|
|
||||||
|
bool
|
||||||
|
CheckToolImage (
|
||||||
|
const image_tool_image_info_t *Image
|
||||||
|
);
|
||||||
|
|
||||||
|
void *
|
||||||
|
ToolImageEmitPe (
|
||||||
|
image_tool_image_info_t *Image,
|
||||||
|
uint32_t *FileSize,
|
||||||
|
bool Strip
|
||||||
|
);
|
||||||
|
|
||||||
|
RETURN_STATUS
|
||||||
|
ScanElf (
|
||||||
|
OUT image_tool_image_info_t *ImageInfo,
|
||||||
|
IN const void *File,
|
||||||
|
IN uint32_t FileSize,
|
||||||
|
IN const char *SymbolsPath OPTIONAL
|
||||||
|
);
|
||||||
|
|
||||||
|
extern CONST UINT8 mHiiResourceSectionHeaderSize;
|
||||||
|
|
||||||
|
VOID
|
||||||
|
InitializeHiiResouceSectionHeader (
|
||||||
|
OUT UINT8 *HiiSectionHeader,
|
||||||
|
IN UINT32 HiiDataAddress,
|
||||||
|
IN UINT32 HiiDataSize
|
||||||
|
);
|
||||||
|
|
||||||
|
RETURN_STATUS
|
||||||
|
ConstructHii (
|
||||||
|
IN const char *FileNames[],
|
||||||
|
IN UINT32 NumOfFiles,
|
||||||
|
IN GUID *HiiGuid,
|
||||||
|
OUT void **Hii,
|
||||||
|
OUT UINT32 *HiiSize
|
||||||
|
);
|
||||||
|
|
||||||
|
#endif // IMAGE_TOOL_H
|
|
@ -0,0 +1,184 @@
|
||||||
|
/** @file
|
||||||
|
Copyright (c) 2023, Marvin Häuser. All rights reserved.
|
||||||
|
SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include "ImageTool.h"
|
||||||
|
|
||||||
|
#include <Uefi/UefiBaseType.h>
|
||||||
|
|
||||||
|
#include <Library/UefiImageLib.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "ImageToolEmit.h"
|
||||||
|
|
||||||
|
static
|
||||||
|
RETURN_STATUS
|
||||||
|
ToolContextConstruct (
|
||||||
|
OUT image_tool_image_info_t *ImageInfo,
|
||||||
|
OUT int8_t *Format,
|
||||||
|
IN const void *File,
|
||||||
|
IN uint32_t FileSize,
|
||||||
|
IN const char *SymbolsPath OPTIONAL
|
||||||
|
)
|
||||||
|
{
|
||||||
|
RETURN_STATUS Status;
|
||||||
|
|
||||||
|
*Format = -1;
|
||||||
|
|
||||||
|
Status = ToolContextConstructUefiImage (
|
||||||
|
ImageInfo,
|
||||||
|
Format,
|
||||||
|
File,
|
||||||
|
FileSize
|
||||||
|
);
|
||||||
|
if (Status == RETURN_UNSUPPORTED) {
|
||||||
|
Status = ScanElf (ImageInfo, File, FileSize, SymbolsPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
RETURN_STATUS
|
||||||
|
ValidateOutputFile (
|
||||||
|
void *OutputFile,
|
||||||
|
uint32_t OutputFileSize,
|
||||||
|
const image_tool_image_info_t *ImageInfo
|
||||||
|
)
|
||||||
|
{
|
||||||
|
RETURN_STATUS Status;
|
||||||
|
bool Result;
|
||||||
|
image_tool_image_info_t OutputImageInfo;
|
||||||
|
int8_t Format;
|
||||||
|
|
||||||
|
Status = ToolContextConstruct (
|
||||||
|
&OutputImageInfo,
|
||||||
|
&Format,
|
||||||
|
OutputFile,
|
||||||
|
OutputFileSize,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
assert (false);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
Result = CheckToolImage (&OutputImageInfo);
|
||||||
|
if (!Result) {
|
||||||
|
raise ();
|
||||||
|
ToolImageDestruct (&OutputImageInfo);
|
||||||
|
return RETURN_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
Result = ToolImageCompare (&OutputImageInfo, ImageInfo);
|
||||||
|
|
||||||
|
ToolImageDestruct (&OutputImageInfo);
|
||||||
|
|
||||||
|
if (!Result) {
|
||||||
|
assert (false);
|
||||||
|
return RETURN_VOLUME_CORRUPTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
return RETURN_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
ToolImageEmit (
|
||||||
|
OUT uint32_t *OutputFileSize,
|
||||||
|
IN const void *Buffer,
|
||||||
|
IN uint32_t BufferSize,
|
||||||
|
IN int8_t Format,
|
||||||
|
IN int32_t Type,
|
||||||
|
IN void *HiiFile,
|
||||||
|
IN uint32_t HiiFileSize,
|
||||||
|
IN bool Relocate,
|
||||||
|
IN uint64_t BaseAddress,
|
||||||
|
IN const char *SymbolsPath OPTIONAL,
|
||||||
|
IN bool Strip,
|
||||||
|
IN bool FixedAddress
|
||||||
|
)
|
||||||
|
{
|
||||||
|
RETURN_STATUS Status;
|
||||||
|
bool Success;
|
||||||
|
image_tool_image_info_t ImageInfo;
|
||||||
|
int8_t SourceFormat;
|
||||||
|
void *OutputFile;
|
||||||
|
|
||||||
|
Status = ToolContextConstruct (
|
||||||
|
&ImageInfo,
|
||||||
|
&SourceFormat,
|
||||||
|
Buffer,
|
||||||
|
BufferSize,
|
||||||
|
SymbolsPath
|
||||||
|
);
|
||||||
|
|
||||||
|
if (SymbolsPath == NULL) {
|
||||||
|
SymbolsPath = "<unknown>";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (RETURN_ERROR (Status)) {
|
||||||
|
fprintf (stderr, "ImageTool: Could not parse input file %s - %llx\n", SymbolsPath, (unsigned long long)Status);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Format == -1) {
|
||||||
|
Format = SourceFormat;
|
||||||
|
if (Format == -1) {
|
||||||
|
fprintf (stderr, "ImageTool: Unknown output format of file %s\n", SymbolsPath);
|
||||||
|
ToolImageDestruct (&ImageInfo);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Type != -1) {
|
||||||
|
ImageInfo.HeaderInfo.Subsystem = (uint16_t)Type;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (HiiFile != NULL) {
|
||||||
|
free (ImageInfo.HiiInfo.Data);
|
||||||
|
|
||||||
|
ImageInfo.HiiInfo.Data = HiiFile;
|
||||||
|
ImageInfo.HiiInfo.DataSize = HiiFileSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
ToolImageSortRelocs (&ImageInfo);
|
||||||
|
|
||||||
|
Success = CheckToolImage (&ImageInfo);
|
||||||
|
if (!Success) {
|
||||||
|
ToolImageDestruct (&ImageInfo);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Relocate) {
|
||||||
|
Success = ToolImageRelocate (&ImageInfo, BaseAddress);
|
||||||
|
if (!Success) {
|
||||||
|
fprintf (stderr, "ImageTool: Failed to relocate input file %s\n", SymbolsPath);
|
||||||
|
ToolImageDestruct (&ImageInfo);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FixedAddress) {
|
||||||
|
ImageInfo.HeaderInfo.FixedAddress = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
OutputFile = NULL;
|
||||||
|
if (Format == UefiImageFormatPe) {
|
||||||
|
OutputFile = ToolImageEmitPe (&ImageInfo, OutputFileSize, Strip);
|
||||||
|
} else {
|
||||||
|
assert (false);
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = ValidateOutputFile (OutputFile, *OutputFileSize, &ImageInfo);
|
||||||
|
|
||||||
|
ToolImageDestruct (&ImageInfo);
|
||||||
|
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
assert (false);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return OutputFile;
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
/** @file
|
||||||
|
Copyright (c) 2023, Marvin Häuser. All rights reserved.
|
||||||
|
SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
**/
|
||||||
|
|
||||||
|
#ifndef IMAGE_TOOL_EMIT_H
|
||||||
|
#define IMAGE_TOOL_EMIT_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include <Base.h>
|
||||||
|
|
||||||
|
void *
|
||||||
|
ToolImageEmit (
|
||||||
|
OUT uint32_t *OutputFileSize,
|
||||||
|
IN const void *Buffer,
|
||||||
|
IN uint32_t BufferSize,
|
||||||
|
IN int8_t Format,
|
||||||
|
IN int32_t Type,
|
||||||
|
IN void *HiiFile,
|
||||||
|
IN uint32_t HiiFileSize,
|
||||||
|
IN bool Relocate,
|
||||||
|
IN uint64_t BaseAddress,
|
||||||
|
IN const char *SymbolsPath OPTIONAL,
|
||||||
|
IN bool Strip,
|
||||||
|
IN bool FixedAddress
|
||||||
|
);
|
||||||
|
|
||||||
|
#endif // IMAGE_TOOL_EMIT_H
|
|
@ -0,0 +1,108 @@
|
||||||
|
## @file
|
||||||
|
# Windows makefile for 'ImageTool' module build.
|
||||||
|
#
|
||||||
|
# Copyright (c) 2022, Mikhail Krichanov. All rights reserved.
|
||||||
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
#
|
||||||
|
!INCLUDE ..\Source\C\Makefiles\ms.common
|
||||||
|
|
||||||
|
APP = ImageTool
|
||||||
|
|
||||||
|
OC_USER = ..\..\OpenCorePkg
|
||||||
|
UDK_PATH = ..\..
|
||||||
|
UDK_ARCH = $(HOST_ARCH)
|
||||||
|
OUT_DIR = .\Windows
|
||||||
|
|
||||||
|
OV = $(UDK_PATH)\MdePkg\Library\BaseOverflowLib
|
||||||
|
PE = $(UDK_PATH)\MdePkg\Library\BasePeCoffLib2
|
||||||
|
UA = $(UDK_PATH)\MdePkg\Library\BaseUefiImageExtraActionLibNull
|
||||||
|
|
||||||
|
OBJECTS = ImageTool.obj Image.obj PeEmit32.obj PeEmit64.obj PeEmitCommon.obj UefiImageScan.obj PeScan.obj ElfScan32.obj ElfScan64.obj ElfScanCommon.obj BinEmit.obj ImageToolEmit.obj
|
||||||
|
OBJECTS = $(OBJECTS) {$(OV)}BaseAlignment.obj BaseBitOverflow.obj {$(UA)}UefiImageExtraActionLib.obj
|
||||||
|
OBJECTS = $(OBJECTS) {$(PE)}PeCoffInit.obj PeCoffInfo.obj PeCoffRelocate.obj PeCoffLoad.obj PeCoffHii.obj PeCoffDebug.obj PeCoffHash.obj
|
||||||
|
|
||||||
|
BASE = $(UDK_PATH)\MdePkg\Library\BaseLib
|
||||||
|
OUT = $(UDK_PATH)\MdePkg\Library\UefiDebugLibConOut
|
||||||
|
PRIN = $(UDK_PATH)\MdePkg\Library\BasePrintLib
|
||||||
|
ERRO = $(UDK_PATH)\MdePkg\Library\BaseDebugPrintErrorLevelLib
|
||||||
|
UIMG = $(UDK_PATH)\MdePkg\Library\BaseUefiImageLib
|
||||||
|
BMPN = $(UDK_PATH)\MdeModulePkg\Library\BaseMemoryProfileLibNull
|
||||||
|
CMEM = $(UDK_PATH)\MdeModulePkg\Library\CommonMemoryAllocationLib
|
||||||
|
USER = $(OC_USER)\User\Library
|
||||||
|
OBJECTS = $(OBJECTS) {$(BASE)}SafeString.obj String.obj SwapBytes16.obj SwapBytes32.obj CpuDeadLoop.obj CheckSum.obj QuickSort.obj LinkedList.obj
|
||||||
|
OBJECTS = $(OBJECTS) {$(OUT)}DebugLib.obj {$(PRIN)}PrintLib.obj PrintLibInternal.obj {$(ERRO)}BaseDebugPrintErrorLevelLib.obj
|
||||||
|
OBJECTS = $(OBJECTS) {$(UIMG)}UefiImageLibPeCoff.obj PeCoffSupport.obj CommonSupport.obj
|
||||||
|
OBJECTS = $(OBJECTS) {$(USER)}UserFile.obj UserBaseMemoryLib.obj UserMath.obj UserPcd.obj UserMisc.obj UserGlobalVar.obj UserBootServices.obj
|
||||||
|
OBJECTS = $(OBJECTS) {$(BMPN)}BaseMemoryProfileLibNull.obj {$(CMEM)}CommonMemoryAllocationLib.obj {$(CMEM)}CommonMemoryAllocationLibEx.obj
|
||||||
|
|
||||||
|
INC = -I . -I $(OC_USER)\User\Include -I $(OC_USER)\Include\Acidanthera
|
||||||
|
INC = $(INC) -I $(UDK_PATH)\MdePkg\Include -I $(UDK_PATH)\MdePkg\Include\Library -I $(UDK_PATH)\MdePkg\Include\$(UDK_ARCH)
|
||||||
|
INC = $(INC) -I $(UDK_PATH)\MdePkg\Library\BaseLib -I $(UDK_PATH)\MdeModulePkg\Include -I $(UDK_PATH)\UefiCpuPkg\Include
|
||||||
|
INC = $(INC) /FI $(OC_USER)\User\Include\UserPcd.h /FI $(UDK_PATH)\MdePkg\Include\Base.h /FI $(OC_USER)\User\Include\UserGlobalVar.h
|
||||||
|
|
||||||
|
all:
|
||||||
|
-if not exist $(OUT_DIR) mkdir $(OUT_DIR)
|
||||||
|
$(MAKE) $(APP)
|
||||||
|
|
||||||
|
$(APP) : $(OBJECTS)
|
||||||
|
-@if not exist $(BIN_PATH) mkdir $(BIN_PATH)
|
||||||
|
@cd $(OUT_DIR)
|
||||||
|
$(LD) /nologo /debug /OPT:REF /OPT:ICF=10 /incremental:no /nodefaultlib:libc.lib /out:..\$@ $(LIBS) $**
|
||||||
|
@copy /y ..\$@ $(BIN_PATH)\$@.exe
|
||||||
|
|
||||||
|
.PHONY:clean
|
||||||
|
.PHONY:cleanall
|
||||||
|
|
||||||
|
clean:
|
||||||
|
del /f /q $(OUT_DIR) $(APP) *.pdb > nul
|
||||||
|
|
||||||
|
cleanall:
|
||||||
|
del /f /q $(OUT_DIR) *.pdb $(BIN_PATH)\$(APP).exe > nul
|
||||||
|
|
||||||
|
.c.obj :
|
||||||
|
$(CC) -c $(CFLAGS) $(INC) $< -Fo$@
|
||||||
|
@move $@ $(OUT_DIR)\
|
||||||
|
|
||||||
|
{$(OV)}.c.obj :
|
||||||
|
$(CC) -c $(CFLAGS) $(INC) $< -Fo$@
|
||||||
|
@move $@ $(OUT_DIR)\
|
||||||
|
|
||||||
|
{$(PE)}.c.obj :
|
||||||
|
$(CC) -c $(CFLAGS) $(INC) $< -Fo$@
|
||||||
|
@move $@ $(OUT_DIR)\
|
||||||
|
|
||||||
|
{$(UA)}.c.obj :
|
||||||
|
$(CC) -c $(CFLAGS) $(INC) $< -Fo$@
|
||||||
|
@move $@ $(OUT_DIR)\
|
||||||
|
|
||||||
|
{$(BASE)}.c.obj :
|
||||||
|
$(CC) -c $(CFLAGS) $(INC) /wd 4005 $< -Fo$@
|
||||||
|
@move $@ $(OUT_DIR)\
|
||||||
|
|
||||||
|
{$(BMPN)}.c.obj :
|
||||||
|
$(CC) -c $(CFLAGS) $(INC) $< -Fo$@
|
||||||
|
@move $@ $(OUT_DIR)\
|
||||||
|
|
||||||
|
{$(CMEM)}.c.obj :
|
||||||
|
$(CC) -c $(CFLAGS) $(INC) $< -Fo$@
|
||||||
|
@move $@ $(OUT_DIR)\
|
||||||
|
|
||||||
|
{$(OUT)}.c.obj :
|
||||||
|
$(CC) -c $(CFLAGS) $(INC) $< -Fo$@
|
||||||
|
@move $@ $(OUT_DIR)\
|
||||||
|
|
||||||
|
{$(PRIN)}.c.obj :
|
||||||
|
$(CC) -c $(CFLAGS) $(INC) /wd 4005 $< -Fo$@
|
||||||
|
@move $@ $(OUT_DIR)\
|
||||||
|
|
||||||
|
{$(ERRO)}.c.obj :
|
||||||
|
$(CC) -c $(CFLAGS) $(INC) $< -Fo$@
|
||||||
|
@move $@ $(OUT_DIR)\
|
||||||
|
|
||||||
|
{$(UIMG)}.c.obj :
|
||||||
|
$(CC) -c $(CFLAGS) $(INC) $< -Fo$@
|
||||||
|
@move $@ $(OUT_DIR)\
|
||||||
|
|
||||||
|
{$(USER)}.c.obj :
|
||||||
|
$(CC) -c $(CFLAGS) $(INC) /D WIN32 /wd 4754 $< -Fo$@
|
||||||
|
@move $@ $(OUT_DIR)\
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,7 @@
|
||||||
|
/** @file
|
||||||
|
Copyright (c) 2023, Marvin Häuser. All rights reserved.
|
||||||
|
SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
**/
|
||||||
|
|
||||||
|
#define PE_ARCH 32
|
||||||
|
#include "PeEmit.c"
|
|
@ -0,0 +1,7 @@
|
||||||
|
/** @file
|
||||||
|
Copyright (c) 2023, Marvin Häuser. All rights reserved.
|
||||||
|
SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
**/
|
||||||
|
|
||||||
|
#define PE_ARCH 64
|
||||||
|
#include "PeEmit.c"
|
|
@ -0,0 +1,39 @@
|
||||||
|
/** @file
|
||||||
|
Copyright (c) 2023, Marvin Häuser. All rights reserved.
|
||||||
|
SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include "PeEmitCommon.h"
|
||||||
|
|
||||||
|
void *
|
||||||
|
ToolImageEmitPe (
|
||||||
|
image_tool_image_info_t *Image,
|
||||||
|
uint32_t *FileSize,
|
||||||
|
bool Strip
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (Strip) {
|
||||||
|
ToolImageStripRelocs (Image);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (Image->HeaderInfo.Machine) {
|
||||||
|
case IMAGE_FILE_MACHINE_I386:
|
||||||
|
case IMAGE_FILE_MACHINE_ARMTHUMB_MIXED:
|
||||||
|
{
|
||||||
|
return ToolImageEmitPe32 (Image, FileSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
case IMAGE_FILE_MACHINE_X64:
|
||||||
|
case IMAGE_FILE_MACHINE_ARM64:
|
||||||
|
{
|
||||||
|
return ToolImageEmitPe64 (Image, FileSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
assert (false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
/** @file
|
||||||
|
Copyright (c) 2023, Marvin Häuser. All rights reserved.
|
||||||
|
SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
**/
|
||||||
|
|
||||||
|
#ifndef PE_EMIT_COMMON_H
|
||||||
|
#define PE_EMIT_COMMON_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "ImageTool.h"
|
||||||
|
|
||||||
|
void *
|
||||||
|
ToolImageEmitPe32 (
|
||||||
|
const image_tool_image_info_t *Image,
|
||||||
|
uint32_t *FileSize
|
||||||
|
);
|
||||||
|
|
||||||
|
void *
|
||||||
|
ToolImageEmitPe64 (
|
||||||
|
const image_tool_image_info_t *Image,
|
||||||
|
uint32_t *FileSize
|
||||||
|
);
|
||||||
|
|
||||||
|
#endif // PE_EMIT_COMMON_H
|
|
@ -0,0 +1,295 @@
|
||||||
|
/** @file
|
||||||
|
Copyright (c) 2021, Marvin Häuser. All rights reserved.
|
||||||
|
Copyright (c) 2022, Mikhail Krichanov. All rights reserved.
|
||||||
|
SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include "ImageTool.h"
|
||||||
|
|
||||||
|
#define PE_COFF_SECT_NAME_RELOC ".reloc\0"
|
||||||
|
#define PE_COFF_SECT_NAME_RESRC ".rsrc\0\0"
|
||||||
|
#define PE_COFF_SECT_NAME_DEBUG ".debug\0"
|
||||||
|
|
||||||
|
bool
|
||||||
|
ScanPeGetRelocInfo (
|
||||||
|
OUT image_tool_reloc_info_t *RelocInfo,
|
||||||
|
IN PE_COFF_LOADER_IMAGE_CONTEXT *Context
|
||||||
|
)
|
||||||
|
{
|
||||||
|
BOOLEAN Overflow;
|
||||||
|
UINT32 RelocBlockRvaMax;
|
||||||
|
UINT32 TopOfRelocDir;
|
||||||
|
UINT32 RelocBlockRva;
|
||||||
|
const EFI_IMAGE_BASE_RELOCATION_BLOCK *RelocBlock;
|
||||||
|
UINT32 RelocBlockSize;
|
||||||
|
UINT32 SizeOfRelocs;
|
||||||
|
UINT32 NumRelocs;
|
||||||
|
UINT32 RelocIndex;
|
||||||
|
uint32_t RelocDirSize;
|
||||||
|
const char *ImageBuffer;
|
||||||
|
UINT16 RelocType;
|
||||||
|
UINT16 RelocOffset;
|
||||||
|
|
||||||
|
assert (RelocInfo != NULL);
|
||||||
|
assert (Context != NULL);
|
||||||
|
|
||||||
|
// FIXME: PE/COFF context access
|
||||||
|
RelocBlockRva = Context->RelocDirRva;
|
||||||
|
RelocDirSize = Context->RelocDirSize;
|
||||||
|
//
|
||||||
|
// Verify the Relocation Directory is not empty.
|
||||||
|
//
|
||||||
|
if (RelocDirSize == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
RelocInfo->Relocs = calloc (RelocDirSize / sizeof (UINT16), sizeof (*RelocInfo->Relocs));
|
||||||
|
if (RelocInfo->Relocs == NULL) {
|
||||||
|
fprintf (stderr, "ImageTool: Could not allocate memory for Relocs[]\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
TopOfRelocDir = RelocBlockRva + RelocDirSize;
|
||||||
|
|
||||||
|
RelocBlockRvaMax = TopOfRelocDir - sizeof (EFI_IMAGE_BASE_RELOCATION_BLOCK);
|
||||||
|
//
|
||||||
|
// Align TopOfRelocDir because, if the policy does not demand Relocation Block
|
||||||
|
// sizes to be aligned, the code below will manually align them. Thus, the
|
||||||
|
// end offset of the last Relocation Block must be compared to a manually
|
||||||
|
// aligned Relocation Directoriy end offset.
|
||||||
|
//
|
||||||
|
Overflow = BaseOverflowAlignUpU32 (
|
||||||
|
TopOfRelocDir,
|
||||||
|
ALIGNOF (EFI_IMAGE_BASE_RELOCATION_BLOCK),
|
||||||
|
&TopOfRelocDir
|
||||||
|
);
|
||||||
|
if (Overflow) {
|
||||||
|
fprintf (stderr, "ImageTool: Overflow during TopOfRelocDir calculation\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Apply all Base Relocations of the Image.
|
||||||
|
//
|
||||||
|
ImageBuffer = (char *)PeCoffLoaderGetImageAddress (Context);
|
||||||
|
while (RelocBlockRva <= RelocBlockRvaMax) {
|
||||||
|
RelocBlock = (const EFI_IMAGE_BASE_RELOCATION_BLOCK *)(const void *)(ImageBuffer + RelocBlockRva);
|
||||||
|
//
|
||||||
|
// Verify the Base Relocation Block size is well-formed.
|
||||||
|
//
|
||||||
|
Overflow = BaseOverflowSubU32 (
|
||||||
|
RelocBlock->SizeOfBlock,
|
||||||
|
sizeof (EFI_IMAGE_BASE_RELOCATION_BLOCK),
|
||||||
|
&SizeOfRelocs
|
||||||
|
);
|
||||||
|
if (Overflow) {
|
||||||
|
fprintf (stderr, "ImageTool: Overflow during SizeOfRelocs calculation\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Verify the Base Relocation Block is in bounds of the Relocation
|
||||||
|
// Directory.
|
||||||
|
//
|
||||||
|
if (SizeOfRelocs > RelocBlockRvaMax - RelocBlockRva) {
|
||||||
|
fprintf (stderr, "ImageTool: Base Relocation Block is out of bounds of the Relocation Directory\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// This arithmetic cannot overflow because we know
|
||||||
|
// 1) RelocBlock->SizeOfBlock <= RelocMax <= TopOfRelocDir
|
||||||
|
// 2) IS_ALIGNED (TopOfRelocDir, ALIGNOF (EFI_IMAGE_BASE_RELOCATION_BLOCK)).
|
||||||
|
//
|
||||||
|
RelocBlockSize = ALIGN_VALUE (
|
||||||
|
RelocBlock->SizeOfBlock,
|
||||||
|
ALIGNOF (EFI_IMAGE_BASE_RELOCATION_BLOCK)
|
||||||
|
);
|
||||||
|
//
|
||||||
|
// This division is safe due to the guarantee made above.
|
||||||
|
//
|
||||||
|
NumRelocs = SizeOfRelocs / sizeof (*RelocBlock->Relocations);
|
||||||
|
//
|
||||||
|
// Process all Base Relocations of the current Block.
|
||||||
|
//
|
||||||
|
for (RelocIndex = 0; RelocIndex < NumRelocs; ++RelocIndex) {
|
||||||
|
RelocType = IMAGE_RELOC_TYPE (RelocBlock->Relocations[RelocIndex]);
|
||||||
|
RelocOffset = IMAGE_RELOC_OFFSET (RelocBlock->Relocations[RelocIndex]);
|
||||||
|
|
||||||
|
// FIXME: Make separate functions for UE
|
||||||
|
switch (RelocType) {
|
||||||
|
case EFI_IMAGE_REL_BASED_ABSOLUTE:
|
||||||
|
continue;
|
||||||
|
case EFI_IMAGE_REL_BASED_HIGHLOW:
|
||||||
|
case EFI_IMAGE_REL_BASED_DIR64:
|
||||||
|
RelocInfo->Relocs[RelocInfo->NumRelocs].Type = (uint8_t)RelocType;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf (stderr, "ImageTool: Unknown RelocType = 0x%x\n", RelocType);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
RelocInfo->Relocs[RelocInfo->NumRelocs].Target = RelocBlock->VirtualAddress + RelocOffset;
|
||||||
|
++RelocInfo->NumRelocs;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// This arithmetic cannot overflow because it has been checked that the
|
||||||
|
// Image Base Relocation Block is in bounds of the Image buffer.
|
||||||
|
//
|
||||||
|
RelocBlockRva += RelocBlockSize;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Verify the Relocation Directory size matches the contained data.
|
||||||
|
//
|
||||||
|
if (RelocBlockRva != TopOfRelocDir) {
|
||||||
|
fprintf (stderr, "ImageTool: Relocation Directory size does not match the contained data\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
ScanPeGetSegmentInfo (
|
||||||
|
OUT image_tool_segment_info_t *SegmentInfo,
|
||||||
|
IN PE_COFF_LOADER_IMAGE_CONTEXT *Context
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const EFI_IMAGE_SECTION_HEADER *Section;
|
||||||
|
uint32_t NumSections;
|
||||||
|
image_tool_segment_t *ImageSegment;
|
||||||
|
const char *ImageBuffer;
|
||||||
|
uint32_t Index;
|
||||||
|
|
||||||
|
assert (SegmentInfo != NULL);
|
||||||
|
assert (Context != NULL);
|
||||||
|
|
||||||
|
NumSections = PeCoffGetSectionTable (Context, &Section);
|
||||||
|
|
||||||
|
SegmentInfo->Segments = calloc (NumSections, sizeof (*SegmentInfo->Segments));
|
||||||
|
if (SegmentInfo->Segments == NULL) {
|
||||||
|
fprintf (stderr, "ImageTool: Could not allocate memory for Segments[]\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImageBuffer = (char *)PeCoffLoaderGetImageAddress (Context);
|
||||||
|
|
||||||
|
ImageSegment = SegmentInfo->Segments;
|
||||||
|
for (Index = 0; Index < NumSections; ++Index, ++Section) {
|
||||||
|
STATIC_ASSERT (
|
||||||
|
sizeof(PE_COFF_SECT_NAME_RELOC) == sizeof(Section->Name) &&
|
||||||
|
sizeof(PE_COFF_SECT_NAME_RESRC) == sizeof(Section->Name) &&
|
||||||
|
sizeof(PE_COFF_SECT_NAME_DEBUG) == sizeof(Section->Name),
|
||||||
|
"Section names exceed section name bounds."
|
||||||
|
);
|
||||||
|
|
||||||
|
if ((Section->Characteristics & EFI_IMAGE_SCN_MEM_DISCARDABLE) == 0
|
||||||
|
&& memcmp (Section->Name, PE_COFF_SECT_NAME_RELOC, sizeof (Section->Name)) != 0
|
||||||
|
&& memcmp (Section->Name, PE_COFF_SECT_NAME_RESRC, sizeof (Section->Name)) != 0
|
||||||
|
&& memcmp (Section->Name, PE_COFF_SECT_NAME_DEBUG, sizeof (Section->Name)) != 0) {
|
||||||
|
ImageSegment->Name = calloc (1, sizeof (Section->Name));
|
||||||
|
if (ImageSegment->Name == NULL) {
|
||||||
|
fprintf (stderr, "ImageTool: Could not allocate memory for Segment Name\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
memmove (ImageSegment->Name, Section->Name, sizeof (Section->Name));
|
||||||
|
|
||||||
|
ImageSegment->ImageAddress = Section->VirtualAddress;
|
||||||
|
ImageSegment->ImageSize = ALIGN_VALUE (Section->VirtualSize, SegmentInfo->SegmentAlignment);
|
||||||
|
ImageSegment->Read = (Section->Characteristics & EFI_IMAGE_SCN_MEM_READ) != 0;
|
||||||
|
ImageSegment->Write = (Section->Characteristics & EFI_IMAGE_SCN_MEM_WRITE) != 0;
|
||||||
|
ImageSegment->Execute = (Section->Characteristics & EFI_IMAGE_SCN_MEM_EXECUTE) != 0;
|
||||||
|
|
||||||
|
ImageSegment->Data = malloc (ImageSegment->ImageSize);
|
||||||
|
if (ImageSegment->Data == NULL) {
|
||||||
|
fprintf (stderr, "ImageTool: Could not allocate memory for Segment Data\n");
|
||||||
|
free (ImageSegment->Name);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
memmove (
|
||||||
|
ImageSegment->Data,
|
||||||
|
ImageBuffer + Section->VirtualAddress,
|
||||||
|
ImageSegment->ImageSize
|
||||||
|
);
|
||||||
|
|
||||||
|
++SegmentInfo->NumSegments;
|
||||||
|
++ImageSegment;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
ScanPeGetDebugInfo (
|
||||||
|
OUT image_tool_debug_info_t *DebugInfo,
|
||||||
|
IN PE_COFF_LOADER_IMAGE_CONTEXT *Context
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const CHAR8 *PdbPath;
|
||||||
|
UINT32 PdbPathSize;
|
||||||
|
RETURN_STATUS Status;
|
||||||
|
|
||||||
|
assert (DebugInfo != NULL);
|
||||||
|
assert (Context != NULL);
|
||||||
|
|
||||||
|
Status = PeCoffGetPdbPath (Context, &PdbPath, &PdbPathSize);
|
||||||
|
if (Status == RETURN_NOT_FOUND) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (RETURN_ERROR (Status)) {
|
||||||
|
fprintf (stderr, "ImageTool: Could not get PdbPath\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
DebugInfo->SymbolsPath = malloc (PdbPathSize);
|
||||||
|
if (DebugInfo->SymbolsPath == NULL) {
|
||||||
|
fprintf (stderr, "ImageTool: Could not allocate memory for SymbolsPath\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
memmove (DebugInfo->SymbolsPath, PdbPath, PdbPathSize);
|
||||||
|
|
||||||
|
assert (PdbPathSize >= 1);
|
||||||
|
assert (DebugInfo->SymbolsPath[PdbPathSize - 1] == '\0');
|
||||||
|
|
||||||
|
DebugInfo->SymbolsPathLen = PdbPathSize - 1;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
ScanPeGetHiiInfo (
|
||||||
|
OUT image_tool_hii_info_t *HiiInfo,
|
||||||
|
IN PE_COFF_LOADER_IMAGE_CONTEXT *Context
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINT32 HiiRva;
|
||||||
|
UINT32 HiiSize;
|
||||||
|
RETURN_STATUS Status;
|
||||||
|
const char *ImageBuffer;
|
||||||
|
|
||||||
|
assert (HiiInfo != NULL);
|
||||||
|
assert (Context != NULL);
|
||||||
|
|
||||||
|
Status = PeCoffGetHiiDataRva (Context, &HiiRva, &HiiSize);
|
||||||
|
if (Status == RETURN_NOT_FOUND) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (RETURN_ERROR (Status)) {
|
||||||
|
fprintf (stderr, "ImageTool: Could not get HiiRva\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
HiiInfo->Data = calloc (1, HiiSize);
|
||||||
|
if (HiiInfo->Data == NULL) {
|
||||||
|
fprintf (stderr, "ImageTool: Could not allocate memory for HiiInfo Data\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImageBuffer = (char *)PeCoffLoaderGetImageAddress (Context);
|
||||||
|
|
||||||
|
memmove (HiiInfo->Data, ImageBuffer + HiiRva, HiiSize);
|
||||||
|
HiiInfo->DataSize = HiiSize;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
/** @file
|
||||||
|
Copyright (c) 2023, Marvin Häuser. All rights reserved.
|
||||||
|
SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
**/
|
||||||
|
|
||||||
|
#ifndef PE_SCAN_H
|
||||||
|
#define PE_SCAN_H
|
||||||
|
|
||||||
|
#include "ImageTool.h"
|
||||||
|
|
||||||
|
bool
|
||||||
|
ScanPeGetRelocInfo (
|
||||||
|
OUT image_tool_reloc_info_t *RelocInfo,
|
||||||
|
IN PE_COFF_LOADER_IMAGE_CONTEXT *Context
|
||||||
|
);
|
||||||
|
|
||||||
|
bool
|
||||||
|
ScanPeGetSegmentInfo (
|
||||||
|
OUT image_tool_segment_info_t *SegmentInfo,
|
||||||
|
IN PE_COFF_LOADER_IMAGE_CONTEXT *Context
|
||||||
|
);
|
||||||
|
|
||||||
|
#endif // PE_SCAN_H
|
|
@ -0,0 +1,279 @@
|
||||||
|
/** @file
|
||||||
|
Copyright (c) 2023, Marvin Häuser. All rights reserved.
|
||||||
|
SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include "ImageTool.h"
|
||||||
|
|
||||||
|
#include <Uefi/UefiBaseType.h>
|
||||||
|
|
||||||
|
#include <Library/UefiImageLib.h>
|
||||||
|
|
||||||
|
#include "PeScan.h"
|
||||||
|
|
||||||
|
static
|
||||||
|
bool
|
||||||
|
ScanUefiImageGetHeaderInfo (
|
||||||
|
OUT image_tool_header_info_t *HeaderInfo,
|
||||||
|
IN UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
|
||||||
|
)
|
||||||
|
{
|
||||||
|
RETURN_STATUS Status;
|
||||||
|
UINT64 Address;
|
||||||
|
|
||||||
|
assert (HeaderInfo != NULL);
|
||||||
|
assert (Context != NULL);
|
||||||
|
|
||||||
|
HeaderInfo->BaseAddress = UefiImageGetPreferredAddress (Context);
|
||||||
|
HeaderInfo->EntryPointAddress = UefiImageGetEntryPointAddress (Context);
|
||||||
|
HeaderInfo->Machine = UefiImageGetMachine (Context);
|
||||||
|
HeaderInfo->Subsystem = UefiImageGetSubsystem (Context);
|
||||||
|
// FIXME:
|
||||||
|
HeaderInfo->IsXip = true;
|
||||||
|
|
||||||
|
Status = UefiImageGetFixedAddress (Context, &Address);
|
||||||
|
if (!RETURN_ERROR (Status)) {
|
||||||
|
if (Address != HeaderInfo->BaseAddress) {
|
||||||
|
fprintf (
|
||||||
|
stderr,
|
||||||
|
"ImageTool: Images with a fixed address different from their base address are not supported.\n"
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
HeaderInfo->FixedAddress = true;
|
||||||
|
} else if (Status != RETURN_NOT_FOUND) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
bool
|
||||||
|
ScanUefiImageGetRelocInfo (
|
||||||
|
OUT image_tool_reloc_info_t *RelocInfo,
|
||||||
|
IN UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINT8 FormatIndex;
|
||||||
|
|
||||||
|
assert (RelocInfo != NULL);
|
||||||
|
assert (Context != NULL);
|
||||||
|
|
||||||
|
FormatIndex = UefiImageGetFormat (Context);
|
||||||
|
|
||||||
|
RelocInfo->RelocsStripped = UefiImageGetRelocsStripped (Context);
|
||||||
|
|
||||||
|
if (FormatIndex == UefiImageFormatPe) {
|
||||||
|
return ScanPeGetRelocInfo (
|
||||||
|
RelocInfo,
|
||||||
|
(PE_COFF_LOADER_IMAGE_CONTEXT *)Context
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf (
|
||||||
|
stderr,
|
||||||
|
"ImageTool: Unsupported UefiImage format %u\n",
|
||||||
|
FormatIndex
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
bool
|
||||||
|
ScanUefiImageGetSegmentInfo (
|
||||||
|
OUT image_tool_segment_info_t *SegmentInfo,
|
||||||
|
IN UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINT8 FormatIndex;
|
||||||
|
|
||||||
|
assert (SegmentInfo != NULL);
|
||||||
|
assert (Context != NULL);
|
||||||
|
|
||||||
|
FormatIndex = UefiImageGetFormat (Context);
|
||||||
|
|
||||||
|
SegmentInfo->SegmentAlignment = UefiImageGetSegmentAlignment (Context);
|
||||||
|
|
||||||
|
if (FormatIndex == UefiImageFormatPe) {
|
||||||
|
return ScanPeGetSegmentInfo (
|
||||||
|
SegmentInfo,
|
||||||
|
(PE_COFF_LOADER_IMAGE_CONTEXT *)Context
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf (
|
||||||
|
stderr,
|
||||||
|
"ImageTool: Unsupported UefiImage format %u\n",
|
||||||
|
FormatIndex
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
ScanUefiImageGetDebugInfo (
|
||||||
|
OUT image_tool_debug_info_t *DebugInfo,
|
||||||
|
IN UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
|
||||||
|
)
|
||||||
|
{
|
||||||
|
RETURN_STATUS Status;
|
||||||
|
const CHAR8 *SymbolsPath;
|
||||||
|
UINT32 SymbolsPathSize;
|
||||||
|
|
||||||
|
assert (DebugInfo != NULL);
|
||||||
|
assert (Context != NULL);
|
||||||
|
|
||||||
|
Status = UefiImageGetSymbolsPath (Context, &SymbolsPath, &SymbolsPathSize);
|
||||||
|
if (Status == RETURN_NOT_FOUND) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (RETURN_ERROR (Status)) {
|
||||||
|
fprintf (stderr, "ImageTool: Could not get SymbolsPath\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert (SymbolsPathSize >= 1);
|
||||||
|
|
||||||
|
DebugInfo->SymbolsPath = malloc (SymbolsPathSize + 1);
|
||||||
|
if (DebugInfo->SymbolsPath == NULL) {
|
||||||
|
fprintf (stderr, "ImageTool: Could not allocate memory for SymbolsPath\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
memmove (DebugInfo->SymbolsPath, SymbolsPath, SymbolsPathSize);
|
||||||
|
assert (DebugInfo->SymbolsPath[SymbolsPathSize - 1] == '\0');
|
||||||
|
|
||||||
|
DebugInfo->SymbolsPathLen = SymbolsPathSize - 1;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
ScanUefiImageGetHiiInfo (
|
||||||
|
OUT image_tool_hii_info_t *HiiInfo,
|
||||||
|
IN UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
|
||||||
|
)
|
||||||
|
{
|
||||||
|
RETURN_STATUS Status;
|
||||||
|
UINT32 HiiRva;
|
||||||
|
UINT32 HiiSize;
|
||||||
|
const char *ImageBuffer;
|
||||||
|
|
||||||
|
assert (HiiInfo != NULL);
|
||||||
|
assert (Context != NULL);
|
||||||
|
|
||||||
|
Status = UefiImageGetHiiDataRva (Context, &HiiRva, &HiiSize);
|
||||||
|
if (Status == RETURN_NOT_FOUND) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (RETURN_ERROR (Status)) {
|
||||||
|
fprintf (stderr, "ImageTool: Malformed HII data\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
HiiInfo->Data = malloc (HiiSize);
|
||||||
|
if (HiiInfo->Data == NULL) {
|
||||||
|
fprintf (stderr, "ImageTool: Could not allocate memory for HiiInfo Data\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImageBuffer = (char *)UefiImageLoaderGetImageAddress (Context);
|
||||||
|
|
||||||
|
memmove (HiiInfo->Data, ImageBuffer + HiiRva, HiiSize);
|
||||||
|
HiiInfo->DataSize = HiiSize;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
RETURN_STATUS
|
||||||
|
ToolContextConstructUefiImage (
|
||||||
|
OUT image_tool_image_info_t *Image,
|
||||||
|
OUT int8_t *Format,
|
||||||
|
IN const void *File,
|
||||||
|
IN size_t FileSize
|
||||||
|
)
|
||||||
|
{
|
||||||
|
RETURN_STATUS Status;
|
||||||
|
UEFI_IMAGE_LOADER_IMAGE_CONTEXT Context;
|
||||||
|
UINT32 ImageSize;
|
||||||
|
UINT32 ImageAlignment;
|
||||||
|
UINT32 DestinationPages;
|
||||||
|
UINT32 DestinationSize;
|
||||||
|
void *Destination;
|
||||||
|
bool Success;
|
||||||
|
|
||||||
|
assert (Image != NULL);
|
||||||
|
assert (File != NULL || FileSize == 0);
|
||||||
|
|
||||||
|
if (FileSize > MAX_UINT32) {
|
||||||
|
fprintf (stderr, "ImageTool: FileSize is too huge\n");
|
||||||
|
return RETURN_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = UefiImageInitializeContext (&Context, File, (UINT32)FileSize);
|
||||||
|
if (RETURN_ERROR (Status)) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
*Format = (int8_t)UefiImageGetFormat (&Context);
|
||||||
|
|
||||||
|
ImageSize = UefiImageGetImageSize (&Context);
|
||||||
|
DestinationPages = EFI_SIZE_TO_PAGES (ImageSize);
|
||||||
|
DestinationSize = EFI_PAGES_TO_SIZE (DestinationPages);
|
||||||
|
ImageAlignment = UefiImageGetSegmentAlignment (&Context);
|
||||||
|
|
||||||
|
Destination = AllocateAlignedCodePages (DestinationPages, ImageAlignment);
|
||||||
|
if (Destination == NULL) {
|
||||||
|
fprintf (stderr, "ImageTool: Could not allocate Destination buffer\n");
|
||||||
|
return RETURN_OUT_OF_RESOURCES;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = UefiImageLoadImage (&Context, Destination, DestinationSize);
|
||||||
|
if (RETURN_ERROR (Status)) {
|
||||||
|
fprintf (stderr, "ImageTool: Could not Load Image\n");
|
||||||
|
FreeAlignedPages (Destination, DestinationPages);
|
||||||
|
return RETURN_VOLUME_CORRUPTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset (Image, 0, sizeof (*Image));
|
||||||
|
|
||||||
|
Success = ScanUefiImageGetHeaderInfo (&Image->HeaderInfo, &Context);
|
||||||
|
if (!Success) {
|
||||||
|
fprintf (stderr, "ImageTool: Could not retrieve header info\n");
|
||||||
|
FreeAlignedPages (Destination, DestinationPages);
|
||||||
|
return RETURN_VOLUME_CORRUPTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
Success = ScanUefiImageGetSegmentInfo (&Image->SegmentInfo, &Context);
|
||||||
|
if (!Success) {
|
||||||
|
fprintf (stderr, "ImageTool: Could not retrieve segment info\n");
|
||||||
|
FreeAlignedPages (Destination, DestinationPages);
|
||||||
|
return RETURN_VOLUME_CORRUPTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
Success = ScanUefiImageGetRelocInfo (&Image->RelocInfo, &Context);
|
||||||
|
if (!Success) {
|
||||||
|
fprintf (stderr, "ImageTool: Could not retrieve reloc info\n");
|
||||||
|
FreeAlignedPages (Destination, DestinationPages);
|
||||||
|
return RETURN_VOLUME_CORRUPTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
Success = ScanUefiImageGetHiiInfo (&Image->HiiInfo, &Context);
|
||||||
|
if (!Success) {
|
||||||
|
fprintf (stderr, "ImageTool: Could not retrieve HII info\n");
|
||||||
|
FreeAlignedPages (Destination, DestinationPages);
|
||||||
|
return RETURN_VOLUME_CORRUPTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
Success = ScanUefiImageGetDebugInfo (&Image->DebugInfo, &Context);
|
||||||
|
if (!Success) {
|
||||||
|
fprintf (stderr, "ImageTool: Could not retrieve debug info\n");
|
||||||
|
FreeAlignedPages (Destination, DestinationPages);
|
||||||
|
return RETURN_VOLUME_CORRUPTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
FreeAlignedPages (Destination, DestinationPages);
|
||||||
|
|
||||||
|
return RETURN_SUCCESS;
|
||||||
|
}
|
|
@ -9,13 +9,13 @@
|
||||||
!ERROR "BASE_TOOLS_PATH is not set! Please run toolsetup.bat first!"
|
!ERROR "BASE_TOOLS_PATH is not set! Please run toolsetup.bat first!"
|
||||||
!ENDIF
|
!ENDIF
|
||||||
|
|
||||||
SUBDIRS = $(BASE_TOOLS_PATH)\Source\C $(BASE_TOOLS_PATH)\Source\Python
|
SUBDIRS = $(BASE_TOOLS_PATH)\Source\C $(BASE_TOOLS_PATH)\Source\Python $(BASE_TOOLS_PATH)\ImageTool $(BASE_TOOLS_PATH)\MicroTool
|
||||||
|
|
||||||
all: c
|
all: c
|
||||||
|
|
||||||
c :
|
c :
|
||||||
@if defined PYTHON_COMMAND $(PYTHON_COMMAND) $(BASE_TOOLS_PATH)\Source\C\Makefiles\NmakeSubdirs.py all $(BASE_TOOLS_PATH)\Source\C
|
@if defined PYTHON_COMMAND $(PYTHON_COMMAND) $(BASE_TOOLS_PATH)\Source\C\Makefiles\NmakeSubdirs.py all $(BASE_TOOLS_PATH)\Source\C $(BASE_TOOLS_PATH)\ImageTool $(BASE_TOOLS_PATH)\MicroTool
|
||||||
@if not defined PYTHON_COMMAND $(PYTHON_HOME)\python.exe $(BASE_TOOLS_PATH)\Source\C\Makefiles\NmakeSubdirs.py all $(BASE_TOOLS_PATH)\Source\C
|
@if not defined PYTHON_COMMAND $(PYTHON_HOME)\python.exe $(BASE_TOOLS_PATH)\Source\C\Makefiles\NmakeSubdirs.py all $(BASE_TOOLS_PATH)\Source\C $(BASE_TOOLS_PATH)\ImageTool $(BASE_TOOLS_PATH)\MicroTool
|
||||||
|
|
||||||
|
|
||||||
subdirs: $(SUBDIRS)
|
subdirs: $(SUBDIRS)
|
||||||
|
@ -31,4 +31,3 @@ clean:
|
||||||
cleanall:
|
cleanall:
|
||||||
@if defined PYTHON_COMMAND $(PYTHON_COMMAND) $(BASE_TOOLS_PATH)\Source\C\Makefiles\NmakeSubdirs.py cleanall $(SUBDIRS)
|
@if defined PYTHON_COMMAND $(PYTHON_COMMAND) $(BASE_TOOLS_PATH)\Source\C\Makefiles\NmakeSubdirs.py cleanall $(SUBDIRS)
|
||||||
@if not defined PYTHON_COMMAND $(PYTHON_HOME)\python.exe $(BASE_TOOLS_PATH)\Source\C\Makefiles\NmakeSubdirs.py cleanall $(SUBDIRS)
|
@if not defined PYTHON_COMMAND $(PYTHON_HOME)\python.exe $(BASE_TOOLS_PATH)\Source\C\Makefiles\NmakeSubdirs.py cleanall $(SUBDIRS)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
## @file
|
||||||
|
# Copyright (c) 2022, Mikhail Krichanov. All rights reserved.
|
||||||
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
##
|
||||||
|
|
||||||
|
PROJECT = MicroTool
|
||||||
|
PRODUCT = $(PROJECT)$(INFIX)$(SUFFIX)
|
||||||
|
OBJS = $(PROJECT).o
|
||||||
|
|
||||||
|
DEBUG = 1
|
||||||
|
SANITIZE = 0
|
||||||
|
OC_USER = ../../OpenCorePkg
|
||||||
|
UDK_PATH = ../..
|
||||||
|
|
||||||
|
include $(OC_USER)/User/Makefile
|
|
@ -0,0 +1,84 @@
|
||||||
|
## @file
|
||||||
|
# Windows makefile for 'MicroTool' module build.
|
||||||
|
#
|
||||||
|
# Copyright (c) 2022, Mikhail Krichanov. All rights reserved.
|
||||||
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
#
|
||||||
|
!INCLUDE ..\Source\C\Makefiles\ms.common
|
||||||
|
|
||||||
|
APP = MicroTool
|
||||||
|
|
||||||
|
OC_USER = ..\..\OpenCorePkg
|
||||||
|
UDK_PATH = ..\..
|
||||||
|
UDK_ARCH = $(HOST_ARCH)
|
||||||
|
OUT_DIR = .\Windows
|
||||||
|
|
||||||
|
OBJECTS = MicroTool.obj
|
||||||
|
|
||||||
|
BASE = $(UDK_PATH)\MdePkg\Library\BaseLib
|
||||||
|
OUT = $(UDK_PATH)\MdePkg\Library\UefiDebugLibConOut
|
||||||
|
PRIN = $(UDK_PATH)\MdePkg\Library\BasePrintLib
|
||||||
|
ERRO = $(UDK_PATH)\MdePkg\Library\BaseDebugPrintErrorLevelLib
|
||||||
|
BMPN = $(UDK_PATH)\MdeModulePkg\Library\BaseMemoryProfileLibNull
|
||||||
|
CMEM = $(UDK_PATH)\MdeModulePkg\Library\CommonMemoryAllocationLib
|
||||||
|
USER = $(OC_USER)\User\Library
|
||||||
|
OBJECTS = $(OBJECTS) {$(BASE)}SafeString.obj String.obj SwapBytes16.obj SwapBytes32.obj CpuDeadLoop.obj CheckSum.obj
|
||||||
|
OBJECTS = $(OBJECTS) {$(OUT)}DebugLib.obj {$(PRIN)}PrintLib.obj PrintLibInternal.obj {$(ERRO)}BaseDebugPrintErrorLevelLib.obj
|
||||||
|
OBJECTS = $(OBJECTS) {$(USER)}UserFile.obj UserBaseMemoryLib.obj UserMath.obj UserPcd.obj UserMisc.obj UserGlobalVar.obj UserBootServices.obj
|
||||||
|
OBJECTS = $(OBJECTS) {$(BMPN)}BaseMemoryProfileLibNull.obj {$(CMEM)}CommonMemoryAllocationLib.obj {$(CMEM)}CommonMemoryAllocationLibEx.obj
|
||||||
|
|
||||||
|
INC = -I . -I $(OC_USER)\User\Include -I $(OC_USER)\Include\Acidanthera
|
||||||
|
INC = $(INC) -I $(UDK_PATH)\MdePkg\Include -I $(UDK_PATH)\MdePkg\Include\Library -I $(UDK_PATH)\MdePkg\Include\$(UDK_ARCH)
|
||||||
|
INC = $(INC) -I $(UDK_PATH)\MdePkg\Library\BaseLib -I $(UDK_PATH)\MdeModulePkg\Include -I $(UDK_PATH)\UefiCpuPkg\Include
|
||||||
|
INC = $(INC) /FI $(OC_USER)\User\Include\UserPcd.h /FI $(UDK_PATH)\MdePkg\Include\Base.h /FI $(OC_USER)\User\Include\UserGlobalVar.h
|
||||||
|
|
||||||
|
all:
|
||||||
|
-@if not exist $(OUT_DIR) mkdir $(OUT_DIR)
|
||||||
|
$(MAKE) $(APP)
|
||||||
|
|
||||||
|
$(APP) : $(OBJECTS)
|
||||||
|
-@if not exist $(BIN_PATH) mkdir $(BIN_PATH)
|
||||||
|
@cd $(OUT_DIR)
|
||||||
|
$(LD) /nologo /debug /OPT:REF /OPT:ICF=10 /incremental:no /nodefaultlib:libc.lib /out:..\$@ $(LIBS) $**
|
||||||
|
@copy /y ..\$@ $(BIN_PATH)\$@.exe
|
||||||
|
|
||||||
|
.PHONY:clean
|
||||||
|
.PHONY:cleanall
|
||||||
|
|
||||||
|
clean:
|
||||||
|
del /f /q $(OUT_DIR) $(APP) *.pdb > nul
|
||||||
|
|
||||||
|
cleanall:
|
||||||
|
del /f /q $(OUT_DIR) *.pdb $(BIN_PATH)\$(APP).exe $(BIN_PATH)\$(APP).exe > nul
|
||||||
|
|
||||||
|
.c.obj :
|
||||||
|
$(CC) -c $(CFLAGS) $(INC) $< -Fo$@
|
||||||
|
@move $@ $(OUT_DIR)\
|
||||||
|
|
||||||
|
{$(BASE)}.c.obj :
|
||||||
|
$(CC) -c $(CFLAGS) $(INC) /wd 4005 $< -Fo$@
|
||||||
|
@move $@ $(OUT_DIR)\
|
||||||
|
|
||||||
|
{$(BMPN)}.c.obj :
|
||||||
|
$(CC) -c $(CFLAGS) $(INC) $< -Fo$@
|
||||||
|
@move $@ $(OUT_DIR)\
|
||||||
|
|
||||||
|
{$(CMEM)}.c.obj :
|
||||||
|
$(CC) -c $(CFLAGS) $(INC) $< -Fo$@
|
||||||
|
@move $@ $(OUT_DIR)\
|
||||||
|
|
||||||
|
{$(OUT)}.c.obj :
|
||||||
|
$(CC) -c $(CFLAGS) $(INC) $< -Fo$@
|
||||||
|
@move $@ $(OUT_DIR)\
|
||||||
|
|
||||||
|
{$(PRIN)}.c.obj :
|
||||||
|
$(CC) -c $(CFLAGS) $(INC) /wd 4005 $< -Fo$@
|
||||||
|
@move $@ $(OUT_DIR)\
|
||||||
|
|
||||||
|
{$(ERRO)}.c.obj :
|
||||||
|
$(CC) -c $(CFLAGS) $(INC) $< -Fo$@
|
||||||
|
@move $@ $(OUT_DIR)\
|
||||||
|
|
||||||
|
{$(USER)}.c.obj :
|
||||||
|
$(CC) -c $(CFLAGS) $(INC) /D WIN32 /wd 4754 $< -Fo$@
|
||||||
|
@move $@ $(OUT_DIR)\
|
|
@ -0,0 +1,298 @@
|
||||||
|
/** @file
|
||||||
|
Copyright (c) 2022, Mikhail Krichanov. All rights reserved.
|
||||||
|
SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include <UserFile.h>
|
||||||
|
|
||||||
|
#define DEFAULT_MC_ALIGNMENT 16
|
||||||
|
#define DEFAULT_MC_PAD_BYTE_VALUE 0xFF
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
UINT32 HeaderVersion;
|
||||||
|
UINT32 PatchId;
|
||||||
|
UINT32 Date;
|
||||||
|
UINT32 CpuId;
|
||||||
|
UINT32 Checksum;
|
||||||
|
UINT32 LoaderVersion;
|
||||||
|
UINT32 PlatformId;
|
||||||
|
UINT32 DataSize; // if 0, then TotalSize = 2048, and TotalSize field is invalid
|
||||||
|
UINT32 TotalSize; // number of bytes
|
||||||
|
UINT32 Reserved[3];
|
||||||
|
} MICROCODE_HEADER;
|
||||||
|
|
||||||
|
static
|
||||||
|
RETURN_STATUS
|
||||||
|
TxtToBin (
|
||||||
|
IN const char *TxtName,
|
||||||
|
IN const char *BinName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
char *Txt;
|
||||||
|
char *TxtStart;
|
||||||
|
uint32_t TxtSize;
|
||||||
|
UINT32 *Buffer;
|
||||||
|
UINT32 *BufferStart;
|
||||||
|
UINT32 FileLength;
|
||||||
|
UINT32 Index;
|
||||||
|
MICROCODE_HEADER *Micro;
|
||||||
|
UINT32 CheckSum;
|
||||||
|
|
||||||
|
assert (TxtName != NULL);
|
||||||
|
assert (BinName != NULL);
|
||||||
|
|
||||||
|
Txt = (char *)UserReadFile (TxtName, &TxtSize);
|
||||||
|
if (Txt == NULL) {
|
||||||
|
fprintf (stderr, "MicroTool: Could not open %s: %s\n", TxtName, strerror (errno));
|
||||||
|
return RETURN_ABORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
Buffer = calloc (1, TxtSize);
|
||||||
|
if (Buffer == NULL) {
|
||||||
|
fprintf (stderr, "MicroTool: Could not allocate memory for Buffer\n");
|
||||||
|
free (Txt);
|
||||||
|
return RETURN_OUT_OF_RESOURCES;
|
||||||
|
}
|
||||||
|
|
||||||
|
BufferStart = Buffer;
|
||||||
|
TxtStart = Txt;
|
||||||
|
FileLength = 0;
|
||||||
|
for (Index = 0; Index < TxtSize; ++Index, ++Txt) {
|
||||||
|
//
|
||||||
|
// Skip Blank Lines and Comment Lines
|
||||||
|
//
|
||||||
|
if (isspace ((int)*Txt)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*Txt == ';') {
|
||||||
|
while ((Index < TxtSize) && (*Txt != '\n')) {
|
||||||
|
++Index;
|
||||||
|
++Txt;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Index == TxtSize) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
++Index;
|
||||||
|
++Txt;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Look for
|
||||||
|
// dd 000000001h ; comment
|
||||||
|
// dd XXXXXXXX
|
||||||
|
// DD XXXXXXXXX
|
||||||
|
// DD XXXXXXXXX
|
||||||
|
//
|
||||||
|
if (((Index + 2) < TxtSize) && (tolower ((int)Txt[0]) == 'd') && (tolower ((int)Txt[1]) == 'd') && isspace ((int)Txt[2])) {
|
||||||
|
//
|
||||||
|
// Skip blanks and look for a hex digit
|
||||||
|
//
|
||||||
|
Txt += 3;
|
||||||
|
Index += 3;
|
||||||
|
while ((Index < TxtSize) && isspace ((int)*Txt)) {
|
||||||
|
++Index;
|
||||||
|
++Txt;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Index == TxtSize) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isxdigit ((int)*Txt)) {
|
||||||
|
if (sscanf (Txt, "%X", Buffer) != 1) {
|
||||||
|
fprintf (stderr, "MicroTool: Could not write into Buffer\n");
|
||||||
|
free (TxtStart);
|
||||||
|
free (BufferStart);
|
||||||
|
return RETURN_ABORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
while ((Index < TxtSize) && (*Txt != '\n')) {
|
||||||
|
++Index;
|
||||||
|
++Txt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
++Buffer;
|
||||||
|
FileLength += sizeof (*Buffer);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf (stderr, "MicroTool: Corrupted input file\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
free (TxtStart);
|
||||||
|
|
||||||
|
if (FileLength == 0) {
|
||||||
|
fprintf (stderr, "MicroTool: No parseable data found in file %s\n", TxtName);
|
||||||
|
free (BufferStart);
|
||||||
|
return RETURN_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FileLength < sizeof (MICROCODE_HEADER)) {
|
||||||
|
fprintf (stderr, "MicroTool: Amount of parsable data in %s is insufficient to contain a microcode header\n", TxtName);
|
||||||
|
free (BufferStart);
|
||||||
|
return RETURN_VOLUME_CORRUPTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Can't do much checking on the header because, per the spec, the
|
||||||
|
// DataSize field may be 0, which means DataSize = 2000 and TotalSize = 2K,
|
||||||
|
// and the TotalSize field is invalid (actually missing). Thus we can't
|
||||||
|
// even verify the Reserved fields are 0.
|
||||||
|
//
|
||||||
|
Micro = (MICROCODE_HEADER *)BufferStart;
|
||||||
|
if (Micro->DataSize == 0) {
|
||||||
|
Index = 2048;
|
||||||
|
} else {
|
||||||
|
Index = Micro->TotalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Index != FileLength) {
|
||||||
|
fprintf (stderr, "MicroTool: File length of %s (0x%x) does not equal expected TotalSize: 0x%04X\n", TxtName, FileLength, Index);
|
||||||
|
free (BufferStart);
|
||||||
|
return RETURN_VOLUME_CORRUPTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Checksum the contents
|
||||||
|
//
|
||||||
|
Buffer = BufferStart;
|
||||||
|
CheckSum = 0;
|
||||||
|
Index = 0;
|
||||||
|
while (Index < FileLength) {
|
||||||
|
CheckSum += *Buffer;
|
||||||
|
|
||||||
|
++Buffer;
|
||||||
|
Index += sizeof (*Buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CheckSum != 0) {
|
||||||
|
fprintf (stderr, "MicroTool: Checksum (0x%x) failed on file %s\n", CheckSum, TxtName);
|
||||||
|
free (BufferStart);
|
||||||
|
return RETURN_VOLUME_CORRUPTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
UserWriteFile (BinName, BufferStart, FileLength);
|
||||||
|
|
||||||
|
free (BufferStart);
|
||||||
|
|
||||||
|
return RETURN_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
RETURN_STATUS
|
||||||
|
Merge (
|
||||||
|
IN const char *Output,
|
||||||
|
IN const char *FileNames[],
|
||||||
|
IN UINT32 NumOfFiles
|
||||||
|
)
|
||||||
|
{
|
||||||
|
void *File;
|
||||||
|
uint32_t FileSize;
|
||||||
|
UINT32 Index;
|
||||||
|
UINT32 Total;
|
||||||
|
char *Buffer;
|
||||||
|
char *BufferStart;
|
||||||
|
UINT32 Addend;
|
||||||
|
|
||||||
|
assert (Output != NULL);
|
||||||
|
assert (FileNames != NULL);
|
||||||
|
|
||||||
|
Total = 0;
|
||||||
|
|
||||||
|
for (Index = 0; Index < NumOfFiles; ++Index) {
|
||||||
|
File = UserReadFile (FileNames[Index], &FileSize);
|
||||||
|
if (File == NULL) {
|
||||||
|
fprintf (stderr, "MicroTool: Could not open %s: %s\n", FileNames[Index], strerror (errno));
|
||||||
|
return RETURN_ABORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
Total += ALIGN_VALUE (FileSize, DEFAULT_MC_ALIGNMENT);
|
||||||
|
|
||||||
|
free (File);
|
||||||
|
}
|
||||||
|
|
||||||
|
Buffer = calloc (1, Total);
|
||||||
|
if (Buffer == NULL) {
|
||||||
|
fprintf (stderr, "MicroTool: Could not allocate memory for Buffer\n");
|
||||||
|
return RETURN_OUT_OF_RESOURCES;
|
||||||
|
}
|
||||||
|
|
||||||
|
BufferStart = Buffer;
|
||||||
|
|
||||||
|
for (Index = 0; Index < NumOfFiles; ++Index) {
|
||||||
|
File = UserReadFile (FileNames[Index], &FileSize);
|
||||||
|
if (File == NULL) {
|
||||||
|
fprintf (stderr, "MicroTool: Could not reopen %s: %s\n", FileNames[Index], strerror (errno));
|
||||||
|
free (BufferStart);
|
||||||
|
return RETURN_ABORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy (Buffer, File, FileSize);
|
||||||
|
Buffer += FileSize;
|
||||||
|
|
||||||
|
Addend = ALIGN_VALUE_ADDEND (FileSize, DEFAULT_MC_ALIGNMENT);
|
||||||
|
memset (Buffer, DEFAULT_MC_PAD_BYTE_VALUE, Addend);
|
||||||
|
Buffer += Addend;
|
||||||
|
|
||||||
|
free (File);
|
||||||
|
}
|
||||||
|
|
||||||
|
UserWriteFile (Output, BufferStart, Total);
|
||||||
|
|
||||||
|
free (BufferStart);
|
||||||
|
|
||||||
|
return RETURN_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main (int argc, const char *argv[])
|
||||||
|
{
|
||||||
|
RETURN_STATUS Status;
|
||||||
|
UINT32 NumOfFiles;
|
||||||
|
|
||||||
|
if (argc < 2) {
|
||||||
|
fprintf (stderr, "MicroTool: No command is specified\n");
|
||||||
|
assert (false);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp (argv[1], "TxtToBin") == 0) {
|
||||||
|
if (argc < 4) {
|
||||||
|
fprintf (stderr, "MicroTool: Command arguments are missing\n");
|
||||||
|
fprintf (stderr, " Usage: MicroTool TxtToBin InputFile OutputFile\n");
|
||||||
|
assert (false);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = TxtToBin (argv[2], argv [3]);
|
||||||
|
if (RETURN_ERROR (Status)) {
|
||||||
|
assert (false);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else if (strcmp (argv[1], "Merge") == 0) {
|
||||||
|
if (argc < 4) {
|
||||||
|
fprintf (stderr, "MicroTool: Command arguments are missing\n");
|
||||||
|
fprintf (stderr, " Usage: MicroTool Merge OutputFile InputFile1 InputFile2 ...\n");
|
||||||
|
assert (false);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
NumOfFiles = (UINT32)argc - 3U;
|
||||||
|
|
||||||
|
Status = Merge (argv[2], &argv[3], NumOfFiles);
|
||||||
|
if (RETURN_ERROR (Status)) {
|
||||||
|
assert (false);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
/** @file
|
||||||
|
|
||||||
|
Unified linker script for GCC, CLANG based builds
|
||||||
|
|
||||||
|
Copyright (c) 2023, Mikhail Krichanov. All rights reserved.<BR>
|
||||||
|
Copyright (c) 2010 - 2021, Intel Corporation. All rights reserved.<BR>
|
||||||
|
Copyright (c) 2015, Linaro Ltd. All rights reserved.<BR>
|
||||||
|
(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
|
||||||
|
|
||||||
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
SECTIONS {
|
||||||
|
|
||||||
|
. = ALIGNED_PE_HEADER_SIZE;
|
||||||
|
|
||||||
|
.text : ALIGN(CONSTANT(MAXPAGESIZE)) {
|
||||||
|
*(.text .text.* .stub .gnu.linkonce.t.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
.rodata : ALIGN(CONSTANT(MAXPAGESIZE)) {
|
||||||
|
*(.rodata .rodata.* .data.rel.ro .data.rel.ro.* .gnu.linkonce.r.*)
|
||||||
|
*(.got .got.*)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The contents of AutoGen.c files are mostly constant from the POV of the
|
||||||
|
* program, but most of it ends up in .data or .bss by default since few of
|
||||||
|
* the variable definitions that get emitted are declared as CONST.
|
||||||
|
* Unfortunately, we cannot pull it into the .text section entirely, since
|
||||||
|
* patchable PCDs are also emitted here, but we can at least move all of the
|
||||||
|
* emitted GUIDs here.
|
||||||
|
*/
|
||||||
|
*:AutoGen.obj(.data.g*Guid)
|
||||||
|
}
|
||||||
|
|
||||||
|
.data : ALIGN(CONSTANT(MAXPAGESIZE)) {
|
||||||
|
*(.data .data.* .gnu.linkonce.d.*)
|
||||||
|
*(.bss .bss.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
.hii : ALIGN(CONSTANT(MAXPAGESIZE)) {
|
||||||
|
KEEP (*(.hii))
|
||||||
|
}
|
||||||
|
|
||||||
|
.eh_frame : ALIGN(CONSTANT(MAXPAGESIZE)) {
|
||||||
|
KEEP (*(.eh_frame))
|
||||||
|
}
|
||||||
|
|
||||||
|
.rela (INFO) : {
|
||||||
|
*(.rela .rela.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
.build-id (INFO) : { *(.note.gnu.build-id) }
|
||||||
|
|
||||||
|
/DISCARD/ : {
|
||||||
|
*(.note.GNU-stack)
|
||||||
|
*(.interp)
|
||||||
|
*(.dynsym)
|
||||||
|
*(.dynstr)
|
||||||
|
*(.hash .gnu.hash)
|
||||||
|
*(.comment)
|
||||||
|
*(COMMON)
|
||||||
|
*(.dynamic)
|
||||||
|
*(.ARM.exidx .ARM.exidx.*)
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,88 +0,0 @@
|
||||||
/** @file
|
|
||||||
|
|
||||||
Unified linker script for CLANG based builds
|
|
||||||
|
|
||||||
Copyright (c) 2010 - 2021, Intel Corporation. All rights reserved.<BR>
|
|
||||||
Copyright (c) 2015, Linaro Ltd. All rights reserved.<BR>
|
|
||||||
(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
|
|
||||||
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
SECTIONS {
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The PE/COFF binary consists of DOS and PE/COFF headers, and a sequence of
|
|
||||||
* section headers adding up to PECOFF_HEADER_SIZE bytes (which differs
|
|
||||||
* between 32-bit and 64-bit builds). The actual start of the .text section
|
|
||||||
* will be rounded up based on its actual alignment.
|
|
||||||
*/
|
|
||||||
. = PECOFF_HEADER_SIZE;
|
|
||||||
|
|
||||||
.text : ALIGN(CONSTANT(MAXPAGESIZE)) {
|
|
||||||
*(.text .text.* .stub .gnu.linkonce.t.*)
|
|
||||||
*(.rodata .rodata.* .gnu.linkonce.r.*)
|
|
||||||
*(.got .got.*)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The contents of AutoGen.c files are mostly constant from the POV of the
|
|
||||||
* program, but most of it ends up in .data or .bss by default since few of
|
|
||||||
* the variable definitions that get emitted are declared as CONST.
|
|
||||||
* Unfortunately, we cannot pull it into the .text section entirely, since
|
|
||||||
* patchable PCDs are also emitted here, but we can at least move all of the
|
|
||||||
* emitted GUIDs here.
|
|
||||||
*/
|
|
||||||
*:AutoGen.obj(.data.g*Guid)
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The alignment of the .data section should be less than or equal to the
|
|
||||||
* alignment of the .text section. This ensures that the relative offset
|
|
||||||
* between these sections is the same in the ELF and the PE/COFF versions of
|
|
||||||
* this binary.
|
|
||||||
*/
|
|
||||||
.data ALIGN(ALIGNOF(.text)) : ALIGN(CONSTANT(MAXPAGESIZE)) {
|
|
||||||
*(.data .data.* .gnu.linkonce.d.*)
|
|
||||||
*(.bss .bss.*)
|
|
||||||
}
|
|
||||||
|
|
||||||
.eh_frame ALIGN(CONSTANT(MAXPAGESIZE)) : {
|
|
||||||
KEEP (*(.eh_frame))
|
|
||||||
}
|
|
||||||
|
|
||||||
.rela (INFO) : {
|
|
||||||
*(.rela .rela.*)
|
|
||||||
}
|
|
||||||
|
|
||||||
.hii : ALIGN(CONSTANT(MAXPAGESIZE)) {
|
|
||||||
KEEP (*(.hii))
|
|
||||||
}
|
|
||||||
|
|
||||||
.got : {
|
|
||||||
*(.got)
|
|
||||||
}
|
|
||||||
ASSERT(SIZEOF(.got) == 0, "Unexpected GOT entries detected!")
|
|
||||||
|
|
||||||
.got.plt (INFO) : {
|
|
||||||
*(.got.plt)
|
|
||||||
}
|
|
||||||
ASSERT(SIZEOF(.got.plt) == 0 || SIZEOF(.got.plt) == 0xc || SIZEOF(.got.plt) == 0x18, "Unexpected GOT/PLT entries detected!")
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Retain the GNU build id but in a non-allocatable section so GenFw
|
|
||||||
* does not copy it into the PE/COFF image.
|
|
||||||
*/
|
|
||||||
.build-id (INFO) : { *(.note.gnu.build-id) }
|
|
||||||
|
|
||||||
/DISCARD/ : {
|
|
||||||
*(.note.GNU-stack)
|
|
||||||
*(.gnu_debuglink)
|
|
||||||
*(.interp)
|
|
||||||
*(.dynsym)
|
|
||||||
*(.dynstr)
|
|
||||||
*(.hash .gnu.hash)
|
|
||||||
*(.comment)
|
|
||||||
*(COMMON)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,88 +0,0 @@
|
||||||
/** @file
|
|
||||||
|
|
||||||
Unified linker script for GCC based builds
|
|
||||||
|
|
||||||
Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.<BR>
|
|
||||||
Copyright (c) 2015, Linaro Ltd. All rights reserved.<BR>
|
|
||||||
(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
|
|
||||||
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
SECTIONS {
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The PE/COFF binary consists of DOS and PE/COFF headers, and a sequence of
|
|
||||||
* section headers adding up to PECOFF_HEADER_SIZE bytes (which differs
|
|
||||||
* between 32-bit and 64-bit builds). The actual start of the .text section
|
|
||||||
* will be rounded up based on its actual alignment.
|
|
||||||
*/
|
|
||||||
. = PECOFF_HEADER_SIZE;
|
|
||||||
|
|
||||||
.text : ALIGN(CONSTANT(COMMONPAGESIZE)) {
|
|
||||||
*(.text .text.* .stub .gnu.linkonce.t.*)
|
|
||||||
*(.rodata .rodata.* .gnu.linkonce.r.*)
|
|
||||||
*(.got .got.*)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The contents of AutoGen.c files are mostly constant from the POV of the
|
|
||||||
* program, but most of it ends up in .data or .bss by default since few of
|
|
||||||
* the variable definitions that get emitted are declared as CONST.
|
|
||||||
* Unfortunately, we cannot pull it into the .text section entirely, since
|
|
||||||
* patchable PCDs are also emitted here, but we can at least move all of the
|
|
||||||
* emitted GUIDs here.
|
|
||||||
*/
|
|
||||||
*:AutoGen.obj(.data.g*Guid)
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The alignment of the .data section should be less than or equal to the
|
|
||||||
* alignment of the .text section. This ensures that the relative offset
|
|
||||||
* between these sections is the same in the ELF and the PE/COFF versions of
|
|
||||||
* this binary.
|
|
||||||
*/
|
|
||||||
.data ALIGN(ALIGNOF(.text)) : ALIGN(CONSTANT(COMMONPAGESIZE)) {
|
|
||||||
*(.data .data.* .gnu.linkonce.d.*)
|
|
||||||
*(.bss .bss.*)
|
|
||||||
}
|
|
||||||
|
|
||||||
.eh_frame ALIGN(CONSTANT(COMMONPAGESIZE)) : {
|
|
||||||
KEEP (*(.eh_frame))
|
|
||||||
}
|
|
||||||
|
|
||||||
.rela (INFO) : {
|
|
||||||
*(.rela .rela.*)
|
|
||||||
}
|
|
||||||
|
|
||||||
.hii : ALIGN(CONSTANT(COMMONPAGESIZE)) {
|
|
||||||
KEEP (*(.hii))
|
|
||||||
}
|
|
||||||
|
|
||||||
.got : {
|
|
||||||
*(.got)
|
|
||||||
}
|
|
||||||
ASSERT(SIZEOF(.got) == 0, "Unexpected GOT entries detected!")
|
|
||||||
|
|
||||||
.got.plt (INFO) : {
|
|
||||||
*(.got.plt)
|
|
||||||
}
|
|
||||||
ASSERT(SIZEOF(.got.plt) == 0 || SIZEOF(.got.plt) == 0xc || SIZEOF(.got.plt) == 0x18, "Unexpected GOT/PLT entries detected!")
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Retain the GNU build id but in a non-allocatable section so GenFw
|
|
||||||
* does not copy it into the PE/COFF image.
|
|
||||||
*/
|
|
||||||
.build-id (INFO) : { *(.note.gnu.build-id) }
|
|
||||||
|
|
||||||
/DISCARD/ : {
|
|
||||||
*(.note.GNU-stack)
|
|
||||||
*(.gnu_debuglink)
|
|
||||||
*(.interp)
|
|
||||||
*(.dynsym)
|
|
||||||
*(.dynstr)
|
|
||||||
*(.dynamic)
|
|
||||||
*(.hash .gnu.hash)
|
|
||||||
*(.comment)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
/** @file
|
||||||
|
|
||||||
|
Unified linker script for GCC, CLANG based builds
|
||||||
|
|
||||||
|
Copyright (c) 2023, Mikhail Krichanov. All rights reserved.<BR>
|
||||||
|
Copyright (c) 2010 - 2021, Intel Corporation. All rights reserved.<BR>
|
||||||
|
Copyright (c) 2015, Linaro Ltd. All rights reserved.<BR>
|
||||||
|
(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
|
||||||
|
|
||||||
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
SECTIONS {
|
||||||
|
|
||||||
|
. = ALIGNED_PE_HEADER_SIZE;
|
||||||
|
|
||||||
|
.text : ALIGN(CONSTANT(MAXPAGESIZE)) {
|
||||||
|
*(.text .text.* .stub .gnu.linkonce.t.*)
|
||||||
|
*(.rodata .rodata.* .data.rel.ro .data.rel.ro.* .gnu.linkonce.r.*)
|
||||||
|
*(.got .got.*)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The contents of AutoGen.c files are mostly constant from the POV of the
|
||||||
|
* program, but most of it ends up in .data or .bss by default since few of
|
||||||
|
* the variable definitions that get emitted are declared as CONST.
|
||||||
|
* Unfortunately, we cannot pull it into the .text section entirely, since
|
||||||
|
* patchable PCDs are also emitted here, but we can at least move all of the
|
||||||
|
* emitted GUIDs here.
|
||||||
|
*/
|
||||||
|
*:AutoGen.obj(.data.g*Guid)
|
||||||
|
}
|
||||||
|
|
||||||
|
.data : ALIGN(CONSTANT(MAXPAGESIZE)) {
|
||||||
|
*(.data .data.* .gnu.linkonce.d.*)
|
||||||
|
*(.bss .bss.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
.hii : ALIGN(CONSTANT(MAXPAGESIZE)) {
|
||||||
|
KEEP (*(.hii))
|
||||||
|
}
|
||||||
|
|
||||||
|
.eh_frame : ALIGN(CONSTANT(MAXPAGESIZE)) {
|
||||||
|
KEEP (*(.eh_frame))
|
||||||
|
}
|
||||||
|
|
||||||
|
.rela (INFO) : {
|
||||||
|
*(.rela .rela.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
.build-id (INFO) : { *(.note.gnu.build-id) }
|
||||||
|
|
||||||
|
/DISCARD/ : {
|
||||||
|
*(.note.GNU-stack)
|
||||||
|
*(.interp)
|
||||||
|
*(.dynsym)
|
||||||
|
*(.dynstr)
|
||||||
|
*(.hash .gnu.hash)
|
||||||
|
*(.comment)
|
||||||
|
*(COMMON)
|
||||||
|
*(.dynamic)
|
||||||
|
*(.ARM.exidx .ARM.exidx.*)
|
||||||
|
}
|
||||||
|
}
|
|
@ -56,7 +56,6 @@ APPLICATIONS = \
|
||||||
EfiRom \
|
EfiRom \
|
||||||
GenFfs \
|
GenFfs \
|
||||||
GenFv \
|
GenFv \
|
||||||
GenFw \
|
|
||||||
GenSec \
|
GenSec \
|
||||||
GenCrc32 \
|
GenCrc32 \
|
||||||
LzmaCompress \
|
LzmaCompress \
|
||||||
|
|
|
@ -3463,7 +3463,7 @@ Returns:
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
EFI_PHYSICAL_ADDRESS
|
EFI_STATUS
|
||||||
AddPadSection (
|
AddPadSection (
|
||||||
IN OUT EFI_PHYSICAL_ADDRESS *BaseAddress,
|
IN OUT EFI_PHYSICAL_ADDRESS *BaseAddress,
|
||||||
IN UINT32 Alignment,
|
IN UINT32 Alignment,
|
||||||
|
@ -3476,14 +3476,14 @@ AddPadSection (
|
||||||
UINT32 FfsHeaderLength;
|
UINT32 FfsHeaderLength;
|
||||||
UINT32 FfsFileLength;
|
UINT32 FfsFileLength;
|
||||||
UINT32 PadSize;
|
UINT32 PadSize;
|
||||||
UINTN PadAddress;
|
EFI_PHYSICAL_ADDRESS PadAddress;
|
||||||
UINT8 *FfsPart;
|
UINT8 *FfsPart;
|
||||||
UINT32 PartSize;
|
UINT32 PartSize;
|
||||||
UINT32 Offset;
|
UINT32 Offset;
|
||||||
EFI_FFS_INTEGRITY_CHECK *IntegrityCheck;
|
EFI_FFS_INTEGRITY_CHECK *IntegrityCheck;
|
||||||
|
|
||||||
PadAddress = ALIGN_VALUE (*BaseAddress + sizeof (EFI_COMMON_SECTION_HEADER), Alignment);
|
PadAddress = ALIGN_VALUE (*BaseAddress + sizeof (EFI_COMMON_SECTION_HEADER), Alignment);
|
||||||
PadSize = PadAddress - *BaseAddress;
|
PadSize = (UINT32)(PadAddress - *BaseAddress);
|
||||||
|
|
||||||
Offset = (UINT32)((UINTN)((*Section).Pe32Section) - (UINTN)(*FfsFile));
|
Offset = (UINT32)((UINTN)((*Section).Pe32Section) - (UINTN)(*FfsFile));
|
||||||
PartSize = GetFfsFileLength (*FfsFile) - Offset;
|
PartSize = GetFfsFileLength (*FfsFile) - Offset;
|
||||||
|
@ -3513,7 +3513,7 @@ AddPadSection (
|
||||||
++NewSection;
|
++NewSection;
|
||||||
ZeroMem ((VOID *)NewSection, PadSize - sizeof (EFI_COMMON_SECTION_HEADER));
|
ZeroMem ((VOID *)NewSection, PadSize - sizeof (EFI_COMMON_SECTION_HEADER));
|
||||||
|
|
||||||
*Section = (EFI_FILE_SECTION_POINTER)(EFI_PE32_SECTION *)((UINT8 *)NewSection + PadSize - sizeof (EFI_COMMON_SECTION_HEADER));
|
(*Section).Pe32Section = (EFI_PE32_SECTION *)((UINT8 *)NewSection + PadSize - sizeof (EFI_COMMON_SECTION_HEADER));
|
||||||
|
|
||||||
CopyMem (
|
CopyMem (
|
||||||
(UINT8 *)((*Section).Pe32Section),
|
(UINT8 *)((*Section).Pe32Section),
|
||||||
|
@ -3947,7 +3947,7 @@ Returns:
|
||||||
PdbPointer = FileName;
|
PdbPointer = FileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
WriteMapFile (FvMapFile, PdbPointer, *FfsFile, NewPe32BaseAddress, &OrigImageContext);
|
WriteMapFile (FvMapFile, PdbPointer, *FfsFile, NewPe32BaseAddress, &ImageContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((*FfsFile)->Type != EFI_FV_FILETYPE_SECURITY_CORE &&
|
if ((*FfsFile)->Type != EFI_FV_FILETYPE_SECURITY_CORE &&
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,19 +0,0 @@
|
||||||
/** @file
|
|
||||||
Header file for Elf32 Convert solution
|
|
||||||
|
|
||||||
Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#ifndef _ELF_32_CONVERT_
|
|
||||||
#define _ELF_32_CONVERT_
|
|
||||||
|
|
||||||
BOOLEAN
|
|
||||||
InitializeElf32 (
|
|
||||||
UINT8 *FileBuffer,
|
|
||||||
ELF_FUNCTION_TABLE *ElfFunctions
|
|
||||||
);
|
|
||||||
|
|
||||||
#endif
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,19 +0,0 @@
|
||||||
/** @file
|
|
||||||
Header file for Elf64 convert solution
|
|
||||||
|
|
||||||
Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#ifndef _ELF_64_CONVERT_
|
|
||||||
#define _ELF_64_CONVERT_
|
|
||||||
|
|
||||||
BOOLEAN
|
|
||||||
InitializeElf64 (
|
|
||||||
UINT8 *FileBuffer,
|
|
||||||
ELF_FUNCTION_TABLE *ElfFunctions
|
|
||||||
);
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,251 +0,0 @@
|
||||||
/** @file
|
|
||||||
Elf convert solution
|
|
||||||
|
|
||||||
Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#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 <assert.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;
|
|
||||||
|
|
||||||
//
|
|
||||||
//mFileBufferSize
|
|
||||||
//
|
|
||||||
UINT32 mFileBufferSize;
|
|
||||||
|
|
||||||
//
|
|
||||||
//*****************************************************************************
|
|
||||||
// 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 * MAX_COFF_ALIGNMENT
|
|
||||||
);
|
|
||||||
if (mCoffFile == NULL) {
|
|
||||||
Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
|
|
||||||
}
|
|
||||||
assert (mCoffFile != NULL);
|
|
||||||
memset (
|
|
||||||
mCoffFile + mCoffOffset, 0,
|
|
||||||
sizeof(EFI_IMAGE_BASE_RELOCATION) + 2 * MAX_COFF_ALIGNMENT
|
|
||||||
);
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
mFileBufferSize = *FileLength;
|
|
||||||
//
|
|
||||||
// Determine ELF type and set function table pointer correctly.
|
|
||||||
//
|
|
||||||
VerboseMsg ("Check Elf 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.");
|
|
||||||
if (!ElfFunctions.WriteSections (SECTION_TEXT)) {
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
if (!ElfFunctions.WriteSections (SECTION_DATA)) {
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
if (!ElfFunctions.WriteSections (SECTION_HII)) {
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Translate and write relocations.
|
|
||||||
//
|
|
||||||
VerboseMsg ("Translate and write relocations.");
|
|
||||||
ElfFunctions.WriteRelocations ();
|
|
||||||
|
|
||||||
//
|
|
||||||
// Write debug info.
|
|
||||||
//
|
|
||||||
VerboseMsg ("Write debug info.");
|
|
||||||
ElfFunctions.WriteDebug ();
|
|
||||||
|
|
||||||
//
|
|
||||||
// For PRM Driver to Write export info.
|
|
||||||
//
|
|
||||||
if (mExportFlag) {
|
|
||||||
VerboseMsg ("Write export info.");
|
|
||||||
ElfFunctions.WriteExport ();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// 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;
|
|
||||||
}
|
|
|
@ -1,122 +0,0 @@
|
||||||
/** @file
|
|
||||||
Header file for Elf convert solution
|
|
||||||
|
|
||||||
Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#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;
|
|
||||||
extern UINT32 mOutImageType;
|
|
||||||
extern UINT32 mFileBufferSize;
|
|
||||||
extern BOOLEAN mExportFlag;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Common EFI specific data.
|
|
||||||
//
|
|
||||||
#define ELF_HII_SECTION_NAME ".hii"
|
|
||||||
#define ELF_STRTAB_SECTION_NAME ".strtab"
|
|
||||||
#define MAX_COFF_ALIGNMENT 0x10000
|
|
||||||
#define ELF_SYMBOL_SECTION_NAME ".symtab"
|
|
||||||
|
|
||||||
//
|
|
||||||
// Platform Runtime Mechanism (PRM) specific data.
|
|
||||||
//
|
|
||||||
#define PRM_MODULE_EXPORT_SYMBOL_NUM 256
|
|
||||||
|
|
||||||
// <to-do> to include PRM header directly once PrmPkg is in main repo
|
|
||||||
#define PRM_HANDLER_NAME_MAXIMUM_LENGTH 128
|
|
||||||
|
|
||||||
#define PRM_MODULE_EXPORT_DESCRIPTOR_NAME "PrmModuleExportDescriptor"
|
|
||||||
#define PRM_MODULE_EXPORT_DESCRIPTOR_SIGNATURE SIGNATURE_64 ('P', 'R', 'M', '_', 'M', 'E', 'D', 'T')
|
|
||||||
#define PRM_MODULE_EXPORT_REVISION 0x0
|
|
||||||
|
|
||||||
//
|
|
||||||
// Platform Runtime Mechanism (PRM) Export Descriptor Structures
|
|
||||||
//
|
|
||||||
#pragma pack(push, 1)
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
EFI_GUID PrmHandlerGuid;
|
|
||||||
CHAR8 PrmHandlerName[PRM_HANDLER_NAME_MAXIMUM_LENGTH];
|
|
||||||
} PRM_HANDLER_EXPORT_DESCRIPTOR_STRUCT;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
UINT64 Signature;
|
|
||||||
UINT16 Revision;
|
|
||||||
UINT16 NumberPrmHandlers;
|
|
||||||
EFI_GUID PlatformGuid;
|
|
||||||
EFI_GUID ModuleGuid;
|
|
||||||
} PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT_HEADER;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT_HEADER Header;
|
|
||||||
PRM_HANDLER_EXPORT_DESCRIPTOR_STRUCT PrmHandlerExportDescriptors[1];
|
|
||||||
} PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT;
|
|
||||||
|
|
||||||
#pragma pack(pop)
|
|
||||||
|
|
||||||
//
|
|
||||||
// Filter Types
|
|
||||||
//
|
|
||||||
typedef enum {
|
|
||||||
SECTION_TEXT,
|
|
||||||
SECTION_HII,
|
|
||||||
SECTION_DATA,
|
|
||||||
SECTION_SYMBOL
|
|
||||||
|
|
||||||
} SECTION_FILTER_TYPES;
|
|
||||||
|
|
||||||
//
|
|
||||||
// FunctionTable
|
|
||||||
//
|
|
||||||
typedef struct {
|
|
||||||
VOID (*ScanSections) ();
|
|
||||||
BOOLEAN (*WriteSections) (SECTION_FILTER_TYPES FilterType);
|
|
||||||
VOID (*WriteRelocations) ();
|
|
||||||
VOID (*WriteDebug) ();
|
|
||||||
VOID (*WriteExport) ();
|
|
||||||
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
|
|
|
@ -1,23 +0,0 @@
|
||||||
## @file
|
|
||||||
# GNU/Linux makefile for 'GenFw' module build.
|
|
||||||
#
|
|
||||||
# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
#
|
|
||||||
MAKEROOT ?= ..
|
|
||||||
|
|
||||||
APPNAME = GenFw
|
|
||||||
|
|
||||||
OBJECTS = GenFw.o ElfConvert.o Elf32Convert.o Elf64Convert.o
|
|
||||||
|
|
||||||
include $(MAKEROOT)/Makefiles/app.makefile
|
|
||||||
|
|
||||||
LIBS = -lCommon
|
|
||||||
ifeq ($(CYGWIN), CYGWIN)
|
|
||||||
LIBS += -L/lib/e2fsprogs -luuid
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(LINUX), Linux)
|
|
||||||
LIBS += -luuid
|
|
||||||
endif
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,50 +0,0 @@
|
||||||
/** @file
|
|
||||||
Header file for GenFw
|
|
||||||
|
|
||||||
Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#ifndef _GEN_FW_H_
|
|
||||||
#define _GEN_FW_H_
|
|
||||||
|
|
||||||
//
|
|
||||||
// Action for this tool.
|
|
||||||
//
|
|
||||||
#define FW_DUMMY_IMAGE 0
|
|
||||||
#define FW_EFI_IMAGE 1
|
|
||||||
#define FW_TE_IMAGE 2
|
|
||||||
#define FW_ACPI_IMAGE 3
|
|
||||||
#define FW_BIN_IMAGE 4
|
|
||||||
#define FW_ZERO_DEBUG_IMAGE 5
|
|
||||||
#define FW_SET_STAMP_IMAGE 6
|
|
||||||
#define FW_MCI_IMAGE 7
|
|
||||||
#define FW_MERGE_IMAGE 8
|
|
||||||
#define FW_RELOC_STRIPEED_IMAGE 9
|
|
||||||
#define FW_HII_PACKAGE_LIST_RCIMAGE 10
|
|
||||||
#define FW_HII_PACKAGE_LIST_BINIMAGE 11
|
|
||||||
#define FW_REBASE_IMAGE 12
|
|
||||||
#define FW_SET_ADDRESS_IMAGE 13
|
|
||||||
|
|
||||||
#define DUMP_TE_HEADER 0x11
|
|
||||||
|
|
||||||
VOID
|
|
||||||
SetHiiResourceHeader (
|
|
||||||
UINT8 *HiiBinData,
|
|
||||||
UINT32 OffsetToFile
|
|
||||||
);
|
|
||||||
|
|
||||||
INTN
|
|
||||||
IsElfHeader (
|
|
||||||
UINT8 *FileBuffer
|
|
||||||
);
|
|
||||||
|
|
||||||
BOOLEAN
|
|
||||||
ConvertElf (
|
|
||||||
UINT8 **FileBuffer,
|
|
||||||
UINT32 *FileLength
|
|
||||||
);
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,18 +0,0 @@
|
||||||
## @file
|
|
||||||
# Windows makefile for 'GenFw' module build.
|
|
||||||
#
|
|
||||||
# Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
|
|
||||||
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
#
|
|
||||||
!INCLUDE ..\Makefiles\ms.common
|
|
||||||
|
|
||||||
APPNAME = GenFw
|
|
||||||
|
|
||||||
LIBS = $(LIB_PATH)\Common.lib
|
|
||||||
|
|
||||||
OBJECTS = GenFw.obj ElfConvert.obj Elf32Convert.obj Elf64Convert.obj
|
|
||||||
|
|
||||||
#CFLAGS = $(CFLAGS) /nodefaultlib:libc.lib
|
|
||||||
|
|
||||||
!INCLUDE ..\Makefiles\ms.app
|
|
||||||
|
|
|
@ -1,252 +0,0 @@
|
||||||
/** @file
|
|
||||||
Ported ELF include files from FreeBSD
|
|
||||||
|
|
||||||
Copyright (c) 2009 - 2010, Apple Inc. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
|
|
||||||
**/
|
|
||||||
/*-
|
|
||||||
* Copyright (c) 1996-1998 John D. Polstra.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* $FreeBSD: src/sys/sys/elf32.h,v 1.8.14.2 2007/12/03 21:30:36 marius Exp $
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SYS_ELF32_H_
|
|
||||||
#define _SYS_ELF32_H_ 1
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ELF definitions common to all 32-bit architectures.
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef UINT32 Elf32_Addr;
|
|
||||||
typedef UINT16 Elf32_Half;
|
|
||||||
typedef UINT32 Elf32_Off;
|
|
||||||
typedef INT32 Elf32_Sword;
|
|
||||||
typedef UINT32 Elf32_Word;
|
|
||||||
typedef UINT64 Elf32_Lword;
|
|
||||||
|
|
||||||
typedef Elf32_Word Elf32_Hashelt;
|
|
||||||
|
|
||||||
/* Non-standard class-dependent datatype used for abstraction. */
|
|
||||||
typedef Elf32_Word Elf32_Size;
|
|
||||||
typedef Elf32_Sword Elf32_Ssize;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ELF header.
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
unsigned char e_ident[EI_NIDENT]; /* File identification. */
|
|
||||||
Elf32_Half e_type; /* File type. */
|
|
||||||
Elf32_Half e_machine; /* Machine architecture. */
|
|
||||||
Elf32_Word e_version; /* ELF format version. */
|
|
||||||
Elf32_Addr e_entry; /* Entry point. */
|
|
||||||
Elf32_Off e_phoff; /* Program header file offset. */
|
|
||||||
Elf32_Off e_shoff; /* Section header file offset. */
|
|
||||||
Elf32_Word e_flags; /* Architecture-specific flags. */
|
|
||||||
Elf32_Half e_ehsize; /* Size of ELF header in bytes. */
|
|
||||||
Elf32_Half e_phentsize; /* Size of program header entry. */
|
|
||||||
Elf32_Half e_phnum; /* Number of program header entries. */
|
|
||||||
Elf32_Half e_shentsize; /* Size of section header entry. */
|
|
||||||
Elf32_Half e_shnum; /* Number of section header entries. */
|
|
||||||
Elf32_Half e_shstrndx; /* Section name strings section. */
|
|
||||||
} Elf32_Ehdr;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Section header.
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
Elf32_Word sh_name; /* Section name (index into the
|
|
||||||
section header string table). */
|
|
||||||
Elf32_Word sh_type; /* Section type. */
|
|
||||||
Elf32_Word sh_flags; /* Section flags. */
|
|
||||||
Elf32_Addr sh_addr; /* Address in memory image. */
|
|
||||||
Elf32_Off sh_offset; /* Offset in file. */
|
|
||||||
Elf32_Word sh_size; /* Size in bytes. */
|
|
||||||
Elf32_Word sh_link; /* Index of a related section. */
|
|
||||||
Elf32_Word sh_info; /* Depends on section type. */
|
|
||||||
Elf32_Word sh_addralign; /* Alignment in bytes. */
|
|
||||||
Elf32_Word sh_entsize; /* Size of each entry in section. */
|
|
||||||
} Elf32_Shdr;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Program header.
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
Elf32_Word p_type; /* Entry type. */
|
|
||||||
Elf32_Off p_offset; /* File offset of contents. */
|
|
||||||
Elf32_Addr p_vaddr; /* Virtual address in memory image. */
|
|
||||||
Elf32_Addr p_paddr; /* Physical address (not used). */
|
|
||||||
Elf32_Word p_filesz; /* Size of contents in file. */
|
|
||||||
Elf32_Word p_memsz; /* Size of contents in memory. */
|
|
||||||
Elf32_Word p_flags; /* Access permission flags. */
|
|
||||||
Elf32_Word p_align; /* Alignment in memory and file. */
|
|
||||||
} Elf32_Phdr;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Dynamic structure. The ".dynamic" section contains an array of them.
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
Elf32_Sword d_tag; /* Entry type. */
|
|
||||||
union {
|
|
||||||
Elf32_Word d_val; /* Integer value. */
|
|
||||||
Elf32_Addr d_ptr; /* Address value. */
|
|
||||||
} d_un;
|
|
||||||
} Elf32_Dyn;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Relocation entries.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Relocations that don't need an addend field. */
|
|
||||||
typedef struct {
|
|
||||||
Elf32_Addr r_offset; /* Location to be relocated. */
|
|
||||||
Elf32_Word r_info; /* Relocation type and symbol index. */
|
|
||||||
} Elf32_Rel;
|
|
||||||
|
|
||||||
/* Relocations that need an addend field. */
|
|
||||||
typedef struct {
|
|
||||||
Elf32_Addr r_offset; /* Location to be relocated. */
|
|
||||||
Elf32_Word r_info; /* Relocation type and symbol index. */
|
|
||||||
Elf32_Sword r_addend; /* Addend. */
|
|
||||||
} Elf32_Rela;
|
|
||||||
|
|
||||||
/* Macros for accessing the fields of r_info. */
|
|
||||||
#define ELF32_R_SYM(info) ((info) >> 8)
|
|
||||||
#define ELF32_R_TYPE(info) ((unsigned char)(info))
|
|
||||||
|
|
||||||
/* Macro for constructing r_info from field values. */
|
|
||||||
#define ELF32_R_INFO(sym, type) (((sym) << 8) + (unsigned char)(type))
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Note entry header
|
|
||||||
*/
|
|
||||||
typedef Elf_Note Elf32_Nhdr;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Move entry
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
Elf32_Lword m_value; /* symbol value */
|
|
||||||
Elf32_Word m_info; /* size + index */
|
|
||||||
Elf32_Word m_poffset; /* symbol offset */
|
|
||||||
Elf32_Half m_repeat; /* repeat count */
|
|
||||||
Elf32_Half m_stride; /* stride info */
|
|
||||||
} Elf32_Move;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The macros compose and decompose values for Move.r_info
|
|
||||||
*
|
|
||||||
* sym = ELF32_M_SYM(M.m_info)
|
|
||||||
* size = ELF32_M_SIZE(M.m_info)
|
|
||||||
* M.m_info = ELF32_M_INFO(sym, size)
|
|
||||||
*/
|
|
||||||
#define ELF32_M_SYM(info) ((info)>>8)
|
|
||||||
#define ELF32_M_SIZE(info) ((unsigned char)(info))
|
|
||||||
#define ELF32_M_INFO(sym, size) (((sym)<<8)+(unsigned char)(size))
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Hardware/Software capabilities entry
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
Elf32_Word c_tag; /* how to interpret value */
|
|
||||||
union {
|
|
||||||
Elf32_Word c_val;
|
|
||||||
Elf32_Addr c_ptr;
|
|
||||||
} c_un;
|
|
||||||
} Elf32_Cap;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Symbol table entries.
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
Elf32_Word st_name; /* String table index of name. */
|
|
||||||
Elf32_Addr st_value; /* Symbol value. */
|
|
||||||
Elf32_Word st_size; /* Size of associated object. */
|
|
||||||
unsigned char st_info; /* Type and binding information. */
|
|
||||||
unsigned char st_other; /* Reserved (not used). */
|
|
||||||
Elf32_Half st_shndx; /* Section index of symbol. */
|
|
||||||
} Elf32_Sym;
|
|
||||||
|
|
||||||
/* Macros for accessing the fields of st_info. */
|
|
||||||
#define ELF32_ST_BIND(info) ((info) >> 4)
|
|
||||||
#define ELF32_ST_TYPE(info) ((info) & 0xf)
|
|
||||||
|
|
||||||
/* Macro for constructing st_info from field values. */
|
|
||||||
#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf))
|
|
||||||
|
|
||||||
/* Macro for accessing the fields of st_other. */
|
|
||||||
#define ELF32_ST_VISIBILITY(oth) ((oth) & 0x3)
|
|
||||||
|
|
||||||
/* Structures used by Sun & GNU symbol versioning. */
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
Elf32_Half vd_version;
|
|
||||||
Elf32_Half vd_flags;
|
|
||||||
Elf32_Half vd_ndx;
|
|
||||||
Elf32_Half vd_cnt;
|
|
||||||
Elf32_Word vd_hash;
|
|
||||||
Elf32_Word vd_aux;
|
|
||||||
Elf32_Word vd_next;
|
|
||||||
} Elf32_Verdef;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
Elf32_Word vda_name;
|
|
||||||
Elf32_Word vda_next;
|
|
||||||
} Elf32_Verdaux;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
Elf32_Half vn_version;
|
|
||||||
Elf32_Half vn_cnt;
|
|
||||||
Elf32_Word vn_file;
|
|
||||||
Elf32_Word vn_aux;
|
|
||||||
Elf32_Word vn_next;
|
|
||||||
} Elf32_Verneed;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
Elf32_Word vna_hash;
|
|
||||||
Elf32_Half vna_flags;
|
|
||||||
Elf32_Half vna_other;
|
|
||||||
Elf32_Word vna_name;
|
|
||||||
Elf32_Word vna_next;
|
|
||||||
} Elf32_Vernaux;
|
|
||||||
|
|
||||||
typedef Elf32_Half Elf32_Versym;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
Elf32_Half si_boundto; /* direct bindings - symbol bound to */
|
|
||||||
Elf32_Half si_flags; /* per symbol flags */
|
|
||||||
} Elf32_Syminfo;
|
|
||||||
|
|
||||||
#endif /* !_SYS_ELF32_H_ */
|
|
|
@ -1,254 +0,0 @@
|
||||||
/** @file
|
|
||||||
Ported ELF include files from FreeBSD
|
|
||||||
|
|
||||||
Copyright (c) 2009 - 2010, Apple Inc. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
/*-
|
|
||||||
* Copyright (c) 1996-1998 John D. Polstra.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* $FreeBSD: src/sys/sys/elf64.h,v 1.10.14.2 2007/12/03 21:30:36 marius Exp $
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SYS_ELF64_H_
|
|
||||||
#define _SYS_ELF64_H_ 1
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ELF definitions common to all 64-bit architectures.
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef UINT64 Elf64_Addr;
|
|
||||||
typedef UINT16 Elf64_Half;
|
|
||||||
typedef UINT64 Elf64_Off;
|
|
||||||
typedef INT32 Elf64_Sword;
|
|
||||||
typedef INT64 Elf64_Sxword;
|
|
||||||
typedef UINT32 Elf64_Word;
|
|
||||||
typedef UINT64 Elf64_Lword;
|
|
||||||
typedef UINT64 Elf64_Xword;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Types of dynamic symbol hash table bucket and chain elements.
|
|
||||||
*
|
|
||||||
* This is inconsistent among 64 bit architectures, so a machine dependent
|
|
||||||
* typedef is required.
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef Elf64_Word Elf64_Hashelt;
|
|
||||||
|
|
||||||
/* Non-standard class-dependent datatype used for abstraction. */
|
|
||||||
typedef Elf64_Xword Elf64_Size;
|
|
||||||
typedef Elf64_Sxword Elf64_Ssize;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ELF header.
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
unsigned char e_ident[EI_NIDENT]; /* File identification. */
|
|
||||||
Elf64_Half e_type; /* File type. */
|
|
||||||
Elf64_Half e_machine; /* Machine architecture. */
|
|
||||||
Elf64_Word e_version; /* ELF format version. */
|
|
||||||
Elf64_Addr e_entry; /* Entry point. */
|
|
||||||
Elf64_Off e_phoff; /* Program header file offset. */
|
|
||||||
Elf64_Off e_shoff; /* Section header file offset. */
|
|
||||||
Elf64_Word e_flags; /* Architecture-specific flags. */
|
|
||||||
Elf64_Half e_ehsize; /* Size of ELF header in bytes. */
|
|
||||||
Elf64_Half e_phentsize; /* Size of program header entry. */
|
|
||||||
Elf64_Half e_phnum; /* Number of program header entries. */
|
|
||||||
Elf64_Half e_shentsize; /* Size of section header entry. */
|
|
||||||
Elf64_Half e_shnum; /* Number of section header entries. */
|
|
||||||
Elf64_Half e_shstrndx; /* Section name strings section. */
|
|
||||||
} Elf64_Ehdr;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Section header.
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
Elf64_Word sh_name; /* Section name (index into the
|
|
||||||
section header string table). */
|
|
||||||
Elf64_Word sh_type; /* Section type. */
|
|
||||||
Elf64_Xword sh_flags; /* Section flags. */
|
|
||||||
Elf64_Addr sh_addr; /* Address in memory image. */
|
|
||||||
Elf64_Off sh_offset; /* Offset in file. */
|
|
||||||
Elf64_Xword sh_size; /* Size in bytes. */
|
|
||||||
Elf64_Word sh_link; /* Index of a related section. */
|
|
||||||
Elf64_Word sh_info; /* Depends on section type. */
|
|
||||||
Elf64_Xword sh_addralign; /* Alignment in bytes. */
|
|
||||||
Elf64_Xword sh_entsize; /* Size of each entry in section. */
|
|
||||||
} Elf64_Shdr;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Program header.
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
Elf64_Word p_type; /* Entry type. */
|
|
||||||
Elf64_Word p_flags; /* Access permission flags. */
|
|
||||||
Elf64_Off p_offset; /* File offset of contents. */
|
|
||||||
Elf64_Addr p_vaddr; /* Virtual address in memory image. */
|
|
||||||
Elf64_Addr p_paddr; /* Physical address (not used). */
|
|
||||||
Elf64_Xword p_filesz; /* Size of contents in file. */
|
|
||||||
Elf64_Xword p_memsz; /* Size of contents in memory. */
|
|
||||||
Elf64_Xword p_align; /* Alignment in memory and file. */
|
|
||||||
} Elf64_Phdr;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Dynamic structure. The ".dynamic" section contains an array of them.
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
Elf64_Sxword d_tag; /* Entry type. */
|
|
||||||
union {
|
|
||||||
Elf64_Xword d_val; /* Integer value. */
|
|
||||||
Elf64_Addr d_ptr; /* Address value. */
|
|
||||||
} d_un;
|
|
||||||
} Elf64_Dyn;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Relocation entries.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Relocations that don't need an addend field. */
|
|
||||||
typedef struct {
|
|
||||||
Elf64_Addr r_offset; /* Location to be relocated. */
|
|
||||||
Elf64_Xword r_info; /* Relocation type and symbol index. */
|
|
||||||
} Elf64_Rel;
|
|
||||||
|
|
||||||
/* Relocations that need an addend field. */
|
|
||||||
typedef struct {
|
|
||||||
Elf64_Addr r_offset; /* Location to be relocated. */
|
|
||||||
Elf64_Xword r_info; /* Relocation type and symbol index. */
|
|
||||||
Elf64_Sxword r_addend; /* Addend. */
|
|
||||||
} Elf64_Rela;
|
|
||||||
|
|
||||||
/* Macros for accessing the fields of r_info. */
|
|
||||||
#define ELF64_R_SYM(info) ((info) >> 32)
|
|
||||||
#define ELF64_R_TYPE(info) ((info) & 0xffffffffL)
|
|
||||||
|
|
||||||
/* Macro for constructing r_info from field values. */
|
|
||||||
#define ELF64_R_INFO(sym, type) (((sym) << 32) + ((type) & 0xffffffffL))
|
|
||||||
|
|
||||||
#define ELF64_R_TYPE_DATA(info) (((Elf64_Xword)(info)<<32)>>40)
|
|
||||||
#define ELF64_R_TYPE_ID(info) (((Elf64_Xword)(info)<<56)>>56)
|
|
||||||
#define ELF64_R_TYPE_INFO(data, type) \
|
|
||||||
(((Elf64_Xword)(data)<<8)+(Elf64_Xword)(type))
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Note entry header
|
|
||||||
*/
|
|
||||||
typedef Elf_Note Elf64_Nhdr;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Move entry
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
Elf64_Lword m_value; /* symbol value */
|
|
||||||
Elf64_Xword m_info; /* size + index */
|
|
||||||
Elf64_Xword m_poffset; /* symbol offset */
|
|
||||||
Elf64_Half m_repeat; /* repeat count */
|
|
||||||
Elf64_Half m_stride; /* stride info */
|
|
||||||
} Elf64_Move;
|
|
||||||
|
|
||||||
#define ELF64_M_SYM(info) ((info)>>8)
|
|
||||||
#define ELF64_M_SIZE(info) ((unsigned char)(info))
|
|
||||||
#define ELF64_M_INFO(sym, size) (((sym)<<8)+(unsigned char)(size))
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Hardware/Software capabilities entry
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
Elf64_Xword c_tag; /* how to interpret value */
|
|
||||||
union {
|
|
||||||
Elf64_Xword c_val;
|
|
||||||
Elf64_Addr c_ptr;
|
|
||||||
} c_un;
|
|
||||||
} Elf64_Cap;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Symbol table entries.
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
Elf64_Word st_name; /* String table index of name. */
|
|
||||||
unsigned char st_info; /* Type and binding information. */
|
|
||||||
unsigned char st_other; /* Reserved (not used). */
|
|
||||||
Elf64_Half st_shndx; /* Section index of symbol. */
|
|
||||||
Elf64_Addr st_value; /* Symbol value. */
|
|
||||||
Elf64_Xword st_size; /* Size of associated object. */
|
|
||||||
} Elf64_Sym;
|
|
||||||
|
|
||||||
/* Macros for accessing the fields of st_info. */
|
|
||||||
#define ELF64_ST_BIND(info) ((info) >> 4)
|
|
||||||
#define ELF64_ST_TYPE(info) ((info) & 0xf)
|
|
||||||
|
|
||||||
/* Macro for constructing st_info from field values. */
|
|
||||||
#define ELF64_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf))
|
|
||||||
|
|
||||||
/* Macro for accessing the fields of st_other. */
|
|
||||||
#define ELF64_ST_VISIBILITY(oth) ((oth) & 0x3)
|
|
||||||
|
|
||||||
/* Structures used by Sun & GNU-style symbol versioning. */
|
|
||||||
typedef struct {
|
|
||||||
Elf64_Half vd_version;
|
|
||||||
Elf64_Half vd_flags;
|
|
||||||
Elf64_Half vd_ndx;
|
|
||||||
Elf64_Half vd_cnt;
|
|
||||||
Elf64_Word vd_hash;
|
|
||||||
Elf64_Word vd_aux;
|
|
||||||
Elf64_Word vd_next;
|
|
||||||
} Elf64_Verdef;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
Elf64_Word vda_name;
|
|
||||||
Elf64_Word vda_next;
|
|
||||||
} Elf64_Verdaux;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
Elf64_Half vn_version;
|
|
||||||
Elf64_Half vn_cnt;
|
|
||||||
Elf64_Word vn_file;
|
|
||||||
Elf64_Word vn_aux;
|
|
||||||
Elf64_Word vn_next;
|
|
||||||
} Elf64_Verneed;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
Elf64_Word vna_hash;
|
|
||||||
Elf64_Half vna_flags;
|
|
||||||
Elf64_Half vna_other;
|
|
||||||
Elf64_Word vna_name;
|
|
||||||
Elf64_Word vna_next;
|
|
||||||
} Elf64_Vernaux;
|
|
||||||
|
|
||||||
typedef Elf64_Half Elf64_Versym;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
Elf64_Half si_boundto; /* direct bindings - symbol bound to */
|
|
||||||
Elf64_Half si_flags; /* per symbol flags */
|
|
||||||
} Elf64_Syminfo;
|
|
||||||
|
|
||||||
#endif /* !_SYS_ELF64_H_ */
|
|
File diff suppressed because it is too large
Load Diff
|
@ -16,7 +16,6 @@ APPLICATIONS = \
|
||||||
GenCrc32 \
|
GenCrc32 \
|
||||||
GenFfs \
|
GenFfs \
|
||||||
GenFv \
|
GenFv \
|
||||||
GenFw \
|
|
||||||
GenSec \
|
GenSec \
|
||||||
LzmaCompress \
|
LzmaCompress \
|
||||||
TianoCompress \
|
TianoCompress \
|
||||||
|
|
|
@ -19,10 +19,9 @@ $(OBJECTS) : $(SOURCE_PATH)\Include\Common\BuildVersion.h
|
||||||
.PHONY:cleanall
|
.PHONY:cleanall
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
del /f /q $(OBJECTS) *.pdb > nul
|
del /f /q *.obj *.pdb > nul
|
||||||
|
|
||||||
cleanall:
|
cleanall:
|
||||||
del /f /q $(OBJECTS) $(APPLICATION) *.pdb $(BIN_PATH)\$(APPNAME).pdb > nul
|
del /f /q *.obj $(APPLICATION) *.pdb $(BIN_PATH)\$(APPNAME).pdb > nul
|
||||||
|
|
||||||
!INCLUDE $(SOURCE_PATH)\Makefiles\ms.rule
|
!INCLUDE $(SOURCE_PATH)\Makefiles\ms.rule
|
||||||
|
|
||||||
|
|
|
@ -103,11 +103,32 @@ class ToolDefClassObject(object):
|
||||||
else:
|
else:
|
||||||
EdkLogger.error("tools_def.txt parser", FILE_NOT_FOUND, ExtraData=FileName)
|
EdkLogger.error("tools_def.txt parser", FILE_NOT_FOUND, ExtraData=FileName)
|
||||||
|
|
||||||
|
Branch = 0
|
||||||
for Index in range(len(FileContent)):
|
for Index in range(len(FileContent)):
|
||||||
Line = FileContent[Index].strip()
|
Line = FileContent[Index].strip()
|
||||||
if Line == "" or Line[0] == '#':
|
if Line == "" or Line[0] == '#':
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if Line.startswith("!ifdef"):
|
||||||
|
Condition = Line[6:].strip()
|
||||||
|
Reference = GlobalData.gMacroRefPattern.findall(Condition)
|
||||||
|
if Reference[0] in GlobalData.gCommandLineDefines:
|
||||||
|
Branch = 1
|
||||||
|
else:
|
||||||
|
Branch = -1
|
||||||
|
continue
|
||||||
|
|
||||||
|
if Line.startswith("!else"):
|
||||||
|
Branch *= -1
|
||||||
|
continue
|
||||||
|
|
||||||
|
if Line.startswith("!endif"):
|
||||||
|
Branch = 0
|
||||||
|
continue
|
||||||
|
|
||||||
|
if Branch == -1:
|
||||||
|
continue
|
||||||
|
|
||||||
if Line.startswith("!include"):
|
if Line.startswith("!include"):
|
||||||
IncFile = Line[8:].strip()
|
IncFile = Line[8:].strip()
|
||||||
Done, IncFile = self.ExpandMacros(IncFile)
|
Done, IncFile = self.ExpandMacros(IncFile)
|
||||||
|
|
|
@ -94,7 +94,7 @@ class DataSection (DataSectionClassObject):
|
||||||
StrippedFile = os.path.join(OutputPath, ModuleName + '.stripped')
|
StrippedFile = os.path.join(OutputPath, ModuleName + '.stripped')
|
||||||
GenFdsGlobalVariable.GenerateFirmwareImage(
|
GenFdsGlobalVariable.GenerateFirmwareImage(
|
||||||
StrippedFile,
|
StrippedFile,
|
||||||
[GenFdsGlobalVariable.MacroExtend(self.SectFileName, Dict)],
|
GenFdsGlobalVariable.MacroExtend(self.SectFileName, Dict),
|
||||||
Strip=True,
|
Strip=True,
|
||||||
IsMakefile = IsMakefile
|
IsMakefile = IsMakefile
|
||||||
)
|
)
|
||||||
|
|
|
@ -289,7 +289,7 @@ class EfiSection (EfiSectionClassObject):
|
||||||
StrippedFile = os.path.join(OutputPath, ModuleName + '.stripped')
|
StrippedFile = os.path.join(OutputPath, ModuleName + '.stripped')
|
||||||
GenFdsGlobalVariable.GenerateFirmwareImage(
|
GenFdsGlobalVariable.GenerateFirmwareImage(
|
||||||
StrippedFile,
|
StrippedFile,
|
||||||
[File],
|
File,
|
||||||
Strip=True,
|
Strip=True,
|
||||||
IsMakefile = IsMakefile
|
IsMakefile = IsMakefile
|
||||||
)
|
)
|
||||||
|
|
|
@ -792,7 +792,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
|
||||||
StrippedFile = os.path.join(self.OutputPath, ModuleName + '.stipped')
|
StrippedFile = os.path.join(self.OutputPath, ModuleName + '.stipped')
|
||||||
GenFdsGlobalVariable.GenerateFirmwareImage(
|
GenFdsGlobalVariable.GenerateFirmwareImage(
|
||||||
StrippedFile,
|
StrippedFile,
|
||||||
[File],
|
File,
|
||||||
Strip=True,
|
Strip=True,
|
||||||
IsMakefile=IsMakefile
|
IsMakefile=IsMakefile
|
||||||
)
|
)
|
||||||
|
@ -835,7 +835,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
|
||||||
StrippedFile = os.path.join(self.OutputPath, ModuleName + '.stipped')
|
StrippedFile = os.path.join(self.OutputPath, ModuleName + '.stipped')
|
||||||
GenFdsGlobalVariable.GenerateFirmwareImage(
|
GenFdsGlobalVariable.GenerateFirmwareImage(
|
||||||
StrippedFile,
|
StrippedFile,
|
||||||
[GenSecInputFile],
|
GenSecInputFile,
|
||||||
Strip=True,
|
Strip=True,
|
||||||
IsMakefile=IsMakefile
|
IsMakefile=IsMakefile
|
||||||
)
|
)
|
||||||
|
|
|
@ -607,36 +607,17 @@ class GenFdsGlobalVariable:
|
||||||
GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate FV")
|
GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate FV")
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def GenerateFirmwareImage(Output, Input, Type="efi", SubType=None, Zero=False,
|
def GenerateFirmwareImage(Output, Input, Format="Auto", Strip=False, IsMakefile=False):
|
||||||
Strip=False, Replace=False, TimeStamp=None, Join=False,
|
|
||||||
Align=None, Padding=None, Convert=False, IsMakefile=False):
|
|
||||||
if not GenFdsGlobalVariable.NeedsUpdate(Output, Input) and not IsMakefile:
|
if not GenFdsGlobalVariable.NeedsUpdate(Output, Input) and not IsMakefile:
|
||||||
return
|
return
|
||||||
GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))
|
GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))
|
||||||
|
|
||||||
Cmd = ["GenFw"]
|
Cmd = ["ImageTool GenImage"]
|
||||||
if Type.lower() == "te":
|
if Format != "Auto":
|
||||||
Cmd.append("-t")
|
Cmd += ("-c", Format)
|
||||||
if SubType:
|
|
||||||
Cmd += ("-e", SubType)
|
|
||||||
if TimeStamp:
|
|
||||||
Cmd += ("-s", TimeStamp)
|
|
||||||
if Align:
|
|
||||||
Cmd += ("-a", Align)
|
|
||||||
if Padding:
|
|
||||||
Cmd += ("-p", Padding)
|
|
||||||
if Zero:
|
|
||||||
Cmd.append("-z")
|
|
||||||
if Strip:
|
if Strip:
|
||||||
Cmd.append("-l")
|
Cmd.append("-s")
|
||||||
if Replace:
|
Cmd += ("-o", Output, Input)
|
||||||
Cmd.append("-r")
|
|
||||||
if Join:
|
|
||||||
Cmd.append("-j")
|
|
||||||
if Convert:
|
|
||||||
Cmd.append("-m")
|
|
||||||
Cmd += ("-o", Output)
|
|
||||||
Cmd += Input
|
|
||||||
if IsMakefile:
|
if IsMakefile:
|
||||||
if " ".join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdList:
|
if " ".join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdList:
|
||||||
GenFdsGlobalVariable.SecCmdList.append(" ".join(Cmd).strip())
|
GenFdsGlobalVariable.SecCmdList.append(" ".join(Cmd).strip())
|
||||||
|
|
|
@ -644,11 +644,11 @@ class ModuleReport(object):
|
||||||
if os.path.isfile(DefaultEFIfile):
|
if os.path.isfile(DefaultEFIfile):
|
||||||
Tempfile = os.path.join(OutputDir, self.ModuleName + "_hash.tmp")
|
Tempfile = os.path.join(OutputDir, self.ModuleName + "_hash.tmp")
|
||||||
# rebase the efi image since its base address may not zero
|
# rebase the efi image since its base address may not zero
|
||||||
cmd = ["GenFw", "--rebase", str(0), "-o", Tempfile, DefaultEFIfile]
|
cmd = ["ImageTool GenImage -b 0 -o", Tempfile, DefaultEFIfile]
|
||||||
try:
|
try:
|
||||||
PopenObject = subprocess.Popen(' '.join(cmd), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
PopenObject = subprocess.Popen(' '.join(cmd), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
||||||
except Exception as X:
|
except Exception as X:
|
||||||
EdkLogger.error("GenFw", COMMAND_FAILURE, ExtraData="%s: %s" % (str(X), cmd[0]))
|
EdkLogger.error("ImageTool", COMMAND_FAILURE, ExtraData="%s: %s" % (str(X), cmd[0]))
|
||||||
EndOfProcedure = threading.Event()
|
EndOfProcedure = threading.Event()
|
||||||
EndOfProcedure.clear()
|
EndOfProcedure.clear()
|
||||||
if PopenObject.stderr:
|
if PopenObject.stderr:
|
||||||
|
@ -661,7 +661,7 @@ class ModuleReport(object):
|
||||||
if PopenObject.stderr:
|
if PopenObject.stderr:
|
||||||
StdErrThread.join()
|
StdErrThread.join()
|
||||||
if PopenObject.returncode != 0:
|
if PopenObject.returncode != 0:
|
||||||
EdkLogger.error("GenFw", COMMAND_FAILURE, "Failed to generate firmware hash image for %s" % (DefaultEFIfile))
|
EdkLogger.error("ImageTool", COMMAND_FAILURE, "Failed to generate firmware hash image for %s" % (DefaultEFIfile))
|
||||||
if os.path.isfile(Tempfile):
|
if os.path.isfile(Tempfile):
|
||||||
self.Hash = hashlib.sha1()
|
self.Hash = hashlib.sha1()
|
||||||
buf = open(Tempfile, 'rb').read()
|
buf = open(Tempfile, 'rb').read()
|
||||||
|
|
|
@ -1522,18 +1522,18 @@ class Build():
|
||||||
BaseAddress = BaseAddress - ModuleInfo.Image.Size
|
BaseAddress = BaseAddress - ModuleInfo.Image.Size
|
||||||
BaseAddress = AlignDown(BaseAddress, ModuleInfo.Image.SectionAlignment)
|
BaseAddress = AlignDown(BaseAddress, ModuleInfo.Image.SectionAlignment)
|
||||||
#
|
#
|
||||||
# Update Image to new BaseAddress by GenFw tool
|
# Update Image to new BaseAddress by ImageTool tool
|
||||||
#
|
#
|
||||||
LaunchCommand(["GenFw", "--rebase", str(BaseAddress), "-r", ModuleOutputImage], ModuleInfo.OutputDir)
|
LaunchCommand(["ImageTool", "GenImage", "-b", str(BaseAddress), "-o", ModuleOutputImage, ModuleOutputImage], ModuleInfo.OutputDir)
|
||||||
LaunchCommand(["GenFw", "--rebase", str(BaseAddress), "-r", ModuleDebugImage], ModuleInfo.DebugDir)
|
LaunchCommand(["ImageTool", "GenImage", "-b", str(BaseAddress), "-o", ModuleOutputImage, ModuleOutputImage], ModuleInfo.DebugDir)
|
||||||
## for SMM module in SMRAM, the SMRAM will be allocated from base to top.
|
## for SMM module in SMRAM, the SMRAM will be allocated from base to top.
|
||||||
else:
|
else:
|
||||||
BaseAddress = AlignUp(BaseAddress, ModuleInfo.Image.SectionAlignment)
|
BaseAddress = AlignUp(BaseAddress, ModuleInfo.Image.SectionAlignment)
|
||||||
#
|
#
|
||||||
# Set new address to the section header only for SMM driver.
|
# Set new address to the section header only for SMM driver.
|
||||||
#
|
#
|
||||||
LaunchCommand(["GenFw", "--address", str(BaseAddress), "-r", ModuleOutputImage], ModuleInfo.OutputDir)
|
LaunchCommand(["ImageTool", "GenImage", "-f -b", str(BaseAddress), "-o", ModuleOutputImage, ModuleOutputImage], ModuleInfo.OutputDir)
|
||||||
LaunchCommand(["GenFw", "--address", str(BaseAddress), "-r", ModuleDebugImage], ModuleInfo.DebugDir)
|
LaunchCommand(["ImageTool", "GenImage", "-f -b", str(BaseAddress), "-o", ModuleOutputImage, ModuleOutputImage], ModuleInfo.DebugDir)
|
||||||
#
|
#
|
||||||
# Collect function address from Map file
|
# Collect function address from Map file
|
||||||
#
|
#
|
||||||
|
|
|
@ -289,7 +289,7 @@ Build\\Nt32\\Debug_MyTools. ActivePlatform is C:\\work\\EdkII\\Nt32Pkg\\Nt32Pkg
|
||||||
\par }\pard\plain \ltrpar\s2\ql \li-1440\ri0\sb400\sa60\sl-340\slmult0\keep\keepn\nowidctlpar\tx1440\wrapdefault\faauto\outlinelevel1\rin0\lin-1440\itap0 \rtlch\fcs1 \af0\afs24\alang1025 \ltrch\fcs0
|
\par }\pard\plain \ltrpar\s2\ql \li-1440\ri0\sb400\sa60\sl-340\slmult0\keep\keepn\nowidctlpar\tx1440\wrapdefault\faauto\outlinelevel1\rin0\lin-1440\itap0 \rtlch\fcs1 \af0\afs24\alang1025 \ltrch\fcs0
|
||||||
\fs24\lang1033\langfe1033\loch\af41\hich\af41\dbch\af13\cgrid\langnp1033\langfenp1033 {\rtlch\fcs1 \ab\af41\afs28 \ltrch\fcs0 \b\fs28\cf17\insrsid5513321 \hich\af41\dbch\af13\loch\f41 See also
|
\fs24\lang1033\langfe1033\loch\af41\hich\af41\dbch\af13\cgrid\langnp1033\langfenp1033 {\rtlch\fcs1 \ab\af41\afs28 \ltrch\fcs0 \b\fs28\cf17\insrsid5513321 \hich\af41\dbch\af13\loch\f41 See also
|
||||||
\par }\pard\plain \ltrpar\ql \li0\ri0\sb200\nowidctlpar\wrapdefault\faauto\rin0\lin0\itap0 \rtlch\fcs1 \af0\afs24\alang1025 \ltrch\fcs0 \fs24\lang1033\langfe1033\loch\af41\hich\af41\dbch\af13\cgrid\langnp1033\langfenp1033 {\rtlch\fcs1 \af41\afs18 \ltrch\fcs0
|
\par }\pard\plain \ltrpar\ql \li0\ri0\sb200\nowidctlpar\wrapdefault\faauto\rin0\lin0\itap0 \rtlch\fcs1 \af0\afs24\alang1025 \ltrch\fcs0 \fs24\lang1033\langfe1033\loch\af41\hich\af41\dbch\af13\cgrid\langnp1033\langfenp1033 {\rtlch\fcs1 \af41\afs18 \ltrch\fcs0
|
||||||
\fs18\cf1\insrsid5513321 \hich\af41\dbch\af13\loch\f41 GenFv, GenFfs, GenSection, GenFw.
|
\fs18\cf1\insrsid5513321 \hich\af41\dbch\af13\loch\f41 GenFv, GenFfs, GenSection.
|
||||||
\par }\pard\plain \ltrpar\s2\ql \li-1440\ri0\sb400\sa60\sl-340\slmult0\keep\keepn\nowidctlpar\tx1440\wrapdefault\faauto\outlinelevel1\rin0\lin-1440\itap0 \rtlch\fcs1 \af0\afs24\alang1025 \ltrch\fcs0
|
\par }\pard\plain \ltrpar\s2\ql \li-1440\ri0\sb400\sa60\sl-340\slmult0\keep\keepn\nowidctlpar\tx1440\wrapdefault\faauto\outlinelevel1\rin0\lin-1440\itap0 \rtlch\fcs1 \af0\afs24\alang1025 \ltrch\fcs0
|
||||||
\fs24\lang1033\langfe1033\loch\af41\hich\af41\dbch\af13\cgrid\langnp1033\langfenp1033 {\rtlch\fcs1 \ab\af41\afs28 \ltrch\fcs0 \b\fs28\cf17\insrsid5513321 \hich\af41\dbch\af13\loch\f41 License
|
\fs24\lang1033\langfe1033\loch\af41\hich\af41\dbch\af13\cgrid\langnp1033\langfenp1033 {\rtlch\fcs1 \ab\af41\afs28 \ltrch\fcs0 \b\fs28\cf17\insrsid5513321 \hich\af41\dbch\af13\loch\f41 License
|
||||||
\par }\pard\plain \ltrpar\ql \li0\ri0\sb200\nowidctlpar\wrapdefault\faauto\rin0\lin0\itap0 \rtlch\fcs1 \af0\afs24\alang1025 \ltrch\fcs0 \fs24\lang1033\langfe1033\loch\af41\hich\af41\dbch\af13\cgrid\langnp1033\langfenp1033 {\rtlch\fcs1 \af41\afs18 \ltrch\fcs0
|
\par }\pard\plain \ltrpar\ql \li0\ri0\sb200\nowidctlpar\wrapdefault\faauto\rin0\lin0\itap0 \rtlch\fcs1 \af0\afs24\alang1025 \ltrch\fcs0 \fs24\lang1033\langfe1033\loch\af41\hich\af41\dbch\af13\cgrid\langnp1033\langfenp1033 {\rtlch\fcs1 \af41\afs18 \ltrch\fcs0
|
||||||
|
|
|
@ -1,179 +0,0 @@
|
||||||
{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1033\deflangfe1033\deftab360{\fonttbl{\f0\fswiss\fprq2\fcharset0 Verdana;}{\f1\froman\fprq2\fcharset0 Times New Roman;}{\f2\fmodern\fprq1\fcharset0 Courier New;}{\f3\fmodern\fprq1\fcharset0 Consolas;}}
|
|
||||||
{\colortbl ;\red8\green96\blue168;\red0\green0\blue0;\red0\green127\blue127;\red128\green0\blue0;\red0\green0\blue255;}
|
|
||||||
{\stylesheet{ Normal;}{\s1 heading 1;}{\s2 heading 2;}}
|
|
||||||
{\*\generator Riched20 10.0.22621}{\*\mmathPr\mnaryLim0\mdispDef1\mwrapIndent1440 }\viewkind4\uc1
|
|
||||||
\pard\keep\keepn\nowidctlpar\s2\li-1440\sb400\sa60\sl-340\slmult0\cf1\b\f0\fs28 Name\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\sb200\cf2\b0\fs18 GenFw.exe \endash build a UEFI image or other image.\par
|
|
||||||
|
|
||||||
\pard\keep\keepn\nowidctlpar\s2\li-1440\sb400\sa60\sl-340\slmult0\tx1440\cf1\b\fs28 Synopsis\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\sb200\cf2\fs18 GenFw.exe -r | -o <OutputFile> [-e <EfiType>] [-c | -t | -l | -u | -b | -z | -s <TimeDate> | -m | -j | --hiipackage | --hiibinpackage | --nonxcompat] [-a] [-p] <InputFile>\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar GenFw.exe \endash h\par
|
|
||||||
GenFw.exe --version\cf0\b0\fs24\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\sb200\cf2\f1\fs18\par
|
|
||||||
|
|
||||||
\pard\keep\keepn\nowidctlpar\s2\li-1440\sb400\sa60\sl-340\slmult0\cf1\b\f0\fs28 Description\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\sb200\cf2\b0\fs18 Genfw is mainly used to process PE32 image to get the expected image data or image file. PE32 is a general-purpose image format that contains, among other information, data identifying the target environment for execution of the image. This utility can modify the standard PE32 image to create UEFI image with EFI subsystem type, PI Terse Executable image with the compact TE image header, zero its debug data or reset its time stamp. It can also extract PE32 image data to create bin file, extract PE32 image data section to create Acpi table image, or dump PI TE image header information. It can also parse the text MicroCode definition file to create the MicroCode binary image, merge (concatenate) several MicroCode binary images into a single file by pad value and alignment requirement. This tool also supports the override the input file with the output contents.\par
|
|
||||||
|
|
||||||
\pard\keep\keepn\nowidctlpar\s2\li-1440\sb400\sa60\sl-340\slmult0\cf1\b\fs28 Options\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\sb200\cf2\b0\fs18 If no options are specified, tool prints usage.\b\par
|
|
||||||
Filename1 [FilenameN]\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\li360\sb200\b0 Input PE/PE32+ image, or TE image, or MicroCode Txt file, or MicroCode bin file, or hii binary packages.\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\sb200\b -o FileName, --outputfile FileName\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\li360\sb200\b0 The EFI image, TeImage, AcpiImage, MicroBin, hii package lists file or other modified PE image will be created.\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\sb200\b -e EFI_FILETYPE, --efiImage EFI_FILETYPE\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\li360\sb200\b0 Create Efi Image. EFI_FILETYPE is one of BASE, SEC, PEI_CORE, PEIM, DXE_CORE, SMM_CORE, DXE_DRIVER, UEFI_APPLICATION, DXE_SAL_DRIVER, UEFI_DRIVER, DXE_RUNTIME_DRIVER, DXE_SMM_DRIVER, SECURITY_CORE, COMBINED_PEIM_DRIVER, PIC_PEIM, RELOCATABLE_PEIM, BS_DRIVER, RT_DRIVER, APPLICATION, SAL_RT_DRIVER to support all module types.\f1\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\sb200\b\f0 -c, --acpi\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\fi360\sb200\b0 Create Acpi table.\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\sb200\b -t, --terse\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\fi360\sb200\b0 Create Te Image.\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\sb200\b -u, --dump\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\fi360\sb200\b0 Dump TeImage Header.\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\sb200\b -z, --zero\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\fi360\sb200\b0 Zero the Debug Data Fields in the PE input image file. It also zeros the time stamp fields.\f1\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\sb200\b\f0 -b, --exe2bin\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\fi360\sb200\b0 Convert the input EXE to the output BIN file.\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\sb200\b -l, --stripped\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\fi360\sb200\b0 Strip off the relocation information data from PE or TE image.\f1\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\sb200\b\f0 -s timedate, --stamp timedate\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\li360\sb200\b0 timedate format is \ldblquote yyyy-mm-dd 00:00:00\rdblquote . If timedata is set to \ldblquote NOW\rdblquote , current system time is used. The support date scope is 1970-1-1 8:0:0 ~ 2038-1-19 3:14:07.\f1\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\sb200\b\f0 -m, --mcifile\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\fi360\sb200\b0 Convert input microcode txt definition file to microcode bin file.\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\sb200\b -j, --join\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\fi360\sb200\b0 Merge multiple microcode bin files to one file.\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\sb200\b -a NUM, --align NUM\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\li360\sb200\b0 NUM is one HEX or DEC format alignment value, which is used to combine multiple microcode bin files.\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\sb200\b -p NUM, --pad NUM\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\li360\sb200\b0 NUM is one HEX or DEC format padding value, which is used to combine multiple microcode bin files.\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\sb200\b --keepexceptiontable\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\fi360\sb200\b0 Don\rquote t clear exception table.\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\sb200\b --keepzeropending\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\fi360\sb200\b0 Don\rquote t strip zero pending of .reloc.\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\sb200\b -r, --replace\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\fi360\sb200\b0 Overwrite the input file with the output content.\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\sb200\b -g HiiPackageListGuid, --hiiguid HiiPackageListGuid\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\fi360\sb200\b0 Guid is used to specify hii package list guid.\f1\par
|
|
||||||
\f0 Its format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\sb200\b --hiipackage \f1\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\fi360\sb200\b0\f0 Combine all input binary hii packages into a single package list as the text resource data file (RC file format).\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\sb200\b --hiibinpackage \f1\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\fi360\sb200\b0\f0 Combine all input binary hii packages into a single package list as the binary resource section.\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\sb200\b --nonxcompat \f1\par
|
|
||||||
\b0\f0 Do not set the IMAGE_DLLCHARACTERISTICS_NX_COMPAT bit of the optional header in the PE header even if the requirements are met.\par
|
|
||||||
\b -v, --verbose\b0\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\fi360\sb200 Turn on verbose output with informational messages.\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\sb200\b -d, --debug level\par
|
|
||||||
\b0\f1\tab\f0 Enable debug message with specified level.\par
|
|
||||||
\b --version\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\fi360\sb200\b0 Show program's version number and exit\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\sb200\b -h, --help\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\fi360\sb200\b0 Show this help message and exit\par
|
|
||||||
|
|
||||||
\pard\keep\keepn\nowidctlpar\s2\fi-1440\sb400\sa60\sl-340\slmult0\tx1440\cf3\b\fs28 Status codes returned\par
|
|
||||||
\trowd\trgaph10\trleft-118\trbrdrl\brdrs\brdrw10 \trbrdrt\brdrs\brdrw10 \trbrdrr\brdrs\brdrw10 \trbrdrb\brdrs\brdrw10 \trpaddl10\trpaddr10\trpaddfl3\trpaddfr3
|
|
||||||
\clbrdrl\brdrw10\brdrs\clbrdrt\brdrw10\brdrs\clbrdrr\brdrw10\brdrs\clbrdrb\brdrw10\brdrs \cellx2852\clbrdrl\brdrw10\brdrs\clbrdrt\brdrw10\brdrs\clbrdrr\brdrw10\brdrs\clbrdrb\brdrw10\brdrs \cellx8702
|
|
||||||
\pard\intbl\widctlpar\ri20\sb60\sa60\sl-200\slmult0\cf4\kerning2\f2\fs18 STATUS_SUCCESS\cf2\kerning0\b0\f0\fs16 \cf4\kerning2\b\f2\fs18\tab 0\cf2\cell\kerning0\b0\f0\fs16 The action was completed as requested.\kerning2\cell\row\trowd\trgaph10\trleft-118\trbrdrl\brdrs\brdrw10 \trbrdrt\brdrs\brdrw10 \trbrdrr\brdrs\brdrw10 \trbrdrb\brdrs\brdrw10 \trpaddl10\trpaddr10\trpaddfl3\trpaddfr3
|
|
||||||
\clbrdrl\brdrw10\brdrs\clbrdrt\brdrw10\brdrs\clbrdrr\brdrw10\brdrs\clbrdrb\brdrw10\brdrs \cellx2852\clbrdrl\brdrw10\brdrs\clbrdrt\brdrw10\brdrs\clbrdrr\brdrw10\brdrs\clbrdrb\brdrw10\brdrs \cellx8702
|
|
||||||
\pard\intbl\widctlpar\ri20\sb60\sa60\sl-200\slmult0\cf4\b\f2\fs18 STATUS_ERROR\cf2\kerning0\b0\f0\fs16 \cf4\kerning2\b\f2\fs18\tab\tab 2\cf0\kerning0\b0\f3\fs19\cell\cf2\kerning2\f0\fs16 The action failed.\cell\row
|
|
||||||
\pard\keep\keepn\nowidctlpar\s2\li-1440\sb400\sa60\sl-340\slmult0\cf1\kerning0\b\fs28 Example\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\sb200\cf2\b0\fs18 1. Generate Efi image with the input PE image, module type and the output file name.\par
|
|
||||||
\b GenFw \endash e PEI_CORE PeiMain.dll \endash o PeiMain.efi\par
|
|
||||||
\b0 2. Generate Te image with the input PE image and the output file name.\par
|
|
||||||
\b GenFw \endash t PeiMain.dll \endash o PeiMain.te\par
|
|
||||||
\b0 3. Generate acpi table image with the input PE image and the output file name.\par
|
|
||||||
\b GenFw \endash c Facs.dll \endash o Facs.acpi\par
|
|
||||||
\b0 4. Dump TeImage Header with the input Te Image and the output file name.\par
|
|
||||||
\b GenFw \endash u PeiMain.te \endash o PeiMain.teheader\par
|
|
||||||
\b0 5. Modify PeImage by zero its debug data.\par
|
|
||||||
\b GenFw \endash z PeiMain.dll \endash o Peimain.zero\par
|
|
||||||
\b0 6. Modify PeImage by set new timestamp and override the input image without the output file name.\par
|
|
||||||
\b GenFw \endash s \ldblquote 2007-8-16 16:06:32\rdblquote PeiMain.dll \endash r\par
|
|
||||||
\b0 7. Extract bin image from PeImage.\par
|
|
||||||
\b GenFw \endash b PeiMain.dll \endash o PeiMain.bin\par
|
|
||||||
\b0 8. Generate the microcode binary file from the micro code txt file.\par
|
|
||||||
\b GenFw \endash m Mci.txt \endash o Mci.bin\par
|
|
||||||
\b0 9. Merge the multiple mci binary files to one file.\par
|
|
||||||
\b GenFw \endash j Mci.bin1 Mci.bin2 Mci.bin3 \endash a 32 \endash p 0xFF \endash o Mci.bin\par
|
|
||||||
\b0 10. Generate the text resource file (RC format) based on all input binary HII packages and their package list guid.\par
|
|
||||||
\b GenFw \endash o SampleHii.rc \endash g D49D2EB0-44D5-4621-9FD6-1A92C9109B99 \endash hiipackage SampleStr.hpk SampleVfr.hpk\f1\par
|
|
||||||
\b0\f0 11. Generate the binary resource section based on all input binary HII packages and their package list guid.\f1\par
|
|
||||||
\b\f0 GenFw \endash o SampleHii.bin \endash g D49D2EB0-44D5-4621-9FD6-1A92C9109B99 \endash hiibinpackage SampleStr.hpk SampleVfr.hpk\f1\par
|
|
||||||
|
|
||||||
\pard\keep\keepn\nowidctlpar\s2\li-1440\sb400\sa60\sl-340\slmult0\cf1\f0\fs28 Bugs\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\sb200\cf2\b0\fs18 No known bugs.\par
|
|
||||||
Report bugs to \cf5\revised edk2-devel@lists.01.org\cf2\revised0\deleted edk2-buildtools-devel@lists.sourceforge.net\deleted0\f1\par
|
|
||||||
|
|
||||||
\pard\keep\keepn\nowidctlpar\s2\li-1440\sb400\sa60\sl-340\slmult0\cf1\b\f0\fs28 Files\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\sb200\cf2\b0\fs18 None\par
|
|
||||||
|
|
||||||
\pard\keep\keepn\nowidctlpar\s2\li-1440\sb400\sa60\sl-340\slmult0\cf1\b\fs28 See also\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\sb200\cf2\b0\fs18 None\par
|
|
||||||
|
|
||||||
\pard\keep\keepn\nowidctlpar\s2\li-1440\sb400\sa60\sl-340\slmult0\cf1\b\fs28 License\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\cf2\b0\fs18 Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.\par
|
|
||||||
This program and the accompanying materials are licensed and made available \par
|
|
||||||
under the terms and conditions of the BSD License which accompanies this \par
|
|
||||||
distribution. The full text of the license may be found at\par
|
|
||||||
{{\field{\*\fldinst{HYPERLINK http://opensource.org/licenses/bsd-license.php }}{\fldrslt{http://opensource.org/licenses/bsd-license.php\ul0\cf0}}}}\f0\fs18\par
|
|
||||||
\par
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\par
|
|
||||||
|
|
||||||
\pard\nowidctlpar\sb200 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\par
|
|
||||||
\cf0\f1\par
|
|
||||||
}
|
|
||||||
|