From patchwork Thu May 18 09:09:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 100065 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp622887qge; Thu, 18 May 2017 02:10:13 -0700 (PDT) X-Received: by 10.99.127.73 with SMTP id p9mr3386350pgn.169.1495098613289; Thu, 18 May 2017 02:10:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495098613; cv=none; d=google.com; s=arc-20160816; b=S3bYwH+bpsdjshrW14n199xDIF6H33WbDZZ3qbjADxVpfYsr5bu3X+t6x+mYIn/cU0 ZSLMIw646W+3BMzj3y01MBS/aiI3e9CNtgAvgO9BwnR6+9KIrr8I7JigcaQeUuNWUnD9 8/Iakj6XU1WGIlgI3jtvRmPB5lRWRUvlSeFGwPBCabQRger+iNuOvSKSRmW8crg3fXKV 1JI2FyD8aEF8KAyGxQByn/1Wtuoq2mJrDHG40gbFNKxk9oZbHNhiIwrZ4jUHvNObhIbx BtdXUbj+9hZ5tlIY6T5rd/KTpb3iiVLr6pN3ZIx+HagcMDbolTgSZukpKnPWXJUOwsH5 zVkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=8rUV/rq1kNPk3NAUQv5B4C7esIjhJK4a6VXAOTwJ00U=; b=k/KOC6hAt773YFYlDkPUJAYc3bFZhzV4D7TV8FuMtpBIXL/vfCSAm1tx579sK/lV48 3mTC7tjn8Q+zKuKi2pxNFzjcbhCdPry8qxjECGGpBmWUKTVElHWFjjV2FnCJ76u4VYE8 jj1swptZevclDOuGDok/UsFJ+QYGuaYd8/23ptQMDRR3qKcm68k2bOYuytptf6CYmVlz gzsjciG6u5maBDJxyt4o1fdjt5kDV7c+im5BGkkr8TE7+tkIhQmwVZE3QfPOOcBkqisp fLoHbRyUQYW5MxrTq0jCXEjs/5pavKPS155veFUHDtXKhPyKe9FwCE8KYQnRzaHFCBEe /aNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d1si4627265pge.155.2017.05.18.02.10.12; Thu, 18 May 2017 02:10:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755314AbdERJKM (ORCPT + 2 others); Thu, 18 May 2017 05:10:12 -0400 Received: from mail-wm0-f54.google.com ([74.125.82.54]:38341 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755130AbdERJKL (ORCPT ); Thu, 18 May 2017 05:10:11 -0400 Received: by mail-wm0-f54.google.com with SMTP id v15so44878220wmv.1 for ; Thu, 18 May 2017 02:10:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7bmH054GHVJV2UpoTpTiCI1JqnTTtopIfvS8K38pvIs=; b=HsSoCNjQguCL0Il93hy3r/dvbxiaheH0S1sKSgHd/dsGynjUO0DuaZMIldCIqT+lcM 8h30ystsylUOfVTopHJshhn+jcC+Rzhtgh8N/E4sBoyy2R0a4gLgmnDPkn8YGDyUt3no VpQ7lW4PhZVhiLQeLLKYh0Q4g0MhUqN5bEJiE= 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:in-reply-to :references; bh=7bmH054GHVJV2UpoTpTiCI1JqnTTtopIfvS8K38pvIs=; b=LcXIAzudmIPTw4iGT5sIg968WUa34KWnh9rT+/LPgwpv6rTkv0CW4pu6m1j8OP2rnh cnpAfPRRU+toGPIQHJn5/gUoTyrNRVjiZAL/iPpnfkOnIxEhTJQuBJgElvFAcxT7tOVp gO/E29sg8Py5gQgW1Q/DU/Ca/AbX6e+aqGXepu0F7tCYXRmhYB8QyNAvriwPkKfWG2Kd XFa/OBPne1gnnkQWlGpRGS26LErsXSpfVfBcA/5rK4bThlYKrW4GSxF4NTVE1U0LJyFn 1/4TZGU+tzGw7QTaKRL8PbsDvJU0ecMw/Sa8LDY7lEU808J+7yNozSJQGd/cIThgjFKo L+2g== X-Gm-Message-State: AODbwcDkzwSLNhIOeOOXK7bXU9+qDHI4Otcx0T0np5WUkA9sJnRBUrJp RP98geCjX7Lbfc77 X-Received: by 10.80.146.71 with SMTP id j7mr2477717eda.17.1495098609756; Thu, 18 May 2017 02:10:09 -0700 (PDT) Received: from localhost.localdomain ([105.129.238.81]) by smtp.gmail.com with ESMTPSA id t17sm1406355edh.1.2017.05.18.02.10.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 May 2017 02:10:08 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org Cc: mark.rutland@arm.com, ghackmann@google.com, matt@codeblueprint.co.uk, mka@chromium.org, Bernhard.Rosenkranzer@linaro.org, grundler@chromium.org, md@google.com, linux-arm-kernel@lists.infradead.org, Ard Biesheuvel Subject: [PATCH 3/3] efi/libstub: arm64: set -fpie when building the EFI stub Date: Thu, 18 May 2017 10:09:53 +0100 Message-Id: <20170518090953.32628-4-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170518090953.32628-1-ard.biesheuvel@linaro.org> References: <20170518090953.32628-1-ard.biesheuvel@linaro.org> Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org Clang may emit absolute symbol references when building in non-PIC mode, even when using the default 'small' code model, which is already mostly position independent to begin with, due to its use of adrp/add pairs that have a relative range of +/- 4 GB. The remedy is to pass the -fpie flag, which can be done safely now that the code has been updated to avoid GOT indirections (which may be emitted due to the compiler assuming that the PIC/PIE code may end up in a shared library that is subject to ELF symbol preemption) Passing -fpie when building code that needs to execute at an a priori unknown offset is arguably an improvement in any case, and given that the recent visibility changes allow the PIC build to pass with GCC as well, let's add -fpie for all arm64 builds rather than only for Clang. Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/libstub/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-efi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Tested-by: Matthias Kaehlcke diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile index f7425960f6a5..e078390ba477 100644 --- a/drivers/firmware/efi/libstub/Makefile +++ b/drivers/firmware/efi/libstub/Makefile @@ -10,7 +10,7 @@ cflags-$(CONFIG_X86) += -m$(BITS) -D__KERNEL__ -O2 \ -fPIC -fno-strict-aliasing -mno-red-zone \ -mno-mmx -mno-sse -cflags-$(CONFIG_ARM64) := $(subst -pg,,$(KBUILD_CFLAGS)) +cflags-$(CONFIG_ARM64) := $(subst -pg,,$(KBUILD_CFLAGS)) -fpie cflags-$(CONFIG_ARM) := $(subst -pg,,$(KBUILD_CFLAGS)) \ -fno-builtin -fpic -mno-single-pic-base