Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2842028imm; Sun, 5 Aug 2018 13:38:12 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcITc4dXn38ANno62nkp34V6n6Vp4ef+x0Zxk7fv9FmEMxibjt6sAZ6SF18wRX3+Ak0RC7/ X-Received: by 2002:a63:571d:: with SMTP id l29-v6mr11578539pgb.296.1533501492011; Sun, 05 Aug 2018 13:38:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533501491; cv=none; d=google.com; s=arc-20160816; b=clWnoBI5sjdYarGX6KerqTuhplrnuE9J7Lsj9MlKey9nEElGjaj9GdmQZILW3OQFql tYiSqkkfkF6ZVjtuIh/pX0z+qYi3dpxWzssdIX/QOP1BypT7aFMN3c06K2xyM4fgcXyb kNGIipImviqsI+D25e6p+T1DOuEJjkqSYXE3QUfVs0Unra3rdbHPdOWPfBDQoSlimQUD iluZzhnRCAZgsAtgvoAQoAe2TF5yDcL3HZ2I5mS5b+fZ4jBGGqpM2k+fIWd2hKoC67bZ LMPVR7Es/uoDN8yMaqtT9zWOgbjMVw7IKteYT6eZNIcBpN/7F9TaBqKc57cE1b4f/lC5 4vdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=VdRPFr6Hw4/YZ+4HqH5cQjVpo3eK/vXvt/gP+IfpLlA=; b=fPrCIViwZJYgjE26eB1wW2KIDfYiAdbPZonCY6DoM706h5Ka9dejcTvmsPc8/LPiHH wBwBODzIj5DJG7hsCqqhk/VCIBY0ODTHirY/Ivmw/duwPaOuhaXjOEoZlSIuQuyhWCbU YgjaBUHHTUGLTA/YVn3bF2MaGsxpwBSbWc6/67H1mAOukV0FZkD5HZJt6GCI1vGsBELK 2U+wPS+zJWEouq6JuM546zxWCrEb9l0W5bn2aSbZBq93Es7Dk695QGaSxBQUc3XwdVZ/ XepiKmKvmLWQTVlQ9q4tY+7m9gMftvtDwweeG6ESe1cMQwvAeghuk65MO5Y37nzuOPEa KiyQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m2-v6si8252582plt.259.2018.08.05.13.37.57; Sun, 05 Aug 2018 13:38:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727083AbeHEWms (ORCPT + 99 others); Sun, 5 Aug 2018 18:42:48 -0400 Received: from terminus.zytor.com ([198.137.202.136]:42081 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726769AbeHEWms (ORCPT ); Sun, 5 Aug 2018 18:42:48 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w75KaopA591449 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 5 Aug 2018 13:36:50 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w75KaoGg591446; Sun, 5 Aug 2018 13:36:50 -0700 Date: Sun, 5 Aug 2018 13:36:50 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Alistair Strachan Message-ID: Cc: mingo@kernel.org, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, hpa@zytor.com, astrachan@google.com, tglx@linutronix.de, andi.kleen@intel.com, luto@kernel.org Reply-To: luto@kernel.org, andi.kleen@intel.com, tglx@linutronix.de, astrachan@google.com, gregkh@linuxfoundation.org, hpa@zytor.com, linux-kernel@vger.kernel.org, mingo@kernel.org In-Reply-To: <20180803173931.117515-1-astrachan@google.com> References: <20180803173931.117515-1-astrachan@google.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/vdso] x86: vdso: Use $LD instead of $CC to link Git-Commit-ID: 379d98ddf41344273d9718556f761420f4dc80b3 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, T_DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 379d98ddf41344273d9718556f761420f4dc80b3 Gitweb: https://git.kernel.org/tip/379d98ddf41344273d9718556f761420f4dc80b3 Author: Alistair Strachan AuthorDate: Fri, 3 Aug 2018 10:39:31 -0700 Committer: Thomas Gleixner CommitDate: Sun, 5 Aug 2018 22:33:50 +0200 x86: vdso: Use $LD instead of $CC to link The vdso{32,64}.so can fail to link with CC=clang when clang tries to find a suitable GCC toolchain to link these libraries with. /usr/bin/ld: arch/x86/entry/vdso/vclock_gettime.o: access beyond end of merged section (782) This happens because the host environment leaked into the cross compiler environment due to the way clang searches for suitable GCC toolchains. Clang is a retargetable compiler, and each invocation of it must provide --target= --gcc-toolchain= to allow it to find the correct binutils for cross compilation. These flags had been added to KBUILD_CFLAGS, but the vdso code uses CC and not KBUILD_CFLAGS (for various reasons) which breaks clang's ability to find the correct linker when cross compiling. Most of the time this goes unnoticed because the host linker is new enough to work anyway, or is incompatible and skipped, but this cannot be reliably assumed. This change alters the vdso makefile to just use LD directly, which bypasses clang and thus the searching problem. The makefile will just use ${CROSS_COMPILE}ld instead, which is always what we want. This matches the method used to link vmlinux. This drops references to DISABLE_LTO; this option doesn't seem to be set anywhere, and not knowing what its possible values are, it's not clear how to convert it from CC to LD flag. Signed-off-by: Alistair Strachan Signed-off-by: Thomas Gleixner Acked-by: Andy Lutomirski Cc: "H. Peter Anvin" Cc: Greg Kroah-Hartman Cc: kernel-team@android.com Cc: joel@joelfernandes.org Cc: Andi Kleen Link: https://lkml.kernel.org/r/20180803173931.117515-1-astrachan@google.com --- arch/x86/entry/vdso/Makefile | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile index 261802b1cc50..42c6c1bea4f4 100644 --- a/arch/x86/entry/vdso/Makefile +++ b/arch/x86/entry/vdso/Makefile @@ -46,10 +46,8 @@ targets += $(vdso_img_sodbg) $(vdso_img-y:%=vdso%.so) CPPFLAGS_vdso.lds += -P -C -VDSO_LDFLAGS_vdso.lds = -m64 -Wl,-soname=linux-vdso.so.1 \ - -Wl,--no-undefined \ - -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096 \ - $(DISABLE_LTO) +VDSO_LDFLAGS_vdso.lds = -m elf_x86_64 -soname linux-vdso.so.1 --no-undefined \ + -z max-page-size=4096 -z common-page-size=4096 $(obj)/vdso64.so.dbg: $(obj)/vdso.lds $(vobjs) FORCE $(call if_changed,vdso) @@ -95,10 +93,8 @@ CFLAGS_REMOVE_vvar.o = -pg # CPPFLAGS_vdsox32.lds = $(CPPFLAGS_vdso.lds) -VDSO_LDFLAGS_vdsox32.lds = -Wl,-m,elf32_x86_64 \ - -Wl,-soname=linux-vdso.so.1 \ - -Wl,-z,max-page-size=4096 \ - -Wl,-z,common-page-size=4096 +VDSO_LDFLAGS_vdsox32.lds = -m elf32_x86_64 -soname linux-vdso.so.1 \ + -z max-page-size=4096 -z common-page-size=4096 # x32-rebranded versions vobjx32s-y := $(vobjs-y:.o=-x32.o) @@ -123,7 +119,7 @@ $(obj)/vdsox32.so.dbg: $(obj)/vdsox32.lds $(vobjx32s) FORCE $(call if_changed,vdso) CPPFLAGS_vdso32.lds = $(CPPFLAGS_vdso.lds) -VDSO_LDFLAGS_vdso32.lds = -m32 -Wl,-m,elf_i386 -Wl,-soname=linux-gate.so.1 +VDSO_LDFLAGS_vdso32.lds = -m elf_i386 -soname linux-gate.so.1 targets += vdso32/vdso32.lds targets += vdso32/note.o vdso32/system_call.o vdso32/sigreturn.o @@ -157,13 +153,13 @@ $(obj)/vdso32.so.dbg: FORCE \ # The DSO images are built using a special linker script. # quiet_cmd_vdso = VDSO $@ - cmd_vdso = $(CC) -nostdlib -o $@ \ + cmd_vdso = $(LD) -nostdlib -o $@ \ $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \ - -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \ + -T $(filter %.lds,$^) $(filter %.o,$^) && \ sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@' -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=both) \ - $(call cc-ldoption, -Wl$(comma)--build-id) -Wl,-Bsymbolic $(LTO_CFLAGS) +VDSO_LDFLAGS = -shared $(call ld-option, --hash-style=both) \ + $(call ld-option, --build-id) -Bsymbolic GCOV_PROFILE := n #