Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp926196pxb; Tue, 3 Nov 2020 16:55:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJwVKXsLq6DljkiwIU+3nzU87wlmci/03FkLqTk1pTJVOyO9kOq5QHrD/tQG8ZSUeG3cbTGE X-Received: by 2002:a17:906:3282:: with SMTP id 2mr13799123ejw.52.1604451341009; Tue, 03 Nov 2020 16:55:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604451341; cv=none; d=google.com; s=arc-20160816; b=Ge04wrnjrF4tbdUn+m4FrgD7tRZQI4Bnsg9FuHIaj3eWNKz8PzoG5ynXfxMBWBVBXu yphs6fTJjHN4hrsjvmNpCSwxjrqX38SvL2pSZ+gAB6RYHJX2MdIKktxIbXUKxs2vIt3s B7vtN4u8GCCTMNmerX8dHRutZxNcp7KfijJfu6NP+ckUyX6mwAfvROUAi5byfboSv75O PHSCn1Dg3yWte3UVTlS2+SPX6vFxLWbgT2QFNUW0ajxpwcXey6Rd1OMPS5/0cBgegosB uG7NkdZwnxn7WAXdOp7uGVHmSUcls9AyRmiYrZyxiQ99uP+kofECcG2eN8zNAjz3LmFb QJyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:sender:dkim-signature; bh=6nth1Ay7JTmqSTdpD6CAIOaNAdyMhdLz3pdbFkquv2w=; b=pt9IcCHvwkA38/flPBuP8Ba3UA9nwbJZgh5d6GMY6c4NShGCT25WnSZw3/N8SdeBa5 IS0N1gdJr5zvIvyc4++b5ObUlDepUS9RzTK6amfkXiEWUxBqba+lm1s7EDhp30OUrMvl DOaHFdNmwJzuGO/p2NjSwN5cuJvwbAO/iHOCy9bovssuTko5x7fdcQl9TR3icbU931Bx 5uFum9+pPg+JJFwuladM/n1HEErQ7Pg7ISlDsX5fO23bEcxjU4AKby9gvt0PMPe7Jvvi tHb/wpx1Nt82jMivC08aWEXH50SgYqsoRm7JIhpwMesjvDbHVgFYqopPNgM5VM//zgmY jvxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="qCw8+F/+"; 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 zn5si385692ejb.202.2020.11.03.16.55.15; Tue, 03 Nov 2020 16:55:40 -0800 (PST) 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="qCw8+F/+"; 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 S1729144AbgKDAxv (ORCPT + 99 others); Tue, 3 Nov 2020 19:53:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729163AbgKDAxt (ORCPT ); Tue, 3 Nov 2020 19:53:49 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75C78C0401C3 for ; Tue, 3 Nov 2020 16:53:49 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id x125so19842693yba.17 for ; Tue, 03 Nov 2020 16:53:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=6nth1Ay7JTmqSTdpD6CAIOaNAdyMhdLz3pdbFkquv2w=; b=qCw8+F/+nLz5LxsUHleH+9cNH3m8jIH+wWmS6NvhkoTCDOMXb3tPmg8l3btrBOReNq Y3ULifDeAVzxVrvFjzWIP1iObBG+hhd9ukxP6x3WCo3dzJDy0kHhduok9ejP4WQQCnWh H++8qGkqToOvbQNp8Ja7apwvBL8Rcz4eq/A796u+jVOzUj8+5MXstB9lsmhVGkRLC7ZX tCuL/kx4KAa4n72lYDbz4OxAYWGyq+6j5y32iRTp90UQJFZZHX//2R00WF9QHVUvR6Uj YtzglSsEY6CUtUJ4ibwKiIJPwoyEryxCrqXFvsBu5z0g3ZXDq1VpbNx8dK5KvKco/zyo WyKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=6nth1Ay7JTmqSTdpD6CAIOaNAdyMhdLz3pdbFkquv2w=; b=qAlT+Uh4/lIH5mU17KWIdeEnVpKV3CW9ajJ4sLyTy51Fs0UMFMNkr6HeDVxZEqnD0K M0+anOzC0MHHd6KqVWSdCAA0ZSutHkMxwrFGferGnVqKKe5qylwsRFGA2/dLnT+g/Wlm AfEJ9s/8pWapnW4RmKdYujRDEZUHMIMPQYRCm0THgtayju9lJUFR5CRL1GInOc4I/VPT q2VAjvPmRuWh5e8ZhpCgy0OxjEEz7xr4Qqq3pAQSzhzme982KDFbdtalP+yrYhITWxvN /ewooUVaYOYXVZfGVbFngD0N46UtV0LMrX55O3Glo02j2n0boOEfq81xghv928uTI73U i37g== X-Gm-Message-State: AOAM532kGewOni8H+07ESOF+C9+J4zDW2LiFR5xC0LfL1xy7eWzpjDNW /GNw8c1K4HA9qQmMrIkTmRlbZ6/55gw3S5q5JO8= Sender: "ndesaulniers via sendgmr" X-Received: from ndesaulniers1.mtv.corp.google.com ([2620:15c:211:202:f693:9fff:fef4:4d25]) (user=ndesaulniers job=sendgmr) by 2002:a25:3188:: with SMTP id x130mr31763518ybx.64.1604451228585; Tue, 03 Nov 2020 16:53:48 -0800 (PST) Date: Tue, 3 Nov 2020 16:53:40 -0800 In-Reply-To: <20201104005343.4192504-1-ndesaulniers@google.com> Message-Id: <20201104005343.4192504-2-ndesaulniers@google.com> Mime-Version: 1.0 References: <20201104005343.4192504-1-ndesaulniers@google.com> X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog Subject: [PATCH v2 1/4] x86_64: Change .weak to SYM_FUNC_START_WEAK for arch/x86/lib/mem*_64.S From: Nick Desaulniers To: Masahiro Yamada Cc: Jakub Jelinek , Linux Kbuild mailing list , Linux Kernel Mailing List , linux-toolchains@vger.kernel.org, clang-built-linux , Fangrui Song , Nathan Chancellor , Sedat Dilek , Dmitry Golovin , Alistair Delva , Sami Tolvanen , stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Fangrui Song Commit 393f203f5fd5 ("x86_64: kasan: add interceptors for memset/memmove/memcpy functions") added .weak directives to arch/x86/lib/mem*_64.S instead of changing the existing ENTRY macros to WEAK. This can lead to the assembly snippet `.weak memcpy ... .globl memcpy` which will produce a STB_WEAK memcpy with GNU as but STB_GLOBAL memcpy with LLVM's integrated assembler before LLVM 12. LLVM 12 (since https://reviews.llvm.org/D90108) will error on such an overridden symbol binding. Commit ef1e03152cb0 ("x86/asm: Make some functions local") changed ENTRY in arch/x86/lib/memcpy_64.S to SYM_FUNC_START_LOCAL, which was ineffective due to the preceding .weak directive. Use the appropriate SYM_FUNC_START_WEAK instead. Fixes: 393f203f5fd5 ("x86_64: kasan: add interceptors for memset/memmove/memcpy functions") Fixes: ef1e03152cb0 ("x86/asm: Make some functions local") Reported-by: Sami Tolvanen Signed-off-by: Fangrui Song Tested-by: Nathan Chancellor Cc: --- arch/x86/lib/memcpy_64.S | 4 +--- arch/x86/lib/memmove_64.S | 4 +--- arch/x86/lib/memset_64.S | 4 +--- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S index 037faac46b0c..1e299ac73c86 100644 --- a/arch/x86/lib/memcpy_64.S +++ b/arch/x86/lib/memcpy_64.S @@ -16,8 +16,6 @@ * to a jmp to memcpy_erms which does the REP; MOVSB mem copy. */ -.weak memcpy - /* * memcpy - Copy a memory block. * @@ -30,7 +28,7 @@ * rax original destination */ SYM_FUNC_START_ALIAS(__memcpy) -SYM_FUNC_START_LOCAL(memcpy) +SYM_FUNC_START_WEAK(memcpy) ALTERNATIVE_2 "jmp memcpy_orig", "", X86_FEATURE_REP_GOOD, \ "jmp memcpy_erms", X86_FEATURE_ERMS diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S index 7ff00ea64e4f..41902fe8b859 100644 --- a/arch/x86/lib/memmove_64.S +++ b/arch/x86/lib/memmove_64.S @@ -24,9 +24,7 @@ * Output: * rax: dest */ -.weak memmove - -SYM_FUNC_START_ALIAS(memmove) +SYM_FUNC_START_WEAK(memmove) SYM_FUNC_START(__memmove) mov %rdi, %rax diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S index 9ff15ee404a4..0bfd26e4ca9e 100644 --- a/arch/x86/lib/memset_64.S +++ b/arch/x86/lib/memset_64.S @@ -6,8 +6,6 @@ #include #include -.weak memset - /* * ISO C memset - set a memory block to a byte value. This function uses fast * string to get better performance than the original function. The code is @@ -19,7 +17,7 @@ * * rax original destination */ -SYM_FUNC_START_ALIAS(memset) +SYM_FUNC_START_WEAK(memset) SYM_FUNC_START(__memset) /* * Some CPUs support enhanced REP MOVSB/STOSB feature. It is recommended -- 2.29.1.341.ge80a0c044ae-goog