aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/symbol-elf.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/symbol-elf.c')
-rw-r--r--tools/perf/util/symbol-elf.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index cef8f426356e..d75349979e65 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -622,7 +622,7 @@ int symsrc__init(struct symsrc *ss, struct dso *dso, const char *name,
622 GElf_Shdr shdr; 622 GElf_Shdr shdr;
623 ss->adjust_symbols = (ehdr.e_type == ET_EXEC || 623 ss->adjust_symbols = (ehdr.e_type == ET_EXEC ||
624 ehdr.e_type == ET_REL || 624 ehdr.e_type == ET_REL ||
625 is_vdso_map(dso->short_name) || 625 dso__is_vdso(dso) ||
626 elf_section_by_name(elf, &ehdr, &shdr, 626 elf_section_by_name(elf, &ehdr, &shdr,
627 ".gnu.prelink_undo", 627 ".gnu.prelink_undo",
628 NULL) != NULL); 628 NULL) != NULL);
@@ -1028,6 +1028,39 @@ int file__read_maps(int fd, bool exe, mapfn_t mapfn, void *data,
1028 return err; 1028 return err;
1029} 1029}
1030 1030
1031enum dso_type dso__type_fd(int fd)
1032{
1033 enum dso_type dso_type = DSO__TYPE_UNKNOWN;
1034 GElf_Ehdr ehdr;
1035 Elf_Kind ek;
1036 Elf *elf;
1037
1038 elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL);
1039 if (elf == NULL)
1040 goto out;
1041
1042 ek = elf_kind(elf);
1043 if (ek != ELF_K_ELF)
1044 goto out_end;
1045
1046 if (gelf_getclass(elf) == ELFCLASS64) {
1047 dso_type = DSO__TYPE_64BIT;
1048 goto out_end;
1049 }
1050
1051 if (gelf_getehdr(elf, &ehdr) == NULL)
1052 goto out_end;
1053
1054 if (ehdr.e_machine == EM_X86_64)
1055 dso_type = DSO__TYPE_X32BIT;
1056 else
1057 dso_type = DSO__TYPE_32BIT;
1058out_end:
1059 elf_end(elf);
1060out:
1061 return dso_type;
1062}
1063
1031static int copy_bytes(int from, off_t from_offs, int to, off_t to_offs, u64 len) 1064static int copy_bytes(int from, off_t from_offs, int to, off_t to_offs, u64 len)
1032{ 1065{
1033 ssize_t r; 1066 ssize_t r;