From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753222AbdHUJW0 (ORCPT ); Mon, 21 Aug 2017 05:22:26 -0400 Received: from terminus.zytor.com ([65.50.211.136]:49499 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753125AbdHUJWX (ORCPT ); Mon, 21 Aug 2017 05:22:23 -0400 Date: Mon, 21 Aug 2017 02:16:44 -0700 From: tip-bot for Ard Biesheuvel Message-ID: Cc: linux-kernel@vger.kernel.org, ard.biesheuvel@linaro.org, torvalds@linux-foundation.org, tglx@linutronix.de, peterz@infradead.org, mka@chromium.org, hpa@zytor.com, mingo@kernel.org, matt@codeblueprint.co.uk Reply-To: mka@chromium.org, peterz@infradead.org, tglx@linutronix.de, linux-kernel@vger.kernel.org, ard.biesheuvel@linaro.org, torvalds@linux-foundation.org, matt@codeblueprint.co.uk, mingo@kernel.org, hpa@zytor.com In-Reply-To: <20170818194947.19347-5-ard.biesheuvel@linaro.org> References: <20170818194947.19347-5-ard.biesheuvel@linaro.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:efi/core] efi/libstub/arm64: Set -fpie when building the EFI stub Git-Commit-ID: 91ee5b21ee026c49e4e7483de69b55b8b47042be X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 91ee5b21ee026c49e4e7483de69b55b8b47042be Gitweb: http://git.kernel.org/tip/91ee5b21ee026c49e4e7483de69b55b8b47042be Author: Ard Biesheuvel AuthorDate: Fri, 18 Aug 2017 20:49:37 +0100 Committer: Ingo Molnar CommitDate: Mon, 21 Aug 2017 09:43:49 +0200 efi/libstub/arm64: Set -fpie when building the EFI stub 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. Tested-by: Matthias Kaehlcke Signed-off-by: Ard Biesheuvel Cc: Linus Torvalds Cc: Matt Fleming Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-efi@vger.kernel.org Link: http://lkml.kernel.org/r/20170818194947.19347-5-ard.biesheuvel@linaro.org Signed-off-by: Ingo Molnar --- 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 37e24f5..cf81e6c 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