From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id A58BD2095B9CF for ; Thu, 24 Aug 2017 06:23:17 -0700 (PDT) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Aug 2017 06:25:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,421,1498546800"; d="scan'208";a="122226999" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga004.jf.intel.com with ESMTP; 24 Aug 2017 06:25:52 -0700 Received: from fmsmsx154.amr.corp.intel.com (10.18.116.70) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 24 Aug 2017 06:25:51 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX154.amr.corp.intel.com (10.18.116.70) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 24 Aug 2017 06:25:51 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.183]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.93]) with mapi id 14.03.0319.002; Thu, 24 Aug 2017 21:25:49 +0800 From: "Zhu, Yonghong" To: "Gao, Liming" , "edk2-devel@lists.01.org" Thread-Topic: [edk2] [Patch] BaseTools: Add the missing -pie link option in GCC tool chain Thread-Index: AQHTG+Z2bYLzlU4E7U+06AciM88mT6KTgPxg Date: Thu, 24 Aug 2017 13:25:49 +0000 Message-ID: References: <1503475444-6116-1-git-send-email-liming.gao@intel.com> In-Reply-To: <1503475444-6116-1-git-send-email-liming.gao@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch] BaseTools: Add the missing -pie link option in GCC tool chain X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Aug 2017 13:23:17 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Yonghong Zhu Best Regards, Zhu Yonghong -----Original Message----- From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Limi= ng Gao Sent: Wednesday, August 23, 2017 4:04 PM To: edk2-devel@lists.01.org Subject: [edk2] [Patch] BaseTools: Add the missing -pie link option in GCC = tool chain 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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D '-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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D '-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 --- 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.t= emplate 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 =3D -nostdlib -W= l,-n,-q,--gc-sections -z comm DEFINE GCC44_IA32_X64_ASLDLINK_FLAGS =3D DEF(GCC44_IA32_X64_DLINK_COMMON) = -Wl,--entry,ReferenceAcpiTable -u ReferenceAcpiTable DEFINE GCC44_IA32_X64_DLINK_FLAGS =3D DEF(GCC44_IA32_X64_DLINK_COMMON) = -Wl,--entry,$(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT) -Wl,-Map,$(DEST_DI= R_DEBUG)/$(BASE_NAME).map DEFINE GCC44_IA32_DLINK2_FLAGS =3D -Wl,--defsym=3DPECOFF_HEADER_SIZE= =3D0x220 DEF(GCC_DLINK2_FLAGS_COMMON) -DEFINE GCC44_X64_DLINK_FLAGS =3D DEF(GCC44_IA32_X64_DLINK_FLAGS) -= Wl,-melf_x86_64,--oformat=3Delf64-x86-64 +DEFINE GCC44_X64_DLINK_FLAGS =3D DEF(GCC44_IA32_X64_DLINK_FLAGS) -= Wl,-melf_x86_64,--oformat=3Delf64-x86-64,-pie DEFINE GCC44_X64_DLINK2_FLAGS =3D -Wl,--defsym=3DPECOFF_HEADER_SIZE= =3D0x228 DEF(GCC_DLINK2_FLAGS_COMMON) DEFINE GCC44_ASM_FLAGS =3D DEF(GCC_ASM_FLAGS) =20 @@ -4582,7 +4582,7 @@ DEFINE GCC49_IA32_X64_DLINK_COMMON =3D -nostdlib -W= l,-n,-q,--gc-sections -z comm DEFINE GCC49_IA32_X64_ASLDLINK_FLAGS =3D DEF(GCC49_IA32_X64_DLINK_COMMON) = -Wl,--entry,ReferenceAcpiTable -u ReferenceAcpiTable DEFINE GCC49_IA32_X64_DLINK_FLAGS =3D DEF(GCC49_IA32_X64_DLINK_COMMON) = -Wl,--entry,$(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT) -Wl,-Map,$(DEST_DI= R_DEBUG)/$(BASE_NAME).map DEFINE GCC49_IA32_DLINK2_FLAGS =3D DEF(GCC48_IA32_DLINK2_FLAGS) -DEFINE GCC49_X64_DLINK_FLAGS =3D DEF(GCC49_IA32_X64_DLINK_FLAGS) -= Wl,-melf_x86_64,--oformat=3Delf64-x86-64 +DEFINE GCC49_X64_DLINK_FLAGS =3D DEF(GCC49_IA32_X64_DLINK_FLAGS) -= Wl,-melf_x86_64,--oformat=3Delf64-x86-64,-pie DEFINE GCC49_X64_DLINK2_FLAGS =3D DEF(GCC48_X64_DLINK2_FLAGS) DEFINE GCC49_ASM_FLAGS =3D DEF(GCC48_ASM_FLAGS) DEFINE GCC49_ARM_ASM_FLAGS =3D DEF(GCC48_ARM_ASM_FLAGS) -- 2.8.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel