From patchwork Fri Sep 30 23:01:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 77193 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp546090qgf; Fri, 30 Sep 2016 16:04:55 -0700 (PDT) X-Received: by 10.66.43.204 with SMTP id y12mr15797308pal.118.1475276695044; Fri, 30 Sep 2016 16:04:55 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id f184si22309722pfb.129.2016.09.30.16.04.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Sep 2016 16:04:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; 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-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bq6oz-0006Hq-TN; Fri, 30 Sep 2016 23:02:25 +0000 Received: from mail-pf0-x22a.google.com ([2607:f8b0:400e:c00::22a]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bq6ov-0006DE-BK for linux-arm-kernel@lists.infradead.org; Fri, 30 Sep 2016 23:02:23 +0000 Received: by mail-pf0-x22a.google.com with SMTP id u78so19122271pfa.1 for ; Fri, 30 Sep 2016 16:01:59 -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; bh=9FBmSgihqEpiC/7SspLUdDq0nrX2YRxZ7xbda9fdKGo=; b=KpNGmOPfsfWCWd4IitZ1ohzm75v5EiRYbIwADyjk5QyMoaaTi2QxT5WmKdzxUU1SMf sQS5SLbUiUIz6/Cg+2LDC9vnwVfMEVJtwv8vfXcqxYIbDhuPoIK+LR+C2FfhhuF3YJQX dNRI8x553USreQmuLvsSxSMsBmQLY7jPB95HQ= 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; bh=9FBmSgihqEpiC/7SspLUdDq0nrX2YRxZ7xbda9fdKGo=; b=AEkP1gFQeQYSN/+Er9hpvcv/2+B8nfqNQY+k0qB92z/dOPnp4Hrok+8vkhePXlq/E1 CX2hZwvNww2Ajkpw8yxCJYL57roglUF7umROD8m1irwWyUqCcwmiLpkxnPSCoRvALEjP 9MZPs7w/GceDP5mueRGnuzU/leTQbR52ZZSp1lNu1zCSAvY8TQMhytjYFPp6hjzaAIim rFuvZTTNRNkwCNMVdR8y99m8vqGpw5BtFLtxzB7Ke2xUeQc+4FgGiT283wbK7Y9v2Lm0 l7JfVk+8wkos165+6X/40I8FCfGBMk4lKf3aC5GfoG3Z/gIhvlEoBDNt1NygvyIL2b0F B0AA== X-Gm-Message-State: AA6/9RnCRiUvL+ZEjJUlpZhXKOtJ3aufabHowePURKFYpGfGpya9LPb260RTiZC9mgEaUA3T X-Received: by 10.98.11.195 with SMTP id 64mr16028616pfl.160.1475276519265; Fri, 30 Sep 2016 16:01:59 -0700 (PDT) Received: from localhost.localdomain ([67.238.99.186]) by smtp.gmail.com with ESMTPSA id j1sm30163474pfg.95.2016.09.30.16.01.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 30 Sep 2016 16:01:57 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org, arnd@arndb.de, matt@codeblueprint.co.uk, jonathanh@nvidia.com Subject: [PATCH] efi/arm: fix absolute relocation detection for older toolchains Date: Fri, 30 Sep 2016 16:01:55 -0700 Message-Id: <1475276515-21801-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160930_160221_629414_079D1BB5 X-CRM114-Status: GOOD ( 15.24 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2607:f8b0:400e:c00:0:0:0:22a listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: olof@lixom.net, Ard Biesheuvel , linux@arm.linux.org.uk, khilman@kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.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'. Signed-off-by: Ard Biesheuvel --- This is a workaround for now. We can revisit this when a need arises to copy more kernel code into the stub, by which time we could put in a more elaborate fix, or decide to no longer care about 'older' versions of objcopy. Since this fixes an ARM specific issue and only affects ARM specific Makefile variables, I am happy for this to go on top of the arm-soc patch that enables CONFIG_EFI for ARM's multi_v7_defconfig (queued for v4.9), given that we have no other changes queued in linux-efi that should conflict with this patch. Matt, any concerns? drivers/firmware/efi/libstub/Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) -- 2.7.4 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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