Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2479950yba; Mon, 15 Apr 2019 12:31:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqz0jw1s0eYcUa1jHqm4HWD/Rrl6CLapMfy06f5gi+u5LeuLzpxop1Ps/Z5jO+oMRJ3sNZSh X-Received: by 2002:a63:330e:: with SMTP id z14mr70326129pgz.4.1555356684399; Mon, 15 Apr 2019 12:31:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555356684; cv=none; d=google.com; s=arc-20160816; b=azpqYIUbR6ztYeQb/NHsrwXutM8b6ZdZ5Vn5BtbBpBVkd9YHnKldFxu03r/OtduKrn s8ZCkJ4cDA1xRqpHFEsXYx0BgTEXnIfX09yp0ozEewoG4HDJRUYlV2Zub1MThejdtkhw 5jH/s62LMxJSgIS7jPS6pIo3gL9qPhzn6al716GDlyhFE6Cmjct8b1/15CQn7Pu5gXyN X7QGzacyj77JhgugG0YaY4BX+PiT8LwumNNgbTWYyk4+du939xXcH4ekoVX50w1cI3X6 SSiSvHRXbhy0pftueHMAfVT1v5myJDFWBt1a21aDw6l2P6wQ2X7mdh4ZFxBtIBv7oyEj b6Fw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0VyO4RIZIsJJ+B4fcpwuMlx9tpbY/2oM+K+ba4FDRFs=; b=ft6E/naGLbR3FLZ/9rXnUbWhJs8/08SqEOZm29/PTASSiP2F3jIynngzK1pAR6Ugh5 7emQIxMR79zur4MWF8s5OXfBDYpYnZA7jK++hq7jjWPKZcLBnwIos1KO00wqxk2kKi62 bUKXKmdpmmKSfuCMZogcNEcJu8/+x1tVsVDJ0yUCuetbavuSO4OIHZ0TOtMB+PtiZKOI k5flCbjh8uxVa1cGQMwMLWwEZOMpNypmECDgXuBubb66Y+3Ziat5iqY217M1UR1V0MUo 4TcXnj28q/1k14rST7Fxeg6geRuRMu/MT1PIQTyj3hkkCz/r2pJNg6l75gsGpa5IY2Xk mIhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fjKWjjCB; 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 c10si47106898pfg.172.2019.04.15.12.31.07; Mon, 15 Apr 2019 12:31:24 -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; dkim=pass header.i=@kernel.org header.s=default header.b=fjKWjjCB; 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 S1728583AbfDOTCN (ORCPT + 99 others); Mon, 15 Apr 2019 15:02:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:60930 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728528AbfDOTCI (ORCPT ); Mon, 15 Apr 2019 15:02:08 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7C07220880; Mon, 15 Apr 2019 19:02:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555354927; bh=BdBY7f36xXKhSzZBeDcMW7F0qpD1zayM0QZpo5oN3X8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fjKWjjCBZNvUrQIgGUVTkxBLwbtCKAAo58vVEVlFKvUsNWBPfL+EFqUMV21IGQrc9 gnVeJY8hUEaogx2ep8S6/gSPMPWYcl4J67YBE5MYM+ImzCHQthBG5sBCWCBPPHEmdG lYBH9FjEKzdrP2JgGVn2rfSp/jZGrKBGB2+H/t6w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alistair Strachan , Thomas Gleixner , Andy Lutomirski , "H. Peter Anvin" , kernel-team@android.com, joel@joelfernandes.org, Andi Kleen , Nathan Chancellor , Sasha Levin Subject: [PATCH 4.14 09/69] x86: vdso: Use $LD instead of $CC to link Date: Mon, 15 Apr 2019 20:58:27 +0200 Message-Id: <20190415183728.632579553@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190415183726.036654568@linuxfoundation.org> References: <20190415183726.036654568@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org commit 379d98ddf41344273d9718556f761420f4dc80b3 upstream. 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 Signed-off-by: Nathan Chancellor Signed-off-by: Sasha Levin --- 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 0a550dc5c525..0defcc939ab4 100644 --- a/arch/x86/entry/vdso/Makefile +++ b/arch/x86/entry/vdso/Makefile @@ -48,10 +48,8 @@ targets += $(vdso_img_sodbg) export 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: $(src)/vdso.lds $(vobjs) FORCE $(call if_changed,vdso) @@ -103,10 +101,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 # 64-bit objects to re-brand as x32 vobjs64-for-x32 := $(filter-out $(vobjs-nox32),$(vobjs-y)) @@ -134,7 +130,7 @@ $(obj)/vdsox32.so.dbg: $(src)/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 # This makes sure the $(obj) subdirectory exists even though vdso32/ # is not a kbuild sub-make subdirectory. @@ -180,13 +176,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 # -- 2.19.1