Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3919326pxv; Mon, 28 Jun 2021 16:40:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyj7Ea3g+VvnLJZs/DimkkVSJJp+AWgOGOdiWtW6U6p2F7JlKt/0/LCcuKjuM3t+Gh33W71 X-Received: by 2002:a5d:888c:: with SMTP id d12mr1505111ioo.194.1624923607711; Mon, 28 Jun 2021 16:40:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624923607; cv=none; d=google.com; s=arc-20160816; b=SFbopMNugvisKWNX8XsB/FnHi6c0VxhqYhQjq12RhM2a2rXXStzAhALJ1GVMj63jdR qM7B/oDGLTxWOQLL27iwyPLVb3KUT1nf+yPN6dgEnHsyS1lyDytD1G0zJ2bKGGaciayB B91yPoaLX0SQG0CkkxApPlsl4S6dmIA/Pleb5JBZFP5bR0MgKjWrsSf/RFsYmE9oAf4z E4MiRoxIlZoziAMq58V/pU/QLgxC5VPO/UkNDSX5GqspFjrozkX8w2o1RhdBK0AWVQsf 0ftOHrT7uf9W5pQ/WEV5PJ1OvXEFsPbgXJ/i8+jWDpZywKP4ShgmBpXnf9cr1sev3J1O c1jQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=beso7VBAe7MQCcx243Y/tF0q9TE4lE7EjU8nTpd7jTs=; b=ywiBULfGiwdRsDI3qHxTKqK/ku52GeAffNcLwtoiiqZyjVolPDSJh9V09i+v6qNelg 4SMYdGsSnlQaxl8j+iSlLrO75f0GoyfrJnSIOKVLl7+gKQ6z8Q2rZyLcrNfk32gDDVIs vp9OOVYhC3ZU9GORSQCUyuVuTSE7rJnRACTu72D/hwRVhSkEhjv0ptu29aCcPtXvAkqJ drTWTFYJBo/X1dqD1BTD4FmFSaScnhzaDuTuSXt76UZ36SAaM4ePjVVk60TLCMgyQ6aa Tgf/05yePHoMAB4xA/MZ52wmd8s00eTzzzLUg3aw/DwTGZd3gWx2tnz2KletiFoc6EdA J9xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=INpVfpbH; 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 h12si15510395ilc.40.2021.06.28.16.39.56; Mon, 28 Jun 2021 16:40:07 -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=INpVfpbH; 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 S234641AbhF1SXc (ORCPT + 99 others); Mon, 28 Jun 2021 14:23:32 -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-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