perf symbols: Try reading the symbol table with libbfd
authorRemi Bernon <rbernon@codeweavers.com>
Fri, 21 Aug 2020 16:52:37 +0000 (18:52 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 4 Sep 2020 17:38:15 +0000 (14:38 -0300)
commiteac9a4342e5447cade4d484261a8992e2ec6f138
tree842a3822bb2965ef25581fa5eec62716ef46dde6
parentba0509dcb7f806403b23234320711c45be9dccec
perf symbols: Try reading the symbol table with libbfd

Wine generates PE binaries for its code modules and also generates debug
files in PE or PDB formats, which perf cannot parse either.

Trying to read symbols on non-ELF binaries with libbfd, when supported,
makes it possible for perf to report symbols and annotations for Windows
applications running under Wine.

Because libbfd doesn't provide symbol size (probably because of some
backends not supporting it), we compute it by first sorting the symbols
by addresses and then considering that they are sequential in a given
section.

v3: Also include local and weak bfd symbols and mark them as such, only
    global symbols were previously reported, and that caused a very
    imprecise address to symbol resolution.

Signed-off-by: Remi Bernon <rbernon@codeweavers.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jacek Caban <jacek@codeweavers.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20200821165238.1340315-2-rbernon@codeweavers.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/symbol.c
tools/perf/util/symbol.h