Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp846528pxu; Wed, 16 Dec 2020 16:42:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJw8iNPcu/dAHSz3PHPrHOLu3ZYEgEzn4VzYM/txp37d8p3gHBcodi7KiQ2IGRzHdYpTkPV1 X-Received: by 2002:aa7:c543:: with SMTP id s3mr9043278edr.88.1608165764078; Wed, 16 Dec 2020 16:42:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608165764; cv=none; d=google.com; s=arc-20160816; b=fqA8KAK5ZvT51dhcwxg4HXRUxLZ4/yVrPQP3v8yKDiZBYTQ2sB/yxUR1qYFHaXOJNy kX0kWKYBcHecRZOQch10IrmmOZRDtYWtZd022dvckHTjN6Q7xOzvOI/D8dVoBsnLYtEY cQBaEwIaitG3KK8G4xpDShZMFjffdqrLe+I4d6S3dDMWyTUq4ouP6hakTnnl5BNgzsc7 pkU9yoIPQFS9Ukb9lAI/LbGEcfQUb3OIWRS6bKjpNlKChuefQYXCE87OksgUGr7MwNH1 ajzIU4SjX+1bqFkYRNfRZrOnYA8CXFfQR70pCwrp0ACuLlqbOOtt7L27StkYdYp4WjVN 2ZGQ== 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=nxxigRkdWQkhwwCHYnp++h3fi9B7YVPUrVzr2I9Y5r69o0Y/XNvauI8/cOyt0ile2u KPogCIeOA5tAwzMmeo9zPnwqP3dfqmpg18ou1sO+VMDufka0yU2jtkhpKj0hssL9rIsv 9cttKJd3lxz7zB+ncBVOVoQB1FfbGpICWYS8J3vpBdAzle8fUumRuPUuSODqub2wXTP6 UHt8wiLWikfW7B9P+8fyEMegSf6mFCB1FZ/yQ7tAIAG1qTCZS+Fg8BSTBEakvd8NtSr1 xiDd63C376c7dczaQ83TwUjI+K1VmHmzxlLriYSgY350LhqOvZaOZiFs2TqxY8ePr6fr HETg== 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 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 lt15si1763065ejb.499.2020.12.16.16.42.21; Wed, 16 Dec 2020 16:42:44 -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=EPE7cvqG; 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 S1725974AbgLQAlr (ORCPT + 99 others); Wed, 16 Dec 2020 19:41:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725871AbgLQAlr (ORCPT ); Wed, 16 Dec 2020 19:41:47 -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 EA8E6C0617A6 for ; Wed, 16 Dec 2020 16:41:06 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id z62so32540522yba.23 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=A59oayArtaTLEWiOUH3Rz8sHJojJIXB2XW9F/8XffF/tHlGM8jqAmUDlYcBdTlnTqV kk4BQj2vjKcRpRZUVcZu5d3y7FedewH1hEfrhlM/gNoulCaA9GFqCeTv0+ZlT6PqUxLt ESd2XQmKX60daOOX+49SIsgQjLTKruqn/MbLfRr44boUByAyuSq+vLYl4LQymvmUIqAa VwGvy3O3BLk0cnhnfeELY2zuZqAsMIIkH9penhKyVC4UkdH74vzykYKxYHbL81kFl+4g /MCEVKfG1Ma8YaiKUqQr+9bKLQaCukuYQW3HoEI12nxfbLoT6RjzA4gv78y7xlZIanZQ UlWg== X-Gm-Message-State: AOAM533l6NOM13GghF96e6p6HXFkKuU3p2VyCvkUOmIpNwNoj/X5BZrx Te25k3f/fvUjwrqlf6B9N1Ce4CgU3EJnfalOYK4= 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 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 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=3Darm64 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=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 Signed-off-by: Nick Desaulniers --- 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