Laszlo: Thanks for your quick test. I will add Bugzilla in commit log. And, I will let you know once I push this patch.
Thanks Liming > -----Original Message----- > From: Laszlo Ersek [mailto:[email protected]] > Sent: Wednesday, August 23, 2017 6:27 PM > To: Gao, Liming <[email protected]> > Cc: [email protected]; Shi, Steven <[email protected]>; Paolo > Bonzini <[email protected]>; Ard Biesheuvel > <[email protected]>; Justen, Jordan L <[email protected]>; > Kinney, Michael D <[email protected]> > Subject: Re: [edk2] [Patch] BaseTools: Add the missing -pie link option in > GCC tool chain > > Hi Liming, > > On 08/23/17 10:04, Liming Gao wrote: > > GCC tool chain uses -fpie in CC_FLAGS. So, add -pie in DLINK_FLAGS. > > > > More discussion in > > https://lists.01.org/pipermail/edk2-devel/2017-August/013508.html > > > > 3.13 Options for Linking > > ======================== > > '-pie' > > Produce a position independent executable on targets that support > > it. For predictable results, you must also specify the same set > > of options used for compilation ('-fpie', '-fPIE', or model > > suboptions) when you specify this linker option. > > > > 3.18 Options for Code Generation Conventions > > ============================================ > > '-fpie' > > '-fPIE' > > These options are similar to '-fpic' and '-fPIC', but generated > > position independent code can be only linked into executables. > > Usually these options are used when '-pie' GCC option is used > > during linking. > > '-fpie' and '-fPIE' both define the macros '__pie__' and > > '__PIE__'. The macros have the value 1 for '-fpie' and 2 for > > '-fPIE'. > > > > Contributed-under: TianoCore Contribution Agreement 1.1 > > Signed-off-by: Liming Gao <[email protected]> > > --- > > BaseTools/Conf/tools_def.template | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/BaseTools/Conf/tools_def.template > > b/BaseTools/Conf/tools_def.template > > index 6076a69..aff0cbd 100755 > > --- a/BaseTools/Conf/tools_def.template > > +++ b/BaseTools/Conf/tools_def.template > > @@ -4502,7 +4502,7 @@ DEFINE GCC44_IA32_X64_DLINK_COMMON = -nostdlib > > -Wl,-n,-q,--gc-sections -z comm > > DEFINE GCC44_IA32_X64_ASLDLINK_FLAGS = DEF(GCC44_IA32_X64_DLINK_COMMON) > > -Wl,--entry,ReferenceAcpiTable -u > ReferenceAcpiTable > > DEFINE GCC44_IA32_X64_DLINK_FLAGS = DEF(GCC44_IA32_X64_DLINK_COMMON) > > -Wl,--entry,$(IMAGE_ENTRY_POINT) -u > $(IMAGE_ENTRY_POINT) -Wl,-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map > > DEFINE GCC44_IA32_DLINK2_FLAGS = > > -Wl,--defsym=PECOFF_HEADER_SIZE=0x220 DEF(GCC_DLINK2_FLAGS_COMMON) > > -DEFINE GCC44_X64_DLINK_FLAGS = DEF(GCC44_IA32_X64_DLINK_FLAGS) > > -Wl,-melf_x86_64,--oformat=elf64-x86-64 > > +DEFINE GCC44_X64_DLINK_FLAGS = DEF(GCC44_IA32_X64_DLINK_FLAGS) > -Wl,-melf_x86_64,--oformat=elf64-x86-64,-pie > > DEFINE GCC44_X64_DLINK2_FLAGS = > > -Wl,--defsym=PECOFF_HEADER_SIZE=0x228 DEF(GCC_DLINK2_FLAGS_COMMON) > > DEFINE GCC44_ASM_FLAGS = DEF(GCC_ASM_FLAGS) > > > > @@ -4582,7 +4582,7 @@ DEFINE GCC49_IA32_X64_DLINK_COMMON = -nostdlib > > -Wl,-n,-q,--gc-sections -z comm > > DEFINE GCC49_IA32_X64_ASLDLINK_FLAGS = DEF(GCC49_IA32_X64_DLINK_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 > > 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 > > +DEFINE GCC49_X64_DLINK_FLAGS = DEF(GCC49_IA32_X64_DLINK_FLAGS) > -Wl,-melf_x86_64,--oformat=elf64-x86-64,-pie > > DEFINE GCC49_X64_DLINK2_FLAGS = DEF(GCC48_X64_DLINK2_FLAGS) > > DEFINE GCC49_ASM_FLAGS = DEF(GCC48_ASM_FLAGS) > > DEFINE GCC49_ARM_ASM_FLAGS = DEF(GCC48_ARM_ASM_FLAGS) > > > > (1) you forgot to CC the participants of the previous thread :) > > (2) Please add a reference to > <https://bugzilla.tianocore.org/show_bug.cgi?id=671> to the commit message. > > (3) I tested the GCC49_X64_DLINK_FLAGS change with the following > commands, on Fedora 26 (the gcc version is "7.1.1 20170622 (Red Hat > 7.1.1-3)"): > > $ git clean -fdx > $ git reset --hard > $ . edksetup.sh --reconfig > $ make -C "$EDK_TOOLS_PATH" > $ build -a X64 -p OvmfPkg/OvmfPkgX64.dsc -t GCC5 -n 6 -b DEBUG > $ qemu-system-x86_64 \ > -m 5120 \ > -smp 8 \ > -pflash Build/OvmfX64/DEBUG_GCC5/FV/OVMF.fd \ > -enable-kvm \ > -global isa-debugcon.iobase=0x402 \ > -debugcon file:debug-gcc5-64.fd.log \ > -net none > > The resultant OVMF binary works fine. (The UEFI shell is reached OK.) > > (4) I regression-tested the GCC44_X64_DLINK_FLAGS change on RHEL-7.4, > using "gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-16)". No regressions were > found. > > Tested-by: Laszlo Ersek <[email protected]> > Reviewed-by: Laszlo Ersek <[email protected]> > > (5) When you push the patch (possibly after receiving comments from > others), please send a reminder for me to revert commit ca56256d5e0b > ("OvmfPkg/build.sh: select the GCC49 toolchain settings for gcc-7.*", > 2017-08-15). > > Thanks! > Laszlo _______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

