Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp508003ybh; Wed, 18 Mar 2020 04:09:40 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvdQ4kwIW1i2dNsJgBf8Ht6M/paRkF9753+JZpUMB3TWWXllpRPUl4GUNcKSIEIcMNDai9c X-Received: by 2002:a9d:de8:: with SMTP id 95mr3443798ots.160.1584529779975; Wed, 18 Mar 2020 04:09:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584529779; cv=none; d=google.com; s=arc-20160816; b=0+5HidUEC1bkfgl8Bfa0Xlr5pBWR3KzFqhDjNnVXcJMrVyFK/3s9ZPfOCk1oyLwffN TKqosMZq4RIYxDWKEriJ30+U5z7Bnb22XA5wyQ52dOzcYlDUcQ0mFVa9rEjKTtm6M9d+ wXArYZd/e2s7x8tshLgiscnun4TkU2QjxgXZrtEuonAfpPCYTphWFfNHAu7tjw/WG9UR LIVznBZpW4U1dV4GPUieXwEqfjl/iU+z4X400m++sj4gpg1EkYl7oNAK6Oftby4eAXXw SUhrWJQS0ZZ+2/9BvPyDltsse0OW26dVl2aFjk6rnw7OVS1kLTf1iVUR+jp6WfXqNeAn tfuA== 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=GJuHIBrfqORNK8Nk//tvsHAKGs0fyhu6IzH+S6F8COs=; b=R1M3rOdek+3SSW1ACOEjK1X4rCzrScSio8ztZWj/i+7WXcVCAEwuDZO6+lkMefjsHQ Hgu0EExbVTwxF2P14dvNyur2BJ9IxoFS87eRxdWdRrSGBqO3hauS8m5y20tjjM9Rxzyg Z9J+HZXSz19mAmAKDqjMQpgY/aCdLIhs+oyVKahCpOawLEl0B8Ut8IhYX4nycbh+EAT1 OZH9sDFkwps43632poNPRJOKKx+xSbBnp0M024S8zYr0BMnYirSDcOPlnPgoeoAo43Bp WpUabLyRn/wpU3NjrhXR0MiYxA/mgtu1p3HzK+QDco/LhIx0BlVoX5wq+NlsfzUsKtsS qPiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HhUGXkr7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k28si3129507otb.94.2020.03.18.04.09.19; Wed, 18 Mar 2020 04:09:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HhUGXkr7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727722AbgCRLHQ (ORCPT + 99 others); Wed, 18 Mar 2020 07:07:16 -0400 Received: from us-smtp-delivery-74.mimecast.com ([63.128.21.74]:60303 "EHLO us-smtp-delivery-74.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726733AbgCRLHQ (ORCPT ); Wed, 18 Mar 2020 07:07:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584529634; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=GJuHIBrfqORNK8Nk//tvsHAKGs0fyhu6IzH+S6F8COs=; b=HhUGXkr7trnQMPN3WqkOZ6MJ75YbdY+NWJLi0hRrPNgnVUmeMLEt8PoVRNjwkwseISNYJR 5QNwkopcRj+yLkr5+WbtKulgp2gZbrAUqIOwCNvKeW6lDhKjIX2Vy1ve2Szx78vzlELyow S6HVXwgfImkkXFr0ijaSRWp9KK8zT64= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-344-iNAxtlBPM4-TwZXDc3dohQ-1; Wed, 18 Mar 2020 07:07:10 -0400 X-MC-Unique: iNAxtlBPM4-TwZXDc3dohQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B06E3477; Wed, 18 Mar 2020 11:07:07 +0000 (UTC) Received: from krava (unknown [10.40.195.82]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D74F894956; Wed, 18 Mar 2020 11:07:01 +0000 (UTC) Date: Wed, 18 Mar 2020 12:06:59 +0100 From: Jiri Olsa To: Leo Yan Cc: Arnaldo Carvalho de Melo , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Namhyung Kim , Thomas Gleixner , Kate Stewart , Greg Kroah-Hartman , Allison Randal , John Garry , Enrico Weigelt , linux-kernel@vger.kernel.org, Mike Leach , Mathieu Poirier , "Naveen N. Rao" , Hendrik Brueckner , Thomas Richter Subject: Re: [PATCH v3] perf symbols: Consolidate symbol fixup issue Message-ID: <20200318110659.GA845874@krava> References: <20200306015759.10084-1-leo.yan@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200306015759.10084-1-leo.yan@linaro.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 06, 2020 at 09:57:58AM +0800, Leo Yan wrote: > After copying Arm64's perf archive with object files and perf.data file > to x86 laptop, the x86's perf kernel symbol resolution fails. It > outputs 'unknown' for all symbols parsing. > > This issue is root caused by the function elf__needs_adjust_symbols(), > x86 perf tool uses one weak version, Arm64 (and powerpc) has rewritten > their own version. elf__needs_adjust_symbols() decides if need to parse > symbols with the relative offset address; but x86 building uses the weak > function which misses to check for the elf type 'ET_DYN', so that it > cannot parse symbols in Arm DSOs due to the wrong result from > elf__needs_adjust_symbols(). > > The DSO parsing should not depend on any specific architecture perf > building; e.g. x86 perf tool can parse Arm and Arm64 DSOs, vice versa. > And confirmed by Naveen N. Rao that powerpc64 kernels are not being > built as ET_DYN anymore and change to ET_EXEC. > > This patch removes the arch specific functions for Arm64 and powerpc and > changes elf__needs_adjust_symbols() as a common function. > > In the common elf__needs_adjust_symbols(), it checks an extra condition > 'ET_DYN' for elf header type. With this fixing, the Arm64 DSO can be > parsed properly with x86's perf tool. > > Before: > > # perf script > main 3258 1 branches: 0 [unknown] ([unknown]) => ffff800010c4665c [unknown] ([kernel.kallsyms]) > main 3258 1 branches: ffff800010c46670 [unknown] ([kernel.kallsyms]) => ffff800010c4eaec [unknown] ([kernel.kallsyms]) > main 3258 1 branches: ffff800010c4eaec [unknown] ([kernel.kallsyms]) => ffff800010c4eb00 [unknown] ([kernel.kallsyms]) > main 3258 1 branches: ffff800010c4eb08 [unknown] ([kernel.kallsyms]) => ffff800010c4e780 [unknown] ([kernel.kallsyms]) > main 3258 1 branches: ffff800010c4e7a0 [unknown] ([kernel.kallsyms]) => ffff800010c4eeac [unknown] ([kernel.kallsyms]) > main 3258 1 branches: ffff800010c4eebc [unknown] ([kernel.kallsyms]) => ffff800010c4ed80 [unknown] ([kernel.kallsyms]) > > After: > > # perf script > main 3258 1 branches: 0 [unknown] ([unknown]) => ffff800010c4665c coresight_timeout+0x54 ([kernel.kallsyms]) > main 3258 1 branches: ffff800010c46670 coresight_timeout+0x68 ([kernel.kallsyms]) => ffff800010c4eaec etm4_enable_hw+0x3cc ([kernel.kallsyms]) > main 3258 1 branches: ffff800010c4eaec etm4_enable_hw+0x3cc ([kernel.kallsyms]) => ffff800010c4eb00 etm4_enable_hw+0x3e0 ([kernel.kallsyms]) > main 3258 1 branches: ffff800010c4eb08 etm4_enable_hw+0x3e8 ([kernel.kallsyms]) => ffff800010c4e780 etm4_enable_hw+0x60 ([kernel.kallsyms]) > main 3258 1 branches: ffff800010c4e7a0 etm4_enable_hw+0x80 ([kernel.kallsyms]) => ffff800010c4eeac etm4_enable+0x2d4 ([kernel.kallsyms]) > main 3258 1 branches: ffff800010c4eebc etm4_enable+0x2e4 ([kernel.kallsyms]) => ffff800010c4ed80 etm4_enable+0x1a8 ([kernel.kallsyms]) > > v3: Changed to check for ET_DYN across all architectures. > > v2: Fixed Arm64 and powerpc native building. > > Reported-by: Mike Leach > Signed-off-by: Leo Yan > Reviewed-by: Naveen N. Rao Acked-by: Jiri Olsa thanks, jirka