From: "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>
To: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
acme@kernel.org, mpe@ellerman.id.au
Subject: [RFC PATCH 6/8] perf tools powerpc: Fix PPC64 ELF ABIv2 symbol decoding
Date: Tue, 9 Dec 2014 23:04:04 +0530 [thread overview]
Message-ID: <fc380ddad57d90d338ea79f319c5f5d1dd6639b9.1418146300.git.naveen.n.rao@linux.vnet.ibm.com> (raw)
In-Reply-To: <cover.1418146300.git.naveen.n.rao@linux.vnet.ibm.com>
In-Reply-To: <cover.1418146300.git.naveen.n.rao@linux.vnet.ibm.com>
PPC64 ELF ABIv2 has a Global Entry Point (GEP) and a Local Entry Point
(LEP). For purposes of probing, we need the LEP. Offset to the LEP is
encoded in st_other.
Signed-off-by: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
---
tools/perf/arch/powerpc/Makefile | 1 +
tools/perf/arch/powerpc/util/elf-sym-decode.c | 27 +++++++++++++++++++++++++++
tools/perf/config/Makefile | 1 +
tools/perf/util/elf_sym.h | 13 +++++++++++++
tools/perf/util/symbol-elf.c | 8 ++++++++
5 files changed, 50 insertions(+)
create mode 100644 tools/perf/arch/powerpc/util/elf-sym-decode.c
create mode 100644 tools/perf/util/elf_sym.h
diff --git a/tools/perf/arch/powerpc/Makefile b/tools/perf/arch/powerpc/Makefile
index 6f7782b..8621439 100644
--- a/tools/perf/arch/powerpc/Makefile
+++ b/tools/perf/arch/powerpc/Makefile
@@ -3,4 +3,5 @@ PERF_HAVE_DWARF_REGS := 1
LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/dwarf-regs.o
LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/skip-callchain-idx.o
endif
+LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/elf-sym-decode.o
LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/header.o
diff --git a/tools/perf/arch/powerpc/util/elf-sym-decode.c b/tools/perf/arch/powerpc/util/elf-sym-decode.c
new file mode 100644
index 0000000..7434656
--- /dev/null
+++ b/tools/perf/arch/powerpc/util/elf-sym-decode.c
@@ -0,0 +1,27 @@
+/*
+ * Decode offset from Global Entry Point to Local Entry Point on PPC64
+ * ELF ABIv2.
+ *
+ * Derived from definitions in arch/powerpc/kernel/module_64.c
+ *
+ * Copyright (C) 2014 Ananth N Mavinakayanahalli, IBM Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#include <gelf.h>
+#include "elf_sym.h"
+
+/* PowerPC64 ABIv2 specific values for the ELF64_Sym st_other field. */
+#define STO_PPC64_LOCAL_BIT 5
+#define STO_PPC64_LOCAL_MASK (7 << STO_PPC64_LOCAL_BIT)
+#define PPC64_LOCAL_ENTRY_OFFSET(other) \
+ (((1 << (((other) & STO_PPC64_LOCAL_MASK) >> STO_PPC64_LOCAL_BIT)) >> 2) << 2)
+
+unsigned int arch_elf_sym_decode_offset(GElf_Sym *sym)
+{
+ return PPC64_LOCAL_ENTRY_OFFSET(sym->st_other);
+}
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 58f6091..8f64557 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -378,6 +378,7 @@ ifeq ($(ARCH),powerpc)
ifndef NO_DWARF
CFLAGS += -DHAVE_SKIP_CALLCHAIN_IDX
endif
+ CFLAGS += -DHAVE_ELF_SYM_DECODE
endif
ifndef NO_LIBUNWIND
diff --git a/tools/perf/util/elf_sym.h b/tools/perf/util/elf_sym.h
new file mode 100644
index 0000000..0176f21
--- /dev/null
+++ b/tools/perf/util/elf_sym.h
@@ -0,0 +1,13 @@
+#ifndef __PERF_ELF_SYM_H
+#define __PERF_ELF_SYM_H
+
+#ifdef HAVE_ELF_SYM_DECODE
+extern unsigned int arch_elf_sym_decode_offset(GElf_Sym *sym);
+#else
+static inline unsigned int arch_elf_sym_decode_offset(GElf_Sym *sym __maybe_unused)
+{
+ return 0;
+}
+#endif
+
+#endif /* __PERF_ELF_SYM_H */
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index 67e4392..92a424e 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -10,6 +10,7 @@
#include "vdso.h"
#include <symbol/kallsyms.h>
#include "debug.h"
+#include "elf_sym.h"
#ifndef HAVE_ELF_GETPHDRNUM_SUPPORT
static int elf_getphdrnum(Elf *elf, size_t *dst)
@@ -848,6 +849,13 @@ int dso__load_sym(struct dso *dso, struct map *map,
(sym.st_value & 1))
--sym.st_value;
+ /*
+ * PPC64 ELF ABIv2 encodes Local Entry Point offset in
+ * the st_other field
+ */
+ if ((map->type == MAP__FUNCTION) && sym.st_other)
+ sym.st_value += arch_elf_sym_decode_offset(&sym);
+
if (dso->kernel || kmodule) {
char dso_name[PATH_MAX];
--
2.1.3
next prev parent reply other threads:[~2014-12-09 17:35 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-09 17:33 [RFC PATCH 0/8] Fix perf probe issues on powerpc Naveen N. Rao
2014-12-09 17:33 ` [RFC PATCH 1/8] kprobes: Fix kallsyms lookup across powerpc ABIv1 and ABIv2 Naveen N. Rao
2014-12-10 9:37 ` Michael Ellerman
2014-12-10 10:26 ` Naveen N. Rao
2014-12-09 17:34 ` [RFC PATCH 2/8] perf probe powerpc: Fix symbol fixup issues due to ELF type Naveen N. Rao
2014-12-09 21:07 ` Arnaldo Carvalho de Melo
2014-12-10 9:35 ` Naveen N. Rao
2014-12-10 9:50 ` Michael Ellerman
2014-12-10 10:41 ` Naveen N. Rao
2014-12-09 17:34 ` [RFC PATCH 3/8] perf probe: Improve detection of file/function name in the probe pattern Naveen N. Rao
2014-12-10 10:00 ` Michael Ellerman
2014-12-10 10:59 ` Naveen N. Rao
2014-12-10 11:12 ` Michael Ellerman
2014-12-09 17:34 ` [RFC PATCH 4/8] perf probe powerpc: Handle powerpc dot symbols Naveen N. Rao
2014-12-10 10:01 ` Michael Ellerman
2014-12-09 17:34 ` [RFC PATCH 5/8] perf probe powerpc: Allow matching against " Naveen N. Rao
2014-12-10 10:03 ` Michael Ellerman
2014-12-09 17:34 ` Naveen N. Rao [this message]
2014-12-10 10:13 ` [RFC PATCH 6/8] perf tools powerpc: Fix PPC64 ELF ABIv2 symbol decoding Michael Ellerman
2014-12-10 11:21 ` Naveen N. Rao
2014-12-09 17:34 ` [RFC PATCH 7/8] perf probe powerpc: Use DWARF info only if necessary Naveen N. Rao
2014-12-10 10:17 ` Michael Ellerman
2014-12-10 11:48 ` Naveen N. Rao
2014-12-09 17:34 ` [RFC PATCH 8/8] perf probe powerpc: Fixup function entry if using kallsyms lookup Naveen N. Rao
2014-12-09 21:14 ` Arnaldo Carvalho de Melo
2014-12-10 4:11 ` Ananth N Mavinakayanahalli
2014-12-10 4:12 ` [RFC PATCH 0/8] Fix perf probe issues on powerpc Ananth N Mavinakayanahalli
2015-01-21 12:51 ` Arnaldo Carvalho de Melo
2015-01-21 15:33 ` Naveen N. Rao
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=fc380ddad57d90d338ea79f319c5f5d1dd6639b9.1418146300.git.naveen.n.rao@linux.vnet.ibm.com \
--to=naveen.n.rao@linux.vnet.ibm.com \
--cc=acme@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
/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;
as well as URLs for NNTP newsgroup(s).