From patchwork Tue Oct 18 15:53:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 78099 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp952489qge; Tue, 18 Oct 2016 08:53:56 -0700 (PDT) X-Received: by 10.98.152.66 with SMTP id q63mr1899232pfd.42.1476806036576; Tue, 18 Oct 2016 08:53:56 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s3si3196347pai.232.2016.10.18.08.53.56; Tue, 18 Oct 2016 08:53:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S938386AbcJRPxt (ORCPT + 27 others); Tue, 18 Oct 2016 11:53:49 -0400 Received: from mail-wm0-f44.google.com ([74.125.82.44]:37555 "EHLO mail-wm0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936591AbcJRPxj (ORCPT ); Tue, 18 Oct 2016 11:53:39 -0400 Received: by mail-wm0-f44.google.com with SMTP id c78so1290005wme.0 for ; Tue, 18 Oct 2016 08:53:39 -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=RDsEhPO6vGEizk1rzFwNAY/uIG3z78mpFtj71Oc8qyM=; b=ksqihC+PTiRDpGEC8M61c0ewQIPobuyK0kMsmFAZweMwX9wxtHOatG+nhJQJzxUNCi GJvNUX53k9CMsH3bILsj38DS5UtMaRS75TTZyOVhXYY+U7uej/kuFqy1sNeGijFNhTlr DhKPX+wSFZT+JIwlVeH/givsuBCH2138gax+k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RDsEhPO6vGEizk1rzFwNAY/uIG3z78mpFtj71Oc8qyM=; b=dU6ode154Gh6sDnoaoFFWNm2LDYVf9HInM6t4TitvyrvWx9sqc1zinm8dMOUEStbuj Q6W6df1OqcdNbBBzu+AxW4hl51ihy6VQtQNd/a3s8R5ePRQf8Mg4skyof1YGTUtTDtec ee1GSndt8WPK3CiXOArBwXT2YO/zotdmX1kU/t7Ba/yTg9T46HadWxjUuQ+uuVuTbYMr m+Rk7MiizS0NJNJWO7LZFfisRSV6lw/cjUJYlMyO6toCFwX5CmiPSmqB5k4ALXLk0+Zu 2ebqn+x9/s+BW+v6uUEwKaUzjz9xN39bu+jP+QFU5GCta0Itoi8pR3OJm8Mt5twidWNw HTUA== X-Gm-Message-State: AA6/9RmIdLYu/2otFwYbPcEHy5pWwWnXvO+v2f3RU35xIpPMNoQjNcBxvCimuXCMVJjgjLEW X-Received: by 10.28.166.214 with SMTP id p205mr1170351wme.24.1476806017962; Tue, 18 Oct 2016 08:53:37 -0700 (PDT) Received: from localhost.localdomain ([105.137.38.75]) by smtp.gmail.com with ESMTPSA id c193sm111939wmd.10.2016.10.18.08.53.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 18 Oct 2016 08:53:37 -0700 (PDT) From: Ard Biesheuvel To: mingo@kernel.org, Thomas Gleixner , "H . Peter Anvin" Cc: Ard Biesheuvel , linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org Subject: [PATCH] efi/arm: Fix absolute relocation detection for older toolchains Date: Tue, 18 Oct 2016 16:53:11 +0100 Message-Id: <1476805991-7160-2-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1476805991-7160-1-git-send-email-ard.biesheuvel@linaro.org> References: <1476805991-7160-1-git-send-email-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When building the ARM kernel with CONFIG_EFI=y, the following build error may occur when using a less recent version of binutils (2.23 or older): STUBCPY drivers/firmware/efi/libstub/lib-sort.stub.o 00000000 R_ARM_ABS32 sort 00000004 R_ARM_ABS32 __ksymtab_strings drivers/firmware/efi/libstub/lib-sort.stub.o: absolute symbol references not allowed in the EFI stub (and when building with debug symbols, the list above is much longer, and contains all the internal references between the .debug sections and the actual code) This issue is caused by the fact that objcopy v2.23 or earlier does not support wildcards in its -R and -j options, which means the following line from the Makefile: STUBCOPY_FLAGS-y := -R .debug* -R *ksymtab* -R *kcrctab* fails to take effect, leaving harmless absolute relocations in the binary that are indistinguishable from relocations that may cause crashes at runtime due to the fact that these relocations are resolved at link time using the virtual address of the kernel, which is always different from the address at which the EFI firmware loads and invokes the stub. So, as a workaround, disable debug symbols explicitly when building the stub for ARM, and strip the ksymtab and kcrctab symbols for the only exported symbol we currently reuse in the stub, which is 'sort'. Cc: Matt Fleming Tested-by: Jon Hunter Reviewed-by: Matt Fleming Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/libstub/Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile index c06945160a41..5e23e2d305e7 100644 --- a/drivers/firmware/efi/libstub/Makefile +++ b/drivers/firmware/efi/libstub/Makefile @@ -11,7 +11,7 @@ cflags-$(CONFIG_X86) += -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2 \ -mno-mmx -mno-sse cflags-$(CONFIG_ARM64) := $(subst -pg,,$(KBUILD_CFLAGS)) -cflags-$(CONFIG_ARM) := $(subst -pg,,$(KBUILD_CFLAGS)) \ +cflags-$(CONFIG_ARM) := $(subst -pg,,$(KBUILD_CFLAGS)) -g0 \ -fno-builtin -fpic -mno-single-pic-base cflags-$(CONFIG_EFI_ARMSTUB) += -I$(srctree)/scripts/dtc/libfdt @@ -79,5 +79,6 @@ quiet_cmd_stubcopy = STUBCPY $@ # decompressor. So move our .data to .data.efistub, which is preserved # explicitly by the decompressor linker script. # -STUBCOPY_FLAGS-$(CONFIG_ARM) += --rename-section .data=.data.efistub +STUBCOPY_FLAGS-$(CONFIG_ARM) += --rename-section .data=.data.efistub \ + -R ___ksymtab+sort -R ___kcrctab+sort STUBCOPY_RELOC-$(CONFIG_ARM) := R_ARM_ABS