Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp965755ybm; Wed, 27 May 2020 12:21:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8mDkUdCRJsuWyGeT19ebCE1jDz5TBs/agREm4u2ohUUYT38kGBwi7KXdb18JmvR2P+YCJ X-Received: by 2002:aa7:d0c4:: with SMTP id u4mr24809603edo.44.1590607319618; Wed, 27 May 2020 12:21:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590607319; cv=none; d=google.com; s=arc-20160816; b=jbcIH/qzlaur1UUbcnZNn1FgVp0toD4v20bxBifv6zJ1o71Ig9lnUTQoMRpgOzKjtA of2ASqO+qhrkA7olN3WtZng6ML+KXV/rvRXASX05cuQDxzqsmQ7VN6V09VuoSyxRO29G KrCEuU6HtMwO3BxlB5+cX4Im1dJ/9/QUoj+J+UdEOSn7x/ZhEC9vAbk/zycX1n964ZrD EJq4CDmEmtSYimTc5m4FGL9KISxZhppCzFp9z8jS9mXPPBBd2b1Hq4VtmvAzaIOCb3xO j8vDk/EJlppgLRrMxHV9xaWzEhr9mM+uzpyj4f3nXJDBy6Tgr6fCNKfboW+sb+zkV6m9 T0eQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=1i+2CYKnygDzk/GvSPMFnlsBZ+PDQAs0JHC2OCU8Rpg=; b=uRwI21dhA/DCQNrZ8iTMBi+J3jqebwHwTltwczX8d2MrpUo4DEdUdrFwagZ6SNqoZF FwvICZVR6lmMCt16zWOZkiLkDQjfTjwbd6abNIWS5/v9vmKHnc37QqW2p5VYI2CnBGsc d+2oG4uWJshAzv+SzRrJk3Iht/w1Y6FbS23SyI79C7x2JqmNDPI2tiKt4DqNOVrapoaH VTvWWGnTuo52e4OkPPYUi1oGkHEV16U92n4zp7qbh6CvWVTgVUhmvwFzvo9O2k9JqQKt 0nwZWhdZFRxiSUacWqa7lAZgiu6X58zKO4ltVGJEC4WKPEb0B4SipBpomyrnKUpeuDNG MumA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Juuy34H7; 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 pk16si2546992ejb.310.2020.05.27.12.21.37; Wed, 27 May 2020 12:21:59 -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=Juuy34H7; 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 S1729304AbgE0SDh (ORCPT + 98 others); Wed, 27 May 2020 14:03:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729082AbgE0SDg (ORCPT ); Wed, 27 May 2020 14:03:36 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 414E9C03E97D for ; Wed, 27 May 2020 11:03:36 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id z26so12159970pfk.12 for ; Wed, 27 May 2020 11:03:36 -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=1i+2CYKnygDzk/GvSPMFnlsBZ+PDQAs0JHC2OCU8Rpg=; b=Juuy34H7e5clylfdiyvSvG4F1wyq9c8Gaj8QNysrOlDgGCGB7A08vEUvk3NP/Wn1H6 Yog5pD+mXyHk+WVgoLhuHW3Omp5d+eepMRoD2hYNRRK5PkkUSlyxec51h45s6fdpYill lA4WHf6wyk335XsVHjeAc4Q2RIQDLyeAIKwrzDBommB66eFrjgaTrHUKh+YskoAupwbq eDWaNMQh5VN1aoa5wksCQ49WwMi1vHRhUDNMtMhCEclzc24PdY4Wv3QfxGMydNAOePYK xdcnU39N8S3XzdUmTP21oRzd9CrtlFniuJBnOhhkPr0/09QMJdtokXOxrAby+3nxwfjm aARA== 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=1i+2CYKnygDzk/GvSPMFnlsBZ+PDQAs0JHC2OCU8Rpg=; b=otc3GfKdR8PxhF1MPLQ1aLZEtBvJeC4qc3YKOUhsyHjahWnUjkmNtW0heXlVmmKCzz NdflOGKt5Y+y6/bXYPsWVfn7c5VpGoQ0/LHq+ywYfmFhWgXsswxeQH+nLmFI/2we0+yf JsD0qLFRVn0e7bu3lo/O0OpsAT44PzKQu2p9HG1M+s2u3z8ASkbSduEkXhp28GxMuXjI Ic8RZgsKeYxxyfdjYv4iDo34OxfKFNQBpL7Xyg0Z8uBJ2sMmqTGXIqdCVUsocS8xE4iO RREsqbn1lZoXVSa2S7EBTXbPJFEkCbz1uxCKZIO/FsqUbKsr0KZ8frDT3viL1iL1v14M p7QA== X-Gm-Message-State: AOAM533vMJU/JP4R0cWGviWTMjTRmZ7Tp+rDQI+rDvDXihXnTaLnf1Jt N6slVXTfLQFNEFCxHiDJuBLKYfr70+YP2Bm0LA+laQ== X-Received: by 2002:aa7:8c44:: with SMTP id e4mr5128942pfd.108.1590602615524; Wed, 27 May 2020 11:03:35 -0700 (PDT) MIME-Version: 1.0 References: <20200527141435.1716510-1-arnd@arndb.de> In-Reply-To: <20200527141435.1716510-1-arnd@arndb.de> From: Nick Desaulniers Date: Wed, 27 May 2020 11:03:24 -0700 Message-ID: Subject: Re: [PATCH] arm64: fix clang integrated assembler build To: Arnd Bergmann Cc: Catalin Marinas , Will Deacon , "# 3.4.x" , Alexios Zavras , Enrico Weigelt , Linux ARM , LKML , clang-built-linux , Bill Wendling , Jian Cai , Fangrui Song Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 27, 2020 at 7:14 AM Arnd Bergmann wrote: > > clang and gas seem to interpret the symbols in memmove.S and > memset.S differently, such that clang does not make them > 'weak' as expected, which leads to a linker error, with both > ld.bfd and ld.lld: > > ld.lld: error: duplicate symbol: memmove > >>> defined at common.c > >>> kasan/common.o:(memmove) in archive mm/built-in.a > >>> defined at memmove.o:(__memmove) in archive arch/arm64/lib/lib.a > > ld.lld: error: duplicate symbol: memset > >>> defined at common.c > >>> kasan/common.o:(memset) in archive mm/built-in.a > >>> defined at memset.o:(__memset) in archive arch/arm64/lib/lib.a > > Copy the exact way these are written in memcpy_64.S, which does > not have the same problem. > > I don't know why this makes a difference, and it would be good > to have someone with a better understanding of assembler internals > review it. > > It might be either a bug in the kernel or a bug in the assembler, > no idea which one. My patch makes it work with all versions of > clang and gcc, which is probably helpful even if it's a workaround > for a clang bug. + Bill, Fangrui, Jian I think we saw this bug or a very similar bug internally around the ordering of .weak to .global. > > Cc: stable@vger.kernel.org > Signed-off-by: Arnd Bergmann > --- > --- > arch/arm64/lib/memcpy.S | 3 +-- > arch/arm64/lib/memmove.S | 3 +-- > arch/arm64/lib/memset.S | 3 +-- > 3 files changed, 3 insertions(+), 6 deletions(-) > > diff --git a/arch/arm64/lib/memcpy.S b/arch/arm64/lib/memcpy.S > index e0bf83d556f2..dc8d2a216a6e 100644 > --- a/arch/arm64/lib/memcpy.S > +++ b/arch/arm64/lib/memcpy.S > @@ -56,9 +56,8 @@ > stp \reg1, \reg2, [\ptr], \val > .endm > > - .weak memcpy > SYM_FUNC_START_ALIAS(__memcpy) > -SYM_FUNC_START_PI(memcpy) > +SYM_FUNC_START_WEAK_PI(memcpy) > #include "copy_template.S" > ret > SYM_FUNC_END_PI(memcpy) > diff --git a/arch/arm64/lib/memmove.S b/arch/arm64/lib/memmove.S > index 02cda2e33bde..1035dce4bdaf 100644 > --- a/arch/arm64/lib/memmove.S > +++ b/arch/arm64/lib/memmove.S > @@ -45,9 +45,8 @@ C_h .req x12 > D_l .req x13 > D_h .req x14 > > - .weak memmove > SYM_FUNC_START_ALIAS(__memmove) > -SYM_FUNC_START_PI(memmove) > +SYM_FUNC_START_WEAK_PI(memmove) > cmp dstin, src > b.lo __memcpy > add tmp1, src, count > diff --git a/arch/arm64/lib/memset.S b/arch/arm64/lib/memset.S > index 77c3c7ba0084..a9c1c9a01ea9 100644 > --- a/arch/arm64/lib/memset.S > +++ b/arch/arm64/lib/memset.S > @@ -42,9 +42,8 @@ dst .req x8 > tmp3w .req w9 > tmp3 .req x9 > > - .weak memset > SYM_FUNC_START_ALIAS(__memset) > -SYM_FUNC_START_PI(memset) > +SYM_FUNC_START_WEAK_PI(memset) > mov dst, dstin /* Preserve return value. */ > and A_lw, val, #255 > orr A_lw, A_lw, A_lw, lsl #8 > -- > 2.26.2 -- Thanks, ~Nick Desaulniers