From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ian Rogers <irogers@google.com>
Cc: Fangrui Song <maskray@google.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev, Sebastian Ullrich <sebasti@nullri.ch>
Subject: Re: [PATCH v2] perf: Fix segbase for ld.lld linked objects
Date: Fri, 3 Jun 2022 21:24:01 +0200 [thread overview]
Message-ID: <Yppf0ZOhRWZunQDx@kernel.org> (raw)
In-Reply-To: <CAP-5=fWXm-G8M_MTBjj2h_JkHgj6WU27GDqJ0hcRthtYG-m4AQ@mail.gmail.com>
Em Fri, May 27, 2022 at 11:51:54AM -0700, Ian Rogers escreveu:
> On Fri, May 27, 2022 at 11:20 AM Fangrui Song <maskray@google.com> wrote:
> >
> > segbase is the address of .eh_frame_hdr and table_data is segbase plus
> > the header size. find_proc_info computes segbase as `map->start +
> > segbase - map->pgoff` which is wrong when
> >
> > * .eh_frame_hdr and .text are in different PT_LOAD program headers
> > * and their p_vaddr difference does not equal their p_offset difference
> >
> > Since 10.0, ld.lld's default --rosegment -z noseparate-code layout has
> > such R and RX PT_LOAD program headers.
> >
> > ld.lld (default) => perf report fails to unwind `perf record
> > --call-graph dwarf` recorded data
> > ld.lld --no-rosegment => ok (trivial, no R PT_LOAD)
> > ld.lld -z separate-code => ok but by luck: there are two PT_LOAD but
> > their p_vaddr difference equals p_offset difference
> >
> > ld.bfd -z noseparate-code => ok (trivial, no R PT_LOAD)
> > ld.bfd -z separate-code (default for Linux/x86) => ok but by luck:
> > there are two PT_LOAD but their p_vaddr difference equals p_offset
> > difference
> >
> > To fix the issue, compute segbase as dso's base address plus
> > PT_GNU_EH_FRAME's p_vaddr. The base address is computed by iterating
> > over all dso-associated maps and then subtract the first PT_LOAD p_vaddr
> > (the minimum guaranteed by generic ABI) from the minimum address.
> >
> > In libunwind, find_proc_info transitively called by unw_step is cached,
> > so the iteration overhead is acceptable.
> >
> > Reported-by: Sebastian Ullrich <sebasti@nullri.ch>
> > Link: https://github.com/ClangBuiltLinux/linux/issues/1646
> > Signed-off-by: Fangrui Song <maskray@google.com>
> > Cc: Ian Rogers <irogers@google.com>
>
> Reviewed-by: Ian Rogers <irogers@google.com>
Thanks, applied.
- Arnaldo
next prev parent reply other threads:[~2022-06-03 19:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-27 18:20 [PATCH v2] perf: Fix segbase for ld.lld linked objects Fangrui Song
2022-05-27 18:51 ` Ian Rogers
2022-06-03 19:24 ` Arnaldo Carvalho de Melo [this message]
2022-05-28 12:06 ` Jiri Olsa
2022-05-28 14:49 ` Ian Rogers
2022-05-29 20:14 ` Jiri Olsa
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=Yppf0ZOhRWZunQDx@kernel.org \
--to=acme@kernel.org \
--cc=irogers@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=maskray@google.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=sebasti@nullri.ch \
/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).