The base address of a DSO mapping should start at the start of the file.
Usually DSOs are mapped from the pgoff 0 so it doesn't matter when it
uses the start of the map address. But generated DSOs for JIT codes
doesn't start from the 0 so it should subtract the offset to calculate
the .eh_frame table offsets correctly.
Fixes: dc2cf4ca866f ("perf unwind: Fix segbase for ld.lld linked objects")
Signed-off-by: Namhyung Kim <[email protected]>
---
tools/perf/util/unwind-libunwind-local.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/util/unwind-libunwind-local.c b/tools/perf/util/unwind-libunwind-local.c
index c0641882fd2f..5e5c3395a499 100644
--- a/tools/perf/util/unwind-libunwind-local.c
+++ b/tools/perf/util/unwind-libunwind-local.c
@@ -327,7 +327,7 @@ static int read_unwind_spec_eh_frame(struct dso *dso, struct unwind_info *ui,
maps__for_each_entry(thread__maps(ui->thread), map_node) {
struct map *map = map_node->map;
- u64 start = map__start(map);
+ u64 start = map__start(map) - map__pgoff(map);
if (map__dso(map) == dso && start < base_addr)
base_addr = start;
--
2.43.0.472.g3155946c3a-goog
On Mon, Dec 11, 2023 at 11:05 PM Namhyung Kim <[email protected]> wrote:
>
> The base address of a DSO mapping should start at the start of the file.
> Usually DSOs are mapped from the pgoff 0 so it doesn't matter when it
> uses the start of the map address. But generated DSOs for JIT codes
> doesn't start from the 0 so it should subtract the offset to calculate
> the .eh_frame table offsets correctly.
>
> Fixes: dc2cf4ca866f ("perf unwind: Fix segbase for ld.lld linked objects")
> Signed-off-by: Namhyung Kim <[email protected]>
Reviewed-by: Ian Rogers <[email protected]>
Thanks,
Ian
> ---
> tools/perf/util/unwind-libunwind-local.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/unwind-libunwind-local.c b/tools/perf/util/unwind-libunwind-local.c
> index c0641882fd2f..5e5c3395a499 100644
> --- a/tools/perf/util/unwind-libunwind-local.c
> +++ b/tools/perf/util/unwind-libunwind-local.c
> @@ -327,7 +327,7 @@ static int read_unwind_spec_eh_frame(struct dso *dso, struct unwind_info *ui,
>
> maps__for_each_entry(thread__maps(ui->thread), map_node) {
> struct map *map = map_node->map;
> - u64 start = map__start(map);
> + u64 start = map__start(map) - map__pgoff(map);
>
> if (map__dso(map) == dso && start < base_addr)
> base_addr = start;
> --
> 2.43.0.472.g3155946c3a-goog
>