[PATCH] perf symbols: Not using the ubuntu debuginfo when dso load
From: Jin Yao
Date: Thu Sep 01 2016 - 03:32:51 EST
In dso__load, it iterates over *interesting" debug images which
have symtab/dynsym/opd section. For example, for loading the
libc-2.23.so on ubuntu 16.04, it will try 2 images in turn.
Try image 1: /lib/x86_64-linux-gnu/libc-2.23.so. Since it doesn't
have ".symtab" section, after symsrc__init return, runtime_ss = ss
(ss is associated with /lib/x86_64-linux-gnu/libc-2.23.so), and
syms_ss = NULL.
Try image 2: /usr/lib/debug/lib/x86_64-linux-gnu/libc-2.23.so.
Since it has ".symtab" section, after symsrc__init return,
syms_ss = ss (ss is associated with /usr/lib/debug/lib/x86_64-linux-gnu/libc-2.23.so),
and runtime_ss is not changed.
Now at the dso__load_sym(dso, map, syms_ss, runtime_ss, filter, kmod),
syms_ss is associated with /usr/lib/debug/lib/x86_64-linux-gnu/libc-2.23.so,
But the dso->name is /lib/x86_64-linux-gnu/libc-2.23.so.
In dso__load_sym, it needs to compute the dso->text_offset.
if (elf_section_by_name(elf, &ehdr, &tshdr, ".text", NULL))
dso->text_offset = tshdr.sh_addr - tshdr.sh_offset;
The issue is that tshdr is the ELF section header for
/usr/lib/debug/lib/x86_64-linux-gnu/libc-2.23.so not the header for
/lib/x86_64-linux-gnu/libc-2.23.so. So the result of dso->text_offset
is not correct.
In symbol__disassemble, it calls map__rip_2objdump to convert symbol start
address to objdump address. The converted address is
rip + map->dso->text_offset
Since this text_offset is not correct, so finally objdump uses wrong
start address to disassemble /lib/x86_64-linux-gnu/libc-2.23.so.
This patch lets dso__load not try ubuntu debuginfo
(/usr/lib/debug/lib/x86_64-linux-gnu/libc-2.23.so in this example), because
1: the image doesn't have valid assembly code (check output of objdump)
2: it can avoid above issue.
Signed-off-by: Jin Yao <yao.jin@xxxxxxxxxxxxxxx>
---
tools/perf/util/symbol.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 37e8d20..25a10a3 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1324,7 +1324,6 @@ static bool dso__is_compatible_symtab_type(struct dso *dso, bool kmod,
case DSO_BINARY_TYPE__DEBUGLINK:
case DSO_BINARY_TYPE__SYSTEM_PATH_DSO:
case DSO_BINARY_TYPE__FEDORA_DEBUGINFO:
- case DSO_BINARY_TYPE__UBUNTU_DEBUGINFO:
case DSO_BINARY_TYPE__BUILDID_DEBUGINFO:
case DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO:
return !kmod && dso->kernel == DSO_TYPE_USER;
@@ -1353,6 +1352,7 @@ static bool dso__is_compatible_symtab_type(struct dso *dso, bool kmod,
return true;
case DSO_BINARY_TYPE__NOT_FOUND:
+ case DSO_BINARY_TYPE__UBUNTU_DEBUGINFO:
default:
return false;
}
--
2.7.4