Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3474841imu; Mon, 28 Jan 2019 05:36:25 -0800 (PST) X-Google-Smtp-Source: ALg8bN7XzwflxTeuYs9RVdaVDBNs4k/qDsaUzl/1aG7pjU+SeJMSTLMdi/JGCTCgpkTNdhYyBeVy X-Received: by 2002:a17:902:714c:: with SMTP id u12mr21588694plm.234.1548682585769; Mon, 28 Jan 2019 05:36:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548682585; cv=none; d=google.com; s=arc-20160816; b=gN0iTCmLMvqdYdGtB36FVOzONG9Fne0Hoe2dyNG0R2Yh7pP7xwk6E8wSnVJNEx4Sye CAyBTVYJ0Y3ByaU4fFusQyB//Kj3BZU+Dox0TkxZQIDdw0qtw5lVC+1CogspwAEHXykQ P3KJ6bdKv27X087WzAksohImiDznnVbd8fEp1HLmJop08x61ZqlBOmudlGISCL4y60Cz TvBnC8zwdUUWuEVOeE1T2/DKOi9Oyf0SM+J/AQsgriAqV8IDoSFcCqqnzkAU2en9Vs8S 7JndfAnJLnoTP8myTSmSKJ7S9AsI7rm6aV82Ser37pb1yx8nkehTZlyHTp4gtTQClCw2 ZExw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Gts6BMGC58Fm3uzuElYMo8J1nV2PtotNmq/NFcDIBlE=; b=TjmCG+d/QbDOesxyYs+R5AsmdxU0IZBx5opwEQz7MU0XWBNpF/kCYqeFY2YrYknXyk 9g/m9B/zsq3t0vxSkxc2SdbOVWdzZls3pEJ4fGPPLUI6f2o9UKkTw0CbFIXy+fcwYgD+ WHjyvhkARaOspmWssvj/47vRPKvwNat64XRKU3qk9T4uyFRlV6UOp5cw31QYB5W5s9gW +bOGDoXz7biIhcq/9V9cARc14QyWhuriHpynscQgxPpka3xix1o4yg1l8q6m1A2Hth8B Dad0kGkhXdOASXxdPeS4QOZfKCW1wGApF0AQIkYPtHwHfjkH3wIPIrkDS+0e3GGS/fAi zlBA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (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 r18si30576015pgb.491.2019.01.28.05.36.10; Mon, 28 Jan 2019 05:36:25 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726792AbfA1Nfb (ORCPT + 99 others); Mon, 28 Jan 2019 08:35:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33186 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726647AbfA1Nfa (ORCPT ); Mon, 28 Jan 2019 08:35:30 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2BABAC058CB7; Mon, 28 Jan 2019 13:35:30 +0000 (UTC) Received: from krava (unknown [10.40.205.232]) by smtp.corp.redhat.com (Postfix) with SMTP id 4F4C12B9FA; Mon, 28 Jan 2019 13:35:27 +0000 (UTC) Date: Mon, 28 Jan 2019 14:35:26 +0100 From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: Jiri Olsa , Nick Clifton , lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan , Masami Hiramatsu Subject: [PATCH] perf tools: Filter out hidden symbols from labels Message-ID: <20190128133526.GD15461@krava> References: <20190115135354.11572-1-jolsa@kernel.org> <960f0b83-a623-67a6-ab55-d56139d10ba2@redhat.com> <20190115173838.GB31411@krava> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190115173838.GB31411@krava> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 28 Jan 2019 13:35:30 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 15, 2019 at 06:38:38PM +0100, Jiri Olsa wrote: > On Tue, Jan 15, 2019 at 04:13:16PM +0000, Nick Clifton wrote: > > Hi Jiri, > > > > > When perf is built with annobin plugin (RHEL8 build) extra symbols > > > are added to its binary: > > > > A bit of background for those wondering why annobin is creating > > these symbols: Annobin is a plugin for gcc that records data > > about how object file were built. It is specifically designed > > to be able to cope with files that are built using multiple > > different sets of optimization options. (Eg because of #pragma > > directives or function specific optimization attributes). It > > generates notes to cover each compiled region of code, and it > > needs the symbols in order to be able to determine exactly which > > areas in a linked binary were compiled with which options. > > > > In the course of developing this plugin I encountered various > > problems with tools not expecting to find extra symbols in a > > binary. Hence I made the symbols local, hidden and with no type. > > It was the best I could do to say "ignore these symbols - they > > are not meant to be seen by anyone but annobin". > > > > > > > + elf_sym__visibility(sym) != STV_HIDDEN; > > > > Just to be awkward, if you are going to ignore STV_HIDDEN > > symbols then you should probably also ignore STV_INTERNAL ones > > as well... Annobin does not generate them, but you never know, > > one day some other tool might create some. > > sounds good, thanks there were no objections for rfc, sending patch thanks, jirka --- When perf is built with annobin plugin (RHEL8 build) extra symbols are added to its binary: # nm perf | grep annobin | head -10 0000000000241100 t .annobin_annotate.c 0000000000326490 t .annobin_annotate.c 0000000000249255 t .annobin_annotate.c_end 00000000003283a8 t .annobin_annotate.c_end 00000000001bce18 t .annobin_annotate.c_end.hot 00000000001bce18 t .annobin_annotate.c_end.hot 00000000001bc3e2 t .annobin_annotate.c_end.unlikely 00000000001bc400 t .annobin_annotate.c_end.unlikely 00000000001bce18 t .annobin_annotate.c.hot 00000000001bce18 t .annobin_annotate.c.hot ... those symbols have no use for report or annotation and should be skipped. Moreover they interfere with dwarf unwind test on ppc arch, where they are mixed with checked symbols and test fails: # perf test dwarf -v 59: Test dwarf unwind : --- start --- test child forked, pid 8515 unwind: .annobin_dwarf_unwind.c:ip = 0x10dba40dc (0x2740dc) ... got: .annobin_dwarf_unwind.c 0x10dba40dc, expecting test__arch_unwind_sample unwind: failed with 'no error' The annobin symbols are defined as NOTYPE/LOCAL/HIDDEN: # readelf -s ./perf | grep annobin | head -1 40: 00000000001bce4f 0 NOTYPE LOCAL HIDDEN 13 .annobin_init.c They can still pass the check for the label symbol. Adding check for HIDDEN and INTERNAL (as suggested by Nick below) visibility and filter out such symbols. > Just to be awkward, if you are going to ignore STV_HIDDEN > symbols then you should probably also ignore STV_INTERNAL ones > as well... Annobin does not generate them, but you never know, > one day some other tool might create some. Link: http://lkml.kernel.org/n/tip-4yuna6qhhg0df3q147cjdyuu@git.kernel.org Signed-off-by: Jiri Olsa --- tools/perf/util/symbol-elf.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index 66a84d5846c8..03cb8c6d620a 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c @@ -87,6 +87,11 @@ static inline uint8_t elf_sym__type(const GElf_Sym *sym) return GELF_ST_TYPE(sym->st_info); } +static inline uint8_t elf_sym__visibility(const GElf_Sym *sym) +{ + return GELF_ST_VISIBILITY(sym->st_other); +} + #ifndef STT_GNU_IFUNC #define STT_GNU_IFUNC 10 #endif @@ -111,7 +116,9 @@ static inline int elf_sym__is_label(const GElf_Sym *sym) return elf_sym__type(sym) == STT_NOTYPE && sym->st_name != 0 && sym->st_shndx != SHN_UNDEF && - sym->st_shndx != SHN_ABS; + sym->st_shndx != SHN_ABS && + elf_sym__visibility(sym) != STV_HIDDEN && + elf_sym__visibility(sym) != STV_INTERNAL; } static bool elf_sym__filter(GElf_Sym *sym) -- 2.17.2