Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf jit: Fix inaccurate DWARF line table

Fix an issue where addresses in the DWARF line table are offset by -0x40
(GEN_ELF_TEXT_OFFSET). This can be seen with `objdump -S` on the ELF
files after perf inject.

Committer notes:

Ian added this in his Acked-by reply:

---
Without too much knowledge this looks good to me. The original code came
from oprofile's jit support:

https://sourceforge.net/p/oprofile/oprofile/ci/master/tree/opjitconv/debug_line.c#l325
---

Signed-off-by: Nick Gasson <nick.gasson@arm.com>
Acked-by: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lore.kernel.org/lkml/20200528051916.6722-1-nick.gasson@arm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Nick Gasson and committed by
Arnaldo Carvalho de Melo
1e4bd2ae 7d7e503c

+2 -2
+2 -2
tools/perf/util/genelf_debug.c
··· 342 342 */ 343 343 344 344 /* start state of the state machine we take care of */ 345 - unsigned long last_vma = code_addr; 345 + unsigned long last_vma = 0; 346 346 char const *cur_filename = NULL; 347 347 unsigned long cur_file_idx = 0; 348 348 int last_line = 1; ··· 473 473 ent = debug_entry_next(ent); 474 474 } 475 475 add_compilation_unit(di, buffer_ext_size(dl)); 476 - add_debug_line(dl, debug, nr_debug_entries, 0); 476 + add_debug_line(dl, debug, nr_debug_entries, GEN_ELF_TEXT_OFFSET); 477 477 add_debug_abbrev(da); 478 478 if (0) buffer_ext_dump(da, "abbrev"); 479 479