From patchwork Tue Nov 21 16:10:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 119370 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5462996qgn; Tue, 21 Nov 2017 08:10:59 -0800 (PST) X-Google-Smtp-Source: AGs4zMZZy5UM2xnR9FLxPnDxQyPvhegUO2gYIku+Ehu3USTKAFGay/u3dpX82zimZqtMF25q4e6M X-Received: by 10.99.132.72 with SMTP id k69mr17917282pgd.437.1511280659083; Tue, 21 Nov 2017 08:10:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511280659; cv=none; d=google.com; s=arc-20160816; b=W02xqxaV1DvERSRlcTGNBxYFNXJgZRXU4znbRACFrZclm5+uVjfr5sRFlA8fGvV2wy p55uwiG8KpuVWwa+2VILFStP84IFPojQrqxHeoueaI9GMIL7uDfSnIrsrokJ5zA2E3Ub +wo+jc78QvlGigZm9kDqLdghXefyLpCocX/Xrj0SanJJa8XgjQj9JINKZK98Z8Q5SQPJ Fb0nxKdPv2JDMZuDzX30yMxuVAqtC/cZe6idW3Ar9mWuNLNrMPjO3HZAj5aHyLg0O87x Y4dpN4H1XoO2Z2tbaxdVHFsSe0y59aatqjTy8tB750CHV97oZxFiFC4P1NrJdyNM9fjm 8sHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=kZQAU719tFzDTFWaK9I/Uls3wv/yHlAZU59jOFCLC6c=; b=c8KCWrd84YnJ2eYABUOhwFOPlGSUdIICFXDSr+yE0gaN1i+Th/TEml8YA7dhyfRD1d tFgq6QHg9gdtA/kiwt328n6aBivN+vOydHb8Kp2A1zM1a0stRnGyEoazRK6EWHTTCT8d RUy/9iGtIbBbR5OkZx0NAYhsIDSEiOjYoFCHtxT0Y/jMHGyiVxRWTLj/uC/2uh1LNiGi r4PCJPP9wQ4MZ19MPHmApC7c9Cp7EMfOcVLHkM2iXS/CkCgLacpZXMcgsUe++eLmpv2R H6x+xWia8glDqO4/Aal6ItPVn8h/yJX3AV80KTCEA2zGIxYx9w8xjEl1FWXJ+jyR4Msp vcAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=krj+GoGU; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id d8si12436158pfg.317.2017.11.21.08.10.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Nov 2017 08:10:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=krj+GoGU; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 602BD2035BB0F; Tue, 21 Nov 2017 08:06:42 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c0c::244; helo=mail-wr0-x244.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x244.google.com (mail-wr0-x244.google.com [IPv6:2a00:1450:400c:c0c::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C38EA21B00DC1 for ; Tue, 21 Nov 2017 08:06:40 -0800 (PST) Received: by mail-wr0-x244.google.com with SMTP id z14so11785630wrb.8 for ; Tue, 21 Nov 2017 08:10:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=t2FQZLdV0B3Ij6Ats93emNXymiYf9ARUmS7ETDPmjFA=; b=krj+GoGUrn2rVOr96W6ThX1ST+94UZ1T6crunupdMsbDLQR8T2Gl9P53eHMW73rDrI 0BkGwJqNLGVP9VkLY9bb4DbEcXwqezJMrgd2yDII8BeTnglrbaS5Hapm6zs98sJyaMjp ocOL8D/5k9DjnM6q0swueEhrHWbqOiXvvPres= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=t2FQZLdV0B3Ij6Ats93emNXymiYf9ARUmS7ETDPmjFA=; b=HUyWZ+CTLy9KSGokPlst07M8rCe/gyC/nbFih6Hdxz6N8zbKLL+cNb7z7BQU0iDGNr y6Z1oDopaLrt5//lR8vh1axd/VBnqtd81hSz4YHOBRx/u9YH/1DcDgiDM7IBO7JaBtDM ICqawfrK8RKhBCTVacbzmweHolTktFVgeMgK04bbC7DrZai+yCwJ9qg3/DXCBQgrmjjH Z2bAs0/6K24OfUKdi+EIvcp1spnvVfVZQ/ghyV6Mpvqt+EljOmvvu/RFK0CU2OPircSo 3Pm68rLvN6gDOXiSqm0vyuKEhqNTZOyqYk6dVbzPmL6/stD3by+CB2Ig/RaCAxHApDFu uhnA== X-Gm-Message-State: AJaThX6RkkyvTqhY16+6yxBe+JD1jjzEKCc16eN8ATslzkWXs6mz8WKd 8GeDaoJirmocyXrX9pQV6t8ooDoFCzQ= X-Received: by 10.223.145.166 with SMTP id 35mr14233538wri.51.1511280653861; Tue, 21 Nov 2017 08:10:53 -0800 (PST) Received: from localhost.localdomain ([154.145.25.106]) by smtp.gmail.com with ESMTPSA id n64sm1621250wmd.36.2017.11.21.08.10.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Nov 2017 08:10:52 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org Date: Tue, 21 Nov 2017 16:10:37 +0000 Message-Id: <20171121161037.26573-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 Subject: [edk2] [PATCH] BaseTools/tools_def AARCH64 ARM: suppres PIE sections via linker script 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: , Cc: daniel.thompson@linaro.org, liming.gao@intel.com, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Recent distro builds of GCC 6 enable PIE linking by default, and allow the previous behavior to be restored by passing the -no-pie command line argument. This was implemented by commits 1894a7c64c0a and 3380a591232d but unfortunately, it turns out that GCC 5 does not support this command line argument, and exits with an error. To avoid the need for yet another toolchain tag, to distinguish between GCC 5 and GCC 6, let's use our GCC linker scripts when building objects from .aslc files. This will ensure that the extra sections that are added by the PIE linker are discarded from the ELF binary, and so they will not corrupt the resulting .acpi file. This reverts 1894a7c64c0a BaseTools/tools_def AARCH64 ARM: disable PIE linking 3380a591232d BaseTools/tools_def AARCH64 ARM: disable PIE linking for .aslc sources Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- BaseTools/Conf/tools_def.template | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Tested-by: Marcin Wojtas Reviewed-by: Liming Gao diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template index aebd7d558633..4d2a3b7dbe56 100755 --- a/BaseTools/Conf/tools_def.template +++ b/BaseTools/Conf/tools_def.template @@ -4356,9 +4356,10 @@ DEFINE GCC_IA32_X64_DLINK_COMMON = DEF(GCC_DLINK_FLAGS_COMMON) --gc-sections DEFINE GCC_ARM_AARCH64_DLINK_COMMON= -Wl,--emit-relocs -nostdlib -Wl,--gc-sections -u $(IMAGE_ENTRY_POINT) -Wl,-e,$(IMAGE_ENTRY_POINT),-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map DEFINE GCC_ARM_DLINK_FLAGS = DEF(GCC_ARM_AARCH64_DLINK_COMMON) -z common-page-size=0x20 DEFINE GCC_AARCH64_DLINK_FLAGS = DEF(GCC_ARM_AARCH64_DLINK_COMMON) -z common-page-size=0x20 +DEFINE GCC_ARM_AARCH64_ASLDLINK_FLAGS = -Wl,--defsym=PECOFF_HEADER_SIZE=0 DEF(GCC_DLINK2_FLAGS_COMMON) -z common-page-size=0x20 DEFINE GCC_IA32_X64_ASLDLINK_FLAGS = DEF(GCC_IA32_X64_DLINK_COMMON) --entry _ReferenceAcpiTable -u $(IMAGE_ENTRY_POINT) -DEFINE GCC_ARM_ASLDLINK_FLAGS = DEF(GCC_ARM_DLINK_FLAGS) -Wl,--entry,ReferenceAcpiTable -u $(IMAGE_ENTRY_POINT) -DEFINE GCC_AARCH64_ASLDLINK_FLAGS = DEF(GCC_AARCH64_DLINK_FLAGS) -Wl,--entry,ReferenceAcpiTable -u $(IMAGE_ENTRY_POINT) +DEFINE GCC_ARM_ASLDLINK_FLAGS = DEF(GCC_ARM_DLINK_FLAGS) -Wl,--entry,ReferenceAcpiTable -u $(IMAGE_ENTRY_POINT) DEF(GCC_ARM_AARCH64_ASLDLINK_FLAGS) +DEFINE GCC_AARCH64_ASLDLINK_FLAGS = DEF(GCC_AARCH64_DLINK_FLAGS) -Wl,--entry,ReferenceAcpiTable -u $(IMAGE_ENTRY_POINT) DEF(GCC_ARM_AARCH64_ASLDLINK_FLAGS) 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 DEFINE GCC_IPF_DLINK_FLAGS = -nostdlib -O2 --gc-sections --dll -static --entry $(IMAGE_ENTRY_POINT) --undefined $(IMAGE_ENTRY_POINT) -Map $(DEST_DIR_DEBUG)/$(BASE_NAME).map DEFINE GCC_IPF_OBJCOPY_FLAGS = -I elf64-ia64-little -O efi-bsdrv-ia64 @@ -4494,12 +4495,12 @@ DEFINE GCC5_ARM_CC_FLAGS = DEF(GCC49_ARM_CC_FLAGS) DEFINE GCC5_ARM_CC_XIPFLAGS = DEF(GCC49_ARM_CC_XIPFLAGS) DEFINE GCC5_AARCH64_CC_FLAGS = DEF(GCC49_AARCH64_CC_FLAGS) DEFINE GCC5_AARCH64_CC_XIPFLAGS = DEF(GCC49_AARCH64_CC_XIPFLAGS) -DEFINE GCC5_ARM_DLINK_FLAGS = DEF(GCC49_ARM_DLINK_FLAGS) -no-pie +DEFINE GCC5_ARM_DLINK_FLAGS = DEF(GCC49_ARM_DLINK_FLAGS) DEFINE GCC5_ARM_DLINK2_FLAGS = DEF(GCC49_ARM_DLINK2_FLAGS) -Wno-error -DEFINE GCC5_AARCH64_DLINK_FLAGS = DEF(GCC49_AARCH64_DLINK_FLAGS) -no-pie +DEFINE GCC5_AARCH64_DLINK_FLAGS = DEF(GCC49_AARCH64_DLINK_FLAGS) DEFINE GCC5_AARCH64_DLINK2_FLAGS = DEF(GCC49_AARCH64_DLINK2_FLAGS) -Wno-error -DEFINE GCC5_ARM_ASLDLINK_FLAGS = DEF(GCC49_ARM_ASLDLINK_FLAGS) -no-pie -DEFINE GCC5_AARCH64_ASLDLINK_FLAGS = DEF(GCC49_AARCH64_ASLDLINK_FLAGS) -no-pie +DEFINE GCC5_ARM_ASLDLINK_FLAGS = DEF(GCC49_ARM_ASLDLINK_FLAGS) +DEFINE GCC5_AARCH64_ASLDLINK_FLAGS = DEF(GCC49_AARCH64_ASLDLINK_FLAGS) #################################################################################### #