16 #include <symbol/kallsyms.h> 19 #define EM_AARCH64 183 24 #ifdef HAVE_CPLUS_DEMANGLE_SUPPORT 25 extern char *cplus_demangle(
const char *,
int);
27 static inline char *bfd_demangle(
void __maybe_unused *v,
const char *c,
int i)
29 return cplus_demangle(c, i);
33 static inline char *bfd_demangle(
void __maybe_unused *v,
34 const char __maybe_unused *c,
40 #define PACKAGE 'perf' 45 #ifndef HAVE_ELF_GETPHDRNUM_SUPPORT 51 ehdr = gelf_getehdr(elf, &gehdr);
61 #ifndef HAVE_ELF_GETSHDRSTRNDX_SUPPORT 64 pr_err(
"%s: update your libelf to > 0.140, this one lacks elf_getshdrstrndx().\n", __func__);
69 #ifndef NT_GNU_BUILD_ID 70 #define NT_GNU_BUILD_ID 3 80 #define elf_symtab__for_each_symbol(syms, nr_syms, idx, sym) \ 81 for (idx = 0, gelf_getsym(syms, idx, &sym);\ 83 idx++, gelf_getsym(syms, idx, &sym)) 87 return GELF_ST_TYPE(sym->st_info);
91 #define STT_GNU_IFUNC 10 99 sym->st_shndx != SHN_UNDEF;
106 sym->st_shndx != SHN_UNDEF;
113 sym->st_shndx != SHN_UNDEF &&
114 sym->st_shndx != SHN_ABS;
123 const Elf_Data *symstrs)
125 return symstrs->d_buf + sym->st_name;
129 const Elf_Data *secstrs)
131 return secstrs->d_buf + shdr->sh_name;
135 const Elf_Data *secstrs)
141 const Elf_Data *secstrs)
158 while ((sec = elf_nextscn(elf, sec)) != NULL) {
159 gelf_getshdr(sec, &shdr);
161 if ((addr >= shdr.sh_addr) &&
162 (addr < (shdr.sh_addr + shdr.sh_size)))
172 GElf_Shdr *shp,
const char *
name,
size_t *idx)
178 if (!elf_rawdata(elf_getscn(elf, ep->e_shstrndx), NULL))
181 while ((sec = elf_nextscn(elf, sec)) != NULL) {
184 gelf_getshdr(sec, shp);
185 str = elf_strptr(elf, ep->e_shstrndx, shp->sh_name);
186 if (str && !strcmp(name, str)) {
205 char *demangled = NULL;
215 demangled = bfd_demangle(NULL, elf_name, demangle_flags);
216 if (demangled == NULL)
228 #define elf_section__for_each_rel(reldata, pos, pos_mem, idx, nr_entries) \ 229 for (idx = 0, pos = gelf_getrel(reldata, 0, &pos_mem); \ 231 ++idx, pos = gelf_getrel(reldata, idx, &pos_mem)) 233 #define elf_section__for_each_rela(reldata, pos, pos_mem, idx, nr_entries) \ 234 for (idx = 0, pos = gelf_getrela(reldata, 0, &pos_mem); \ 236 ++idx, pos = gelf_getrela(reldata, idx, &pos_mem)) 247 uint32_t nr_rel_entries, idx;
249 u64 plt_offset, plt_header_size, plt_entry_size;
252 GElf_Shdr shdr_rel_plt, shdr_dynsym;
253 Elf_Data *reldata, *
syms, *symstrs;
254 Elf_Scn *scn_plt_rel, *scn_symstrs, *scn_dynsym;
257 char sympltname[1024];
259 int nr = 0, symidx,
err = 0;
267 scn_dynsym = ss->dynsym;
268 shdr_dynsym = ss->dynshdr;
269 dynsym_idx = ss->dynsym_idx;
271 if (scn_dynsym == NULL)
276 if (scn_plt_rel == NULL) {
279 if (scn_plt_rel == NULL)
285 if (shdr_rel_plt.sh_link != dynsym_idx)
295 reldata = elf_getdata(scn_plt_rel, NULL);
299 syms = elf_getdata(scn_dynsym, NULL);
303 scn_symstrs = elf_getscn(elf, shdr_dynsym.sh_link);
304 if (scn_symstrs == NULL)
307 symstrs = elf_getdata(scn_symstrs, NULL);
311 if (symstrs->d_size == 0)
314 nr_rel_entries = shdr_rel_plt.sh_size / shdr_rel_plt.sh_entsize;
315 plt_offset = shdr_plt.sh_offset;
316 switch (ehdr.e_machine) {
318 plt_header_size = 20;
323 plt_header_size = 32;
328 plt_header_size = shdr_plt.sh_entsize;
329 plt_entry_size = shdr_plt.sh_entsize;
332 plt_offset += plt_header_size;
334 if (shdr_rel_plt.sh_type == SHT_RELA) {
335 GElf_Rela pos_mem, *pos;
339 const char *elf_name = NULL;
340 char *demangled = NULL;
341 symidx = GELF_R_SYM(pos->r_info);
342 gelf_getsym(syms, symidx, &sym);
346 if (demangled != NULL)
347 elf_name = demangled;
348 snprintf(sympltname,
sizeof(sympltname),
353 STB_GLOBAL, STT_FUNC, sympltname);
357 plt_offset += plt_entry_size;
361 }
else if (shdr_rel_plt.sh_type == SHT_REL) {
362 GElf_Rel pos_mem, *pos;
365 const char *elf_name = NULL;
366 char *demangled = NULL;
367 symidx = GELF_R_SYM(pos->r_info);
368 gelf_getsym(syms, symidx, &sym);
372 if (demangled != NULL)
373 elf_name = demangled;
374 snprintf(sympltname,
sizeof(sympltname),
379 STB_GLOBAL, STT_FUNC, sympltname);
383 plt_offset += plt_entry_size;
393 pr_debug(
"%s: problems reading %s PLT info.\n",
406 #define NOTE_ALIGN(n) (((n) + 3) & -4U) 425 if (gelf_getehdr(elf, &ehdr) == NULL) {
426 pr_err(
"%s: cannot get elf header.\n", __func__);
438 ".note.gnu.build-id", NULL);
456 data = elf_getdata(sec, NULL);
461 while (ptr < (data->d_buf + data->d_size)) {
467 ptr +=
sizeof(*nhdr);
471 nhdr->n_namesz ==
sizeof(
"GNU")) {
472 if (memcmp(name,
"GNU",
sizeof(
"GNU")) == 0) {
473 size_t sz =
min(size, descsz);
475 memset(bf + sz, 0, size - sz);
495 fd = open(filename, O_RDONLY);
501 pr_debug2(
"%s: cannot read %s ELF file.\n", __func__, filename);
521 fd = open(filename, O_RDONLY);
528 size_t namesz, descsz;
530 if (read(fd, &nhdr,
sizeof(nhdr)) !=
sizeof(nhdr))
536 nhdr.n_namesz ==
sizeof(
"GNU")) {
537 if (read(fd, bf, namesz) != (ssize_t)namesz)
539 if (memcmp(bf,
"GNU",
sizeof(
"GNU")) == 0) {
540 size_t sz =
min(descsz, size);
541 if (read(fd, build_id, sz) == (ssize_t)sz) {
542 memset(build_id + sz, 0, size - sz);
546 }
else if (read(fd, bf, descsz) != (ssize_t)descsz)
549 int n = namesz + descsz;
551 if (n > (
int)
sizeof(bf)) {
553 pr_debug(
"%s: truncating reading of build id in sysfs file %s: n_namesz=%u, n_descsz=%u.\n",
554 __func__, filename, nhdr.n_namesz, nhdr.n_descsz);
556 if (read(fd, bf, n) != n)
576 fd = open(filename, O_RDONLY);
582 pr_debug2(
"%s: cannot read %s ELF file.\n", __func__, filename);
590 if (gelf_getehdr(elf, &ehdr) == NULL) {
591 pr_err(
"%s: cannot get elf header.\n", __func__);
596 ".gnu_debuglink", NULL);
600 data = elf_getdata(sec, NULL);
605 strncpy(debuglink, data->d_buf, size);
619 static unsigned int const endian = 1;
626 if (*(
unsigned char const *)&endian != 1)
632 if (*(
unsigned char const *)&endian != 0)
637 pr_err(
"unrecognized DSO data encoding %d\n", eidata);
646 return ss->dynsym || ss->opdsec;
651 return ss->symtab != NULL;
663 return ehdr.e_type == ET_EXEC || ehdr.e_type == ET_REL;
681 fd = open(name, O_RDONLY);
690 pr_debug(
"%s: cannot read %s ELF file.\n", __func__, name);
695 if (gelf_getehdr(elf, &ehdr) == NULL) {
697 pr_debug(
"%s: cannot get elf header.\n", __func__);
716 pr_debug(
"%s: build id mismatch for %s.\n", __func__, name);
722 ss->is_64_bit = (gelf_getclass(elf) == ELFCLASS64);
726 if (ss->symshdr.sh_type != SHT_SYMTAB)
732 if (ss->dynshdr.sh_type != SHT_DYNSYM)
738 if (ss->opdshdr.sh_type != SHT_PROGBITS)
742 ss->adjust_symbols =
true;
746 ss->
name = strdup(name);
798 GElf_Sym *
sym __maybe_unused) { }
801 GElf_Sym *
sym, GElf_Shdr *shdr,
803 struct dso **curr_dsop,
struct map **curr_mapp,
804 const char *section_name,
805 bool adjust_kernel_syms,
bool kmodule,
bool *remap_kernel)
807 struct dso *curr_dso = *curr_dsop;
808 struct map *curr_map;
812 if (adjust_kernel_syms)
813 sym->st_value -= shdr->sh_addr - shdr->sh_offset;
818 if (strcmp(section_name,
".text") == 0) {
824 if (*remap_kernel && dso->
kernel) {
825 *remap_kernel =
false;
827 map->
end = map->
start + shdr->sh_size;
828 map->
pgoff = shdr->sh_offset;
845 if (*remap_kernel && kmodule) {
846 *remap_kernel =
false;
847 map->
pgoff = shdr->sh_offset;
858 snprintf(dso_name,
sizeof(dso_name),
"%s%s", dso->
short_name, section_name);
861 if (curr_map == NULL) {
862 u64
start = sym->st_value;
865 start += map->
start + shdr->sh_offset;
868 if (curr_dso == NULL)
875 if (curr_map == NULL)
878 if (adjust_kernel_syms) {
880 curr_map->
end = curr_map->
start + shdr->sh_size;
881 curr_map->
pgoff = shdr->sh_offset;
896 *curr_mapp = curr_map;
897 *curr_dsop = curr_dso;
899 *curr_dsop = curr_map->
dso;
905 struct symsrc *runtime_ss,
int kmodule)
909 struct map *curr_map = map;
910 struct dso *curr_dso = dso;
911 Elf_Data *symstrs, *secstrs;
918 Elf_Data *
syms, *opddata = NULL;
920 Elf_Scn *
sec, *sec_strndx;
923 bool remap_kernel =
false, adjust_kernel_syms =
false;
930 dso->
rel = syms_ss->ehdr.e_type == ET_REL;
936 if (kmodule && syms_ss->symtab)
939 if (!syms_ss->symtab) {
948 syms_ss->symtab = syms_ss->dynsym;
949 syms_ss->symshdr = syms_ss->dynshdr;
953 ehdr = syms_ss->ehdr;
954 sec = syms_ss->symtab;
955 shdr = syms_ss->symshdr;
959 dso->
text_offset = tshdr.sh_addr - tshdr.sh_offset;
961 if (runtime_ss->opdsec)
962 opddata = elf_rawdata(runtime_ss->opdsec, NULL);
964 syms = elf_getdata(sec, NULL);
968 sec = elf_getscn(elf, shdr.sh_link);
972 symstrs = elf_getdata(sec, NULL);
976 sec_strndx = elf_getscn(runtime_ss->elf, runtime_ss->ehdr.e_shstrndx);
977 if (sec_strndx == NULL)
980 secstrs = elf_getdata(sec_strndx, NULL);
984 nr_syms = shdr.sh_size / shdr.sh_entsize;
986 memset(&sym, 0,
sizeof(sym));
1017 if (dso->
kernel || kmodule) {
1018 remap_kernel =
true;
1024 char *demangled = NULL;
1026 const char *section_name;
1027 bool used_opd =
false;
1035 if (ehdr.e_machine == EM_ARM || ehdr.e_machine ==
EM_AARCH64) {
1036 if (elf_name[0] ==
'$' && strchr(
"adtx", elf_name[1])
1037 && (elf_name[2] ==
'\0' || elf_name[2] ==
'.'))
1041 if (runtime_ss->opdsec && sym.st_shndx == runtime_ss->opdidx) {
1042 u32 offset = sym.st_value - syms_ss->opdshdr.sh_addr;
1043 u64 *opd = opddata->d_buf + offset;
1044 sym.st_value =
DSO__SWAP(dso, u64, *opd);
1058 if (sym.st_shndx == SHN_ABS)
1061 sec = elf_getscn(runtime_ss->elf, sym.st_shndx);
1065 gelf_getshdr(sec, &shdr);
1074 if ((ehdr.e_machine == EM_ARM) &&
1075 (GELF_ST_TYPE(sym.st_info) == STT_FUNC) &&
1079 if (dso->
kernel || kmodule) {
1081 section_name, adjust_kernel_syms, kmodule, &remap_kernel))
1083 }
else if ((used_opd && runtime_ss->adjust_symbols) ||
1084 (!used_opd && syms_ss->adjust_symbols)) {
1085 pr_debug4(
"%s: adjusting symbol: st_value: %#" PRIx64
" " 1086 "sh_addr: %#" PRIx64
" sh_offset: %#" PRIx64
"\n", __func__,
1087 (u64)sym.st_value, (u64)shdr.sh_addr,
1088 (u64)shdr.sh_offset);
1089 sym.st_value -= shdr.sh_addr - shdr.sh_offset;
1093 if (demangled != NULL)
1094 elf_name = demangled;
1097 GELF_ST_BIND(sym.st_info),
1098 GELF_ST_TYPE(sym.st_info), elf_name);
1138 for (i = 0; i < phdrnum; i++) {
1139 if (gelf_getphdr(elf, i, &phdr) == NULL)
1141 if (phdr.p_type != PT_LOAD)
1144 if (!(phdr.p_flags & PF_X))
1147 if (!(phdr.p_flags & PF_R))
1150 sz =
min(phdr.p_memsz, phdr.p_filesz);
1153 err = mapfn(phdr.p_vaddr, sz, phdr.p_offset, data);
1171 *is_64_bit = (gelf_getclass(elf) == ELFCLASS64);
1191 if (ek != ELF_K_ELF)
1194 if (gelf_getclass(elf) == ELFCLASS64) {
1199 if (gelf_getehdr(elf, &ehdr) == NULL)
1202 if (ehdr.e_machine == EM_X86_64)
1212 static int copy_bytes(
int from, off_t from_offs,
int to, off_t to_offs, u64 len)
1222 if (lseek(to, to_offs, SEEK_SET) != to_offs)
1225 if (lseek(from, from_offs, SEEK_SET) != from_offs)
1233 r = read(from, buf, n);
1239 r = write(to, buf, n);
1264 kcore->
fd = open(filename, O_RDONLY);
1265 if (kcore->
fd == -1)
1268 kcore->
elf = elf_begin(kcore->
fd, ELF_C_READ, NULL);
1273 if (kcore->
elfclass == ELFCLASSNONE)
1276 ehdr = gelf_getehdr(kcore->
elf, &kcore->
ehdr);
1283 elf_end(kcore->
elf);
1295 kcore->
fd = mkstemp(filename);
1297 kcore->
fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0400);
1298 if (kcore->
fd == -1)
1301 kcore->
elf = elf_begin(kcore->
fd, ELF_C_WRITE, NULL);
1305 if (!gelf_newehdr(kcore->
elf, elfclass))
1313 elf_end(kcore->
elf);
1322 elf_end(kcore->
elf);
1329 GElf_Ehdr *kehdr = &from->
ehdr;
1331 memcpy(ehdr->e_ident, kehdr->e_ident, EI_NIDENT);
1332 ehdr->e_type = kehdr->e_type;
1333 ehdr->e_machine = kehdr->e_machine;
1334 ehdr->e_version = kehdr->e_version;
1337 ehdr->e_flags = kehdr->e_flags;
1338 ehdr->e_phnum = count;
1339 ehdr->e_shentsize = 0;
1341 ehdr->e_shstrndx = 0;
1343 if (from->
elfclass == ELFCLASS32) {
1344 ehdr->e_phoff =
sizeof(Elf32_Ehdr);
1345 ehdr->e_ehsize =
sizeof(Elf32_Ehdr);
1346 ehdr->e_phentsize =
sizeof(Elf32_Phdr);
1348 ehdr->e_phoff =
sizeof(Elf64_Ehdr);
1349 ehdr->e_ehsize =
sizeof(Elf64_Ehdr);
1350 ehdr->e_phentsize =
sizeof(Elf64_Phdr);
1353 if (!gelf_update_ehdr(to->
elf, ehdr))
1356 if (!gelf_newphdr(to->
elf, count))
1367 .p_flags = PF_R | PF_W | PF_X,
1376 if (!gelf_update_phdr(kcore->
elf, idx, &phdr))
1384 return elf_update(kcore->
elf, ELF_C_WRITE);
1409 struct list_head phdrs;
1413 #define kcore_copy__for_each_phdr(k, p) \ 1414 list_for_each_entry((p), &(k)->phdrs, node) 1445 list_for_each_entry_safe(p, tmp, &kci->
phdrs,
node) {
1458 list_add_tail(&s->
node, &kci->
syms);
1468 list_for_each_entry_safe(s, tmp, &kci->
syms,
node) {
1479 if (!kallsyms__is_function(type))
1482 if (strchr(name,
'[')) {
1494 if (!strcmp(name,
"_stext")) {
1499 if (!strcmp(name,
"_etext")) {
1515 scnprintf(kallsyms_filename,
PATH_MAX,
"%s/kallsyms", dir);
1520 if (kallsyms__parse(kallsyms_filename, kci,
1528 const char *
name __maybe_unused,
1544 scnprintf(modules_filename,
PATH_MAX,
"%s/modules", dir);
1557 u64 pgoff, u64 s, u64 e)
1561 if (s < start || s >= end)
1564 offset = (s -
start) + pgoff;
1565 len = e < end ? e - s : end - s;
1573 u64 end = start + len;
1583 list_for_each_entry(sdat, &kci->
syms,
node) {
1611 u64 pend = p->
addr + p->
len - 1;
1708 scnprintf(from_filename,
PATH_MAX,
"%s/%s", from_dir, name);
1709 scnprintf(to_filename,
PATH_MAX,
"%s/%s", to_dir, name);
1718 scnprintf(filename,
PATH_MAX,
"%s/%s", dir, name);
1720 return unlink(filename);
1733 if (!buf_from || !buf_to)
1747 if (
readn(to, buf_to, len) != (
int)len)
1750 if (memcmp(buf_from, buf_to, len))
1762 const char *to_filename)
1764 int from, to,
err = -1;
1766 from = open(from_filename, O_RDONLY);
1770 to = open(to_filename, O_RDONLY);
1772 goto out_close_from;
1788 scnprintf(from_filename,
PATH_MAX,
"%s/%s", from_dir, name);
1789 scnprintf(to_filename,
PATH_MAX,
"%s/%s", to_dir, name);
1821 struct kcore extract;
1822 int idx = 0,
err = -1;
1829 INIT_LIST_HEAD(&kci.
phdrs);
1830 INIT_LIST_HEAD(&kci.
syms);
1836 goto out_unlink_kallsyms;
1838 scnprintf(kcore_filename,
PATH_MAX,
"%s/kcore", from_dir);
1839 scnprintf(extract_filename,
PATH_MAX,
"%s/kcore", to_dir);
1842 goto out_unlink_modules;
1845 goto out_kcore_close;
1848 goto out_kcore_close;
1851 goto out_extract_close;
1853 offset = gelf_fsize(extract.
elf, ELF_T_EHDR, 1, EV_CURRENT) +
1854 gelf_fsize(extract.
elf, ELF_T_PHDR, kci.
phnum, EV_CURRENT);
1861 goto out_extract_close;
1865 if (sz < 0 || sz > offset)
1866 goto out_extract_close;
1874 goto out_extract_close;
1878 goto out_extract_close;
1881 goto out_extract_close;
1888 unlink(extract_filename);
1894 out_unlink_kallsyms:
1907 struct kcore extract;
1909 int idx = 0,
err = -1;
1917 goto out_kcore_close;
1920 goto out_extract_close;
1923 goto out_extract_close;
1926 if (sz < 0 || sz > offset)
1927 goto out_extract_close;
1930 goto out_extract_close;
1949 #ifdef HAVE_GELF_GETNOTE_SUPPORT 1961 static int populate_sdt_note(Elf **
elf,
const char *
data,
size_t len,
1962 struct list_head *sdt_notes)
1964 const char *provider, *
name, *
args;
1967 GElf_Addr base_off = 0;
1977 .d_buf = &buf, .d_type = ELF_T_ADDR, .d_version = EV_CURRENT,
1978 .d_size = gelf_fsize((*
elf), ELF_T_ADDR,
NR_ADDR, EV_CURRENT),
1979 .d_off = 0, .d_align = 0
1982 .d_buf = (
void *)
data, .d_type = ELF_T_ADDR,
1983 .d_version = EV_CURRENT, .d_size = dst.d_size, .d_off = 0,
1995 if (len < dst.d_size + 3)
1999 if (gelf_xlatetom(*
elf, &dst, &src,
2000 elf_getident(*
elf, NULL)[EI_DATA]) == NULL) {
2001 pr_err(
"gelf_xlatetom : %s\n", elf_errmsg(-1));
2006 provider =
data + dst.d_size;
2008 name = (
const char *)memchr(provider,
'\0',
data + len - provider);
2017 tmp->
name = strdup(name);
2023 args = memchr(name,
'\0',
data + len - name);
2031 if (args == NULL ||
data + len - args < 2 ||
2032 args[1] ==
':' || args[1] ==
'\0')
2035 tmp->
args = strdup(++args);
2042 if (gelf_getclass(*
elf) == ELFCLASS32) {
2043 memcpy(&tmp->
addr, &buf, 3 *
sizeof(Elf32_Addr));
2046 memcpy(&tmp->
addr, &buf, 3 *
sizeof(Elf64_Addr));
2050 if (!gelf_getehdr(*
elf, &ehdr)) {
2051 pr_debug(
"%s : cannot get elf header.\n", __func__);
2064 base_off = shdr.sh_offset;
2075 list_add_tail(&tmp->
note_list, sdt_notes);
2099 static int construct_sdt_notes_list(Elf *
elf,
struct list_head *sdt_notes)
2102 Elf_Scn *scn = NULL;
2105 size_t shstrndx, next;
2107 size_t name_off, desc_off, offset;
2110 if (gelf_getehdr(
elf, &ehdr) == NULL) {
2126 if ((shdr.sh_type != SHT_NOTE) || (shdr.sh_flags & SHF_ALLOC)) {
2131 data = elf_getdata(scn, NULL);
2134 for (offset = 0; (next = gelf_getnote(data, offset, &nhdr, &name_off,
2135 &desc_off)) > 0; offset = next) {
2143 ret = populate_sdt_note(&
elf, ((data->d_buf) + desc_off),
2144 nhdr.n_descsz, sdt_notes);
2149 if (list_empty(sdt_notes))
2169 fd = open(target, O_RDONLY);
2178 ret = construct_sdt_notes_list(elf, head);
2197 list_for_each_entry_safe(pos, tmp, sdt_notes,
note_list) {
2218 list_for_each_entry(sdt_ptr, start,
note_list)
2226 elf_version(EV_CURRENT);
bool symsrc__possibly_runtime(struct symsrc *ss)
static int copy_bytes(int from, off_t from_offs, int to, off_t to_offs, u64 len)
u64(* map_ip)(struct map *, u64)
static bool elf_sym__filter(GElf_Sym *sym)
static int kcore__add_phdr(struct kcore *kcore, int idx, off_t offset, u64 addr, u64 len)
static void kcore_copy__layout(struct kcore_copy_info *kci)
static struct phdr_data * kcore_copy_info__addnew(struct kcore_copy_info *kci, u64 addr, u64 len, off_t offset)
enum dso_type dso__type_fd(int fd)
struct map * map_groups__find_by_name(struct map_groups *mg, const char *name)
int(* mapfn_t)(u64 start, u64 len, u64 pgoff, void *data)
static void dso__set_loaded(struct dso *dso)
static u64 map__unmap_ip(struct map *map, u64 ip)
static int kcore_copy__parse_kallsyms(struct kcore_copy_info *kci, const char *dir)
struct kmap * map__kmap(struct map *map)
static u64 map__map_ip(struct map *map, u64 ip)
#define PERF_KCORE_EXTRACT
int cleanup_sdt_note_list(struct list_head *sdt_notes)
char * dso__demangle_sym(struct dso *dso, int kmodule, const char *elf_name)
static u64 identity__map_ip(struct map *map __maybe_unused, u64 ip)
ssize_t readn(int fd, void *buf, size_t n)
void dsos__add(struct dsos *dsos, struct dso *dso)
static uint8_t elf_sym__type(const GElf_Sym *sym)
void kcore_extract__delete(struct kcore_extract *kce)
void rust_demangle_sym(char *sym)
static int kcore_copy__parse_modules(struct kcore_copy_info *kci, const char *dir)
int filename__read_build_id(const char *filename, void *bf, size_t size)
#define DSO__SWAP(dso, type, val)
#define pr_debug2(fmt,...)
struct phdr_data * remaps
static bool is_entry_trampoline(const char *name)
int copyfile_mode(const char *from, const char *to, mode_t mode)
static bool elf_sym__is_object(const GElf_Sym *sym)
static char * demangle_sym(struct dso *dso, int kmodule, const char *elf_name)
int filename__read_debuglink(const char *filename, char *debuglink, size_t size)
void __weak arch__sym_update(struct symbol *s __maybe_unused, GElf_Sym *sym __maybe_unused)
int get_sdt_note_list(struct list_head *head, const char *target)
x86 movsq based memset() in arch/x86/lib/memset_64.S") MEMSET_FN(memset_erms
#define PERF_ELF_C_READ_MMAP
void map__put(struct map *map)
void dso__put(struct dso *dso)
void symbols__insert(struct rb_root *symbols, struct symbol *sym)
void symbol__elf_init(void)
union sdt_note::@149 addr
bool symbol__restricted_filename(const char *filename, const char *restricted_filename)
#define pr_debug4(fmt,...)
enum dso_load_errno load_errno
static bool elf_sec__filter(GElf_Shdr *shdr, Elf_Data *secstrs)
#define JAVA_DEMANGLE_NORET
struct symbol * symbol__new(u64 start, u64 len, u8 binding, u8 type, const char *name)
static int kcore_copy__compare_files(const char *from_filename, const char *to_filename)
struct map_groups * groups
bool __weak elf__needs_adjust_symbols(GElf_Ehdr ehdr)
int file__read_maps(int fd, bool exe, mapfn_t mapfn, void *data, bool *is_64_bit)
#define pr_debug(fmt,...)
static void kcore_copy__free_syms(struct kcore_copy_info *kci)
static int kcore_copy__process_kallsyms(void *arg, const char *name, char type, u64 start)
int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss)
void __symbols__insert(struct rb_root *symbols, struct symbol *sym, bool kernel)
int kcore_extract__create(struct kcore_extract *kce)
bool dso__needs_decompress(struct dso *dso)
char * java_demangle_sym(const char *str, int flags)
static u64 ref_reloc(struct kmap *kmap)
int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss, struct symsrc *runtime_ss, int kmodule)
bool dso__is_vdso(struct dso *dso)
Elf_Scn * elf_section_by_name(Elf *elf, GElf_Ehdr *ep, GElf_Shdr *shp, const char *name, size_t *idx)
static int elf_read_build_id(Elf *elf, void *bf, size_t size)
enum dso_swap_type needs_swap
static int str(yyscan_t scanner, int token)
static int kcore_copy__process_modules(void *arg, const char *name __maybe_unused, u64 start, u64 size __maybe_unused)
static int elf_sym__is_function(const GElf_Sym *sym)
static const char * elf_sym__name(const GElf_Sym *sym, const Elf_Data *symstrs)
void symbols__delete(struct rb_root *symbols)
enum dso_binary_type type
void symbols__fixup_end(struct rb_root *symbols)
static int elf_getshdrstrndx(Elf *elf __maybe_unused, size_t *dst __maybe_unused)
void map_groups__fixup_end(struct map_groups *mg)
static int kcore_copy__calc_maps(struct kcore_copy_info *kci, const char *dir, Elf *elf)
enum dso_kernel_type kernel
struct ref_reloc_sym * ref_reloc_sym
x86 movsq based memcpy() in arch/x86/lib/memcpy_64.S") MEMCPY_FN(memcpy_erms
struct list_head note_list
#define elf_symtab__for_each_symbol(syms, nr_syms, idx, sym)
static int kcore_copy__unlink(const char *dir, const char *name)
bool ignore_vmlinux_buildid
#define elf_section__for_each_rela(reldata, pos, pos_mem, idx, nr_entries)
static struct sym_data * kcore_copy__new_sym(struct kcore_copy_info *kci, u64 addr)
static void map_groups__remove(struct map_groups *mg, struct map *map)
static size_t elf_addr_to_index(Elf *elf, GElf_Addr addr)
bool rust_is_mangled(const char *sym)
static struct map * map__get(struct map *map)
static int dso__swap_init(struct dso *dso, unsigned char eidata)
static int elf_getphdrnum(Elf *elf, size_t *dst)
static int kcore_copy__copy_file(const char *from_dir, const char *to_dir, const char *name)
static int kcore__init(struct kcore *kcore, char *filename, int elfclass, bool temp)
static int elf_sec__is_text(const GElf_Shdr *shdr, const Elf_Data *secstrs)
static int kcore__open(struct kcore *kcore, const char *filename)
struct dso * dso__new(const char *name)
static void kcore_copy__free_phdrs(struct kcore_copy_info *kci)
static bool elf_sec__is_data(const GElf_Shdr *shdr, const Elf_Data *secstrs)
static int sym(yyscan_t scanner, int type, int config)
static void kcore__close(struct kcore *kcore)
int sdt_notes__get_count(struct list_head *start)
static int kcore__copy_hdr(struct kcore *from, struct kcore *to, size_t count)
static off_t kcore__write(struct kcore *kcore)
int kcore_copy(const char *from_dir, const char *to_dir)
enum dso_binary_type symtab_type
#define kcore_copy__for_each_phdr(k, p)
void symsrc__destroy(struct symsrc *ss)
int modules__parse(const char *filename, void *arg, int(*process_module)(void *arg, const char *name, u64 start, u64 size))
static int dso__process_kernel_symbol(struct dso *dso, struct map *map, GElf_Sym *sym, GElf_Shdr *shdr, struct map_groups *kmaps, struct kmap *kmap, struct dso **curr_dsop, struct map **curr_mapp, const char *section_name, bool adjust_kernel_syms, bool kmodule, bool *remap_kernel)
int symsrc__init(struct symsrc *ss, struct dso *dso, const char *name, enum dso_binary_type type)
u64(* unmap_ip)(struct map *, u64)
int dso__decompress_kmodule_fd(struct dso *dso, const char *name)
int sysfs__read_build_id(const char *filename, void *build_id, size_t size)
static bool ref_reloc_sym_not_found(struct kmap *kmap)
#define elf_section__for_each_rel(reldata, pos, pos_mem, idx, nr_entries)
static struct phdr_data * phdr_data__new(u64 addr, u64 len, off_t offset)
static int kcore_copy__read_map(u64 start, u64 len, u64 pgoff, void *data)
static bool want_demangle(bool is_kernel_sym)
static void kcore_copy__find_remaps(struct kcore_copy_info *kci)
static void map_groups__insert(struct map_groups *mg, struct map *map)
static int elf_read_maps(Elf *elf, bool exe, mapfn_t mapfn, void *data)
bool symsrc__has_symtab(struct symsrc *ss)
void symbols__fixup_duplicate(struct rb_root *symbols)
static int kcore_copy__compare_fds(int from, int to)
static int kcore_copy__read_maps(struct kcore_copy_info *kci, Elf *elf)
static int elf_sym__is_label(const GElf_Sym *sym)
struct map_groups * map__kmaps(struct map *map)
static int kcore_copy__map(struct kcore_copy_info *kci, u64 start, u64 end, u64 pgoff, u64 s, u64 e)
bool dso__build_id_equal(const struct dso *dso, u8 *build_id)
static const char * elf_sec__name(const GElf_Shdr *shdr, const Elf_Data *secstrs)
struct map * map__new2(u64 start, struct dso *dso)
void static void * zalloc(size_t size)
static int kcore_copy__compare_file(const char *from_dir, const char *to_dir, const char *name)