Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp1048301ybm; Wed, 27 May 2020 14:52:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKigVgCdMm4hWCQUPRZqN7KxYZ2lCReN91j6RnZddkBbrdGJaCAtQHZQqfiOqNHtHwuhMN X-Received: by 2002:a50:fd04:: with SMTP id i4mr188014eds.43.1590616373314; Wed, 27 May 2020 14:52:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590616373; cv=none; d=google.com; s=arc-20160816; b=TuBxR+T1Sx30PTfo6ZnrIvbwYCZ5bNwXo3+dHOrDQlhD7yBAZf9WtfrKYGFxtCJN5U GaezZQOI0eNAT7bisXbG1dSwUF25JVrR1LCFUYcdBsPSh/deGvq47WpUjrBXwQHRK16+ DsZmzON7Z0VAOg/4AFkaJsQwWk0C35HSKtww/DFB21KFrvphjqNEJ5kZvZdtVHOtarjt e9PmsfIEGklCXtO5nedItbTyGf/az+aH2GNpLvvsguAMPftH/muXWhiiSda3aCLT23gL w50Y6SvAfINbhy7rnA2xCXtorvfkbd6CVjAUml93AzMMBp0HTIgz5nYXgQ908AygItIG BidQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=iA+KkSp+x1pCOvFG2laI62cGHgeFrOqb4fOzsNTxNXU=; b=KnzID6ghQCw4QP5P/by5aGFnnq+QLCMn1mKzVtO8y3oTnXSeL6LxrXK9oQY7anMLxd xrn+IYruoaejYhgUDSnEz8kd42PIACKW5bcfQh88Da9vj060rA9gi0dZhRPDr3Kmqp4b RXLeNba/vfHJrUw+kdAT74zrEhgXiKHCfcuLSpIYQVTL1QKLkGFoxwzb5A0DeQSXM+F+ AyMRg8936Vfoe/v0TFIBEQdlD40oWNmQP6zbfMzbsIfoh+lxnudHtSODgFWhQWaxkaON YfU9AvpAiFBqia741NB7BhMeZrx/JWEx9ogZkgu6RY7yg4uhs7kgZ2TnagKcXCQnqGEt qxPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=s5sgK5hV; 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 g6si2369070edq.605.2020.05.27.14.52.29; Wed, 27 May 2020 14:52:53 -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=s5sgK5hV; 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 S1726911AbgE0Srm (ORCPT + 99 others); Wed, 27 May 2020 14:47:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726482AbgE0Srg (ORCPT ); Wed, 27 May 2020 14:47:36 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5EABC08C5C2 for ; Wed, 27 May 2020 11:28:49 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id f21so9186454pgg.12 for ; Wed, 27 May 2020 11:28:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=iA+KkSp+x1pCOvFG2laI62cGHgeFrOqb4fOzsNTxNXU=; b=s5sgK5hVj6s8lKi3Rri8hD77o4Tgsh/f//XKeSLPPL6IoaX/9mCJYEHRJ32vVuTTGB dFOJ6DX54r/GDHqGsERVaSkKn7VZP6w7vmoq01S+s7Vgp4NCjhtVzBjBz/ibFnvGcWta mSfHvumiHewYuXpM4XZwLfp01LJYUKENxLfVUkXnOtA0BezWqdmG+dG9FruFxrFvx+z0 OLSDlugaSodJcE0avHyTiDxelPvs1YxJU3Ddg4TK5lzP7IpA32ZcQqmyQOKAlpQDiDDP fF30dP0+KbJyDOf08di6glcZut8WphRJqfLPENPijbkDbzZ6pcV6gQGYyCj6OH9Rd9v6 fRqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=iA+KkSp+x1pCOvFG2laI62cGHgeFrOqb4fOzsNTxNXU=; b=ubItvF1VL3SvZkCUPigJTxfVRdXh7PPsFLIa9NdYyAbZunQoVJBKEDbNzUvYUNGzTJ 8APFqK1OhPCDD1If/apibZNQP2kEEdJeO1qnVzTyqN5g8QLtwhjpGrCrdgzitz5hrZlv uNU2n6covs+ELypQpMaaooYUPC/v3fQFgpDd+LsZkC5qw7Pm+455HepDKFnOgAlmJIAx f0U3mE1j15XxsUF/DpgGFsksK2plimw8B8J6HgPQgjwbHFKxlBDEPPNKYYaNNbdGjuek 87yOmVN0r3MfGJX/3ArZEAToNJukcZpiDAlfUzOM+ZwKQzyoi0PCjK+F+eCwIgtqt7dV IUAw== X-Gm-Message-State: AOAM5308tG4QbaOyk/juvh07TM7vWy75C8pcMpyZbcXH6clGxPwh1IBc DERxyMi+eAJ8qsXeQPBRV5WXlf4YtN6ntg== X-Received: by 2002:a63:e008:: with SMTP id e8mr5139090pgh.451.1590604128900; Wed, 27 May 2020 11:28:48 -0700 (PDT) Received: from google.com ([2620:15c:2ce:0:9efe:9f1:9267:2b27]) by smtp.gmail.com with ESMTPSA id z8sm2517225pgc.80.2020.05.27.11.28.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 May 2020 11:28:48 -0700 (PDT) Date: Wed, 27 May 2020 11:28:43 -0700 From: Fangrui Song To: Nick Desaulniers Cc: Arnd Bergmann , Catalin Marinas , Will Deacon , "# 3.4.x" , Alexios Zavras , Enrico Weigelt , Linux ARM , LKML , clang-built-linux , Bill Wendling , Jian Cai Subject: Re: [PATCH] arm64: fix clang integrated assembler build Message-ID: <20200527182843.g6tbow4lqsvwl2ah@google.com> References: <20200527141435.1716510-1-arnd@arndb.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-05-27, 'Nick Desaulniers' via Clang Built Linux wrote: >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. This may be another instance of https://sourceware.org/pipermail/binutils/2020-March/000299.html https://lore.kernel.org/linuxppc-dev/20200325164257.170229-1-maskray@google.com/ I haven't checked but there may be both a .globl directive and a .weak directive >> 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 > >-- >You received this message because you are subscribed to the Google Groups "Clang Built Linux" group. >To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-linux+unsubscribe@googlegroups.com. >To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/CAKwvOdnNxj-MdKj3aWoefF2W9PPG-TSeNU4Ym-N8NODJB5Yw_w%40mail.gmail.com.