Message ID | 2ed246c95cac628cffc1628c115a4b791459f8fe.1724698250.git.scclevenger@os.amperecomputing.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | arm-cs-trace-disasm.py/perf must accommodate non-zero DSO text offset | expand |
On 8/26/2024 10:35 PM, Steve Clevenger wrote: > > Changes in V2: > - Updated mailing list distribution > > Use dso__is_pie() to check whether the DSO file is a Position > Independent Executable (PIE). If PIE, change the MAPPING_TYPE to > MAPPING_TYPE__IDENTITY so a zero map pgoff (text offset) is passed > into the script. > > > Signed-off-by: Steve Clevenger <scclevenger@os.amperecomputing.com> > --- > tools/perf/util/map.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c > index e1d14936a60d..df7c06fc373e 100644 > --- a/tools/perf/util/map.c > +++ b/tools/perf/util/map.c > @@ -171,8 +171,11 @@ struct map *map__new(struct machine *machine, u64 start, u64 len, > assert(!dso__kernel(dso)); > map__init(result, start, start + len, pgoff, dso); > > + if (map->pgoff && !no_dso) > + no_dso = dso__is_pie(dso); // PIE check Here the logic is whatever the `pgoff` is (zero or non-zero), we need to always set the mapping type as MAPPING_TYPE__IDENTITY. It is no need to check pgoff and is no matter with 'no_dso'. So we can simply check dso__is_pie() and set IDENTITY flag for the true case. if (dso__is_pie(dso)) { map__set_mapping_type(map, MAPPING_TYPE__IDENTITY); } else if (anon || no_dso) { ... } BTW, please rebase the series on the top of the perf-tools-next branch [1], I saw this patch has merging conflict on it. Thanks, Leo [1] https://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git branch: perf-tools-next > + > if (anon || no_dso) { > - map->mapping_type = MAPPING_TYPE__IDENTITY; > + map__set_mapping_type(map, MAPPING_TYPE__IDENTITY); > > /* > * Set memory without DSO as loaded. All map__find_* > -- > 2.25.1 >
On 8/27/2024 12:55 PM, Leo Yan wrote: > On 8/26/2024 10:35 PM, Steve Clevenger wrote: >> >> Changes in V2: >> - Updated mailing list distribution >> >> Use dso__is_pie() to check whether the DSO file is a Position >> Independent Executable (PIE). If PIE, change the MAPPING_TYPE to >> MAPPING_TYPE__IDENTITY so a zero map pgoff (text offset) is passed >> into the script. >> >> >> Signed-off-by: Steve Clevenger <scclevenger@os.amperecomputing.com> >> --- >> tools/perf/util/map.c | 5 ++++- >> 1 file changed, 4 insertions(+), 1 deletion(-) >> >> diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c >> index e1d14936a60d..df7c06fc373e 100644 >> --- a/tools/perf/util/map.c >> +++ b/tools/perf/util/map.c >> @@ -171,8 +171,11 @@ struct map *map__new(struct machine *machine, u64 start, u64 len, >> assert(!dso__kernel(dso)); >> map__init(result, start, start + len, pgoff, dso); >> >> + if (map->pgoff && !no_dso) >> + no_dso = dso__is_pie(dso); // PIE check > > Here the logic is whatever the `pgoff` is (zero or non-zero), we need to > always set the mapping type as MAPPING_TYPE__IDENTITY. It is no need to check > pgoff and is no matter with 'no_dso'. So we can simply check dso__is_pie() and > set IDENTITY flag for the true case. > > if (dso__is_pie(dso)) { > map__set_mapping_type(map, MAPPING_TYPE__IDENTITY); > } else if (anon || no_dso) { > ... > } > > BTW, please rebase the series on the top of the perf-tools-next branch [1], I > saw this patch has merging conflict on it. > > Thanks, > Leo Hi Leo, I combined the dso__is_pie() call onto the end of the existing 'if' statement you now show as an 'else if'. Please see V3 of the patch series. Steve > > [1] https://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git > branch: perf-tools-next >> + >> if (anon || no_dso) { >> - map->mapping_type = MAPPING_TYPE__IDENTITY; >> + map__set_mapping_type(map, MAPPING_TYPE__IDENTITY); >> >> /* >> * Set memory without DSO as loaded. All map__find_* >> -- >> 2.25.1 >>
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index e1d14936a60d..df7c06fc373e 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c @@ -171,8 +171,11 @@ struct map *map__new(struct machine *machine, u64 start, u64 len, assert(!dso__kernel(dso)); map__init(result, start, start + len, pgoff, dso); + if (map->pgoff && !no_dso) + no_dso = dso__is_pie(dso); // PIE check + if (anon || no_dso) { - map->mapping_type = MAPPING_TYPE__IDENTITY; + map__set_mapping_type(map, MAPPING_TYPE__IDENTITY); /* * Set memory without DSO as loaded. All map__find_*
Changes in V2: - Updated mailing list distribution Use dso__is_pie() to check whether the DSO file is a Position Independent Executable (PIE). If PIE, change the MAPPING_TYPE to MAPPING_TYPE__IDENTITY so a zero map pgoff (text offset) is passed into the script. Signed-off-by: Steve Clevenger <scclevenger@os.amperecomputing.com> --- tools/perf/util/map.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)