Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2996125rwd; Fri, 2 Jun 2023 19:10:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5YcevGTBtwwj+1TZhZ6vk16cHAMefKljUv82O9NPm5LSAbOICRCZW2ua71ZqgGow46vVd2 X-Received: by 2002:a05:6358:5290:b0:123:2b2e:529d with SMTP id g16-20020a056358529000b001232b2e529dmr15084417rwa.6.1685758202113; Fri, 02 Jun 2023 19:10:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685758202; cv=none; d=google.com; s=arc-20160816; b=Xyn4FK9283vIrJetX3gfEq/8KcBJ/4nrCYlDpVwldYf9l9SE4l+ypl7PUlPaTHnBNH 1PGfaFYOFU48pbCJUZMAC6LZz+kZrvDFWoRw34fpkvFbNPHaM5TxHoAE70VfyC7cd4Ao fuw+qHRC6Rt0eZaq6yl8hX2omTOicGln0RDGDx4TtMKWn9jeGIblIfM3f0/9QTNT99f3 f7ovZMRFRn4J14NR7Zt/oIBvRKk3CtnbImuujuV4R5Ea/z0XHcXTvIcP8zl/I83Mnqya 2f0lB+rqDApy+/62nenLhsZY/5AZ4PFRyMrPwLXIr+yTls05SyOYj5xDjlVX/oQNyd6f W90A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=xrP2RHSpZGR0BjaUdGPtqA51UJdSeGare1HJk4rba/M=; b=ukU14SEzgCWjK0Tn/9vTmoti0MceD3iLjDA16qaJ6in26aNEtmwXPG4cud69W2mTea beQ7J6BK3Q7tdYS1W+AuXriNore9mgTlo6RhGMz0KDig3C0+SdF0RTJPRodCYVAh8r5J 9U8EQrKGWQjR3bthLtRAKYDEbCKk8abgx5Hc/RAbib/Egie3bpU9nft+J+rEoePOAnh8 8KHOzJ50ydgWOOgwJiIMVfghc/xNyWZ74wJtXHtnJ1CF6gXfwyHTU44P/Tp1qDXBMAte lZOpNNubIXfhhjtq6uL0/bG014lZco6izG0Qosy7gKCM9N9tSFwD89zbMRqEAeyyFOcZ 4I0g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o29-20020a637e5d000000b0053fc757bb07si1886310pgn.554.2023.06.02.19.09.50; Fri, 02 Jun 2023 19:10:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237002AbjFCBiM convert rfc822-to-8bit (ORCPT + 99 others); Fri, 2 Jun 2023 21:38:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235959AbjFCBiM (ORCPT ); Fri, 2 Jun 2023 21:38:12 -0400 Received: from mail-yb1-f173.google.com (mail-yb1-f173.google.com [209.85.219.173]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D1CA1B6; Fri, 2 Jun 2023 18:38:10 -0700 (PDT) Received: by mail-yb1-f173.google.com with SMTP id 3f1490d57ef6-bacf5b89da7so2976561276.2; Fri, 02 Jun 2023 18:38:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685756289; x=1688348289; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gMdUwU9Lc9+VbG5jbwUz5cd6Cu7tJyrnLtx+vLrmeGI=; b=CccsbsUOPQn873uXnKRGFH5EmU6ts6BlklM8F2EbjV59FqDv+24KsbDdy9nBNtmGMH XLJoYYRqN+bcwNAyeDFeOqPTXdaisSSvD2ksE3UN6AyLDgKHKB3MUPHI9eTbN/tpy/+4 wIaly3MA3bYMha22Pp7gokgknauztmXjeTSn0ccdE1Dqm0hWwUCRsCqAl94y+w7LmHlR Kp7C/C045SOSQyhvbtnHKch6qWDh8h6BUBdr4x1e9stkXc+ySMKHSswhmtj2SD56bdpE qq9HH+WbkF+gexrfTNj3RgVMAUi3jOoR8ohkhwT4iAtqe/qPFM3uUF2F4of86M9PzqMM zBkA== X-Gm-Message-State: AC+VfDw7h+SNGWqAVGs4KiLFlv0EcTmQLwbKpcBvacYvbKtZ5Sd64NaJ a+kUeKEmXXEuCyjwalYyS6KKYFODdj7cxDIfWPs= X-Received: by 2002:a25:d653:0:b0:b9e:5d84:d859 with SMTP id n80-20020a25d653000000b00b9e5d84d859mr4613556ybg.46.1685756289232; Fri, 02 Jun 2023 18:38:09 -0700 (PDT) MIME-Version: 1.0 References: <20230602123815.255001-1-paniii94@gmail.com> In-Reply-To: <20230602123815.255001-1-paniii94@gmail.com> From: Namhyung Kim Date: Fri, 2 Jun 2023 18:37:58 -0700 Message-ID: Subject: Re: [PATCH v2] Subject: perf jit: Fix incorrect file name in DWARF line table To: Elisabeth Cc: Elisabeth Panholzer , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Fri, Jun 2, 2023 at 5:38 AM Elisabeth wrote: > > From: elisabeth > > Fixes an issue where an incorrect filename was added in the DWARF line table of > an ELF object file when calling 'perf inject --jit' due to not checking the > filename of a debug entry against the repeated name marker (/xff/0). > The marker is mentioned in the tools/perf/util/jitdump.h header, which describes > the jitdump binary format, and indicitates that the filename in a debug entry > is the same as the previous enrty. > In the function emit_lineno_info(), in the file tools/perf/util/genelf-debug.c, > the debug entry filename gets compared to the previous entry filename. If they > are not the same, a new filename is added to the DWARF line table. However, > since there is no check against '\xff\0', in some cases '\xff\0' is inserted > as the filename into the DWARF line table. > This can be seen with `objdump --dwarf=line` on the ELF file after `perf inject --jit`. > It also makes no source code information show up in 'perf annotate'. > > Signed-off-by: Elisabeth Panholzer > Cc: linux-kernel@vger.kernel.org > Cc: linux-perf-users@vger.kernel.org Acked-by: Namhyung Kim Thanks, Namhyung > --- > Changes in v2: > - Made the commit message more descriptive > - Added a comment that mentions the jitdump format > - Changed memcmp() to strcmp() > > tools/perf/util/genelf_debug.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/tools/perf/util/genelf_debug.c b/tools/perf/util/genelf_debug.c > index aa5dcc56b2ac..138fdf87eaa2 100644 > --- a/tools/perf/util/genelf_debug.c > +++ b/tools/perf/util/genelf_debug.c > @@ -337,6 +337,9 @@ static void emit_lineno_info(struct buffer_ext *be, > { > size_t i; > > + /* as described in the jitdump format */ > + const char repeated_name_marker[] = {'\xff', '\0'}; > + > /* > * Machine state at start of a statement program > * address = 0 > @@ -363,7 +366,8 @@ static void emit_lineno_info(struct buffer_ext *be, > /* > * check if filename changed, if so add it > */ > - if (!cur_filename || strcmp(cur_filename, ent->name)) { > + if ((!cur_filename || strcmp(cur_filename, ent->name)) && > + strcmp(repeated_name_marker, ent->name)) { > emit_lne_define_filename(be, ent->name); > cur_filename = ent->name; > emit_set_file(be, ++cur_file_idx); > -- > 2.34.1 >