All of lore.kernel.org
 help / color / mirror / Atom feed
From: "tip-bot for Naveen N. Rao" <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: ananth@in.ibm.com, naveen.n.rao@linux.vnet.ibm.com,
	hpa@zytor.com, srikar@linux.vnet.ibm.com, mpe@ellerman.id.au,
	acme@redhat.com, tglx@linutronix.de, mingo@kernel.org,
	sukadev@linux.vnet.ibm.com, linux-kernel@vger.kernel.org,
	masami.hiramatsu.pt@hitachi.com
Subject: [tip:perf/core] perf probe ppc: Fix symbol fixup issues due to ELF type
Date: Tue, 5 May 2015 20:10:11 -0700	[thread overview]
Message-ID: <tip-d2332098331fffe9358b50cebc8954ecd6560448@git.kernel.org> (raw)
In-Reply-To: <41392bb856ef62d929995e0b61967689b7915207.1430217967.git.naveen.n.rao@linux.vnet.ibm.com>

Commit-ID:  d2332098331fffe9358b50cebc8954ecd6560448
Gitweb:     http://git.kernel.org/tip/d2332098331fffe9358b50cebc8954ecd6560448
Author:     Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
AuthorDate: Tue, 28 Apr 2015 17:35:35 +0530
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 4 May 2015 12:43:42 -0300

perf probe ppc: Fix symbol fixup issues due to ELF type

If using the symbol table, symbol addresses are not being fixed up
properly, resulting in probes being placed at wrong addresses:

  # perf probe do_fork
  Added new event:
    probe:do_fork        (on do_fork)

  You can now use it in all perf tools, such as:

	  perf record -e probe:do_fork -aR sleep 1

  # cat /sys/kernel/debug/tracing/kprobe_events
  p:probe/do_fork _text+635952
  # printf "%x" 635952
  9b430
  # grep do_fork /boot/System.map
  c0000000000ab430 T .do_fork

Fix by checking for ELF type ET_DYN used by ppc64 kernels.

Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Reviewed-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Cc: linuxppc-dev@lists.ozlabs.org
Link: http://lkml.kernel.org/r/41392bb856ef62d929995e0b61967689b7915207.1430217967.git.naveen.n.rao@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/arch/powerpc/util/Build          |  1 +
 tools/perf/arch/powerpc/util/sym-handling.c | 19 +++++++++++++++++++
 tools/perf/util/symbol-elf.c                |  8 ++++++--
 tools/perf/util/symbol.h                    |  4 ++++
 4 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/tools/perf/arch/powerpc/util/Build b/tools/perf/arch/powerpc/util/Build
index 0af6e9b..7b8b0d1 100644
--- a/tools/perf/arch/powerpc/util/Build
+++ b/tools/perf/arch/powerpc/util/Build
@@ -1,4 +1,5 @@
 libperf-y += header.o
+libperf-y += sym-handling.o
 
 libperf-$(CONFIG_DWARF) += dwarf-regs.o
 libperf-$(CONFIG_DWARF) += skip-callchain-idx.o
diff --git a/tools/perf/arch/powerpc/util/sym-handling.c b/tools/perf/arch/powerpc/util/sym-handling.c
new file mode 100644
index 0000000..c9de001
--- /dev/null
+++ b/tools/perf/arch/powerpc/util/sym-handling.c
@@ -0,0 +1,19 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation.
+ *
+ * Copyright (C) 2015 Naveen N. Rao, IBM Corporation
+ */
+
+#include "debug.h"
+#include "symbol.h"
+
+#ifdef HAVE_LIBELF_SUPPORT
+bool elf__needs_adjust_symbols(GElf_Ehdr ehdr)
+{
+	return ehdr.e_type == ET_EXEC ||
+	       ehdr.e_type == ET_REL ||
+	       ehdr.e_type == ET_DYN;
+}
+#endif
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index a7ab606..54347ba 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -630,6 +630,11 @@ void symsrc__destroy(struct symsrc *ss)
 	close(ss->fd);
 }
 
+bool __weak elf__needs_adjust_symbols(GElf_Ehdr ehdr)
+{
+	return ehdr.e_type == ET_EXEC || ehdr.e_type == ET_REL;
+}
+
 int symsrc__init(struct symsrc *ss, struct dso *dso, const char *name,
 		 enum dso_binary_type type)
 {
@@ -711,8 +716,7 @@ int symsrc__init(struct symsrc *ss, struct dso *dso, const char *name,
 						     ".gnu.prelink_undo",
 						     NULL) != NULL);
 	} else {
-		ss->adjust_symbols = ehdr.e_type == ET_EXEC ||
-				     ehdr.e_type == ET_REL;
+		ss->adjust_symbols = elf__needs_adjust_symbols(ehdr);
 	}
 
 	ss->name   = strdup(name);
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 0956150..8cb0af4 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -303,4 +303,8 @@ int setup_list(struct strlist **list, const char *list_str,
 int setup_intlist(struct intlist **list, const char *list_str,
 		  const char *list_name);
 
+#ifdef HAVE_LIBELF_SUPPORT
+bool elf__needs_adjust_symbols(GElf_Ehdr ehdr);
+#endif
+
 #endif /* __PERF_SYMBOL */

  parent reply	other threads:[~2015-05-06  3:11 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-28 12:05 [PATCH v3 0/7] Fixes for perf probe issues on ppc Naveen N. Rao
2015-04-28 12:05 ` Naveen N. Rao
2015-04-28 12:05 ` [PATCH v3 1/7] perf probe: Improve detection of file/function name in the probe pattern Naveen N. Rao
2015-04-28 12:05   ` Naveen N. Rao
2015-04-28 13:46   ` Arnaldo Carvalho de Melo
2015-04-28 13:46     ` Arnaldo Carvalho de Melo
2015-05-06  3:13   ` [tip:perf/core] perf probe: Improve detection of file/ function " tip-bot for Naveen N. Rao
2015-04-28 12:05 ` [PATCH v3 2/7] perf probe/ppc: Fix symbol fixup issues due to ELF type Naveen N. Rao
2015-04-28 12:05   ` Naveen N. Rao
2015-04-28 13:48   ` Arnaldo Carvalho de Melo
2015-04-28 13:48     ` Arnaldo Carvalho de Melo
2015-05-06  3:10   ` tip-bot for Naveen N. Rao [this message]
2015-04-28 12:05 ` [PATCH v3 3/7] perf probe/ppc: Use the right prefix when ignoring SyS symbols on ppc Naveen N. Rao
2015-04-28 12:05   ` Naveen N. Rao
2015-05-06  3:10   ` [tip:perf/core] perf probe ppc: " tip-bot for Naveen N. Rao
2015-04-28 12:05 ` [PATCH v3 4/7] perf probe/ppc: Enable matching against dot symbols automatically Naveen N. Rao
2015-04-28 12:05   ` Naveen N. Rao
2015-05-06  3:10   ` [tip:perf/core] perf probe ppc: " tip-bot for Naveen N. Rao
2015-04-28 12:05 ` [PATCH v3 5/7] perf probe/ppc64le: Fix ppc64 ABIv2 symbol decoding Naveen N. Rao
2015-04-28 12:05   ` Naveen N. Rao
2015-05-06  3:11   ` [tip:perf/core] perf probe ppc64le: " tip-bot for Ananth N Mavinakayanahalli
2015-04-28 12:05 ` [PATCH v3 6/7] perf probe/ppc64le: Prefer symbol table lookup over DWARF Naveen N. Rao
2015-04-28 12:05   ` Naveen N. Rao
2015-05-06  3:11   ` [tip:perf/core] perf probe ppc64le: " tip-bot for Naveen N. Rao
2015-04-28 12:05 ` [PATCH v3 7/7] perf probe/ppc64le: Fixup function entry if using kallsyms lookup Naveen N. Rao
2015-04-28 12:05   ` Naveen N. Rao
2015-05-06  3:11   ` [tip:perf/core] perf probe ppc64le: " tip-bot for Naveen N. Rao
2015-04-28 13:54 ` [PATCH v3 0/7] Fixes for perf probe issues on ppc Arnaldo Carvalho de Melo
2015-04-28 13:54   ` Arnaldo Carvalho de Melo
2015-04-28 16:12   ` Naveen N. Rao
2015-04-28 16:12     ` Naveen N. Rao
2015-04-28 16:40     ` Arnaldo Carvalho de Melo
2015-04-28 16:40       ` Arnaldo Carvalho de Melo
2015-04-28 22:17   ` Masami Hiramatsu
2015-04-28 22:17     ` Masami Hiramatsu
2015-04-29  5:18     ` Naveen N. Rao
2015-04-29  5:18       ` Naveen N. Rao
2015-04-29  5:37   ` Srikar Dronamraju
2015-04-29  5:37     ` Srikar Dronamraju
2015-04-29 22:09     ` Arnaldo Carvalho de Melo
2015-04-29 22:09       ` Arnaldo Carvalho de Melo

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=tip-d2332098331fffe9358b50cebc8954ecd6560448@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=acme@redhat.com \
    --cc=ananth@in.ibm.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=mingo@kernel.org \
    --cc=mpe@ellerman.id.au \
    --cc=naveen.n.rao@linux.vnet.ibm.com \
    --cc=srikar@linux.vnet.ibm.com \
    --cc=sukadev@linux.vnet.ibm.com \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.