From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754103AbcIAHcs (ORCPT ); Thu, 1 Sep 2016 03:32:48 -0400 Received: from mga03.intel.com ([134.134.136.65]:53061 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751146AbcIAHcr (ORCPT ); Thu, 1 Sep 2016 03:32:47 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.30,266,1470726000"; d="scan'208";a="873982095" From: Jin Yao To: acme@kernel.org, jolsa@kernel.org Cc: Linux-kernel@vger.kernel.org, yao.jin@linux.intel.com Subject: [PATCH] perf symbols: Not using the ubuntu debuginfo when dso load Date: Thu, 1 Sep 2016 15:40:54 +0800 Message-Id: <1472715654-18632-1-git-send-email-yao.jin@linux.intel.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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