总结的工具链
gcc命令参数参考:
/usr/bin/aarch64-linux-gnu-gcc
-g
-Os
-fshort-wchar
-fno-builtin
-fno-strict-aliasing
-Wall
-Werror
-Wno-array-bounds
-include
AutoGen.h
-fno-common
-ffunction-sections
-fdata-sections
-DSTRING_ARRAY_NAME=ShellStrings
-mlittle-endian
-fno-short-enums
-fverbose-asm
-funsigned-char
-Wno-address
-fno-asynchronous-unwind-tables
-fno-unwind-tables
-fno-pic
-fno-pie
-ffixed-x18
-mcmodel=small
-flto
-Wno-unused-but-set-variable
-Wno-unused-const-variable
-c
-o /Shell.obj
/edk2/ShellPkg/Application/Shell/Shell.c
链接命令参考:
aarch64-linux-gnu-gcc -o Shell.dll \
-nostdlib \
-Wl,--gc-sections \
-u _ModuleEntryPoint \
-Wl,-e,_ModuleEntryPoint,-Map,/Shell.map
-z common-page-size=0x1000 \
-Os \
-flto \
-Wno-lto-type-mismatch \
-g \
-fshort-wchar \
-fno-builtin \
-Wall \
-Wno-array-bounds \
-include AutoGen.h \
-fno-common \
-ffunction-sections \
-fdata-sections \
-mlittle-endian \
-fno-short-enums \
-fverbose-asm \
-funsigned-char \
-Wno-address \
-fno-asynchronous-unwind-tables \
-fno-unwind-tables \
-fno-pic \
-fno-pie \
-ffixed-x18 \
-mcmodel=small \
-Wno-unused-but-set-variable \
-Wno-unused-const-variable \
-Wl,--script=/edk2/BaseTools/Scripts/GccBase.lds \
-Wl,--defsym=PECOFF_HEADER_SIZE=0x228 \
-Wno-error \
Shell.obj
GenFw命令参考:
GenFw -e UEFI_APPLICATION -o /Shell.efi /Shell.dll详尽的工具链
GCC过程:
"$(DLINK)" -o Shell.dll $(DLINK_FLAGS) -Wl,--start-group,@$(STATIC_LIBRARY_FILES_LIST),--end-group $(CC_FLAGS) $(DLINK2_FLAGS)
"$(OBJCOPY)" $(OBJCOPY_FLAGS) Shell.dll翻译出来就是:
aarch64-linux-gnu-gcc -o Shell.dll -Wl,--emit-relocs -nostdlib -Wl,--gc-sections -u _ModuleEntryPoint -Wl,-e,_ModuleEntryPoint,-Map,/edk2/Build/Shell/RELEASE_GCC5/AARCH64/ShellPkg/Application/Shell/Shell/DEBUG/Shell.map -z common-page-size=0x20 -z common-page-size=0x1000 -flto -Os -L/edk2/ArmPkg/Library/GccLto -llto-aarch64 -Wl,-plugin-opt=-pass-through=-llto-aarch64 -Wno-lto-type-mismatch -Wl,--start-group,@/edk2/Build/Shell/RELEASE_GCC5/AARCH64/ShellPkg/Application/Shell/Shell/OUTPUT/static_library_files.lst,--end-group -g -Os -fshort-wchar -fno-builtin -fno-strict-aliasing -Wall -Werror -Wno-array-bounds -include AutoGen.h -fno-common -ffunction-sections -fdata-sections -DSTRING_ARRAY_NAME=ShellStrings -g -Os -fshort-wchar -fno-builtin -fno-strict-aliasing -Wall -Werror -Wno-array-bounds -include AutoGen.h -fno-common -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 -mcmodel=small -flto -Wno-unused-but-set-variable -Wno-unused-const-variable -D DISABLE_NEW_DEPRECATED_INTERFACES -Wl,--script=/edk2/BaseTools/Scripts/GccBase.lds -Wl,--defsym=PECOFF_HEADER_SIZE=0x228 -Wno-error
"echo" objcopy not needed for /edk2/Build/Shell/RELEASE_GCC5/AARCH64/ShellPkg/Application/Shell/Shell/DEBUG/Shell.dll
objcopy not needed for /edk2/Build/Shell/RELEASE_GCC5/AARCH64/ShellPkg/Application/Shell/Shell/DEBUG/Shell.dll
这里需要补充做一个逐参数的解析,以确定一下哪些是真正必要的东西:
efi过程:
$(CP) Shell.dll $(DEBUG_DIR)/$(MODULE_NAME).debug
$(OBJCOPY) $(OBJCOPY_STRIPFLAG) Shell.dll
$(OBJCOPY) $(OBJCOPY_ADDDEBUGFLAG) Shell.dll
-$(CP) $(DEBUG_DIR)/$(MODULE_NAME).debug $(BIN_DIR)/$(MODULE_NAME_GUID).debug
"$(GENFW)" -e $(MODULE_TYPE) -o Shell.efi Shell.dll $(GENFW_FLAGS)
$(CP) Shell.efi $(DEBUG_DIR)
$(CP) Shell.efi $(BIN_DIR)/$(MODULE_NAME_GUID).efi
-$(CP) $(DEBUG_DIR)/*.map $(OUTPUT_DIR)翻译出来就是:
cp -f /edk2/Build/Shell/RELEASE_GCC5/AARCH64/ShellPkg/Application/Shell/Shell/DEBUG/Shell.dll /edk2/Build/Shell/RELEASE_GCC5/AARCH64/ShellPkg/Application/Shell/Shell/DEBUG/Shell.debug
echo --strip-unneeded -R .eh_frame /edk2/Build/Shell/RELEASE_GCC5/AARCH64/ShellPkg/Application/Shell/Shell/DEBUG/Shell.dll
echo /edk2/Build/Shell/RELEASE_GCC5/AARCH64/ShellPkg/Application/Shell/Shell/DEBUG/Shell.dll
cp -f /edk2/Build/Shell/RELEASE_GCC5/AARCH64/ShellPkg/Application/Shell/Shell/DEBUG/Shell.debug /edk2/Build/Shell/RELEASE_GCC5/AARCH64/Shell_7C04A583-9E3E-4f1c-AD65-E05268D0B4D1.debug
"GenFw" -e UEFI_APPLICATION -o /edk2/Build/Shell/RELEASE_GCC5/AARCH64/ShellPkg/Application/Shell/Shell/OUTPUT/Shell.efi /edk2/Build/Shell/RELEASE_GCC5/AARCH64/ShellPkg/Application/Shell/Shell/DEBUG/Shell.dll
cp -f /edk2/Build/Shell/RELEASE_GCC5/AARCH64/ShellPkg/Application/Shell/Shell/OUTPUT/Shell.efi /edk2/Build/Shell/RELEASE_GCC5/AARCH64/ShellPkg/Application/Shell/Shell/DEBUG
cp -f /edk2/Build/Shell/RELEASE_GCC5/AARCH64/ShellPkg/Application/Shell/Shell/OUTPUT/Shell.efi /edk2/Build/Shell/RELEASE_GCC5/AARCH64/Shell_7C04A583-9E3E-4f1c-AD65-E05268D0B4D1.efi
cp -f /edk2/Build/Shell/RELEASE_GCC5/AARCH64/ShellPkg/Application/Shell/Shell/DEBUG/*.map /edk2/Build/Shell/RELEASE_GCC5/AARCH64/ShellPkg/Application/Shell/Shell/OUTPUT其参数整理为:
GenFw -e UEFI_APPLICATION -o /Shell.efi /Shell.dll
对于GenFw来说,似乎没有什么多余的东西需要做。