perf jit: Fix incorrect file name in DWARF line table
authorelisabeth <paniii94@gmail.com>
Fri, 2 Jun 2023 12:38:15 +0000 (14:38 +0200)
committerNamhyung Kim <namhyung@kernel.org>
Wed, 21 Jun 2023 05:18:58 +0000 (22:18 -0700)
commit362f9c907fd8c2be3d5c5686ea787bca25443cdc
treedad1e6253552f3f0d57ac70b214b7138fe9e9d36
parent4ca0d340ce206985d9b9956993d7c81eeb1d3198
perf jit: Fix incorrect file name in DWARF line table

Fixes an issue where an incorrect filename was added in the DWARF line table of
an ELF object file when calling 'perf inject --jit' due to not checking the
filename of a debug entry against the repeated name marker (/xff/0).
The marker is mentioned in the tools/perf/util/jitdump.h header, which describes
the jitdump binary format, and indicitates that the filename in a debug entry
is the same as the previous enrty.

In the function emit_lineno_info(), in the file tools/perf/util/genelf-debug.c,
the debug entry filename gets compared to the previous entry filename. If they
are not the same, a new filename is added to the DWARF line table. However,
since there is no check against '\xff\0', in some cases '\xff\0' is inserted
as the filename into the DWARF line table.

This can be seen with `objdump --dwarf=line` on the ELF file after `perf inject --jit`.
It also makes no source code information show up in 'perf annotate'.

Signed-off-by: Elisabeth Panholzer <elisabeth@leaningtech.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20230602123815.255001-1-paniii94@gmail.com
[ Fixed a trailing white space, removed a subject prefix ]
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/util/genelf_debug.c