From patchwork Tue Aug 3 11:48:36 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 60731 X-Patchwork-Delegate: stefan.bader@canonical.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id 13A84B6F06 for ; Tue, 3 Aug 2010 22:24:38 +1000 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.69) (envelope-from ) id 1OgGXl-0005mc-GU; Tue, 03 Aug 2010 13:24:29 +0100 Received: from cam-admin0.cambridge.arm.com ([217.140.96.50]) by chlorine.canonical.com with esmtp (Exim 4.69) (envelope-from ) id 1OgFzD-0007YR-SH for kernel-team@lists.ubuntu.com; Tue, 03 Aug 2010 12:48:48 +0100 Received: from localhost.localdomain (e200948.cambridge.arm.com [10.1.77.66]) by cam-admin0.cambridge.arm.com (8.12.6/8.12.6) with ESMTP id o73BmOFB014848; Tue, 3 Aug 2010 12:48:30 +0100 (BST) From: Dave Martin To: linux-kernel@vger.kernel.org Subject: [PATCH 2/2] perf symbols: work around incorrect ET_EXEC symbol adjustment Date: Tue, 3 Aug 2010 12:48:36 +0100 Message-Id: <1280836116-6654-3-git-send-email-dave.martin@linaro.org> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1280836116-6654-1-git-send-email-dave.martin@linaro.org> References: <1280836116-6654-1-git-send-email-dave.martin@linaro.org> X-Mailman-Approved-At: Tue, 03 Aug 2010 13:24:27 +0100 Cc: Nicolas Pitre , Dave Martin , Linaro Dev , Will Deacon , Arnaldo Carvalho de Melo , kernel-team@lists.ubuntu.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: kernel-team-bounces@lists.ubuntu.com Errors-To: kernel-team-bounces@lists.ubuntu.com Workaround to adjust .text symbols from ET_EXEC images correctly. This is not a complete fix, but addresses the common case and does not create additional assumptions beyond those which perf already makes. ELF images with a weird link map may still be processed incorrectly (as at present) -- that will require a separate fix. The workaround allows correct symbol offsets to be generated for ET_EXEC executables on systems with separated debug info (where section sh_offset fields from the debug image may bear no relation to the layout of the executable image). The cover note accompanying this patch contains a more detailed explanation. Signed-off-by: Dave Martin --- tools/perf/util/symbol.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 3b8c005..3930398 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -1135,7 +1135,15 @@ static int dso__load_sym(struct dso *self, struct map *map, const char *name, "sh_addr: %#Lx sh_offset: %#Lx\n", __func__, (u64)sym.st_value, (u64)shdr.sh_addr, (u64)shdr.sh_offset); - sym.st_value -= shdr.sh_addr - shdr.sh_offset; + /* Assumptions: + * a) shdr.sh_addr - shdr.sh_offset == + * map->start - map->pgoff + * b) map->pgoff == 0 + * These are true iff we are looking at a function + * symbol in the main executable segment _and_ + * the main executable segment starts at the start of + * the ELF image (normally true). */ + sym.st_value -= map->start; } /* * We need to figure out if the object was created from C++ sources