perf: Port symbol-elf.c
authorBarret Rhoden <brho@cs.berkeley.edu>
Thu, 26 May 2016 20:36:53 +0000 (16:36 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Thu, 16 Jun 2016 15:48:39 +0000 (11:48 -0400)
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
tools/profile/perf/elf.h [new file with mode: 0644]
tools/profile/perf/symbol-elf.c

diff --git a/tools/profile/perf/elf.h b/tools/profile/perf/elf.h
new file mode 100644 (file)
index 0000000..cc86df2
--- /dev/null
@@ -0,0 +1,8 @@
+#pragma once
+
+#include <stddef.h>
+
+#define BUILD_ID_SIZE   20
+
+int filename__read_build_id(const char *filename, void *bf, size_t size);
+void symbol__elf_init(void);
index d779c3c..6d46740 100644 (file)
@@ -9,54 +9,27 @@
 #include <string.h>
 #include <unistd.h>
 #include <inttypes.h>
+#include <stdbool.h>
 
-#include "symbol.h"
-#include "machine.h"
-#include "vdso.h"
-#include <symbol/kallsyms.h>
-#include "debug.h"
+#include <gelf.h>
+#include <libelf.h>
+#include "xlib.h"
+#include "elf.h"
 
-#ifndef EM_AARCH64
-#define EM_AARCH64     183  /* ARM 64 bit */
-#endif
+#define pr_err(args...) fprintf(stderr, args)
+#define pr_debug2(args...) pr_err(args)
 
+#define PERF_ELF_C_READ_MMAP ELF_C_READ_MMAP
 
-#ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
-extern char *cplus_demangle(const char *, int);
+enum map_type {
+       MAP__FUNCTION = 0,
+       MAP__VARIABLE,
+};
 
-static inline char *bfd_demangle(void __maybe_unused *v, const char *c, int i)
-{
-       return cplus_demangle(c, i);
-}
-#else
-#ifdef NO_DEMANGLE
-static inline char *bfd_demangle(void __maybe_unused *v,
-                                const char __maybe_unused *c,
-                                int __maybe_unused i)
+static inline char *bfd_demangle(void *v, const char *c, int i)
 {
        return NULL;
 }
-#else
-#define PACKAGE 'perf'
-#include <bfd.h>
-#endif
-#endif
-
-#ifndef HAVE_ELF_GETPHDRNUM_SUPPORT
-static int elf_getphdrnum(Elf *elf, size_t *dst)
-{
-       GElf_Ehdr gehdr;
-       GElf_Ehdr *ehdr;
-
-       ehdr = gelf_getehdr(elf, &gehdr);
-       if (!ehdr)
-               return -1;
-
-       *dst = ehdr->e_phnum;
-
-       return 0;
-}
-#endif
 
 #ifndef NT_GNU_BUILD_ID
 #define NT_GNU_BUILD_ID 3