From: Fangrui Song <maskray@google.com>
To: Leo Yan <leo.yan@linaro.org>
Cc: 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>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] perf symbol: Skip recording symbols in '.gnu.warning.*' sections
Date: Sat, 23 Jul 2022 20:42:20 -0700 [thread overview]
Message-ID: <CAFP8O3LJq1rt6i0_rAW5pShUiA=FJ38ceb4Ps0KmLdCNzC9xbQ@mail.gmail.com> (raw)
In-Reply-To: <20220724022857.2621520-3-leo.yan@linaro.org>
On Sat, Jul 23, 2022 at 7:29 PM Leo Yan <leo.yan@linaro.org> wrote:
>
> Some symbols are observed their '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 symbols, this
> kind of symbols are only used for linker warning.
>
> This patch skips to record symbols from '.gnu.warning.*' sections by
> detecting the sub string '.gnu.warning' is contained in section name.
>
> Signed-off-by: Leo Yan <leo.yan@linaro.org>
Presumably __evoke_link_warning_getwd is due to `clang -fuse-ld=lld
-static ...` on a file calling the deprecated getwd.
GNU ld and gold implement a .gnu.warning.* feature which removes the
section. ld.lld just ignores this section as the usefulness of the
functionality is unclear.
The section .gnu.warning.getwd does not have the SHF_ALLOC flag. Such
sections are not part of memory images and I think it is more generic
ignoring all symbols residing in a non-SHF_ALLOC section.
> ---
> tools/perf/util/symbol-elf.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
> index ef6ced5c5746..4b621e355c0e 100644
> --- a/tools/perf/util/symbol-elf.c
> +++ b/tools/perf/util/symbol-elf.c
> @@ -1277,6 +1277,14 @@ dso__load_sym_internal(struct dso *dso, struct map *map, struct symsrc *syms_ss,
>
> section_name = elf_sec__name(&shdr, secstrs);
>
> + /*
> + * A symbol coming from ".gnu.warning.*" sections is used to
> + * generate linker warnings, its 'sym.st_value' field usually
> + * is zero, skip to record it.
> + */
> + if (strstr(section_name, ".gnu.warning"))
> + continue;
> +
> /* On ARM, symbols for thumb functions have 1 added to
> * the symbol address as a flag - remove it */
> if ((ehdr.e_machine == EM_ARM) &&
> --
> 2.25.1
>
--
宋方睿
next prev parent reply other threads:[~2022-07-24 3:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-24 2:28 [PATCH v2 0/2] perf symbol: Minor fixing Leo Yan
2022-07-24 2:28 ` [PATCH v2 1/2] perf symbol: Correct address for bss symbols Leo Yan
2022-07-24 2:28 ` [PATCH v2 2/2] perf symbol: Skip recording symbols in '.gnu.warning.*' sections Leo Yan
2022-07-24 3:42 ` Fangrui Song [this message]
2022-07-24 5:23 ` 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='CAFP8O3LJq1rt6i0_rAW5pShUiA=FJ38ceb4Ps0KmLdCNzC9xbQ@mail.gmail.com' \
--to=maskray@google.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=leo.yan@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.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).