From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.4 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0825AC10F13 for ; Thu, 11 Apr 2019 03:51:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 98BFE217D4 for ; Thu, 11 Apr 2019 03:51:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GQ0VJGkq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726564AbfDKDvv (ORCPT ); Wed, 10 Apr 2019 23:51:51 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:46059 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726551AbfDKDvv (ORCPT ); Wed, 10 Apr 2019 23:51:51 -0400 Received: by mail-ed1-f65.google.com with SMTP id o26so3869035edv.12 for ; Wed, 10 Apr 2019 20:51:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=27xgBQgM1ahZImSmLW/hFog1t8F3JZWKXRh4mnQFdtU=; b=GQ0VJGkqL/7HK0z96RwCILeIUOEwXpVanwCMV6zZSCXLuq+Nl7dHmzWQGhnizt6msu FHwnhlMEtglxp1zoUshClje4vfNukrOG0DsYgxhPoA3MLIjKE2BQoP4t0rLa3WnwzmoR QAZxQYimWCHNy8kfq8z6f3t37sCbpqR4RYEbdJESib400U27mcVFXSTyHDS3BHJhIeRF y6jRn1EGLBnAAKYgtFQ51jBjxpYcW33DMIXRap0iazqfWQVrihoF9w/tbRpO635HnFqb OhChUqVNwjXQyviOhJOZtUptzdFjIcZzJKA5xaSYR4ujTfQWO9dN/t7ETIIxBXBxmQy1 DrFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=27xgBQgM1ahZImSmLW/hFog1t8F3JZWKXRh4mnQFdtU=; b=UK+n8sJalbWmGy5LlnlUGinVH+3YWy7OGpxQ5OMnCACPe7h8Su0SVV/IyfWIX6i+1b 0z1gi9OP/SAKp5LlMOyWsDwhQCCu/+ekGsnz1E35JFdUB5YQXHA411+wEn7wXQZ1qHtQ OuXd8UKD8InuFHH9f/9mlaS6US/9WHDCCsI73nE74xYGSedimv+SOglZ3ARCRVYXLK63 BEsHRttozIUG7OESmSASQK9hSi8808m7UiKYSbJxcCpoiNR0o9QLunKiobW+IzEwvsvZ 8GgLk4BkZBZSa4ocVSUjf+mFCh3wp9uZ/RI7M7upcRnCbpVd4Y59sR8s+zUwxBHnEHO3 adUg== X-Gm-Message-State: APjAAAUwiQFDMidCoTliriXUs3BnIV7l1WLnuqI2+dPFnj31eH3KW+Lr U4vvhmpDP/NlS4qHDFi/sbU= X-Google-Smtp-Source: APXvYqzxhMgavATm4xW0n2uYDEa9Ip9MlzysDFVOEmknLbUC7XAW26kygGpoMAGrtLOsOykv21txcw== X-Received: by 2002:a50:b646:: with SMTP id c6mr29376550ede.150.1554954707381; Wed, 10 Apr 2019 20:51:47 -0700 (PDT) Received: from archlinux-i9 ([2a01:4f9:2b:2b84::2]) by smtp.gmail.com with ESMTPSA id f15sm6858133eja.39.2019.04.10.20.51.45 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 10 Apr 2019 20:51:45 -0700 (PDT) Date: Wed, 10 Apr 2019 20:51:43 -0700 From: Nathan Chancellor To: Greg Kroah-Hartman , Sasha Levin Cc: stable@vger.kernel.org, Alistair Strachan , Sami Tolvanen , Nick Desaulniers Subject: LLD patches for x86_64 Message-ID: <20190411035143.GA14196@archlinux-i9> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="k+w/mQv8wyuph6w0" Content-Disposition: inline User-Agent: Mutt/1.11.4 (2019-03-13) Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org --k+w/mQv8wyuph6w0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi Greg and Sasha, Please apply the following mbox files to their respective trees. They contain upstream patches that allow a tip of tree LLD to link an x86 kernel image as well as a patch to avoid using $(LD) to check for the location of binutils, which won't always be accurate when linking with LLD. This was tested with both the upstream defconfig and Android's x86_64_cuttlefish_defconfig in their respective trees (building/linking with both Clang/LLD and GCC/ld.bfd then booting in QEMU). For 5.0, a simple cherry-pick of commit ad15006cc784 ("kbuild: clang: choose GCC_TOOLCHAIN_DIR not on LD") will do. Greg, the merge into kernel/common will result in two conflicts: * Makefile: Make the diff match upstream commit ad15006cc784 ("kbuild: clang: choose GCC_TOOLCHAIN_DIR not on LD") * arch/x86/entry/vdso/Makefile: Take the right hand side, effectively replacing common commit 35b779802c2e ("x86: vdso: Fix leaky vdso linker with CC=clang.") with the proper upstream commit 379d98ddf413 ("x86: vdso: Use $LD instead of $CC to link") Also, while you are at it, would you mind picking up upstream commit 5f074f3e192f ("lib/string.c: implement a basic bcmp")? It is cc'd for stable but it's worth mentioning now so we can stop carrying it out of tree :) Let me know if there are any issues, comments, or concerns, Nathan --k+w/mQv8wyuph6w0 Content-Type: application/mbox Content-Disposition: attachment; filename="lld-4.4.mbox" Content-Transfer-Encoding: quoted-printable =46rom 9a607e600adedd84e58205ae812974322094efe5 Mon Sep 17 00:00:00 2001=0A= =46rom: Nick Desaulniers =0ADate: Mon, 11 Feb 2019= 11:30:04 -0800=0ASubject: [PATCH 1/4] kbuild: clang: choose GCC_TOOLCHAIN_= DIR not on LD=0A=0Acommit ad15006cc78459d059af56729c4d9bed7c7fd860 upstream= =2E=0A=0AThis causes an issue when trying to build with `make LD=3Dld.lld` = if=0Ald.lld and the rest of your cross tools aren't in the same directory= =0A(ex. /usr/local/bin) (as is the case for Android's build system), as the= =0AGCC_TOOLCHAIN_DIR then gets set based on `which $(LD)` which will point= =0Awhere LLVM tools are, not GCC/binutils tools are located.=0A=0AInstead, = select the GCC_TOOLCHAIN_DIR based on another tool provided by=0Abinutils f= or which LLVM does not provide a substitute for, such as=0Aelfedit.=0A=0AFi= xes: 785f11aa595b ("kbuild: Add better clang cross build support")=0ALink: = https://github.com/ClangBuiltLinux/linux/issues/341=0ASuggested-by: Nathan = Chancellor =0AReviewed-by: Nathan Chancellor =0ATested-by: Nathan Chancellor =0ASigned-off-by: Nick Desaulniers =0ASigne= d-off-by: Masahiro Yamada =0ASigned-off-by: = Nathan Chancellor =0A---=0A Makefile | 2 +-=0A 1 = file changed, 1 insertion(+), 1 deletion(-)=0A=0Adiff --git a/Makefile b/Ma= kefile=0Aindex 35be7983ef2d..7bf3fb717921 100644=0A--- a/Makefile=0A+++ b/M= akefile=0A@@ -610,7 +610,7 @@ all: vmlinux=0A ifeq ($(cc-name),clang)=0A if= neq ($(CROSS_COMPILE),)=0A CLANG_TARGET :=3D --target=3D$(notdir $(CROSS_CO= MPILE:%-=3D%))=0A-GCC_TOOLCHAIN_DIR :=3D $(dir $(shell which $(LD)))=0A+GCC= _TOOLCHAIN_DIR :=3D $(dir $(shell which $(CROSS_COMPILE)elfedit))=0A CLANG_= PREFIX :=3D --prefix=3D$(GCC_TOOLCHAIN_DIR)=0A GCC_TOOLCHAIN :=3D $(realpat= h $(GCC_TOOLCHAIN_DIR)/..)=0A endif=0A-- =0A2.21.0=0A=0A=0AFrom c0cccc8cb3c= 2a4c74550f7cabbfe1a05426a0d45 Mon Sep 17 00:00:00 2001=0AFrom: George Rimar= =0ADate: Fri, 11 Jan 2019 12:10:12 -0800=0ASubjec= t: [PATCH 2/4] x86/build: Specify elf_i386 linker emulation explicitly=0A f= or i386 objects=0A=0Acommit 927185c124d62a9a4d35878d7f6d432a166b74e3 upstre= am.=0A=0AThe kernel uses the OUTPUT_FORMAT linker script command in it's li= nker=0Ascripts. Most of the time, the -m option is passed to the linker wit= h=0Acorrect architecture, but sometimes (at least for x86_64) the -m option= =0Acontradicts the OUTPUT_FORMAT directive.=0A=0ASpecifically, arch/x86/boo= t and arch/x86/realmode/rm produce i386 object=0Afiles, but are linked with= the -m elf_x86_64 linker flag when building=0Afor x86_64.=0A=0AThe GNU lin= ker manpage doesn't explicitly state any tie-breakers between=0A-m and OUTP= UT_FORMAT. But with BFD and Gold linkers, OUTPUT_FORMAT=0Aoverrides the emu= lation value specified with the -m option.=0A=0ALLVM lld has a different be= havior, however. When supplied with=0Acontradicting -m and OUTPUT_FORMAT va= lues it fails with the following=0Aerror message:=0A=0A ld.lld: error: arc= h/x86/realmode/rm/header.o is incompatible with elf_x86_64=0A=0ATherefore, = just add the correct -m after the incorrect one (it overrides=0Ait), so the= linker invocation looks like this:=0A=0A ld -m elf_x86_64 -z max-page-siz= e=3D0x200000 -m elf_i386 --emit-relocs -T \=0A realmode.lds header.o tra= mpoline_64.o stack.o reboot.o -o realmode.elf=0A=0AThis is not a functional= change for GNU ld, because (although not=0Aexplicitly documented) OUTPUT_F= ORMAT overrides -m EMULATION.=0A=0ATested by building x86_64 kernel with GN= U gcc/ld toolchain and booting=0Ait in QEMU.=0A=0A [ bp: massage and clarif= y text. ]=0A=0ASuggested-by: Dmitry Golovin =0ASigned-off-= by: George Rimar =0ASigned-off-by: Tri Vo =0ASigned-off-by: Borislav Petkov =0ATested-by: Tri = Vo =0ATested-by: Nick Desaulniers =0ACc: "H. Peter Anvin" =0ACc: Ingo Molnar =0ACc: Michael Matz =0ACc: Thomas Gleixner =0ACc: morbo@google.com=0ACc: ndesaulniers@google.com=0ACc: ruiu@goog= le.com=0ACc: x86-ml =0ALink: https://lkml.kernel.org/r/2019= 0111201012.71210-1-trong@android.com=0A[nc: Fix conflicts due to lack of co= mmit 58ab5e0c2c40 ("Kbuild: arch:=0A look for generated headers in obtr= ee") in this tree]=0ASigned-off-by: Nathan Chancellor =0A---=0A arch/x86/boot/Makefile | 2 +-=0A arch/x86/realmode/= rm/Makefile | 2 +-=0A 2 files changed, 2 insertions(+), 2 deletions(-)=0A= =0Adiff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile=0Aindex 6da= 2cd0897f3..e94745321cac 100644=0A--- a/arch/x86/boot/Makefile=0A+++ b/arch/= x86/boot/Makefile=0A@@ -100,7 +100,7 @@ $(obj)/zoffset.h: $(obj)/compressed= /vmlinux FORCE=0A AFLAGS_header.o +=3D -I$(obj)=0A $(obj)/header.o: $(obj)/= voffset.h $(obj)/zoffset.h=0A =0A-LDFLAGS_setup.elf :=3D -T=0A+LDFLAGS_setu= p.elf :=3D -m elf_i386 -T=0A $(obj)/setup.elf: $(src)/setup.ld $(SETUP_OBJS= ) FORCE=0A $(call if_changed,ld)=0A =0Adiff --git a/arch/x86/realmode/rm/M= akefile b/arch/x86/realmode/rm/Makefile=0Aindex 2730d775ef9a..228cb16962ba = 100644=0A--- a/arch/x86/realmode/rm/Makefile=0A+++ b/arch/x86/realmode/rm/M= akefile=0A@@ -43,7 +43,7 @@ $(obj)/pasyms.h: $(REALMODE_OBJS) FORCE=0A targ= ets +=3D realmode.lds=0A $(obj)/realmode.lds: $(obj)/pasyms.h=0A =0A-LDFLAG= S_realmode.elf :=3D --emit-relocs -T=0A+LDFLAGS_realmode.elf :=3D -m elf_i3= 86 --emit-relocs -T=0A CPPFLAGS_realmode.lds +=3D -P -C -I$(obj)=0A =0A tar= gets +=3D realmode.elf=0A-- =0A2.21.0=0A=0A=0AFrom ea44fbb53e24856dd3a2e90e= d641acb0f61c695a Mon Sep 17 00:00:00 2001=0AFrom: Alistair Strachan =0ADate: Fri, 3 Aug 2018 10:39:31 -0700=0ASubject: [PATCH 3/= 4] x86: vdso: Use $LD instead of $CC to link=0A=0Acommit 379d98ddf41344273d= 9718556f761420f4dc80b3 upstream.=0A=0AThe vdso{32,64}.so can fail to link w= ith CC=3Dclang when clang tries to find=0Aa suitable GCC toolchain to link = these libraries with.=0A=0A/usr/bin/ld: arch/x86/entry/vdso/vclock_gettime.= o:=0A access beyond end of merged section (782)=0A=0AThis happens because = the host environment leaked into the cross compiler=0Aenvironment due to th= e way clang searches for suitable GCC toolchains.=0A=0AClang is a retargeta= ble compiler, and each invocation of it must provide=0A--target=3D --gcc-toolchain=3D to allow it to find the=0Acorrect binutils= for cross compilation. These flags had been added to=0AKBUILD_CFLAGS, but = the vdso code uses CC and not KBUILD_CFLAGS (for various=0Areasons) which b= reaks clang's ability to find the correct linker when cross=0Acompiling.=0A= =0AMost of the time this goes unnoticed because the host linker is new enou= gh=0Ato work anyway, or is incompatible and skipped, but this cannot be rel= iably=0Aassumed.=0A=0AThis change alters the vdso makefile to just use LD d= irectly, which=0Abypasses clang and thus the searching problem. The makefil= e will just use=0A${CROSS_COMPILE}ld instead, which is always what we want.= This matches the=0Amethod used to link vmlinux.=0A=0AThis drops references= to DISABLE_LTO; this option doesn't seem to be set=0Aanywhere, and not kno= wing what its possible values are, it's not clear how=0Ato convert it from = CC to LD flag.=0A=0ASigned-off-by: Alistair Strachan = =0ASigned-off-by: Thomas Gleixner =0AAcked-by: Andy Lut= omirski =0ACc: "H. Peter Anvin" =0ACc: Greg= Kroah-Hartman =0ACc: kernel-team@android.com= =0ACc: joel@joelfernandes.org=0ACc: Andi Kleen =0ALin= k: https://lkml.kernel.org/r/20180803173931.117515-1-astrachan@google.com= =0ASigned-off-by: Nathan Chancellor =0A---=0A arc= h/x86/entry/vdso/Makefile | 22 +++++++++-------------=0A 1 file changed, 9 = insertions(+), 13 deletions(-)=0A=0Adiff --git a/arch/x86/entry/vdso/Makefi= le b/arch/x86/entry/vdso/Makefile=0Aindex 265c0ed68118..84c4a7105c2a 100644= =0A--- a/arch/x86/entry/vdso/Makefile=0A+++ b/arch/x86/entry/vdso/Makefile= =0A@@ -41,10 +41,8 @@ targets +=3D $(vdso_img_sodbg)=0A =0A export CPPFLAGS= _vdso.lds +=3D -P -C=0A =0A-VDSO_LDFLAGS_vdso.lds =3D -m64 -Wl,-soname=3Dli= nux-vdso.so.1 \=0A- -Wl,--no-undefined \=0A- -Wl,-z,max-page-size=3D409= 6 -Wl,-z,common-page-size=3D4096 \=0A- $(DISABLE_LTO)=0A+VDSO_LDFLAGS_vds= o.lds =3D -m elf_x86_64 -soname linux-vdso.so.1 --no-undefined \=0A+ -z m= ax-page-size=3D4096 -z common-page-size=3D4096=0A =0A $(obj)/vdso64.so.dbg:= $(src)/vdso.lds $(vobjs) FORCE=0A $(call if_changed,vdso)=0A@@ -90,10 +88= ,8 @@ CFLAGS_REMOVE_vvar.o =3D -pg=0A #=0A =0A CPPFLAGS_vdsox32.lds =3D $(C= PPFLAGS_vdso.lds)=0A-VDSO_LDFLAGS_vdsox32.lds =3D -Wl,-m,elf32_x86_64 \=0A-= -Wl,-soname=3Dlinux-vdso.so.1 \=0A- -Wl,-z,max-page-size=3D4096 = \=0A- -Wl,-z,common-page-size=3D4096=0A+VDSO_LDFLAGS_vdsox32.lds =3D -= m elf32_x86_64 -soname linux-vdso.so.1 \=0A+ -z max-page-size=3D4096 -= z common-page-size=3D4096=0A =0A # 64-bit objects to re-brand as x32=0A vob= js64-for-x32 :=3D $(filter-out $(vobjs-nox32),$(vobjs-y))=0A@@ -121,7 +117,= 7 @@ $(obj)/vdsox32.so.dbg: $(src)/vdsox32.lds $(vobjx32s) FORCE=0A $(call= if_changed,vdso)=0A =0A CPPFLAGS_vdso32.lds =3D $(CPPFLAGS_vdso.lds)=0A-VD= SO_LDFLAGS_vdso32.lds =3D -m32 -Wl,-m,elf_i386 -Wl,-soname=3Dlinux-gate.so.= 1=0A+VDSO_LDFLAGS_vdso32.lds =3D -m elf_i386 -soname linux-gate.so.1=0A =0A= # This makes sure the $(obj) subdirectory exists even though vdso32/=0A # = is not a kbuild sub-make subdirectory.=0A@@ -157,13 +153,13 @@ $(obj)/vdso3= 2.so.dbg: FORCE \=0A # The DSO images are built using a special linker scri= pt.=0A #=0A quiet_cmd_vdso =3D VDSO $@=0A- cmd_vdso =3D $(CC) -nost= dlib -o $@ \=0A+ cmd_vdso =3D $(LD) -nostdlib -o $@ \=0A $(VD= SO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \=0A- -Wl,-T,$(fi= lter %.lds,$^) $(filter %.o,$^) && \=0A+ -T $(filter %.lds,$^) $(fi= lter %.o,$^) && \=0A sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'=0A = =0A-VDSO_LDFLAGS =3D -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-st= yle=3Dboth) \=0A- $(call cc-ldoption, -Wl$(comma)--build-id) -Wl,-Bsymbolic= $(LTO_CFLAGS)=0A+VDSO_LDFLAGS =3D -shared $(call ld-option, --hash-style= =3Dboth) \=0A+ $(call ld-option, --build-id) -Bsymbolic=0A GCOV_PROFILE := =3D n=0A =0A #=0A-- =0A2.21.0=0A=0A=0AFrom b22299ee0b94b2e2ed1492d38631a054= 92e42c63 Mon Sep 17 00:00:00 2001=0AFrom: Nick Desaulniers =0ADate: Thu, 6 Dec 2018 11:12:31 -0800=0ASubject: [PATCH 4/4] x86= /vdso: Drop implicit common-page-size linker flag=0A=0Acommit ac3e233d29f7f= 77f28243af0132057d378d3ea58 upstream.=0A=0AGNU linker's -z common-page-size= 's default value is based on the target=0Aarchitecture. arch/x86/entry/vdso= /Makefile sets it to the architecture=0Adefault, which is implicit and redu= ndant. Drop it.=0A=0AFixes: 2aae950b21e4 ("x86_64: Add vDSO for x86-64 with= gettimeofday/clock_gettime/getcpu")=0AReported-by: Dmitry Golovin =0AReported-by: Bill Wendling =0ASuggested-by: D= mitry Golovin =0ASuggested-by: Rui Ueyama =0ASigned-off-by: Nick Desaulniers =0ASigned-off-= by: Borislav Petkov =0AAcked-by: Andy Lutomirski =0ACc: Andi Kleen =0ACc: Fangrui Song =0ACc: "H. Peter Anvin" =0ACc: Ingo Molnar =0ACc: Thomas Gleixner =0ACc: x86-ml =0ALink: https://lkml.kernel.org/r/20181206191231.192355-1-ndesaulnie= rs@google.com=0ALink: https://bugs.llvm.org/show_bug.cgi?id=3D38774=0ALink:= https://github.com/ClangBuiltLinux/linux/issues/31=0ASigned-off-by: Nathan= Chancellor =0A---=0A arch/x86/entry/vdso/Makefil= e | 4 ++--=0A 1 file changed, 2 insertions(+), 2 deletions(-)=0A=0Adiff --g= it a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile=0Aindex 84= c4a7105c2a..297dda4d5947 100644=0A--- a/arch/x86/entry/vdso/Makefile=0A+++ = b/arch/x86/entry/vdso/Makefile=0A@@ -42,7 +42,7 @@ targets +=3D $(vdso_img_= sodbg)=0A export CPPFLAGS_vdso.lds +=3D -P -C=0A =0A VDSO_LDFLAGS_vdso.lds = =3D -m elf_x86_64 -soname linux-vdso.so.1 --no-undefined \=0A- -z max-pag= e-size=3D4096 -z common-page-size=3D4096=0A+ -z max-page-size=3D4096=0A = =0A $(obj)/vdso64.so.dbg: $(src)/vdso.lds $(vobjs) FORCE=0A $(call if_chan= ged,vdso)=0A@@ -89,7 +89,7 @@ CFLAGS_REMOVE_vvar.o =3D -pg=0A =0A CPPFLAGS_= vdsox32.lds =3D $(CPPFLAGS_vdso.lds)=0A VDSO_LDFLAGS_vdsox32.lds =3D -m elf= 32_x86_64 -soname linux-vdso.so.1 \=0A- -z max-page-size=3D4096 -z com= mon-page-size=3D4096=0A+ -z max-page-size=3D4096=0A =0A # 64-bit objec= ts to re-brand as x32=0A vobjs64-for-x32 :=3D $(filter-out $(vobjs-nox32),$= (vobjs-y))=0A-- =0A2.21.0=0A=0A --k+w/mQv8wyuph6w0 Content-Type: application/mbox Content-Disposition: attachment; filename="lld-4.9.mbox" Content-Transfer-Encoding: quoted-printable =46rom 23652f2bb349553d68015ee6ef591fad16baaff8 Mon Sep 17 00:00:00 2001=0A= =46rom: Nick Desaulniers =0ADate: Mon, 11 Feb 2019= 11:30:04 -0800=0ASubject: [PATCH 1/3] kbuild: clang: choose GCC_TOOLCHAIN_= DIR not on LD=0A=0Acommit ad15006cc78459d059af56729c4d9bed7c7fd860 upstream= =2E=0A=0AThis causes an issue when trying to build with `make LD=3Dld.lld` = if=0Ald.lld and the rest of your cross tools aren't in the same directory= =0A(ex. /usr/local/bin) (as is the case for Android's build system), as the= =0AGCC_TOOLCHAIN_DIR then gets set based on `which $(LD)` which will point= =0Awhere LLVM tools are, not GCC/binutils tools are located.=0A=0AInstead, = select the GCC_TOOLCHAIN_DIR based on another tool provided by=0Abinutils f= or which LLVM does not provide a substitute for, such as=0Aelfedit.=0A=0AFi= xes: 785f11aa595b ("kbuild: Add better clang cross build support")=0ALink: = https://github.com/ClangBuiltLinux/linux/issues/341=0ASuggested-by: Nathan = Chancellor =0AReviewed-by: Nathan Chancellor =0ATested-by: Nathan Chancellor =0ASigned-off-by: Nick Desaulniers =0ASigne= d-off-by: Masahiro Yamada =0ASigned-off-by: = Nathan Chancellor =0A---=0A Makefile | 2 +-=0A 1 = file changed, 1 insertion(+), 1 deletion(-)=0A=0Adiff --git a/Makefile b/Ma= kefile=0Aindex f44094d2b147..ba3c48809f44 100644=0A--- a/Makefile=0A+++ b/M= akefile=0A@@ -507,7 +507,7 @@ endif=0A ifeq ($(cc-name),clang)=0A ifneq ($(= CROSS_COMPILE),)=0A CLANG_FLAGS :=3D --target=3D$(notdir $(CROSS_COMPILE:%-= =3D%))=0A-GCC_TOOLCHAIN_DIR :=3D $(dir $(shell which $(LD)))=0A+GCC_TOOLCHA= IN_DIR :=3D $(dir $(shell which $(CROSS_COMPILE)elfedit))=0A CLANG_FLAGS += =3D --prefix=3D$(GCC_TOOLCHAIN_DIR)=0A GCC_TOOLCHAIN :=3D $(realpath $(GCC_= TOOLCHAIN_DIR)/..)=0A endif=0A-- =0A2.21.0=0A=0A=0AFrom 50198f300f5672a50a0= 6cc0f4e9e4cee3591fd8b Mon Sep 17 00:00:00 2001=0AFrom: Alistair Strachan =0ADate: Fri, 3 Aug 2018 10:39:31 -0700=0ASubject: [PAT= CH 2/3] x86: vdso: Use $LD instead of $CC to link=0A=0AThe vdso{32,64}.so c= an fail to link with CC=3Dclang when clang tries to find=0Aa suitable GCC t= oolchain to link these libraries with.=0A=0A/usr/bin/ld: arch/x86/entry/vds= o/vclock_gettime.o:=0A access beyond end of merged section (782)=0A=0AThis= happens because the host environment leaked into the cross compiler=0Aenvi= ronment due to the way clang searches for suitable GCC toolchains.=0A=0ACla= ng is a retargetable compiler, and each invocation of it must provide=0A--t= arget=3D --gcc-toolchain=3D to allow it to find the= =0Acorrect binutils for cross compilation. These flags had been added to=0A= KBUILD_CFLAGS, but the vdso code uses CC and not KBUILD_CFLAGS (for various= =0Areasons) which breaks clang's ability to find the correct linker when cr= oss=0Acompiling.=0A=0AMost of the time this goes unnoticed because the host= linker is new enough=0Ato work anyway, or is incompatible and skipped, but= this cannot be reliably=0Aassumed.=0A=0AThis change alters the vdso makefi= le to just use LD directly, which=0Abypasses clang and thus the searching p= roblem. The makefile will just use=0A${CROSS_COMPILE}ld instead, which is a= lways what we want. This matches the=0Amethod used to link vmlinux.=0A=0ATh= is drops references to DISABLE_LTO; this option doesn't seem to be set=0Aan= ywhere, and not knowing what its possible values are, it's not clear how=0A= to convert it from CC to LD flag.=0A=0ASigned-off-by: Alistair Strachan =0ASigned-off-by: Thomas Gleixner = =0AAcked-by: Andy Lutomirski =0ACc: "H. Peter Anvin" =0ACc: Greg Kroah-Hartman =0ACc: kern= el-team@android.com=0ACc: joel@joelfernandes.org=0ACc: Andi Kleen =0ALink: https://lkml.kernel.org/r/20180803173931.117515-1-ast= rachan@google.com=0ASigned-off-by: Nathan Chancellor =0A---=0A arch/x86/entry/vdso/Makefile | 22 +++++++++-------------=0A 1= file changed, 9 insertions(+), 13 deletions(-)=0A=0Adiff --git a/arch/x86/= entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile=0Aindex d5409660f5de..2a= e92c6b1de6 100644=0A--- a/arch/x86/entry/vdso/Makefile=0A+++ b/arch/x86/ent= ry/vdso/Makefile=0A@@ -47,10 +47,8 @@ targets +=3D $(vdso_img_sodbg)=0A =0A= export CPPFLAGS_vdso.lds +=3D -P -C=0A =0A-VDSO_LDFLAGS_vdso.lds =3D -m64 = -Wl,-soname=3Dlinux-vdso.so.1 \=0A- -Wl,--no-undefined \=0A- -Wl,-z,max= -page-size=3D4096 -Wl,-z,common-page-size=3D4096 \=0A- $(DISABLE_LTO)=0A+= VDSO_LDFLAGS_vdso.lds =3D -m elf_x86_64 -soname linux-vdso.so.1 --no-undefi= ned \=0A+ -z max-page-size=3D4096 -z common-page-size=3D4096=0A =0A $(obj= )/vdso64.so.dbg: $(src)/vdso.lds $(vobjs) FORCE=0A $(call if_changed,vdso)= =0A@@ -96,10 +94,8 @@ CFLAGS_REMOVE_vvar.o =3D -pg=0A #=0A =0A CPPFLAGS_vds= ox32.lds =3D $(CPPFLAGS_vdso.lds)=0A-VDSO_LDFLAGS_vdsox32.lds =3D -Wl,-m,el= f32_x86_64 \=0A- -Wl,-soname=3Dlinux-vdso.so.1 \=0A- -Wl,-z,max-p= age-size=3D4096 \=0A- -Wl,-z,common-page-size=3D4096=0A+VDSO_LDFLAGS_v= dsox32.lds =3D -m elf32_x86_64 -soname linux-vdso.so.1 \=0A+ -z max-pa= ge-size=3D4096 -z common-page-size=3D4096=0A =0A # 64-bit objects to re-bra= nd as x32=0A vobjs64-for-x32 :=3D $(filter-out $(vobjs-nox32),$(vobjs-y))= =0A@@ -127,7 +123,7 @@ $(obj)/vdsox32.so.dbg: $(src)/vdsox32.lds $(vobjx32s= ) FORCE=0A $(call if_changed,vdso)=0A =0A CPPFLAGS_vdso32.lds =3D $(CPPFLA= GS_vdso.lds)=0A-VDSO_LDFLAGS_vdso32.lds =3D -m32 -Wl,-m,elf_i386 -Wl,-sonam= e=3Dlinux-gate.so.1=0A+VDSO_LDFLAGS_vdso32.lds =3D -m elf_i386 -soname linu= x-gate.so.1=0A =0A # This makes sure the $(obj) subdirectory exists even th= ough vdso32/=0A # is not a kbuild sub-make subdirectory.=0A@@ -165,13 +161,= 13 @@ $(obj)/vdso32.so.dbg: FORCE \=0A # The DSO images are built using a s= pecial linker script.=0A #=0A quiet_cmd_vdso =3D VDSO $@=0A- cmd_vd= so =3D $(CC) -nostdlib -o $@ \=0A+ cmd_vdso =3D $(LD) -nostdlib -o $@ = \=0A $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \=0A- = -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \=0A+ -T $(fil= ter %.lds,$^) $(filter %.o,$^) && \=0A sh $(srctree)/$(src)/checkundef.s= h '$(NM)' '$@'=0A =0A-VDSO_LDFLAGS =3D -fPIC -shared $(call cc-ldoption, -W= l$(comma)--hash-style=3Dboth) \=0A- $(call cc-ldoption, -Wl$(comma)--build-= id) -Wl,-Bsymbolic $(LTO_CFLAGS)=0A+VDSO_LDFLAGS =3D -shared $(call ld-opti= on, --hash-style=3Dboth) \=0A+ $(call ld-option, --build-id) -Bsymbolic=0A = GCOV_PROFILE :=3D n=0A =0A #=0A-- =0A2.21.0=0A=0A=0AFrom 27221a138c922f2b98= 113cece0a9c2b80da3bd38 Mon Sep 17 00:00:00 2001=0AFrom: Nick Desaulniers =0ADate: Thu, 6 Dec 2018 11:12:31 -0800=0ASubject: [= PATCH 3/3] x86/vdso: Drop implicit common-page-size linker flag=0A=0AGNU li= nker's -z common-page-size's default value is based on the target=0Aarchite= cture. arch/x86/entry/vdso/Makefile sets it to the architecture=0Adefault, = which is implicit and redundant. Drop it.=0A=0AFixes: 2aae950b21e4 ("x86_64= : Add vDSO for x86-64 with gettimeofday/clock_gettime/getcpu")=0AReported-b= y: Dmitry Golovin =0AReported-by: Bill Wendling =0ASuggested-by: Dmitry Golovin =0ASuggested-by: R= ui Ueyama =0ASigned-off-by: Nick Desaulniers =0ASigned-off-by: Borislav Petkov =0AAcked-by: Andy= Lutomirski =0ACc: Andi Kleen =0ACc: = Fangrui Song =0ACc: "H. Peter Anvin" =0A= Cc: Ingo Molnar =0ACc: Thomas Gleixner =0ACc: x86-ml =0ALink: https://lkml.kernel.org/r/20181206= 191231.192355-1-ndesaulniers@google.com=0ALink: https://bugs.llvm.org/show_= bug.cgi?id=3D38774=0ALink: https://github.com/ClangBuiltLinux/linux/issues/= 31=0ASigned-off-by: Nathan Chancellor =0A---=0A a= rch/x86/entry/vdso/Makefile | 4 ++--=0A 1 file changed, 2 insertions(+), 2 = deletions(-)=0A=0Adiff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entr= y/vdso/Makefile=0Aindex 2ae92c6b1de6..756dc9432d15 100644=0A--- a/arch/x86/= entry/vdso/Makefile=0A+++ b/arch/x86/entry/vdso/Makefile=0A@@ -48,7 +48,7 @= @ targets +=3D $(vdso_img_sodbg)=0A export CPPFLAGS_vdso.lds +=3D -P -C=0A = =0A VDSO_LDFLAGS_vdso.lds =3D -m elf_x86_64 -soname linux-vdso.so.1 --no-un= defined \=0A- -z max-page-size=3D4096 -z common-page-size=3D4096=0A+ -z= max-page-size=3D4096=0A =0A $(obj)/vdso64.so.dbg: $(src)/vdso.lds $(vobjs)= FORCE=0A $(call if_changed,vdso)=0A@@ -95,7 +95,7 @@ CFLAGS_REMOVE_vvar.o= =3D -pg=0A =0A CPPFLAGS_vdsox32.lds =3D $(CPPFLAGS_vdso.lds)=0A VDSO_LDFLA= GS_vdsox32.lds =3D -m elf32_x86_64 -soname linux-vdso.so.1 \=0A- -z ma= x-page-size=3D4096 -z common-page-size=3D4096=0A+ -z max-page-size=3D4= 096=0A =0A # 64-bit objects to re-brand as x32=0A vobjs64-for-x32 :=3D $(fi= lter-out $(vobjs-nox32),$(vobjs-y))=0A-- =0A2.21.0=0A=0A --k+w/mQv8wyuph6w0 Content-Type: application/mbox Content-Disposition: attachment; filename="lld-4.14.mbox" Content-Transfer-Encoding: quoted-printable =46rom e0fc493ee7a71bf2b8aacfe395d9a5d61057b1fa Mon Sep 17 00:00:00 2001=0A= =46rom: Nick Desaulniers =0ADate: Mon, 11 Feb 2019= 11:30:04 -0800=0ASubject: [PATCH 1/3] kbuild: clang: choose GCC_TOOLCHAIN_= DIR not on LD=0A=0Acommit ad15006cc78459d059af56729c4d9bed7c7fd860 upstream= =2E=0A=0AThis causes an issue when trying to build with `make LD=3Dld.lld` = if=0Ald.lld and the rest of your cross tools aren't in the same directory= =0A(ex. /usr/local/bin) (as is the case for Android's build system), as the= =0AGCC_TOOLCHAIN_DIR then gets set based on `which $(LD)` which will point= =0Awhere LLVM tools are, not GCC/binutils tools are located.=0A=0AInstead, = select the GCC_TOOLCHAIN_DIR based on another tool provided by=0Abinutils f= or which LLVM does not provide a substitute for, such as=0Aelfedit.=0A=0AFi= xes: 785f11aa595b ("kbuild: Add better clang cross build support")=0ALink: = https://github.com/ClangBuiltLinux/linux/issues/341=0ASuggested-by: Nathan = Chancellor =0AReviewed-by: Nathan Chancellor =0ATested-by: Nathan Chancellor =0ASigned-off-by: Nick Desaulniers =0ASigne= d-off-by: Masahiro Yamada =0ASigned-off-by: = Nathan Chancellor =0A---=0A Makefile | 2 +-=0A 1 = file changed, 1 insertion(+), 1 deletion(-)=0A=0Adiff --git a/Makefile b/Ma= kefile=0Aindex da223c660c9a..85753250984c 100644=0A--- a/Makefile=0A+++ b/M= akefile=0A@@ -480,7 +480,7 @@ endif=0A ifeq ($(cc-name),clang)=0A ifneq ($(= CROSS_COMPILE),)=0A CLANG_FLAGS :=3D --target=3D$(notdir $(CROSS_COMPILE:%-= =3D%))=0A-GCC_TOOLCHAIN_DIR :=3D $(dir $(shell which $(LD)))=0A+GCC_TOOLCHA= IN_DIR :=3D $(dir $(shell which $(CROSS_COMPILE)elfedit))=0A CLANG_FLAGS += =3D --prefix=3D$(GCC_TOOLCHAIN_DIR)=0A GCC_TOOLCHAIN :=3D $(realpath $(GCC_= TOOLCHAIN_DIR)/..)=0A endif=0A-- =0A2.21.0=0A=0A=0AFrom 46266b3e0ba6d6fadf9= 8af8f68535b201d29d913 Mon Sep 17 00:00:00 2001=0AFrom: Alistair Strachan =0ADate: Fri, 3 Aug 2018 10:39:31 -0700=0ASubject: [PAT= CH 2/3] x86: vdso: Use $LD instead of $CC to link=0A=0Acommit 379d98ddf4134= 4273d9718556f761420f4dc80b3 upstream.=0A=0AThe vdso{32,64}.so can fail to l= ink with CC=3Dclang when clang tries to find=0Aa suitable GCC toolchain to = link these libraries with.=0A=0A/usr/bin/ld: arch/x86/entry/vdso/vclock_get= time.o:=0A access beyond end of merged section (782)=0A=0AThis happens bec= ause the host environment leaked into the cross compiler=0Aenvironment due = to the way clang searches for suitable GCC toolchains.=0A=0AClang is a reta= rgetable compiler, and each invocation of it must provide=0A--target=3D --gcc-toolchain=3D to allow it to find the=0Acorrect bin= utils for cross compilation. These flags had been added to=0AKBUILD_CFLAGS,= but the vdso code uses CC and not KBUILD_CFLAGS (for various=0Areasons) wh= ich breaks clang's ability to find the correct linker when cross=0Acompilin= g.=0A=0AMost of the time this goes unnoticed because the host linker is new= enough=0Ato work anyway, or is incompatible and skipped, but this cannot b= e reliably=0Aassumed.=0A=0AThis change alters the vdso makefile to just use= LD directly, which=0Abypasses clang and thus the searching problem. The ma= kefile will just use=0A${CROSS_COMPILE}ld instead, which is always what we = want. This matches the=0Amethod used to link vmlinux.=0A=0AThis drops refer= ences to DISABLE_LTO; this option doesn't seem to be set=0Aanywhere, and no= t knowing what its possible values are, it's not clear how=0Ato convert it = =66rom CC to LD flag.=0A=0ASigned-off-by: Alistair Strachan =0ASigned-off-by: Thomas Gleixner =0AAcked-by: A= ndy Lutomirski =0ACc: "H. Peter Anvin" =0AC= c: Greg Kroah-Hartman =0ACc: kernel-team@androi= d.com=0ACc: joel@joelfernandes.org=0ACc: Andi Kleen = =0ALink: https://lkml.kernel.org/r/20180803173931.117515-1-astrachan@google= =2Ecom=0ASigned-off-by: Nathan Chancellor =0A---= =0A arch/x86/entry/vdso/Makefile | 22 +++++++++-------------=0A 1 file chan= ged, 9 insertions(+), 13 deletions(-)=0A=0Adiff --git a/arch/x86/entry/vdso= /Makefile b/arch/x86/entry/vdso/Makefile=0Aindex 0a550dc5c525..0defcc939ab4= 100644=0A--- a/arch/x86/entry/vdso/Makefile=0A+++ b/arch/x86/entry/vdso/Ma= kefile=0A@@ -48,10 +48,8 @@ targets +=3D $(vdso_img_sodbg)=0A =0A export CP= PFLAGS_vdso.lds +=3D -P -C=0A =0A-VDSO_LDFLAGS_vdso.lds =3D -m64 -Wl,-sonam= e=3Dlinux-vdso.so.1 \=0A- -Wl,--no-undefined \=0A- -Wl,-z,max-page-size= =3D4096 -Wl,-z,common-page-size=3D4096 \=0A- $(DISABLE_LTO)=0A+VDSO_LDFLA= GS_vdso.lds =3D -m elf_x86_64 -soname linux-vdso.so.1 --no-undefined \=0A+ = -z max-page-size=3D4096 -z common-page-size=3D4096=0A =0A $(obj)/vdso64.s= o.dbg: $(src)/vdso.lds $(vobjs) FORCE=0A $(call if_changed,vdso)=0A@@ -103= ,10 +101,8 @@ CFLAGS_REMOVE_vvar.o =3D -pg=0A #=0A =0A CPPFLAGS_vdsox32.lds= =3D $(CPPFLAGS_vdso.lds)=0A-VDSO_LDFLAGS_vdsox32.lds =3D -Wl,-m,elf32_x86_= 64 \=0A- -Wl,-soname=3Dlinux-vdso.so.1 \=0A- -Wl,-z,max-page-size= =3D4096 \=0A- -Wl,-z,common-page-size=3D4096=0A+VDSO_LDFLAGS_vdsox32.l= ds =3D -m elf32_x86_64 -soname linux-vdso.so.1 \=0A+ -z max-page-size= =3D4096 -z common-page-size=3D4096=0A =0A # 64-bit objects to re-brand as x= 32=0A vobjs64-for-x32 :=3D $(filter-out $(vobjs-nox32),$(vobjs-y))=0A@@ -13= 4,7 +130,7 @@ $(obj)/vdsox32.so.dbg: $(src)/vdsox32.lds $(vobjx32s) FORCE= =0A $(call if_changed,vdso)=0A =0A CPPFLAGS_vdso32.lds =3D $(CPPFLAGS_vdso= =2Elds)=0A-VDSO_LDFLAGS_vdso32.lds =3D -m32 -Wl,-m,elf_i386 -Wl,-soname=3Dl= inux-gate.so.1=0A+VDSO_LDFLAGS_vdso32.lds =3D -m elf_i386 -soname linux-gat= e.so.1=0A =0A # This makes sure the $(obj) subdirectory exists even though = vdso32/=0A # is not a kbuild sub-make subdirectory.=0A@@ -180,13 +176,13 @@= $(obj)/vdso32.so.dbg: FORCE \=0A # The DSO images are built using a specia= l linker script.=0A #=0A quiet_cmd_vdso =3D VDSO $@=0A- cmd_vdso = =3D $(CC) -nostdlib -o $@ \=0A+ cmd_vdso =3D $(LD) -nostdlib -o $@ \= =0A $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \=0A- = -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \=0A+ -T $(filt= er %.lds,$^) $(filter %.o,$^) && \=0A sh $(srctree)/$(src)/checkundef.sh= '$(NM)' '$@'=0A =0A-VDSO_LDFLAGS =3D -fPIC -shared $(call cc-ldoption, -Wl= $(comma)--hash-style=3Dboth) \=0A- $(call cc-ldoption, -Wl$(comma)--build-i= d) -Wl,-Bsymbolic $(LTO_CFLAGS)=0A+VDSO_LDFLAGS =3D -shared $(call ld-optio= n, --hash-style=3Dboth) \=0A+ $(call ld-option, --build-id) -Bsymbolic=0A G= COV_PROFILE :=3D n=0A =0A #=0A-- =0A2.21.0=0A=0A=0AFrom 03cdb633e988092a73a= 00a19bf1c8a9e864f22ce Mon Sep 17 00:00:00 2001=0AFrom: Nick Desaulniers =0ADate: Thu, 6 Dec 2018 11:12:31 -0800=0ASubject: [P= ATCH 3/3] x86/vdso: Drop implicit common-page-size linker flag=0A=0Acommit = ac3e233d29f7f77f28243af0132057d378d3ea58 upstream.=0A=0AGNU linker's -z com= mon-page-size's default value is based on the target=0Aarchitecture. arch/x= 86/entry/vdso/Makefile sets it to the architecture=0Adefault, which is impl= icit and redundant. Drop it.=0A=0AFixes: 2aae950b21e4 ("x86_64: Add vDSO fo= r x86-64 with gettimeofday/clock_gettime/getcpu")=0AReported-by: Dmitry Gol= ovin =0AReported-by: Bill Wendling =0ASu= ggested-by: Dmitry Golovin =0ASuggested-by: Rui Ueyama =0ASigned-off-by: Nick Desaulniers = =0ASigned-off-by: Borislav Petkov =0AAcked-by: Andy Lutomirski = =0ACc: Andi Kleen =0ACc: Fangrui Song= =0ACc: "H. Peter Anvin" =0ACc: Ingo Mol= nar =0ACc: Thomas Gleixner =0ACc: x86= -ml =0ALink: https://lkml.kernel.org/r/20181206191231.19235= 5-1-ndesaulniers@google.com=0ALink: https://bugs.llvm.org/show_bug.cgi?id= =3D38774=0ALink: https://github.com/ClangBuiltLinux/linux/issues/31=0ASigne= d-off-by: Nathan Chancellor =0A---=0A arch/x86/en= try/vdso/Makefile | 4 ++--=0A 1 file changed, 2 insertions(+), 2 deletions(= -)=0A=0Adiff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Mak= efile=0Aindex 0defcc939ab4..839015f1b0de 100644=0A--- a/arch/x86/entry/vdso= /Makefile=0A+++ b/arch/x86/entry/vdso/Makefile=0A@@ -49,7 +49,7 @@ targets = +=3D $(vdso_img_sodbg)=0A export CPPFLAGS_vdso.lds +=3D -P -C=0A =0A VDSO_L= DFLAGS_vdso.lds =3D -m elf_x86_64 -soname linux-vdso.so.1 --no-undefined \= =0A- -z max-page-size=3D4096 -z common-page-size=3D4096=0A+ -z max-page= -size=3D4096=0A =0A $(obj)/vdso64.so.dbg: $(src)/vdso.lds $(vobjs) FORCE=0A= $(call if_changed,vdso)=0A@@ -102,7 +102,7 @@ CFLAGS_REMOVE_vvar.o =3D -p= g=0A =0A CPPFLAGS_vdsox32.lds =3D $(CPPFLAGS_vdso.lds)=0A VDSO_LDFLAGS_vdso= x32.lds =3D -m elf32_x86_64 -soname linux-vdso.so.1 \=0A- -z max-page-= size=3D4096 -z common-page-size=3D4096=0A+ -z max-page-size=3D4096=0A = =0A # 64-bit objects to re-brand as x32=0A vobjs64-for-x32 :=3D $(filter-ou= t $(vobjs-nox32),$(vobjs-y))=0A-- =0A2.21.0=0A=0A --k+w/mQv8wyuph6w0 Content-Type: application/mbox Content-Disposition: attachment; filename="lld-4.19.mbox" Content-Transfer-Encoding: quoted-printable =46rom c69aa31f8a1a4c98049db18e88097f02dbf5ca79 Mon Sep 17 00:00:00 2001=0A= =46rom: Nick Desaulniers =0ADate: Mon, 11 Feb 2019= 11:30:04 -0800=0ASubject: [PATCH 1/2] kbuild: clang: choose GCC_TOOLCHAIN_= DIR not on LD=0A=0Acommit ad15006cc78459d059af56729c4d9bed7c7fd860 upstream= =2E=0A=0AThis causes an issue when trying to build with `make LD=3Dld.lld` = if=0Ald.lld and the rest of your cross tools aren't in the same directory= =0A(ex. /usr/local/bin) (as is the case for Android's build system), as the= =0AGCC_TOOLCHAIN_DIR then gets set based on `which $(LD)` which will point= =0Awhere LLVM tools are, not GCC/binutils tools are located.=0A=0AInstead, = select the GCC_TOOLCHAIN_DIR based on another tool provided by=0Abinutils f= or which LLVM does not provide a substitute for, such as=0Aelfedit.=0A=0AFi= xes: 785f11aa595b ("kbuild: Add better clang cross build support")=0ALink: = https://github.com/ClangBuiltLinux/linux/issues/341=0ASuggested-by: Nathan = Chancellor =0AReviewed-by: Nathan Chancellor =0ATested-by: Nathan Chancellor =0ASigned-off-by: Nick Desaulniers =0ASigne= d-off-by: Masahiro Yamada =0ASigned-off-by: = Nathan Chancellor =0A---=0A Makefile | 2 +-=0A 1 = file changed, 1 insertion(+), 1 deletion(-)=0A=0Adiff --git a/Makefile b/Ma= kefile=0Aindex 8fdfe0af5862..c07f25e2e11b 100644=0A--- a/Makefile=0A+++ b/M= akefile=0A@@ -483,7 +483,7 @@ endif=0A ifeq ($(cc-name),clang)=0A ifneq ($(= CROSS_COMPILE),)=0A CLANG_FLAGS :=3D --target=3D$(notdir $(CROSS_COMPILE:%-= =3D%))=0A-GCC_TOOLCHAIN_DIR :=3D $(dir $(shell which $(LD)))=0A+GCC_TOOLCHA= IN_DIR :=3D $(dir $(shell which $(CROSS_COMPILE)elfedit))=0A CLANG_FLAGS += =3D --prefix=3D$(GCC_TOOLCHAIN_DIR)=0A GCC_TOOLCHAIN :=3D $(realpath $(GCC_= TOOLCHAIN_DIR)/..)=0A endif=0A-- =0A2.21.0=0A=0A=0AFrom a60f07738a976ab8ca4= 368693385250851079cd1 Mon Sep 17 00:00:00 2001=0AFrom: Nick Desaulniers =0ADate: Thu, 6 Dec 2018 11:12:31 -0800=0ASubject: [P= ATCH 2/2] x86/vdso: Drop implicit common-page-size linker flag=0A=0Acommit = ac3e233d29f7f77f28243af0132057d378d3ea58 upstream.=0A=0AGNU linker's -z com= mon-page-size's default value is based on the target=0Aarchitecture. arch/x= 86/entry/vdso/Makefile sets it to the architecture=0Adefault, which is impl= icit and redundant. Drop it.=0A=0AFixes: 2aae950b21e4 ("x86_64: Add vDSO fo= r x86-64 with gettimeofday/clock_gettime/getcpu")=0AReported-by: Dmitry Gol= ovin =0AReported-by: Bill Wendling =0ASu= ggested-by: Dmitry Golovin =0ASuggested-by: Rui Ueyama =0ASigned-off-by: Nick Desaulniers = =0ASigned-off-by: Borislav Petkov =0AAcked-by: Andy Lutomirski = =0ACc: Andi Kleen =0ACc: Fangrui Song= =0ACc: "H. Peter Anvin" =0ACc: Ingo Mol= nar =0ACc: Thomas Gleixner =0ACc: x86= -ml =0ALink: https://lkml.kernel.org/r/20181206191231.19235= 5-1-ndesaulniers@google.com=0ALink: https://bugs.llvm.org/show_bug.cgi?id= =3D38774=0ALink: https://github.com/ClangBuiltLinux/linux/issues/31=0ASigne= d-off-by: Nathan Chancellor =0A---=0A arch/x86/en= try/vdso/Makefile | 4 ++--=0A 1 file changed, 2 insertions(+), 2 deletions(= -)=0A=0Adiff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Mak= efile=0Aindex c3d7ccd25381..5bfe2243a08f 100644=0A--- a/arch/x86/entry/vdso= /Makefile=0A+++ b/arch/x86/entry/vdso/Makefile=0A@@ -47,7 +47,7 @@ targets = +=3D $(vdso_img_sodbg) $(vdso_img-y:%=3Dvdso%.so)=0A CPPFLAGS_vdso.lds +=3D= -P -C=0A =0A VDSO_LDFLAGS_vdso.lds =3D -m elf_x86_64 -soname linux-vdso.so= =2E1 --no-undefined \=0A- -z max-page-size=3D4096 -z common-page-size=3D4= 096=0A+ -z max-page-size=3D4096=0A =0A $(obj)/vdso64.so.dbg: $(obj)/vdso.= lds $(vobjs) FORCE=0A $(call if_changed,vdso)=0A@@ -98,7 +98,7 @@ CFLAGS_R= EMOVE_vvar.o =3D -pg=0A =0A CPPFLAGS_vdsox32.lds =3D $(CPPFLAGS_vdso.lds)= =0A VDSO_LDFLAGS_vdsox32.lds =3D -m elf32_x86_64 -soname linux-vdso.so.1 \= =0A- -z max-page-size=3D4096 -z common-page-size=3D4096=0A+ -z ma= x-page-size=3D4096=0A =0A # x32-rebranded versions=0A vobjx32s-y :=3D $(vob= js-y:.o=3D-x32.o)=0A-- =0A2.21.0=0A=0A --k+w/mQv8wyuph6w0--