Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp329523pxu; Wed, 14 Oct 2020 02:25:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxAQz3ChWRJC8NXiD5VdNzv9eETExlFI2c9e7JbnpZjaj09LZn4iKpxKw95wIELEL4fI23j X-Received: by 2002:a17:907:40bb:: with SMTP id nu19mr4131839ejb.246.1602667521984; Wed, 14 Oct 2020 02:25:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602667521; cv=none; d=google.com; s=arc-20160816; b=Xpu/0jv0bZdwdocQJO9at3hg3kya3RQU4JrwSXWskns8OwwAZE3ZPG1zXf2i0AasAL NmLszyXwyBlRw4llr/3TwNpEwhDMqMwBX+SsVCj5Q10NR7GKUjZvhKYdv9FvfqU57hLu lCfNIh29dzOo6aHcMC2xN4r5HkyS84dVUKCMN0D4W8pShg4p4BOG+DQsXzDEnwm0RIcp OCPU0klf0uCvCpN1pI+6oHu75xYwNPHw58EceNS/A3sJ0s/PRh2ZDOthLKhF+WaD7a4l VkcTolbtIk8AdQrWdDTO10sPJUqVpPA9aMEe7zn2XmMhKpDY71FZaKTzHvSOKvUcU2RJ vw/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=t+96sOhB1uhq2YjHHSuH7V+uCK/i5ddWXeBGT6qagJA=; b=ORgTdbpDgDnH5YUgVsCNk7ZgjI7F7D+m7TVQ7sdtG4jJ1xeeH+IDm1eFAG6J9+vX9C 4Qfc6HfgE5do770bKNEKbKtV7vH+8EQYYfZPrm1Je7v0rJksQK1lrq46NpwIcJk7ZY4C q/51c3UXpb/Du0WuJQZmXcoYgdsQPFNJWo8W/9ymL8jBeT6nfvoZ4PRTASiItxvOFCG7 fU2pbqkUN2TMo7YmxfkKyHju+L/UpG3E3ezCJn9t0+AmEwzfmTW3yGMuvBpfzCGCiyGY gk9tnXbCMvMr2XkL75du7GU4MaGeNe2yVeynIvGipTJVC5YPAspcztI332UwUxPI7deT m+tA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="d6OEbf/+"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h28si2367710edj.130.2020.10.14.02.24.59; Wed, 14 Oct 2020 02:25:21 -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=@google.com header.s=20161025 header.b="d6OEbf/+"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727414AbgJNJWe (ORCPT + 99 others); Wed, 14 Oct 2020 05:22:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727833AbgJNJVv (ORCPT ); Wed, 14 Oct 2020 05:21:51 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B78FC0610D1 for ; Tue, 13 Oct 2020 15:37:33 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id g29so663512pgl.2 for ; Tue, 13 Oct 2020 15:37:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=t+96sOhB1uhq2YjHHSuH7V+uCK/i5ddWXeBGT6qagJA=; b=d6OEbf/+V3UpxQdj2KMVlgOQcefOZdwa3t2IYeg6hJ+lKu3UXruJnPByJcdjka4MBR 4SAdUkNgqPXDj4W0srOyR8s0lLtX9jrVvv0PCkGks13TUOW/kXDX1+1bZds9tEkeOmvM 2It/ZbepycqUMq/DB66R6g1+UPLJEEF4lV8N6vhEI7yQ/pCURkPMf676QOZ8OLCMGOX3 ZMFYznBYfJd8pEsQVQHk+Qm/3WXO+FNY0mxUsBY3+ZAo2CPE+iFBagq/vFVv3jAHyFAn mouDl5Sa1TlXuHRXscWk1l0p38nOax3UPYKSdeQSsUJRmh4em6/PrjM1mx1+AuIsBZvb SWlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=t+96sOhB1uhq2YjHHSuH7V+uCK/i5ddWXeBGT6qagJA=; b=uHrO9MB3pEx2efWsxIMzMYaDvWYL4hKTpBpWF+ycE4+fEW2urOo4ur2kY8bEYgzLqY z4RJWTwFSrgvqTs2JlGhPEyjQemmazfE4JrkwcTzrgbOB7PWpkKmkAdjwBb+IYHzTzbt zuBsM1oKn7uxIlAQqcFq+0ybP+KOKkUe2kDhTskzI4it8iXNXkbSvHhkQ+ipRQllwG6G murBe6rdSEZVU53uQMs52GbVuVcHEZ0tD2TKlefa3uONFVkN2VMtUwweIkbuoBlhh9VP NRVm+4qQrE2ejSaFT1qmgjx9ju1Pz6FZKCcz2LdDhFh5Kfe6W2XMykj0c5PFDziZf3mD FV5g== X-Gm-Message-State: AOAM5304iMh23j94AJf3zGDLDB4i260IAI17wxw19VxMSG8L57cs54FK 94fxnV/L+68XAQ3B3O4IrWavGHZvt9s624ILpPMic5iKUm8= X-Received: by 2002:a63:1f03:: with SMTP id f3mr1305731pgf.381.1602628652646; Tue, 13 Oct 2020 15:37:32 -0700 (PDT) MIME-Version: 1.0 References: <20201013033947.2257501-1-natechancellor@gmail.com> In-Reply-To: <20201013033947.2257501-1-natechancellor@gmail.com> From: Nick Desaulniers Date: Tue, 13 Oct 2020 15:37:21 -0700 Message-ID: Subject: Re: [PATCH] arm64: vdso32: Allow ld.lld to properly link the VDSO To: Nathan Chancellor Cc: Catalin Marinas , Will Deacon , Masahiro Yamada , Vincenzo Frascino , Linux ARM , Linux Kbuild mailing list , LKML , clang-built-linux Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 12, 2020 at 8:41 PM Nathan Chancellor wrote: > > As it stands now, the vdso32 Makefile hardcodes the linker to ld.bfd > using -fuse-ld=bfd with $(CC). This was taken from the arm vDSO > Makefile, as the comment notes, done in commit d2b30cd4b722 ("ARM: > 8384/1: VDSO: force use of BFD linker"). > > Commit fe00e50b2db8 ("ARM: 8858/1: vdso: use $(LD) instead of $(CC) to > link VDSO") changed that Makefile to use $(LD) directly instead of > through $(CC), which matches how the rest of the kernel operates. Since > then, LD=ld.lld means that the arm vDSO will be linked with ld.lld, > which has shown no problems so far. > > Allow ld.lld to link this vDSO as we do the regular arm vDSO. To do > this, we need to do a few things: > > * Add a LD_COMPAT variable, which defaults to $(CROSS_COMPILE_COMPAT)ld > with gcc and $(LD) if LLVM is 1, which will be ld.lld, or > $(CROSS_COMPILE_COMPAT)ld if not, which matches the logic of the main > Makefile. It is overrideable for further customization and avoiding > breakage. > > * Eliminate cc32-ldoption, which matches commit 055efab3120b ("kbuild: > drop support for cc-ldoption"). > > With those, we can use $(LD_COMPAT) in cmd_ldvdso and change the flags > from compiler linker flags to linker flags directly. We eliminate > -mfloat-abi=soft because it is not handled by the linker. > > Link: https://github.com/ClangBuiltLinux/linux/issues/1033 > Reported-by: Nick Desaulniers > Signed-off-by: Nathan Chancellor Thanks for the patch and summary of related changes! This is immediately useful for Android. Reviewed-by: Nick Desaulniers Tested-by: Nick Desaulniers > --- > > NOTE: This patch is currently based on the kbuild tree due to the > --build-id -> --build-id=sha1 change that Bill did. If the arm64 > maintainers would prefer to take this patch, I can rebase it (althought > presumably this won't hit mainline until at least 5.11 so it can > probably just stay as is for now). > > arch/arm64/kernel/vdso32/Makefile | 23 ++++++++++++----------- > 1 file changed, 12 insertions(+), 11 deletions(-) > > diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile > index 7f96a1a9f68c..1cf00c58805d 100644 > --- a/arch/arm64/kernel/vdso32/Makefile > +++ b/arch/arm64/kernel/vdso32/Makefile > @@ -22,16 +22,21 @@ endif > > CC_COMPAT ?= $(CC) > CC_COMPAT += $(CC_COMPAT_CLANG_FLAGS) > + > +ifeq ($(LLVM),1) > +LD_COMPAT ?= $(LD) > +else > +LD_COMPAT ?= $(CROSS_COMPILE_COMPAT)ld > +endif > else > CC_COMPAT ?= $(CROSS_COMPILE_COMPAT)gcc > +LD_COMPAT ?= $(CROSS_COMPILE_COMPAT)ld > endif > > cc32-option = $(call try-run,\ > $(CC_COMPAT) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2)) > cc32-disable-warning = $(call try-run,\ > $(CC_COMPAT) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1))) > -cc32-ldoption = $(call try-run,\ > - $(CC_COMPAT) $(1) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2)) > cc32-as-instr = $(call try-run,\ > printf "%b\n" "$(1)" | $(CC_COMPAT) $(VDSO_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3)) > > @@ -122,14 +127,10 @@ dmbinstr := $(call cc32-as-instr,dmb ishld,-DCONFIG_AS_DMB_ISHLD=1) > VDSO_CFLAGS += $(dmbinstr) > VDSO_AFLAGS += $(dmbinstr) > > -VDSO_LDFLAGS := $(VDSO_CPPFLAGS) > # From arm vDSO Makefile > -VDSO_LDFLAGS += -Wl,-Bsymbolic -Wl,--no-undefined -Wl,-soname=linux-vdso.so.1 > -VDSO_LDFLAGS += -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096 > -VDSO_LDFLAGS += -nostdlib -shared -mfloat-abi=soft > -VDSO_LDFLAGS += -Wl,--hash-style=sysv > -VDSO_LDFLAGS += -Wl,--build-id=sha1 > -VDSO_LDFLAGS += $(call cc32-ldoption,-fuse-ld=bfd) > +VDSO_LDFLAGS += -Bsymbolic --no-undefined -soname=linux-vdso.so.1 > +VDSO_LDFLAGS += -z max-page-size=4096 -z common-page-size=4096 > +VDSO_LDFLAGS += -nostdlib -shared --hash-style=sysv --build-id=sha1 > > > # Borrow vdsomunge.c from the arm vDSO > @@ -189,8 +190,8 @@ quiet_cmd_vdsold_and_vdso_check = LD32 $@ > cmd_vdsold_and_vdso_check = $(cmd_vdsold); $(cmd_vdso_check) > > quiet_cmd_vdsold = LD32 $@ > - cmd_vdsold = $(CC_COMPAT) -Wp,-MD,$(depfile) $(VDSO_LDFLAGS) \ > - -Wl,-T $(filter %.lds,$^) $(filter %.o,$^) -o $@ > + cmd_vdsold = $(LD_COMPAT) $(VDSO_LDFLAGS) \ > + -T $(filter %.lds,$^) $(filter %.o,$^) -o $@ > quiet_cmd_vdsocc = CC32 $@ > cmd_vdsocc = $(CC_COMPAT) -Wp,-MD,$(depfile) $(VDSO_CFLAGS) -c -o $@ $< > quiet_cmd_vdsocc_gettimeofday = CC32 $@ > > base-commit: 172aad81a882443eefe1bd860c4eddc81b14dd5b > -- > 2.29.0.rc0 > -- Thanks, ~Nick Desaulniers