From mboxrd@z Thu Jan 1 00:00:00 1970 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=-13.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no 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 2DC6BC11F64 for ; Mon, 28 Jun 2021 18:21:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 11F9561C7B for ; Mon, 28 Jun 2021 18:21:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235461AbhF1SXd (ORCPT ); Mon, 28 Jun 2021 14:23:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233562AbhF1SXV (ORCPT ); Mon, 28 Jun 2021 14:23:21 -0400 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31B51C061574 for ; Mon, 28 Jun 2021 11:20:55 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id j4so34250455lfc.8 for ; Mon, 28 Jun 2021 11:20:55 -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=beso7VBAe7MQCcx243Y/tF0q9TE4lE7EjU8nTpd7jTs=; b=INpVfpbHRshQB5FvW1owFUibqPb80t8mMeuTMDUhKCiZXhrI3GeyDSrg4x0eR9ycyf SCt1QiDDpcJdXlk8QCCCJjhKRbGwsGVRRW/E0Kfwk6wM1PpJ83lD8Du18O/r67vJbaAH wS3LKhFnuE0eo9X9sUzB0S28jSArTaWVC2H01rs0nIvrDzses72eW+dHBNt/P9/Fr3SG P0btg5jNWiHA5qI1WktBZ16k19iQr0xgp2e6uhlq8iFl3B4Ji4oquyhnS0Ap7pxNCY/Y BdHnTJKMM+JMkGL/O7QdOy+AwyNCjOPTyW1SZuYoDrn8qfmEjo0LPZuj23uHCWBx2jeQ okqQ== 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=beso7VBAe7MQCcx243Y/tF0q9TE4lE7EjU8nTpd7jTs=; b=a9pkvI/YC+ipWK8JSbysK7G0xnYrY4DtQ4Vt68N4Zem5DAsqpedjavzOzmD1mBH2cj QeZVc8+Gs3R/xuvVWlR7Gj/WYjPf5cgpnRXlderBxvT/sMiTGhnt7VEtF9jDt/wH93Eu lTPwbq6H31F03P4NYZD2qZMs7jXFFSMevBlvwEvG0jS8Oyea1uEettQEUx75h3urkK7+ ifaardIWWWI6rqv3Ju35GQVQqYVKK9xcXuDNOnv6UfWJRNqTMWvVR/Uj64Pt220PGUjR LzI1709kRl4BVj892VTQzCBQkQau3LNb2kZdsxod8Lm5kHRvSjITiEIhkFj4HqEJeuI/ eD5Q== X-Gm-Message-State: AOAM532KBRAZJ5l/95UQPd4Ls57XnkxMVpVJ9v3U/j2ThOqNQL7atk21 pfZrJjqPUhTrrBkxroRFwGUNOW4HK1ILARS71uLQZA== X-Google-Smtp-Source: ABdhPJwTYBDH9MLG9PcH6cneZ9d3Ga2u8rCYEs5cyo45CDONOb6eSNua6P42B8byPlDbRgDbRbwuiTCQOMWYNyyCb8E= X-Received: by 2002:ac2:4438:: with SMTP id w24mr20583194lfl.73.1624904453291; Mon, 28 Jun 2021 11:20:53 -0700 (PDT) MIME-Version: 1.0 References: <20210622183858.2962637-1-ndesaulniers@google.com> <20210622201822.ayavok3d2fw3u2pl@google.com> In-Reply-To: From: Nick Desaulniers Date: Mon, 28 Jun 2021 11:20:41 -0700 Message-ID: Subject: Re: [PATCH] kallsyms: strip LTO suffixes from static functions To: Fangrui Song Cc: Kees Cook , "KE . LI" , Nathan Chancellor , Andrew Morton , Stephen Rothwell , Miroslav Benes , "Gustavo A. R. Silva" , Stephen Boyd , Sami Tolvanen , Joe Perches , linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 28, 2021 at 10:54 AM Nick Desaulniers wrote: > > On Tue, Jun 22, 2021 at 1:18 PM Fangrui Song wrote: > > > > On 2021-06-22, 'Nick Desaulniers' via Clang Built Linux wrote: > > >+/* > > >+ * LLVM mangles static functions for full LTO so that two static functions with > > >+ * the same identifier do not collide when all code is combined into one > > >+ * module. The scheme used converts references to foo into > > >+ * foo.llvm.974640843467629774, for example. This can break hooking of static > > >+ * functions with kprobes. > > >+ */ > > > > The comment should say ThinLTO instead. > > > > The .llvm.123 suffix is for global scope promotion for local linkage > > symbols. The scheme is ThinLTO specific. This ensures that a local > > Oh, boy. Indeed. I had identified the mangling coming from > getGlobalNameForLocal(), but looking at the call chain now I see: > > FunctionImportGlobalProcessing::processGlobalForThinLTO() > -> FunctionImportGlobalProcessing::getPromotedName() > -> ModuleSummaryIndex::getGlobalNameForLocal() > > I'm not sure then how I figured it was specific to full LTO. > > Android recently switched from thin LTO to full LTO, which is what I > assumed was the cause of the bug report. Rereading our internal bug > report, it was tested against a prior version that did the symbol > truncation for thinLTO. I then assumed this was full LTO specific for > whatever reason, and modified the patch to only apply to full LTO. I > see via the above call chain that this patch is not correct. Let me > send my original patch as a v2. b/189560201 if you're interested. I can even see the .llvm. symbol names via `llvm-nm` on vmlinux for thinLTO builds. No such symbols exist for full LTO. -- Thanks, ~Nick Desaulniers