Commit b2fe96a3 authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo

perf tools: Fix module symbol processing

The 'dso->kernel' condition is true also for kernel modules now,
and there are several places that were omited by the initial change:

  - we need to identify modules separately in dso__process_kernel_symbol
  - we need to set 'dso->kernel' for module from buildid table
  - there's no need to use 'dso->kernel || kmodule' in one condition

Committer testing:

Before:

  # perf test -v object
  <SNIP>
  Objdump command is: objdump -z -d --start-address=0xffffffff813e682f --stop-address=0xffffffff813e68af /usr/lib/debug/lib/modules/5.7.14-200.fc32.x86_64/vmlinux
  Bytes read match those read by objdump
  Reading object code for memory address: 0xffffffffc02dc257
  File is: /lib/modules/5.7.14-200.fc32.x86_64/kernel/arch/x86/crypto/crc32c-intel.ko.xz
  On file address is: 0xffffffffc02dc2e7
  dso__data_read_offset failed
  test child finished with -1
  ---- end ----
  Object code reading: FAILED!
  #

After:

  # perf test object
  26: Object code reading                                   : Ok
  # perf test object
  26: Object code reading                                   : Ok
  # perf test object
  26: Object code reading                                   : Ok
  # perf test object
  26: Object code reading                                   : Ok
  # perf test object
  26: Object code reading                                   : Ok
  #

Fixes: 02213cec ("perf maps: Mark module DSOs with kernel type")
Reported-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
parent 1c695c88
...@@ -2090,9 +2090,8 @@ static int __event_process_build_id(struct perf_record_header_build_id *bev, ...@@ -2090,9 +2090,8 @@ static int __event_process_build_id(struct perf_record_header_build_id *bev,
if (!kmod_path__parse_name(&m, filename) && m.kmod) if (!kmod_path__parse_name(&m, filename) && m.kmod)
dso__set_module_info(dso, &m, machine); dso__set_module_info(dso, &m, machine);
else
dso->kernel = dso_space;
dso->kernel = dso_space;
free(m.name); free(m.name);
} }
......
...@@ -872,7 +872,7 @@ static int dso__process_kernel_symbol(struct dso *dso, struct map *map, ...@@ -872,7 +872,7 @@ static int dso__process_kernel_symbol(struct dso *dso, struct map *map,
* kallsyms and identity maps. Overwrite it to * kallsyms and identity maps. Overwrite it to
* map to the kernel dso. * map to the kernel dso.
*/ */
if (*remap_kernel && dso->kernel) { if (*remap_kernel && dso->kernel && !kmodule) {
*remap_kernel = false; *remap_kernel = false;
map->start = shdr->sh_addr + ref_reloc(kmap); map->start = shdr->sh_addr + ref_reloc(kmap);
map->end = map->start + shdr->sh_size; map->end = map->start + shdr->sh_size;
...@@ -1068,7 +1068,7 @@ int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss, ...@@ -1068,7 +1068,7 @@ int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss,
* Initial kernel and module mappings do not map to the dso. * Initial kernel and module mappings do not map to the dso.
* Flag the fixups. * Flag the fixups.
*/ */
if (dso->kernel || kmodule) { if (dso->kernel) {
remap_kernel = true; remap_kernel = true;
adjust_kernel_syms = dso->adjust_symbols; adjust_kernel_syms = dso->adjust_symbols;
} }
...@@ -1130,7 +1130,7 @@ int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss, ...@@ -1130,7 +1130,7 @@ int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss,
(sym.st_value & 1)) (sym.st_value & 1))
--sym.st_value; --sym.st_value;
if (dso->kernel || kmodule) { if (dso->kernel) {
if (dso__process_kernel_symbol(dso, map, &sym, &shdr, kmaps, kmap, &curr_dso, &curr_map, if (dso__process_kernel_symbol(dso, map, &sym, &shdr, kmaps, kmap, &curr_dso, &curr_map,
section_name, adjust_kernel_syms, kmodule, &remap_kernel)) section_name, adjust_kernel_syms, kmodule, &remap_kernel))
goto out_elf_end; goto out_elf_end;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment