From: Leo Yan <leo.yan@linaro.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Mark Rutland <mark.rutland@arm.com>, Jiri Olsa <jolsa@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Ian Rogers <irogers@google.com>,
Fangrui Song <maskray@google.com>,
Chang Rui <changruinj@gmail.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Leo Yan <leo.yan@linaro.org>
Subject: [PATCH v3 2/2] perf symbol: Skip symbols if SHF_ALLOC flag is not set
Date: Sun, 24 Jul 2022 14:00:13 +0800 [thread overview]
Message-ID: <20220724060013.171050-3-leo.yan@linaro.org> (raw)
In-Reply-To: <20220724060013.171050-1-leo.yan@linaro.org>
Some symbols are observed the 'st_value' field are zeros. E.g.
libc.so.6 in Ubuntu contains a symbol '__evoke_link_warning_getwd' which
resides in the '.gnu.warning.getwd' section.
Unlike normal sections, such kind of sections are used for linker
warning when a file calls deprecated functions, but they are not part of
memory images, the symbols in these sections should be dropped.
This patch checks the section attribute SHF_ALLOC bit, if the bit is not
set, it skips symbols to avoid spurious ones.
Suggested-by: Fangrui Song <maskray@google.com>
Signed-off-by: Leo Yan <leo.yan@linaro.org>
---
tools/perf/util/symbol-elf.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index ef6ced5c5746..b3be5b1d9dbb 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -1255,6 +1255,17 @@ dso__load_sym_internal(struct dso *dso, struct map *map, struct symsrc *syms_ss,
gelf_getshdr(sec, &shdr);
+ /*
+ * If the attribute bit SHF_ALLOC is not set, the section
+ * doesn't occupy memory during process execution.
+ * E.g. ".gnu.warning.*" section is used by linker to generate
+ * warnings when calling deprecated functions, the symbols in
+ * the section aren't loaded to memory during process execution,
+ * so skip them.
+ */
+ if (!(shdr.sh_flags & SHF_ALLOC))
+ continue;
+
secstrs = secstrs_sym;
/*
--
2.25.1
next prev parent reply other threads:[~2022-07-24 6:00 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-24 6:00 [PATCH v3 0/2] perf symbol: Minor fixing Leo Yan
2022-07-24 6:00 ` [PATCH v3 1/2] perf symbol: Correct address for bss symbols Leo Yan
2022-07-25 18:29 ` Arnaldo Carvalho de Melo
2022-07-26 0:53 ` Leo Yan
2022-07-26 1:04 ` Arnaldo Carvalho de Melo
2022-07-26 1:06 ` Leo Yan
2022-07-30 5:13 ` Ian Rogers
2022-07-30 9:38 ` Leo Yan
2022-07-30 15:21 ` Ian Rogers
2022-07-31 12:37 ` Leo Yan
2022-07-31 16:51 ` Ian Rogers
2022-07-24 6:00 ` Leo Yan [this message]
2022-07-25 16:54 ` [PATCH v3 0/2] perf symbol: Minor fixing Namhyung Kim
2022-07-26 0:55 ` Leo Yan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220724060013.171050-3-leo.yan@linaro.org \
--to=leo.yan@linaro.org \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=changruinj@gmail.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=maskray@google.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).