perf symbols: Ignore mapping symbols on aarch64
[firefly-linux-kernel-4.4.55.git] / tools / perf / util / symbol-elf.c
index 1e23a5bfb044a4cf39f2a0dfbbb5bf26bbad4b4b..225eb73ee78b7f52a64feb035fcf0c2336fdc7d9 100644 (file)
 #include <symbol/kallsyms.h>
 #include "debug.h"
 
+#ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
+extern char *cplus_demangle(const char *, int);
+
+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)
+{
+       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)
 {
@@ -546,6 +567,38 @@ static int dso__swap_init(struct dso *dso, unsigned char eidata)
        return 0;
 }
 
+static int decompress_kmodule(struct dso *dso, const char *name,
+                             enum dso_binary_type type)
+{
+       int fd;
+       const char *ext = strrchr(name, '.');
+       char tmpbuf[] = "/tmp/perf-kmod-XXXXXX";
+
+       if (type != DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP &&
+           type != DSO_BINARY_TYPE__GUEST_KMODULE_COMP &&
+           type != DSO_BINARY_TYPE__BUILD_ID_CACHE)
+               return -1;
+
+       if (!ext || !is_supported_compression(ext + 1)) {
+               ext = strrchr(dso->name, '.');
+               if (!ext || !is_supported_compression(ext + 1))
+                       return -1;
+       }
+
+       fd = mkstemp(tmpbuf);
+       if (fd < 0)
+               return -1;
+
+       if (!decompress_to_file(ext + 1, name, fd)) {
+               close(fd);
+               fd = -1;
+       }
+
+       unlink(tmpbuf);
+
+       return fd;
+}
+
 bool symsrc__possibly_runtime(struct symsrc *ss)
 {
        return ss->dynsym || ss->opdsec;
@@ -571,7 +624,11 @@ int symsrc__init(struct symsrc *ss, struct dso *dso, const char *name,
        Elf *elf;
        int fd;
 
-       fd = open(name, O_RDONLY);
+       if (dso__needs_decompress(dso))
+               fd = decompress_kmodule(dso, name, type);
+       else
+               fd = open(name, O_RDONLY);
+
        if (fd < 0)
                return -1;
 
@@ -802,10 +859,9 @@ int dso__load_sym(struct dso *dso, struct map *map,
                /* Reject ARM ELF "mapping symbols": these aren't unique and
                 * don't identify functions, so will confuse the profile
                 * output: */
-               if (ehdr.e_machine == EM_ARM) {
-                       if (!strcmp(elf_name, "$a") ||
-                           !strcmp(elf_name, "$d") ||
-                           !strcmp(elf_name, "$t"))
+               if (ehdr.e_machine == EM_ARM || ehdr.e_machine == EM_AARCH64) {
+                       if (elf_name[0] == '$' && strchr("adtx", elf_name[1])
+                           && (elf_name[2] == '\0' || elf_name[2] == '.'))
                                continue;
                }