From nobody Fri May 3 15:12:53 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1503475465021895.5357905144617; Wed, 23 Aug 2017 01:04:25 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id B00B22095B9E3; Wed, 23 Aug 2017 01:01:47 -0700 (PDT) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 0A0702095B9D3 for ; Wed, 23 Aug 2017 01:01:47 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Aug 2017 01:04:08 -0700 Received: from shwde7172.ccr.corp.intel.com ([10.239.9.14]) by orsmga002.jf.intel.com with ESMTP; 23 Aug 2017 01:04:08 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,415,1498546800"; d="scan'208";a="127280810" From: Liming Gao To: edk2-devel@lists.01.org Date: Wed, 23 Aug 2017 16:04:04 +0800 Message-Id: <1503475444-6116-1-git-send-email-liming.gao@intel.com> X-Mailer: git-send-email 2.8.0.windows.1 Subject: [edk2] [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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Laszlo Ersek Reviewed-by: Yonghong Zhu Tested-by: Laszlo Ersek --- 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) --=20 2.8.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel