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: 9732967 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 35AD9600CC for ; Thu, 18 May 2017 09:11:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 218CC286DF for ; Thu, 18 May 2017 09:11:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 143FA287B7; Thu, 18 May 2017 09:11:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 80495286DF for ; Thu, 18 May 2017 09:11:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=i9qwOQyJRZFbKaYR6bD+R3h/0xTWMdSyNyDd7aX3r2o=; b=sY3BcOCNsnhcATT0RZJ8VkBNEB /+YdNH/XT2FI1sKVw8aueyeCt3ptsscyiHlplbgmpvWWfGApCtul3otxJ9cmSiu2+Fr/END/4j9E4 ZRYYvL/AZd5zhiaRVJrhnl7CbmRFC85XBVcKMjrnm7yjUvdT+jeUtoW3Pnvf5+DlSg04VsY9scXYb C9Getg8Nk/Me3anI9TLCTXPhVvGzUXO4EjvMgCVkt8Pw7DZh2HmCtd79uaC834BhRlrW7nq59RVvJ wNsIK4lMH8Hy4dWNcR3NKkwycLv6gfpiWL6cDXnMOWOLXNIM5j9rwL0TuDZWjgU59T029RIFsM2Nl Gm2aQCEw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dBHSg-0001Hm-Fb; Thu, 18 May 2017 09:11:10 +0000 Received: from mail-wm0-x22b.google.com ([2a00:1450:400c:c09::22b]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dBHS3-0000NZ-Je for linux-arm-kernel@lists.infradead.org; Thu, 18 May 2017 09:10:35 +0000 Received: by mail-wm0-x22b.google.com with SMTP id d127so44687282wmf.0 for ; Thu, 18 May 2017 02:10:11 -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=KPs2EQhIU2lsG8vgFlxJuS078F8hR6ilzQmc9KNvjOOluviD9/xYcBGnV38AV+RE++ fbnYJPwmUV4Cg1J+7NOJ2PToz2YqCp8PpbOR4ww+ddMj/UBSdR7I7E7a+sabstujd/nb bKqQ0ZPFnOYtiDMKYmGAL60bbDqXOeb6mnU6rW/K2JkFMcMxuDP3EYNll/rd/dSe2+EH 5GQvoG2nh1r/KTwXQyp2manXCJ7JqnXRq7rBYMyc1H8ZW1kx3JhNxEihT4N5gMKSgesV c++vQuPeimjUTupXbZkaeLuq6f2rZCcYWvrFcfkbijlTcwc1Q2REg1gjwSQAQTrzlDIT zNSw== X-Gm-Message-State: AODbwcC12Bu/rRKiEJamcpbyoUddzqKuUzKbPh0kDl/ETZVVQlCv1p3E sMrv3K21QhzRV37W 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170518_021032_208396_4AD96E98 X-CRM114-Status: GOOD ( 10.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, Ard Biesheuvel , matt@codeblueprint.co.uk, ghackmann@google.com, md@google.com, grundler@chromium.org, mka@chromium.org, linux-arm-kernel@lists.infradead.org, Bernhard.Rosenkranzer@linaro.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Tested-by: Matthias Kaehlcke --- drivers/firmware/efi/libstub/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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