Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4227878pxu; Tue, 20 Oct 2020 11:17:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNHti0Bjzt+opjDbT37MdP0/5yZtjN1v334X1BP4TCvWVxeqzkXFSLZ3ePpnDumoYxR8P3 X-Received: by 2002:aa7:d384:: with SMTP id x4mr4180015edq.105.1603217846315; Tue, 20 Oct 2020 11:17:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603217846; cv=none; d=google.com; s=arc-20160816; b=ezi6UUEAH40bRtgMys6f9ab1zZ9gKgedqtIlwvpp/8cQ+DGwA2gOSKC4v73yW/2J9/ Sk6xloaOZJZuFYuV4XZhtyPgiz0Zr1jyCMNK0df/Z0Qodtt1h555Iw5uK9bC290y21VL /LPRzTQUIruVkYE+l6X+sNHDaUH3Wnz9JSHF9r/J9eKmFb4vYsl3ZqWUiwFR/h7nMt/p wfMkETsa33jKAbrEmStjYwrRFGdqMG5vfAMxt6cTOOgkRSJgWlT8kHf4d4Vm2tv6MMWE 8IZR60bPpOAWM2b/HLFxJqEmqSrQC450MTRaHYW44AjixcK8WNLDr6SOMVqF5vHNCPVu TCLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tRiShrUt1sTjH+sdv59h0JyXdNaA2SG4GeoIP63o8wM=; b=AaFIQkCB0b1MCIg0+eAmZHOGZY5uDV61OlXJUkF+MAU39kUDUMPcxuD2hxmlGxBFye m51u5lOEklcA0x91FvgmaGh8/S2Oa5iIAxGJsjU9/BuA9JThYXiK4fIN+g5soqShgoYu 9+kTKYJAiUEwtKGsw1C7PTCsmjpLclW7AG//OAue/M882P3gNL86CLL88YoVVqFPJHis I4u/2VxIO7fcj3oYSbLKZxn6BDCfPWIiNYnfEgI3o7uZy+IV8y+XZXEThOFSZnuztKJB syUkIS7CQ5F73wqPuV4ZATuFCnL9pwlJWoiC/ktjoZz+8W+ddQU59YwU52c9rbdFwq3q tTbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=e3krGkYg; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cn23si1611780edb.364.2020.10.20.11.17.04; Tue, 20 Oct 2020 11:17:26 -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=@gmail.com header.s=20161025 header.b=e3krGkYg; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389902AbgJTBP2 (ORCPT + 99 others); Mon, 19 Oct 2020 21:15:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389894AbgJTBP2 (ORCPT ); Mon, 19 Oct 2020 21:15:28 -0400 Received: from mail-io1-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C957C0613CE; Mon, 19 Oct 2020 18:15:26 -0700 (PDT) Received: by mail-io1-xd44.google.com with SMTP id b15so439732iod.13; Mon, 19 Oct 2020 18:15:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tRiShrUt1sTjH+sdv59h0JyXdNaA2SG4GeoIP63o8wM=; b=e3krGkYgqO4VmM1cAcJRWfGjadPaXVp9xbvn2O8n1yL4BED5i8IHz19sTvr56wBTug 0nnsV4GPzaEOEZvUfp6UVSzQhKE5je7a6arDbGDy35PUP1bFLX/NzeWnAwP8UWeVtKQ6 SZfSM3QaCEfb2GK075DGZc9mXeR67R+GpeWO0kn6hj+hbMxiy07pOZPD+XtUxf3Q2UL7 ile6TT2sE52qNuNYmiOrun89m517A4R5QBbMTpdz5HWvJdEd1Idr7NR3uIy+8QwaRN03 BXMtvPxe+Wliiba31xCpgg8s0Erj/HHZiC1vqtXf6cJMJHvT/nW4amGpMHiq4Qi03Sd4 QVeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tRiShrUt1sTjH+sdv59h0JyXdNaA2SG4GeoIP63o8wM=; b=YBpSopXyG6t9Z17cT+ilZnv5ThNUjc1xAA+QjrNsCT3C6P9arDy9NmwcA+6Gw9Cwa8 Xuvda4MwPzXvA94uF2NFhWK+ddrFivX74ZyFpRNcj4mmy3sYizx9mmKI3t/9zMKHGLfc 3nF9+x5omL7kdqyBSQgo0IjiRdp4Fhx9R78EmnKDOBdSf+E2ZU1vPcVS+DyJoY9pGVWY /DOb1z3y+8MRI/PZsfD60ClsJPkht/v72z9ub41qKGODzjLYheF5eJnGMqEMtLxBLO2F NOUZCO4pHCYpMr0EpAi33IWeYb+uarHR5w1aDwrnoR/YmVRtPPg6C6n2a4Fin0sx4ZrH +zOQ== X-Gm-Message-State: AOAM530E5+0D2sPtTlI65HpGB3QYRp6Dcc2ugE5MoSg20vRyZqka+IV3 vD0mYMzNGjJstT/szwtGVE4= X-Received: by 2002:a6b:7f43:: with SMTP id m3mr399912ioq.114.1603156525808; Mon, 19 Oct 2020 18:15:25 -0700 (PDT) Received: from localhost.localdomain ([2604:1380:45d1:2600::3]) by smtp.gmail.com with ESMTPSA id t16sm357646ild.27.2020.10.19.18.15.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Oct 2020 18:15:25 -0700 (PDT) From: Nathan Chancellor To: Catalin Marinas , Will Deacon , Masahiro Yamada Cc: linux-arm-kernel@lists.infradead.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Nathan Chancellor , Nick Desaulniers , Vincenzo Frascino Subject: [PATCH v2] arm64: vdso32: Allow ld.lld to properly link the VDSO Date: Mon, 19 Oct 2020 18:14:07 -0700 Message-Id: <20201020011406.1818918-1-natechancellor@gmail.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20201013033947.2257501-1-natechancellor@gmail.com> References: <20201013033947.2257501-1-natechancellor@gmail.com> MIME-Version: 1.0 X-Patchwork-Bot: notify Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Reviewed-by: Nick Desaulniers Tested-by: Nick Desaulniers Reviewed-by: Vincenzo Frascino Signed-off-by: Nathan Chancellor --- v1 -> v2: * Change ifeq ($(LLVM),1) to ifneq ($(LLVM),) to match the main Makefile per Vincenzo. * Carry forward Nick and Vincenzo's tags. 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..79280c53b9a6 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) + +ifneq ($(LLVM),) +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: 0fa21cf4489fe11737d56f8056dda1ba0257bd8d -- 2.29.0