1From 96fa2a7f2f54f1e6330275b5eba07e1efdbd865b Mon Sep 17 00:00:00 2001 2From: Alexander Kanavin <alex.kanavin@gmail.com> 3Date: Mon, 14 Jun 2021 19:56:28 +0200 4Subject: [PATCH 3/4] debug prefix map 5 6We want to pass ${DEBUG_PREFIX_MAP} to gcc commands and also pass in 7 --debug-prefix-map to nasm (we carry a patch to nasm for this). The 8tools definitions file is built by ovmf-native so we need to pass this in 9at target build time when we know the right values so we use the environment. 10 11By using determininistc file paths during the ovmf build, it removes the 12opportunitity for gcc/ld to change the output binaries due to path lengths 13overflowing section sizes and causing small changes in the binary output. 14Previously we relied on the stripped output being the same which isn't always 15the case if the size of the debug symbols varies. 16 17Upstream-Status: Submitted [https://github.com/tianocore/edk2/pull/2202] 18Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> 19Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com> 20--- 21 BaseTools/Conf/tools_def.template | 18 +++++++++--------- 22 1 file changed, 9 insertions(+), 9 deletions(-) 23 24diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template 25index 14f3b643c4..4987488e88 100755 26--- a/BaseTools/Conf/tools_def.template 27+++ b/BaseTools/Conf/tools_def.template 28@@ -896,7 +896,7 @@ NOOPT_*_*_OBJCOPY_ADDDEBUGFLAG = --add-gnu-debuglink="$(DEBUG_DIR)/$(MODULE_ 29 *_*_*_DTC_PATH = DEF(DTC_BIN) 30 31 # All supported GCC archs except LOONGARCH64 support -mstack-protector-guard=global, so set that on everything except LOONGARCH64 32-DEFINE GCC_ALL_CC_FLAGS = -g -Os -fshort-wchar -fno-builtin -fno-strict-aliasing -Wall -Werror -Wno-array-bounds -include AutoGen.h -fno-common -fstack-protector 33+DEFINE GCC_ALL_CC_FLAGS = -g -Os -fshort-wchar -fno-builtin -fno-strict-aliasing -Wall -Werror -Wno-array-bounds -include AutoGen.h -fno-common -fstack-protector ENV(GCC_PREFIX_MAP) 34 DEFINE GCC_IA32_X64_CC_FLAGS = -mstack-protector-guard=global 35 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 -mstack-protector-guard=global 36 DEFINE GCC_LOONGARCH64_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS) -mabi=lp64d -fno-asynchronous-unwind-tables -Wno-address -fno-short-enums -fsigned-char -ffunction-sections -fdata-sections 37@@ -918,8 +918,8 @@ DEFINE GCC_ARM_ASLDLINK_FLAGS = DEF(GCC_ARM_DLINK_FLAGS) -Wl,--entry,Refere 38 DEFINE GCC_AARCH64_ASLDLINK_FLAGS = DEF(GCC_AARCH64_DLINK_FLAGS) -Wl,--entry,ReferenceAcpiTable -u $(IMAGE_ENTRY_POINT) DEF(GCC_ARM_AARCH64_ASLDLINK_FLAGS) 39 DEFINE GCC_LOONGARCH64_ASLDLINK_FLAGS = DEF(GCC_LOONGARCH64_DLINK_FLAGS) -Wl,--entry,ReferenceAcpiTable -u $(IMAGE_ENTRY_POINT) 40 DEFINE GCC_IA32_X64_DLINK_FLAGS = DEF(GCC_IA32_X64_DLINK_COMMON) --entry _$(IMAGE_ENTRY_POINT) --file-alignment 0x20 --section-alignment 0x20 -Map $(DEST_DIR_DEBUG)/$(BASE_NAME).map 41-DEFINE GCC_ASM_FLAGS = -c -x assembler -imacros AutoGen.h 42-DEFINE GCC_PP_FLAGS = -E -x assembler-with-cpp -include AutoGen.h 43+DEFINE GCC_ASM_FLAGS = -c -x assembler -imacros AutoGen.h ENV(GCC_PREFIX_MAP) 44+DEFINE GCC_PP_FLAGS = -E -x assembler-with-cpp -include AutoGen.h ENV(GCC_PREFIX_MAP) 45 DEFINE GCC_VFRPP_FLAGS = -x c -E -P -DVFRCOMPILE --include $(MODULE_NAME)StrDefs.h 46 DEFINE GCC_ASLPP_FLAGS = -x c -E -include AutoGen.h 47 DEFINE GCC_ASLCC_FLAGS = -x c 48@@ -1072,7 +1072,7 @@ DEFINE GCC5_LOONGARCH64_PP_FLAGS = -mabi=lp64d -march=loongarch64 DEF( 49 *_GCC48_IA32_DLINK2_FLAGS = DEF(GCC48_IA32_DLINK2_FLAGS) 50 *_GCC48_IA32_RC_FLAGS = DEF(GCC_IA32_RC_FLAGS) 51 *_GCC48_IA32_OBJCOPY_FLAGS = 52-*_GCC48_IA32_NASM_FLAGS = -f elf32 53+*_GCC48_IA32_NASM_FLAGS = -f elf32 ENV(NASM_PREFIX_MAP) 54 55 DEBUG_GCC48_IA32_CC_FLAGS = DEF(GCC48_IA32_CC_FLAGS) 56 RELEASE_GCC48_IA32_CC_FLAGS = DEF(GCC48_IA32_CC_FLAGS) -Wno-unused-but-set-variable 57@@ -1100,7 +1100,7 @@ RELEASE_GCC48_IA32_CC_FLAGS = DEF(GCC48_IA32_CC_FLAGS) -Wno-unused-but-set 58 *_GCC48_X64_DLINK2_FLAGS = DEF(GCC48_X64_DLINK2_FLAGS) 59 *_GCC48_X64_RC_FLAGS = DEF(GCC_X64_RC_FLAGS) 60 *_GCC48_X64_OBJCOPY_FLAGS = 61-*_GCC48_X64_NASM_FLAGS = -f elf64 62+*_GCC48_X64_NASM_FLAGS = -f elf64 ENV(NASM_PREFIX_MAP) 63 64 DEBUG_GCC48_X64_CC_FLAGS = DEF(GCC48_X64_CC_FLAGS) 65 RELEASE_GCC48_X64_CC_FLAGS = DEF(GCC48_X64_CC_FLAGS) -Wno-unused-but-set-variable 66@@ -1209,7 +1209,7 @@ RELEASE_GCC48_AARCH64_CC_FLAGS = DEF(GCC48_AARCH64_CC_FLAGS) -Wno-unused-but-s 67 *_GCC49_IA32_DLINK2_FLAGS = DEF(GCC49_IA32_DLINK2_FLAGS) 68 *_GCC49_IA32_RC_FLAGS = DEF(GCC_IA32_RC_FLAGS) 69 *_GCC49_IA32_OBJCOPY_FLAGS = 70-*_GCC49_IA32_NASM_FLAGS = -f elf32 71+*_GCC49_IA32_NASM_FLAGS = -f elf32 ENV(NASM_PREFIX_MAP) 72 73 DEBUG_GCC49_IA32_CC_FLAGS = DEF(GCC49_IA32_CC_FLAGS) 74 RELEASE_GCC49_IA32_CC_FLAGS = DEF(GCC49_IA32_CC_FLAGS) -Wno-unused-but-set-variable -Wno-unused-const-variable 75@@ -1237,7 +1237,7 @@ RELEASE_GCC49_IA32_CC_FLAGS = DEF(GCC49_IA32_CC_FLAGS) -Wno-unused-but-set 76 *_GCC49_X64_DLINK2_FLAGS = DEF(GCC49_X64_DLINK2_FLAGS) 77 *_GCC49_X64_RC_FLAGS = DEF(GCC_X64_RC_FLAGS) 78 *_GCC49_X64_OBJCOPY_FLAGS = 79-*_GCC49_X64_NASM_FLAGS = -f elf64 80+*_GCC49_X64_NASM_FLAGS = -f elf64 ENV(NASM_PREFIX_MAP) 81 82 DEBUG_GCC49_X64_CC_FLAGS = DEF(GCC49_X64_CC_FLAGS) 83 RELEASE_GCC49_X64_CC_FLAGS = DEF(GCC49_X64_CC_FLAGS) -Wno-unused-but-set-variable -Wno-unused-const-variable 84@@ -1496,7 +1496,7 @@ RELEASE_GCCNOLTO_AARCH64_DLINK_XIPFLAGS = -z common-page-size=0x20 85 *_GCC5_IA32_DLINK2_FLAGS = DEF(GCC5_IA32_DLINK2_FLAGS) -no-pie 86 *_GCC5_IA32_RC_FLAGS = DEF(GCC_IA32_RC_FLAGS) 87 *_GCC5_IA32_OBJCOPY_FLAGS = 88-*_GCC5_IA32_NASM_FLAGS = -f elf32 89+*_GCC5_IA32_NASM_FLAGS = -f elf32 ENV(NASM_PREFIX_MAP) 90 91 DEBUG_GCC5_IA32_CC_FLAGS = DEF(GCC5_IA32_CC_FLAGS) -flto 92 DEBUG_GCC5_IA32_DLINK_FLAGS = DEF(GCC5_IA32_X64_DLINK_FLAGS) -flto -Os -Wl,-m,elf_i386,--oformat=elf32-i386 93@@ -1528,7 +1528,7 @@ RELEASE_GCC5_IA32_DLINK_FLAGS = DEF(GCC5_IA32_X64_DLINK_FLAGS) -flto -Os -Wl, 94 *_GCC5_X64_DLINK2_FLAGS = DEF(GCC5_X64_DLINK2_FLAGS) 95 *_GCC5_X64_RC_FLAGS = DEF(GCC_X64_RC_FLAGS) 96 *_GCC5_X64_OBJCOPY_FLAGS = 97-*_GCC5_X64_NASM_FLAGS = -f elf64 98+*_GCC5_X64_NASM_FLAGS = -f elf64 ENV(NASM_PREFIX_MAP) 99 100 DEBUG_GCC5_X64_CC_FLAGS = DEF(GCC5_X64_CC_FLAGS) -flto -DUSING_LTO 101 DEBUG_GCC5_X64_DLINK_FLAGS = DEF(GCC5_X64_DLINK_FLAGS) -flto -Os 102-- 1032.39.5 104 105