From patchwork Tue Oct 20 01:14:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 11845591 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=-17.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable 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 EF3F7C433E7 for ; Tue, 20 Oct 2020 01:16:58 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6247520760 for ; Tue, 20 Oct 2020 01:16:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="cBKvw+cb"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="e3krGkYg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6247520760 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=kkMVZEKI4qUKYhtQFaKG1X8CzZ55WQOnZm9fex9COoU=; b=cBKvw+cbZumAFmMbXM/tWJCCP 9No/e57MOboLy4S38zTAQAaZqVCJjJpiVMhzZ5+GmLDFLTF8bNg8EvqJFYzaT8ut3OdxVevUbP8Y2 c40N7D+73VIPI6JOFzEijY9WV9a7MXW9drBE/ZMrHmKp2P/CSG+rqMi//VRHsLLbDM0M2W27I6OMS gF4f8z+5hS3Xzl02bKq/u7Z/3Vjq+xBULmzUO/QA8D+ERj3f6EwQ1QX5QwX9OPtyjsNrqoLQJT/cy 806+RozsBbUAw1DYbHOL/OeOyc989DMGnfQDUdCyc628aGALDaYu5qMbDIvpHSflsjGdp78waXUuv 06GVr/OkQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kUgFP-0007CB-Gw; Tue, 20 Oct 2020 01:15:31 +0000 Received: from mail-io1-xd44.google.com ([2607:f8b0:4864:20::d44]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kUgFL-0007Bi-Qp for linux-arm-kernel@lists.infradead.org; Tue, 20 Oct 2020 01:15:29 +0000 Received: by mail-io1-xd44.google.com with SMTP id k21so464896ioa.9 for ; Mon, 19 Oct 2020 18:15:27 -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=neGg9mvYc2gJerJBvaQqVXx9QeE2cq6UEpliktZeoBuO/H0T+k5e8DUNb9TtRQNukL I4dWdaEvbzOAACFOipwt1qUV1qs2WY1mm9+XKLkkXGkuulr5qGWhn5xQeRFNj/aIoVAP AXNyxF+pu0r2BMd+9dxlPPyg2Qr325dnHffD9zIaa579+pISsZ1Sg+1o79WkdLC07Kv+ YB9dA9a130wue2SSsDsoFnx/KvdrQphxxxrt7IOCc8Fxn0ToZeZWUn9p/4gyczkRpzJ/ /sIlXJWs6/Mkoq+zHJIgg7wzw6DvdZU67rGIksd/qXmkN3HZIPyxPFJWNI9RLyFDTwl4 Vv0g== X-Gm-Message-State: AOAM5311RCQd89F/H483HFhrXLS19D+Hm8YwJPW7cq8uX9SoDacY45UL jvGUvoBzvxoOOjalWiP6FDA= X-Google-Smtp-Source: ABdhPJyLWcIpobZwJhM8mXlvbTqrqTmqKAOLlP7hYWYDqhmVfa6lhMFK/8j6Uvor5L4+wG5pVpG+Yg== 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201019_211528_783890_A3F0D2EA X-CRM114-Status: GOOD ( 16.95 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kbuild@vger.kernel.org, Nick Desaulniers , linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Nathan Chancellor , Vincenzo Frascino , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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(-) base-commit: 0fa21cf4489fe11737d56f8056dda1ba0257bd8d 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 $@