Re: [PATCH v2 2/3] perf symbols: Try reading the symbol table with libbfd

From: Remi Bernon
Date: Wed Aug 05 2020 - 02:50:33 EST

On 2020-08-04 22:32, Jiri Olsa wrote:
On Tue, Aug 04, 2020 at 10:57:35AM +0200, Remi Bernon wrote:


+int dso__load_bfd_symbols(struct dso *dso, const char *debugfile)
+ int err = -1;
+ long symbols_size, symbols_count;
+ asection *section;
+ asymbol **symbols, *sym;
+ struct symbol *symbol;
+ bfd *abfd;
+ u_int i;
+ u64 start, len;
+ abfd = bfd_openr(dso->long_name, NULL);
+ if (!abfd)
+ return -1;
+ if (!bfd_check_format(abfd, bfd_object)) {
+ pr_debug2("%s: cannot read %s bfd file.\n", __func__,
+ dso->long_name);
+ goto out_close;
+ }
+ if (bfd_get_flavour(abfd) == bfd_target_elf_flavour)
+ goto out_close;

aah, so the code is actualy only for non elf objects,
somehow I thought it's replacing the symbol load globaly


Maybe it could but because libbfd exposes the common subset of all its backends, it doesn't provide symbol sizes for instance (that's how I understand it). So I didn't want to lose features compared to what the libelf path is currently doing.

For non-elf objects, the implementation here works around that by assuming that all the symbols are following each other contiguously, but that's a little bit incorrect.
Rémi Bernon <rbernon@xxxxxxxxxxxxxxx>