Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1700864pxu; Thu, 17 Dec 2020 17:00:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJwGcuspemIw9WeKcy93i2iDqnVvfYzI4IaXDrFF3Z9iijax/6qGQQll3mykmibFdVj8KmhH X-Received: by 2002:a17:906:168f:: with SMTP id s15mr1642101ejd.180.1608253236535; Thu, 17 Dec 2020 17:00:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608253236; cv=none; d=google.com; s=arc-20160816; b=oh0RByt3cKSqJjSuZgU0fnPpM5MbwftiZxxJ52ZJlNrK4K1SP9UwCHCtY5II43cMmk ciN70S6xlELSk+ItKobxpD7ps3PO+UxjCrrHljq/9hJnUu4669tpEeNQp85GIxQCe+NY jJsDYbr8x8/ROuDzSq6g/957Z2nzLIQ3+dxN/DlmtgAMS1LayELDyHqJAiHWM9wDgNM6 fyeeWaQVjO0EMFLM5xM+cacK5t7eCP+f32syGF1DmNvwkPl8VGxqJp8uitykvxj6/Cv9 auBmNcU/caeAdqZEMHXU9pbdUVDcv+rK+kV1VfSIoyfeDxPiaFKaqAPQsJX0wOumHazC AznA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:from:subject :references:mime-version:message-id:in-reply-to:date:sender :dkim-signature; bh=ERR2VE2oCwVj0NVrLHMHrJrZvp//bs46UVD4KXEsUV4=; b=JY+N7E3/w2LOkjZ1maDiBmfiYRKQaVRPUbtpTfyNeb5WR/Lks0t0gCGofO4XepOesq RqkVdEolrRGPuHRy/3Q/BX7CCBcEZNBZkee0nY5bAF4jz6ABk7iunW3NOeLuH1Ej0L+V 87Z+7OWmb5/pRX0V6uKhgZGLu8bwaX195/GK+d6kETJFnRl0zx5HYGFgNfx+g8D5GvqB BQflXqsBK6Y4NfwTFrCSaaNRRLeeiXLLh6yhLbAbqoX6J5wwaqtjm9rdRfNVFJyasox2 hMbBbRR9ZmAitbpF1QMTGfBh8ugRJoVc+eviGK8UKTHQYlRgceriyjeOz1vrNBbh24Er r1sQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=kGo+noPT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m15si5315966edp.363.2020.12.17.17.00.13; Thu, 17 Dec 2020 17:00:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=kGo+noPT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732074AbgLRAZW (ORCPT + 99 others); Thu, 17 Dec 2020 19:25:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728179AbgLRAZW (ORCPT ); Thu, 17 Dec 2020 19:25:22 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9E38C061794 for ; Thu, 17 Dec 2020 16:24:41 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id m203so533793ybf.1 for ; Thu, 17 Dec 2020 16:24:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc:content-transfer-encoding; bh=ERR2VE2oCwVj0NVrLHMHrJrZvp//bs46UVD4KXEsUV4=; b=kGo+noPT2sAcMd9H4DHcFIPyvTbkVbBAZXLSRZGw92t40O6jtpQ1pVyIsyVdt/EG1O kB2HpGKjev7+TPuMeWx9py1VLcPFBxqGVDMMHkrcVA8O9VHU2Xb+HjmoClG2L+KlBDb3 mQpC281cO1ZSrRuj4nL0zI3rEChn24EiDyuwL0WZ3ia9eaMMUEhC96Z0hjYY5FiqhNiy s73i34Blc94eiBPAPtC4hiG4HAvhuO0rmRwZNV5G6df847xe/pOxBbTEnLoZK9BRrFUH zAPODaE3aZi/5c+v+R+Dv/mM1tIUbV1vpQBh4BzAhFTRdHFUFjFd2BLcgZzkvvkBF6GL 40Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc:content-transfer-encoding; bh=ERR2VE2oCwVj0NVrLHMHrJrZvp//bs46UVD4KXEsUV4=; b=f/d6JLaB5ox3o3H+nNQHb2aKL4vD5z2d+9/1AHH6paGLZmxpCdSimnbPPbai32TIul bZYFBOwAmW4Mohhuc3SfWZeqHWdIGT8dItxI8B9IKsXDb+kEYW/CEftb3xw5ppfp/HDH QEJBgqybEHunYvR+Qu11Kuy/nSKRRAu2irtt1OpHclRc0GLX8U0IDnsRXQk8aK5JZyvY 4FUvH2hVMxvj8PP0R9yRNO3MtPQ3ZKZBG3tJwFY1/lQKIraiIFc8jP3C7vxm/RQVSFSd ucd5n4uJ42Bucru/MJJVscXb0sB7Bipt/Q7IuDrAC9L+/GSezt7GmkRglBt62BW4gVNN tWnQ== X-Gm-Message-State: AOAM530cYJcaH5IJ1DdTQvbUiX6pn0DBn/ni0VEjDxApms3QmlMmKQgZ FSyAFYl3dBYZcTVSR3Zyn0dtXTfXD1Cflrc25kg= Sender: "ndesaulniers via sendgmr" X-Received: from ndesaulniers1.mtv.corp.google.com ([2620:15c:211:202:f693:9fff:fef4:4d25]) (user=ndesaulniers job=sendgmr) by 2002:a5b:b0b:: with SMTP id z11mr2665128ybp.164.1608251080932; Thu, 17 Dec 2020 16:24:40 -0800 (PST) Date: Thu, 17 Dec 2020 16:24:32 -0800 In-Reply-To: Message-Id: <20201218002432.788499-1-ndesaulniers@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.2.684.gfbc64c5ab5-goog Subject: [PATCH v2] arm64: link with -z norelro for LLD or aarch64-elf From: Nick Desaulniers To: Catalin Marinas , Will Deacon Cc: kernel-team , Peter Smith , clang-built-linux , stable , Ard Biesheuvel , "=?UTF-8?q?F=C4=81ng-ru=C3=AC=20S=C3=B2ng?=" , Quentin Perret , Alan Modra , Nick Desaulniers , "kernelci . org bot" , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With GNU binutils 2.35+, linking with BFD produces warnings for vmlinux: aarch64-linux-gnu-ld: warning: -z norelro ignored BFD can produce this warning when the target emulation mode does not support RELRO program headers, and -z relro or -z norelro is passed. Alan Modra clarifies: The default linker emulation for an aarch64-linux ld.bfd is -maarch64linux, the default for an aarch64-elf linker is -maarch64elf. They are not equivalent. If you choose -maarch64elf you get an emulation that doesn't support -z relro. The ARCH=3Darm64 kernel prefers -maarch64elf, but may fall back to -maarch64linux based on the toolchain configuration. LLD will always create RELRO program header regardless of target emulation. To avoid the above warning when linking with BFD, pass -z norelro only when linking with LLD or with -maarch64linux. Cc: Alan Modra Cc: F=C4=81ng-ru=C3=AC S=C3=B2ng Fixes: 3b92fa7485eb ("arm64: link with -z norelro regardless of CONFIG_RELO= CATABLE") Reported-by: kernelci.org bot Reported-by: Quentin Perret Acked-by: Ard Biesheuvel Signed-off-by: Nick Desaulniers --- Changes V1 -> V2: * s/relocation types/program headers/ * s/newer GNU binutils/GNU binutils 2.35+/ * Pick up Ard's Ack. Note: maintainers may want to pick up the following tag: Fixes: 3bbd3db86470 ("arm64: relocatable: fix inconsistencies in linker scr= ipt and options") or drop the existing fixes tag (this patch is more so in response to change to BFD to warn than fix a kernel regression, IMO, but I don't care). Either way, it would be good to fix this for the newly minted v5.10.y. I'll probably be offline for the next two weeks for the holidays, so no promises on quick replies. Happy holidays+new year! arch/arm64/Makefile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile index 6be9b3750250..90309208bb28 100644 --- a/arch/arm64/Makefile +++ b/arch/arm64/Makefile @@ -10,7 +10,7 @@ # # Copyright (C) 1995-2001 by Russell King =20 -LDFLAGS_vmlinux :=3D--no-undefined -X -z norelro +LDFLAGS_vmlinux :=3D--no-undefined -X =20 ifeq ($(CONFIG_RELOCATABLE), y) # Pass --no-apply-dynamic-relocs to restore pre-binutils-2.27 behaviour @@ -115,16 +115,20 @@ KBUILD_CPPFLAGS +=3D -mbig-endian CHECKFLAGS +=3D -D__AARCH64EB__ # Prefer the baremetal ELF build target, but not all toolchains include # it so fall back to the standard linux version if needed. -KBUILD_LDFLAGS +=3D -EB $(call ld-option, -maarch64elfb, -maarch64linuxb) +KBUILD_LDFLAGS +=3D -EB $(call ld-option, -maarch64elfb, -maarch64linuxb -= z norelro) UTS_MACHINE :=3D aarch64_be else KBUILD_CPPFLAGS +=3D -mlittle-endian CHECKFLAGS +=3D -D__AARCH64EL__ # Same as above, prefer ELF but fall back to linux target if needed. -KBUILD_LDFLAGS +=3D -EL $(call ld-option, -maarch64elf, -maarch64linux) +KBUILD_LDFLAGS +=3D -EL $(call ld-option, -maarch64elf, -maarch64linux -z = norelro) UTS_MACHINE :=3D aarch64 endif =20 +ifeq ($(CONFIG_LD_IS_LLD), y) +KBUILD_LDFLAGS +=3D -z norelro +endif + CHECKFLAGS +=3D -D__aarch64__ =20 ifeq ($(CONFIG_DYNAMIC_FTRACE_WITH_REGS),y) --=20 2.29.2.684.gfbc64c5ab5-goog