From patchwork Thu Dec 17 00:40:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nick Desaulniers X-Patchwork-Id: 344914 Delivered-To: patch@linaro.org Received: by 2002:a17:906:4755:0:0:0:0 with SMTP id j21csp792121ejs; Wed, 16 Dec 2020 16:41:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJwF6myNORv6jCz43n5lCYyRXuV2VnhvaEDnAIQiRK5SN10lKnPXa7X6KSUcOZav7PCb9Ue2 X-Received: by 2002:a17:906:878d:: with SMTP id za13mr32808757ejb.395.1608165708631; Wed, 16 Dec 2020 16:41:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608165708; cv=none; d=google.com; s=arc-20160816; b=PjH1DYJcHoYg1aVY0iwsxVfA+yQWpLwvUTl4Leghqj4ujepZczKNQuk/9ga4axQWo2 OAEtQ9xD+tPBx7eC8x0caRc/ICkVxzME0nu7RDP9FovaM63/DzZsL3RCopRS46bk9QEh eqlVraF2Ubg6l+fhl3woa3WvVMzQigp3L/2lZ/bZkIuPLJU7q+J4QH0c4MGRA9gctvdU zSgnohEK1xIHqeb8JQ30oZ6cRTnOg4VvhMgZmxa3ipWSXEHXq/hQ+lGJJwDZTLMRr0uG Ra3AkAyWsdviKXXRvG2kj81fpDySAcYgDMWXXfAO1ILwjqMQe+YBsOmXofUni6GzbU71 U31Q== 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=nQgcH8JHZsnhKqD6NfgVnumKz059kSgcZknDGcmmB+s=; b=RJHGwZy1yhsASTMKp/FExA7LDLuw8+WlYXN02NB9Gz6luYhLp10NxWS2rlw4885XC9 DPKnVOJXnqSLz6LrJXKSaKTdIuNnZazmKr1sE3XlQCY4KEWc/CSESQ6F+LXzxCRpuuZc z3UNhiNcHggPhblHexUi9eBmvzNMkPXy4RJSgujCx2/CNNT2xVBcX74DI6TYgqanQH4q 2KVDuU5SlQjqCxSumPBH7sqsPERhDU9kQ4jeT0fuxebhxhVPWwwlZnqvrwumCDm2cQfY Wifrtvkn4KAoLZrGU554r9bXvFz4RyBtuaT8jYDajBoU7Dl8yif83Xew+JXxYfv0dG7e kpzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=EPE7cvqG; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-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 c7si3286853edr.193.2020.12.16.16.41.48; Wed, 16 Dec 2020 16:41:48 -0800 (PST) Received-SPF: pass (google.com: domain of stable-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=EPE7cvqG; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-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 S1725889AbgLQAlr (ORCPT + 14 others); Wed, 16 Dec 2020 19:41:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725840AbgLQAlr (ORCPT ); Wed, 16 Dec 2020 19:41:47 -0500 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D78BCC06179C for ; Wed, 16 Dec 2020 16:41:06 -0800 (PST) Received: by mail-yb1-xb4a.google.com with SMTP id m203so9951446ybf.1 for ; Wed, 16 Dec 2020 16:41:06 -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=nQgcH8JHZsnhKqD6NfgVnumKz059kSgcZknDGcmmB+s=; b=EPE7cvqG1CwG1U3Og2cZeOASwzVU7A+l3tQlQ2Q1Qj+umQaGHp3C5Fzz5bGK0Crd04 /n0YTZKkbnJr55TZON2xRNoUuFq97eIpqlag40vlkNDS9th2edu7BRoJnTUF+LPOl8rU 5QaH44QM+D7Kwn3CKIxtIUPM9XYOv/kqIUwu885gR114fRktV2zSCPew4FsWlE4Rnrqj Sef/7Zkk91vRjq1xBxnjAM/t8D+kC9wSde//oqYHh2BBIY2f/0vJh1lY1ypqnmuM7/Hi +/2Bf97sUoUrVjttz+wvnStPfEKtpMxMUPz5lBve+Tqg6wmZ2Ta5IY6wJaVGLQbdGFHN YyZQ== 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=nQgcH8JHZsnhKqD6NfgVnumKz059kSgcZknDGcmmB+s=; b=AaxZffDGQP3wrHlEQjjNumFR/IwG7nUx23ME0ilDpadP4PzKx9fCNs+szEMyLaYhyB +CchnkCE8JsX05aGTVH4jJtOB+AXPLh0/EZf6TWuErt45ltXIfRpcPHADRlT//CrGQ1R 9VK4Mf0a8cF4TstFXqHREnsi6dpFo7MhuNF/vy4b1NQsh5WouTO7uid5kx7A/xNeztYs wPLilS5r+15+dP5PUPPoIGeUp6hL2sYCGnzxXkG9Qm+f7OYFfsW/kNbRSx/c41o5iiBK jXmDn4/xJaIK288XMqyC3RfK/2ZmzadrACIhzYiZ4iq1X4LJVNh33ClMRNisRDa7O6ej aK0g== X-Gm-Message-State: AOAM531dNdbT4e8HS5mIthTCeqW1Nl35s1F8hDhpsA6oA91dHMBRYkWb LZK50imjY39XbmSjiK5VZS4uVFDag/cjyM97tN8= 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:a25:ed7:: with SMTP id 206mr50304845ybo.136.1608165666117; Wed, 16 Dec 2020 16:41:06 -0800 (PST) Date: Wed, 16 Dec 2020 16:40:51 -0800 In-Reply-To: Message-Id: <20201217004051.1247544-1-ndesaulniers@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.2.684.gfbc64c5ab5-goog Subject: [PATCH] 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 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org With newer GNU binutils, 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 relocation types, 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=arm64 kernel prefers -maarch64elf, but may fall back to -maarch64linux based on the toolchain configuration. LLD will always create RELRO relocation types 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: Ard Biesheuvel Cc: Fāng-ruì Sòng Fixes: 3b92fa7485eb ("arm64: link with -z norelro regardless of CONFIG_RELOCATABLE") Reported-by: kernelci.org bot Reported-by: Quentin Perret Signed-off-by: Nick Desaulniers --- arch/arm64/Makefile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) -- 2.29.2.684.gfbc64c5ab5-goog Acked-by: Ard Biesheuvel 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 -LDFLAGS_vmlinux :=--no-undefined -X -z norelro +LDFLAGS_vmlinux :=--no-undefined -X ifeq ($(CONFIG_RELOCATABLE), y) # Pass --no-apply-dynamic-relocs to restore pre-binutils-2.27 behaviour @@ -115,16 +115,20 @@ KBUILD_CPPFLAGS += -mbig-endian CHECKFLAGS += -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 += -EB $(call ld-option, -maarch64elfb, -maarch64linuxb) +KBUILD_LDFLAGS += -EB $(call ld-option, -maarch64elfb, -maarch64linuxb -z norelro) UTS_MACHINE := aarch64_be else KBUILD_CPPFLAGS += -mlittle-endian CHECKFLAGS += -D__AARCH64EL__ # Same as above, prefer ELF but fall back to linux target if needed. -KBUILD_LDFLAGS += -EL $(call ld-option, -maarch64elf, -maarch64linux) +KBUILD_LDFLAGS += -EL $(call ld-option, -maarch64elf, -maarch64linux -z norelro) UTS_MACHINE := aarch64 endif +ifeq ($(CONFIG_LD_IS_LLD), y) +KBUILD_LDFLAGS += -z norelro +endif + CHECKFLAGS += -D__aarch64__ ifeq ($(CONFIG_DYNAMIC_FTRACE_WITH_REGS),y)