Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp217639pxj; Thu, 20 May 2021 07:55:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnQp9oesQqiH3XMsKu/sPh5G6Wf3ynrVuZMnLZuQVKI7B5i8yaBnZoOBWqISK8KrX2DZkP X-Received: by 2002:a05:6402:30a2:: with SMTP id df2mr5315155edb.176.1621522505239; Thu, 20 May 2021 07:55:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621522505; cv=none; d=google.com; s=arc-20160816; b=uWa9CUB67kh5ELSTJwng7WaVKWEcjjnHS1+tF+Fl1DLG66TJ0L0vknx8UfCYeiGy7w 3uYD4EEsPAUxHXNeVKe8hBILgTwsKIcJT+RyVBIgYWumJbkAwbxfg6iHItgUKHPFlcEW VvvXdIQ9S2Q7P94ZDKWJBM9cPEChcXDRrellu6c8hzJn4McjXZpe8M4/cqv8e2cQpEVP wmO9TJg+xlDDa83yc+onbubGdSZ99Xq9JQjMa8eQT9kzLwJTG9sX9uM1hWaLD17M0iQx +rv2HnuwSm0Ep9+Jo3rJbUtpQUFhjKBKndgOq4wyGE08t7dxbRgWK9PUfEJCFl9ihJOh OyPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Fvg7oqfnfE00mpyHDERE8rztmCEMMbIM70TGIE6OnNc=; b=KaENV5xHcbEsWbarBdNsgZUzdMVuJQ/E+cSz1nNkXzfz9Hphf+VdK4EuqwODT++7/U jI5UiWWK4bi1XjAayoPyJKnnO65tvJYxvWl1vMU71ziAE4o/DDf3+tTZnHWjCME8fEh1 /dMmGFT7TF6JA9LdIo1ZwqajqUIVtZJ2pTCVmaSpf7DkIsWzcqvFiRon8UDzodi3OGKk ynusdtZvV9i+DFMtjEmV5xUSy3PHOlijdajHRQVWrkJD+1GfgpsfbnJGxDuoCRBP0vaJ 6neGeo4127hTdyn9QeRRrsRLvhesYgc1V9/Z3H/UD18ClB3ntJ8bcWikQDGOSSv04ZA7 Rlxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Um/Go0/t"; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j20si1977706edq.307.2021.05.20.07.54.40; Thu, 20 May 2021 07:55:05 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b="Um/Go0/t"; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231741AbhETJ0y (ORCPT + 99 others); Thu, 20 May 2021 05:26:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:52996 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231733AbhETJ0a (ORCPT ); Thu, 20 May 2021 05:26:30 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A7D1B61358; Thu, 20 May 2021 09:25:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621502709; bh=ew4M8HlQkJCi7mRSE24rJFwi4BQphLpJSQz2xNFxnQE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Um/Go0/tFY0HHdvhSQCrFNwb1LJJyNxLDK+iRUxm7BjE0jtFYkm7nG+ajnRm4ZM8c N02lo6l/iDQAGhjHW9lel8/pGhb9XK51L0ngV9HEHVz5wZ3+oW5NxjPA2/jF25GGUs Eqc7ip3HqJZ4tEHq8cGQxXsVA5mGJ8WbbrDeevlc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nathan Chancellor , Fangrui Song , Palmer Dabbelt , Sasha Levin Subject: [PATCH 5.12 23/45] riscv: Use $(LD) instead of $(CC) to link vDSO Date: Thu, 20 May 2021 11:22:11 +0200 Message-Id: <20210520092054.270508163@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092053.516042993@linuxfoundation.org> References: <20210520092053.516042993@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nathan Chancellor [ Upstream commit 7f3d349065d0c643f7f7013fbf9bc9f2c90b675f ] Currently, the VDSO is being linked through $(CC). This does not match how the rest of the kernel links objects, which is through the $(LD) variable. When linking with clang, there are a couple of warnings about flags that will not be used during the link: clang-12: warning: argument unused during compilation: '-no-pie' [-Wunused-command-line-argument] clang-12: warning: argument unused during compilation: '-pg' [-Wunused-command-line-argument] '-no-pie' was added in commit 85602bea297f ("RISC-V: build vdso-dummy.o with -no-pie") to override '-pie' getting added to the ld command from distribution versions of GCC that enable PIE by default. It is technically no longer needed after commit c2c81bb2f691 ("RISC-V: Fix the VDSO symbol generaton for binutils-2.35+"), which removed vdso-dummy.o in favor of generating vdso-syms.S from vdso.so with $(NM) but this also resolves the issue in case it ever comes back due to having full control over the $(LD) command. '-pg' is for function tracing, it is not used during linking as clang states. These flags could be removed/filtered to fix the warnings but it is easier to just match the rest of the kernel and use $(LD) directly for linking. See commits fe00e50b2db8 ("ARM: 8858/1: vdso: use $(LD) instead of $(CC) to link VDSO") 691efbedc60d ("arm64: vdso: use $(LD) instead of $(CC) to link VDSO") 2ff906994b6c ("MIPS: VDSO: Use $(LD) instead of $(CC) to link VDSO") 2b2a25845d53 ("s390/vdso: Use $(LD) instead of $(CC) to link vDSO") for more information. The flags are converted to linker flags and '--eh-frame-hdr' is added to match what is added by GCC implicitly, which can be seen by adding '-v' to GCC's invocation. Additionally, since this area is being modified, use the $(OBJCOPY) variable instead of an open coded $(CROSS_COMPILE)objcopy so that the user's choice of objcopy binary is respected. Link: https://github.com/ClangBuiltLinux/linux/issues/803 Link: https://github.com/ClangBuiltLinux/linux/issues/970 Signed-off-by: Nathan Chancellor Reviewed-by: Fangrui Song Signed-off-by: Palmer Dabbelt Signed-off-by: Sasha Levin --- arch/riscv/kernel/vdso/Makefile | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/arch/riscv/kernel/vdso/Makefile b/arch/riscv/kernel/vdso/Makefile index 71a315e73cbe..ca2b40dfd24b 100644 --- a/arch/riscv/kernel/vdso/Makefile +++ b/arch/riscv/kernel/vdso/Makefile @@ -41,11 +41,10 @@ KASAN_SANITIZE := n $(obj)/vdso.o: $(obj)/vdso.so # link rule for the .so file, .lds has to be first -SYSCFLAGS_vdso.so.dbg = $(c_flags) $(obj)/vdso.so.dbg: $(src)/vdso.lds $(obj-vdso) FORCE $(call if_changed,vdsold) -SYSCFLAGS_vdso.so.dbg = -shared -s -Wl,-soname=linux-vdso.so.1 \ - -Wl,--build-id=sha1 -Wl,--hash-style=both +LDFLAGS_vdso.so.dbg = -shared -s -soname=linux-vdso.so.1 \ + --build-id=sha1 --hash-style=both --eh-frame-hdr # We also create a special relocatable object that should mirror the symbol # table and layout of the linked DSO. With ld --just-symbols we can then @@ -60,13 +59,10 @@ $(obj)/%.so: $(obj)/%.so.dbg FORCE # actual build commands # The DSO images are built using a special linker script -# Add -lgcc so rv32 gets static muldi3 and lshrdi3 definitions. # Make sure only to export the intended __vdso_xxx symbol offsets. quiet_cmd_vdsold = VDSOLD $@ - cmd_vdsold = $(CC) $(KBUILD_CFLAGS) $(call cc-option, -no-pie) -nostdlib -nostartfiles $(SYSCFLAGS_$(@F)) \ - -Wl,-T,$(filter-out FORCE,$^) -o $@.tmp && \ - $(CROSS_COMPILE)objcopy \ - $(patsubst %, -G __vdso_%, $(vdso-syms)) $@.tmp $@ && \ + cmd_vdsold = $(LD) $(ld_flags) -T $(filter-out FORCE,$^) -o $@.tmp && \ + $(OBJCOPY) $(patsubst %, -G __vdso_%, $(vdso-syms)) $@.tmp $@ && \ rm $@.tmp # Extracts symbol offsets from the VDSO, converting them into an assembly file -- 2.30.2