From patchwork Tue Oct 13 03:39:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 11834931 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2E53A1592 for ; Tue, 13 Oct 2020 03:41:42 +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 E04132073A for ; Tue, 13 Oct 2020 03:41:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="fH+xAFak"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ic1DgpAt" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E04132073A 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+patchwork-linux-arm=patchwork.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: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:In-Reply-To:References:List-Owner; bh=r3VM4cHA3aOlWUCaiw2mlav8P16sAnRCtMc+DLp3Wl4=; b=fH+xAFakgZav6BOfWpfVg7PBGZ 3ua46UEo4YbsahPtvL/xEwYrLd7qzvb1dBHCcV5+2AQSu0BXcpRdmSd3K46ZXVaGhoWhpc3/C7Y+n Js2293fuuvIC7v3WBjbZcm8CZ2YrOQffHsgnpNT5E8LBgo8iTAusOSnmYDyi9FtnLsnJl3MGSX8mB Tqdyb1vytNJ5HY6YsPIz1hQ2pz9cz5zCcejaTfCYU1aBTjY2i4V1AKlfz1octl8v3BFXrArK+mSCA dJZlIqxpG2i8W58ChMOCa67WbG374DrjggHYfeUjMswZDtYWns8/6A7hx2IcTEHoB449kqN8lqM0q qMiRNXuA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kSBBj-0005LM-NY; Tue, 13 Oct 2020 03:41:23 +0000 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kSBBh-0005Kj-1D for linux-arm-kernel@lists.infradead.org; Tue, 13 Oct 2020 03:41:22 +0000 Received: by mail-pf1-x441.google.com with SMTP id j18so3253821pfa.0 for ; Mon, 12 Oct 2020 20:41:20 -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:mime-version :content-transfer-encoding; bh=QnFBf559stGtGycK6x7rPCyISX6Wjd0zGUVwkdWXItY=; b=Ic1DgpAtmYSK3H9X+FshZNBMed9A+u0Is3uJTYQoFwqpNo+dm0KU8kCJcTVb8aijJO NK36xXlolH80VTP3ZdEXEWliYUj/9+t2Al50Q3uN68xRJyGb4Hnw71fxBsLcxJX5ACDc +N0zKKQhQUq0Jri3ZDZC/DfQVsd7rFWFRxRjkXjtqqfEdZM+u5Y70pVzCHx/WRj/Fd1A NHuc7y6eYwfORXPksrbbGewbaU6JWX0HDs3jcQC1l1Bdyrqjzdyy3DaEl3vfo1j7pqEt ooz3ezPuNcvKFoxUGKoMKRGFTITVvudk3ZNtOf/O4Gpk1ymVmXzLMMu+IblYmQn4G4pp 7C1Q== 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:mime-version :content-transfer-encoding; bh=QnFBf559stGtGycK6x7rPCyISX6Wjd0zGUVwkdWXItY=; b=HfLZK0ZWlg5WlyH+LczRXdBRCOy5p+xApbXBP52iLqC/JDfdN+TRCOsLTMzghpYjME FDtLi4tS0Cr/PMmu60AtJNTC/RbB6ajwz+ZPfsr0YtbfIJnDnVq9V27x3Lg58mE+nmrT 4ZLxGNDOTwfEmuayonzwNGkjNk+KxavWOF/biZiIoLuzpt5kwSBCBVNp3EMAfspdmWL7 qemBFpAMf9cE6laFvNPbwqDbq7dB3c/TiuPvkQJHSJDrUcEOoMPF7T+Ng2+2YvEIz+k2 GNyI7kl0fX4a0QacGeX5QO3BLqMXaJUWeM/0g5A4WqspRvC6qykRKDirAuKxMxNYR6Bq 5k/Q== X-Gm-Message-State: AOAM533snziqCB4lWz6ydsweG/XzIPfRPCcP83YmWBTrYnl59cpNBxGl 0F3xMYZIS1+Z3UuTmUxPPHo= X-Google-Smtp-Source: ABdhPJyGwYce2sNmmbxXit4l2re9HBR70WjzKY24wEySbkGo9wMoKKJVaEd2pbN7PkAVsKz3HH/ksQ== X-Received: by 2002:a17:90a:62c5:: with SMTP id k5mr23551844pjs.100.1602560479246; Mon, 12 Oct 2020 20:41:19 -0700 (PDT) Received: from localhost.localdomain ([2604:1380:45e1:2200::1]) by smtp.gmail.com with ESMTPSA id b21sm13944484pfb.97.2020.10.12.20.41.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2020 20:41:18 -0700 (PDT) From: Nathan Chancellor To: Catalin Marinas , Will Deacon , Masahiro Yamada Subject: [PATCH] arm64: vdso32: Allow ld.lld to properly link the VDSO Date: Mon, 12 Oct 2020 20:39:48 -0700 Message-Id: <20201013033947.2257501-1-natechancellor@gmail.com> X-Mailer: git-send-email 2.29.0.rc0 MIME-Version: 1.0 X-Patchwork-Bot: notify X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201012_234121_186739_A659EAAA X-CRM114-Status: GOOD ( 17.07 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:441 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [natechancellor[at]gmail.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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+patchwork-linux-arm=patchwork.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 Signed-off-by: Nathan Chancellor Reviewed-by: Nick Desaulniers Tested-by: Nick Desaulniers Reviewed-by: Vincenzo Frascino --- 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(-) base-commit: 172aad81a882443eefe1bd860c4eddc81b14dd5b 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 $@