mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dave Martin <dave.martin@linaro.org>
To: linux-kernel@vger.kernel.org
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>,
	Nicolas Pitre <nicolas.pitre@linaro.org>,
	kernel-team@lists.ubuntu.com, Will Deacon <Will.Deacon@arm.com>,
	Linaro Dev <linaro-dev@lists.linaro.org>,
	Dave Martin <dave.martin@linaro.org>
Subject: [PATCH 2/2] perf symbols: work around incorrect ET_EXEC symbol adjustment
Date: Tue,  3 Aug 2010 12:48:36 +0100	[thread overview]
Message-ID: <1280836116-6654-3-git-send-email-dave.martin@linaro.org> (raw)
In-Reply-To: <1280836116-6654-1-git-send-email-dave.martin@linaro.org>

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 <dave.martin@linaro.org>
---
 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
-- 
1.7.0.4


  parent reply	other threads:[~2010-08-03 11:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-03 11:48 [PATCH 0/2] perf: symbol offset breakage with separated debug Dave Martin
2010-08-03 11:48 ` [PATCH 1/2] perf events: Fix mmap offset determination Dave Martin
2010-08-03 14:31   ` Arnaldo Carvalho de Melo
2010-08-05  8:00   ` [tip:perf/core] " tip-bot for Dave Martin
2010-08-03 11:48 ` Dave Martin [this message]
2010-08-12 13:19   ` [PATCH v2] perf symbols: fix symbol offset breakage with separated debug Dave Martin
2010-08-13  9:27     ` [PATCH v3] " Dave Martin
2010-08-03 13:54 ` [PATCH 0/2] perf: " Arnaldo Carvalho de Melo
2010-08-04  8:29 ` Dave Martin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1280836116-6654-3-git-send-email-dave.martin@linaro.org \
    --to=dave.martin@linaro.org \
    --cc=Will.Deacon@arm.com \
    --cc=acme@redhat.com \
    --cc=kernel-team@lists.ubuntu.com \
    --cc=linaro-dev@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nicolas.pitre@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®