Skip to content

Commit 362f9c9

Browse files
epanholznamhyung
authored andcommitted
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 <[email protected]> Acked-by: Namhyung Kim <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Fixed a trailing white space, removed a subject prefix ] Signed-off-by: Namhyung Kim <[email protected]>
1 parent 4ca0d34 commit 362f9c9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tools/perf/util/genelf_debug.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,9 @@ static void emit_lineno_info(struct buffer_ext *be,
337337
{
338338
size_t i;
339339

340+
/* as described in the jitdump format */
341+
const char repeated_name_marker[] = {'\xff', '\0'};
342+
340343
/*
341344
* Machine state at start of a statement program
342345
* address = 0
@@ -363,7 +366,8 @@ static void emit_lineno_info(struct buffer_ext *be,
363366
/*
364367
* check if filename changed, if so add it
365368
*/
366-
if (!cur_filename || strcmp(cur_filename, ent->name)) {
369+
if ((!cur_filename || strcmp(cur_filename, ent->name)) &&
370+
strcmp(repeated_name_marker, ent->name)) {
367371
emit_lne_define_filename(be, ent->name);
368372
cur_filename = ent->name;
369373
emit_set_file(be, ++cur_file_idx);

0 commit comments

Comments
 (0)