Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3017215ybt; Mon, 29 Jun 2020 13:01:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYf+95w39ivvOhd4ocWwuuxzjPlX61lzgGde+eSSCmFoeec2UcZJj5EZdXW9K5fOiWUgh5 X-Received: by 2002:a17:906:f1d5:: with SMTP id gx21mr15022878ejb.121.1593460903791; Mon, 29 Jun 2020 13:01:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593460903; cv=none; d=google.com; s=arc-20160816; b=mdIBsLxtxGjUQiriJunpgoFfxZqc+W1j7hYKZNj7N9wN/rBGEKe+r+nvMKg8R92prq C6AMLyP0uZAF10nGNmqa53Nokqx6rPQhtuWCXDZ/HnfmlXPT336wOWjpW5/5xMEz7ZCB A3l5RjJaTZXKpTlfPo6L+4aXSbtYCvAgLTKvWPSqRyxfcKfBoer9yulBidFH0p3WlxvO 8a48Xw/NGU50YZTGH3HqpUjk8QJI73yzznoBVISpzv6aJRgt3Lk3Am4TKejHmX+YmdmL 6XKEnbPOf+1aCUWhZeOOMeUvgwOZHNvPQvAY315gb0Mr7WMPUREf7v0YIo6wtO7Dc9TY svZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3JgnEGcDwXpsASk6okxZ3uhf6AfousRHMh8U1fKtYMg=; b=L+GrUGNcH0cs7pvcuFOqLd79XEdtocPqnM/dMdi3tOqvPUOUouyDWzl8x6tGMXFsr/ uiWu7kRg3Wrj2lv45HczcNVJYFMSOKi1Zc2GjV0jVM5/7/IP7vGaxoeZ6rHjEyLgSIul Ar95BI2Pj/ZHEUaIj4rDHU8B7rfBkrHpUpU6Z+urCDpcTFYte01GTgRUIva+O8znktlj 1EJGCoFnURHj48uiBfKM7nYxITgQcIsbCNgXM7LcIgy+5+2rSLvxK8f820xwRbMaIGMM zscKrOtcgpr544p7uMdBcgMDpC4n1j8nVBFGe0UfcZjSLno3lxka80U+7By1VG2qqjJU sClA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wbeRL4tR; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a41si313154edf.30.2020.06.29.13.01.20; Mon, 29 Jun 2020 13:01:43 -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=@kernel.org header.s=default header.b=wbeRL4tR; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388510AbgF2T64 (ORCPT + 99 others); Mon, 29 Jun 2020 15:58:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:47676 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387582AbgF2TkR (ORCPT ); Mon, 29 Jun 2020 15:40:17 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 11A5C248FD; Mon, 29 Jun 2020 15:27:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593444450; bh=/yIniaPFKZ11CTcjGIIKnnQplSH1xgEGXA3jO9oQshA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wbeRL4tR7ihLCg4/rNQlrchZ306zwve4xxxg9X1/RnMaA5AGCHRgzYCf0FZ/04Ff3 Dfp/naWRwvsYO+GSSt0YcV+Cp6ec+bJaHanrsEWSQ3hdkT0FR9IuP280cWETA/xaL/ gNfYr5xtLi1YD1vyfeimyl/3DIiEI1DrpJDMJ8P0= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Nathan Chancellor , Nick Desaulniers , Heiko Carstens , Vasily Gorbik , Sasha Levin Subject: [PATCH 5.4 130/178] s390/vdso: Use $(LD) instead of $(CC) to link vDSO Date: Mon, 29 Jun 2020 11:24:35 -0400 Message-Id: <20200629152523.2494198-131-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200629152523.2494198-1-sashal@kernel.org> References: <20200629152523.2494198-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.4.50-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.4.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.4.50-rc1 X-KernelTest-Deadline: 2020-07-01T15:25+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nathan Chancellor [ Upstream commit 2b2a25845d534ac6d55086e35c033961fdd83a26 ] 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 clang is built in a default configuration, it first attempts to use the target triple's default linker, which is just ld. However, the user can override this through the CLANG_DEFAULT_LINKER cmake define so that clang uses another linker by default, such as LLVM's own linker, ld.lld. This can be useful to get more optimized links across various different projects. However, this is problematic for the s390 vDSO because ld.lld does not have any s390 emulatiom support: https://github.com/llvm/llvm-project/blob/llvmorg-10.0.1-rc1/lld/ELF/Driver.cpp#L132-L150 Thus, if a user is using a toolchain with ld.lld as the default, they will see an error, even if they have specified ld.bfd through the LD make variable: $ make -j"$(nproc)" -s ARCH=s390 CROSS_COMPILE=s390x-linux-gnu- LLVM=1 \ LD=s390x-linux-gnu-ld \ defconfig arch/s390/kernel/vdso64/ ld.lld: error: unknown emulation: elf64_s390 clang-11: error: linker command failed with exit code 1 (use -v to see invocation) Normally, '-fuse-ld=bfd' could be used to get around this; however, this can be fragile, depending on paths and variable naming. The cleaner solution for the kernel is to take advantage of the fact that $(LD) can be invoked directly, which bypasses the heuristics of $(CC) and respects the user's choice. Similar changes have been done for ARM, ARM64, and MIPS. Link: https://lkml.kernel.org/r/20200602192523.32758-1-natechancellor@gmail.com Link: https://github.com/ClangBuiltLinux/linux/issues/1041 Signed-off-by: Nathan Chancellor Reviewed-by: Nick Desaulniers [heiko.carstens@de.ibm.com: add --build-id flag] Signed-off-by: Heiko Carstens Signed-off-by: Vasily Gorbik Signed-off-by: Sasha Levin --- arch/s390/kernel/vdso64/Makefile | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/arch/s390/kernel/vdso64/Makefile b/arch/s390/kernel/vdso64/Makefile index bec19e7e6e1cf..4a66a1cb919b1 100644 --- a/arch/s390/kernel/vdso64/Makefile +++ b/arch/s390/kernel/vdso64/Makefile @@ -18,8 +18,8 @@ KBUILD_AFLAGS_64 += -m64 -s KBUILD_CFLAGS_64 := $(filter-out -m64,$(KBUILD_CFLAGS)) KBUILD_CFLAGS_64 += -m64 -fPIC -shared -fno-common -fno-builtin -KBUILD_CFLAGS_64 += -nostdlib -Wl,-soname=linux-vdso64.so.1 \ - -Wl,--hash-style=both +ldflags-y := -fPIC -shared -nostdlib -soname=linux-vdso64.so.1 \ + --hash-style=both --build-id -T $(targets:%=$(obj)/%.dbg): KBUILD_CFLAGS = $(KBUILD_CFLAGS_64) $(targets:%=$(obj)/%.dbg): KBUILD_AFLAGS = $(KBUILD_AFLAGS_64) @@ -37,8 +37,8 @@ KASAN_SANITIZE := n $(obj)/vdso64_wrapper.o : $(obj)/vdso64.so # link rule for the .so file, .lds has to be first -$(obj)/vdso64.so.dbg: $(src)/vdso64.lds $(obj-vdso64) FORCE - $(call if_changed,vdso64ld) +$(obj)/vdso64.so.dbg: $(obj)/vdso64.lds $(obj-vdso64) FORCE + $(call if_changed,ld) # strip rule for the .so file $(obj)/%.so: OBJCOPYFLAGS := -S @@ -50,8 +50,6 @@ $(obj-vdso64): %.o: %.S FORCE $(call if_changed_dep,vdso64as) # actual build commands -quiet_cmd_vdso64ld = VDSO64L $@ - cmd_vdso64ld = $(CC) $(c_flags) -Wl,-T $(filter %.lds %.o,$^) -o $@ quiet_cmd_vdso64as = VDSO64A $@ cmd_vdso64as = $(CC) $(a_flags) -c -o $@ $< -- 2.25.1