15 #include <sys/utsname.h>
17 #ifndef NT_GNU_BUILD_ID
18 #define NT_GNU_BUILD_ID 3
21 static void dsos__add(struct list_head
*head
, struct dso
*dso
);
22 static struct map
*map__new2(u64 start
, struct dso
*dso
, enum map_type type
);
23 static int dso__load_kernel_sym(struct dso
*self
, struct map
*map
,
24 symbol_filter_t filter
);
25 static int vmlinux_path__nr_entries
;
26 static char **vmlinux_path
;
28 struct symbol_conf symbol_conf
= {
29 .exclude_other
= true,
31 .try_vmlinux_path
= true,
34 bool dso__loaded(const struct dso
*self
, enum map_type type
)
36 return self
->loaded
& (1 << type
);
39 bool dso__sorted_by_name(const struct dso
*self
, enum map_type type
)
41 return self
->sorted_by_name
& (1 << type
);
44 static void dso__set_sorted_by_name(struct dso
*self
, enum map_type type
)
46 self
->sorted_by_name
|= (1 << type
);
49 bool symbol_type__is_a(char symbol_type
, enum map_type map_type
)
53 return symbol_type
== 'T' || symbol_type
== 'W';
55 return symbol_type
== 'D' || symbol_type
== 'd';
61 static void symbols__fixup_end(struct rb_root
*self
)
63 struct rb_node
*nd
, *prevnd
= rb_first(self
);
64 struct symbol
*curr
, *prev
;
69 curr
= rb_entry(prevnd
, struct symbol
, rb_node
);
71 for (nd
= rb_next(prevnd
); nd
; nd
= rb_next(nd
)) {
73 curr
= rb_entry(nd
, struct symbol
, rb_node
);
75 if (prev
->end
== prev
->start
)
76 prev
->end
= curr
->start
- 1;
80 if (curr
->end
== curr
->start
)
81 curr
->end
= roundup(curr
->start
, 4096);
84 static void __map_groups__fixup_end(struct map_groups
*self
, enum map_type type
)
86 struct map
*prev
, *curr
;
87 struct rb_node
*nd
, *prevnd
= rb_first(&self
->maps
[type
]);
92 curr
= rb_entry(prevnd
, struct map
, rb_node
);
94 for (nd
= rb_next(prevnd
); nd
; nd
= rb_next(nd
)) {
96 curr
= rb_entry(nd
, struct map
, rb_node
);
97 prev
->end
= curr
->start
- 1;
101 * We still haven't the actual symbols, so guess the
102 * last map final address.
107 static void map_groups__fixup_end(struct map_groups
*self
)
110 for (i
= 0; i
< MAP__NR_TYPES
; ++i
)
111 __map_groups__fixup_end(self
, i
);
114 static struct symbol
*symbol__new(u64 start
, u64 len
, const char *name
)
116 size_t namelen
= strlen(name
) + 1;
117 struct symbol
*self
= zalloc(symbol_conf
.priv_size
+
118 sizeof(*self
) + namelen
);
122 if (symbol_conf
.priv_size
)
123 self
= ((void *)self
) + symbol_conf
.priv_size
;
126 self
->end
= len
? start
+ len
- 1 : start
;
128 pr_debug4("%s: %s %#Lx-%#Lx\n", __func__
, name
, start
, self
->end
);
130 memcpy(self
->name
, name
, namelen
);
135 void symbol__delete(struct symbol
*self
)
137 free(((void *)self
) - symbol_conf
.priv_size
);
140 static size_t symbol__fprintf(struct symbol
*self
, FILE *fp
)
142 return fprintf(fp
, " %llx-%llx %s\n",
143 self
->start
, self
->end
, self
->name
);
146 void dso__set_long_name(struct dso
*self
, char *name
)
150 self
->long_name
= name
;
151 self
->long_name_len
= strlen(name
);
154 static void dso__set_basename(struct dso
*self
)
156 self
->short_name
= basename(self
->long_name
);
159 struct dso
*dso__new(const char *name
)
161 struct dso
*self
= zalloc(sizeof(*self
) + strlen(name
) + 1);
165 strcpy(self
->name
, name
);
166 dso__set_long_name(self
, self
->name
);
167 self
->short_name
= self
->name
;
168 for (i
= 0; i
< MAP__NR_TYPES
; ++i
)
169 self
->symbols
[i
] = self
->symbol_names
[i
] = RB_ROOT
;
170 self
->slen_calculated
= 0;
171 self
->origin
= DSO__ORIG_NOT_FOUND
;
173 self
->sorted_by_name
= 0;
174 self
->has_build_id
= 0;
180 static void symbols__delete(struct rb_root
*self
)
183 struct rb_node
*next
= rb_first(self
);
186 pos
= rb_entry(next
, struct symbol
, rb_node
);
187 next
= rb_next(&pos
->rb_node
);
188 rb_erase(&pos
->rb_node
, self
);
193 void dso__delete(struct dso
*self
)
196 for (i
= 0; i
< MAP__NR_TYPES
; ++i
)
197 symbols__delete(&self
->symbols
[i
]);
198 if (self
->long_name
!= self
->name
)
199 free(self
->long_name
);
203 void dso__set_build_id(struct dso
*self
, void *build_id
)
205 memcpy(self
->build_id
, build_id
, sizeof(self
->build_id
));
206 self
->has_build_id
= 1;
209 static void symbols__insert(struct rb_root
*self
, struct symbol
*sym
)
211 struct rb_node
**p
= &self
->rb_node
;
212 struct rb_node
*parent
= NULL
;
213 const u64 ip
= sym
->start
;
218 s
= rb_entry(parent
, struct symbol
, rb_node
);
224 rb_link_node(&sym
->rb_node
, parent
, p
);
225 rb_insert_color(&sym
->rb_node
, self
);
228 static struct symbol
*symbols__find(struct rb_root
*self
, u64 ip
)
238 struct symbol
*s
= rb_entry(n
, struct symbol
, rb_node
);
242 else if (ip
> s
->end
)
251 struct symbol_name_rb_node
{
252 struct rb_node rb_node
;
256 static void symbols__insert_by_name(struct rb_root
*self
, struct symbol
*sym
)
258 struct rb_node
**p
= &self
->rb_node
;
259 struct rb_node
*parent
= NULL
;
260 struct symbol_name_rb_node
*symn
= ((void *)sym
) - sizeof(*parent
), *s
;
264 s
= rb_entry(parent
, struct symbol_name_rb_node
, rb_node
);
265 if (strcmp(sym
->name
, s
->sym
.name
) < 0)
270 rb_link_node(&symn
->rb_node
, parent
, p
);
271 rb_insert_color(&symn
->rb_node
, self
);
274 static void symbols__sort_by_name(struct rb_root
*self
, struct rb_root
*source
)
278 for (nd
= rb_first(source
); nd
; nd
= rb_next(nd
)) {
279 struct symbol
*pos
= rb_entry(nd
, struct symbol
, rb_node
);
280 symbols__insert_by_name(self
, pos
);
284 static struct symbol
*symbols__find_by_name(struct rb_root
*self
, const char *name
)
294 struct symbol_name_rb_node
*s
;
297 s
= rb_entry(n
, struct symbol_name_rb_node
, rb_node
);
298 cmp
= strcmp(name
, s
->sym
.name
);
311 struct symbol
*dso__find_symbol(struct dso
*self
,
312 enum map_type type
, u64 addr
)
314 return symbols__find(&self
->symbols
[type
], addr
);
317 struct symbol
*dso__find_symbol_by_name(struct dso
*self
, enum map_type type
,
320 return symbols__find_by_name(&self
->symbol_names
[type
], name
);
323 void dso__sort_by_name(struct dso
*self
, enum map_type type
)
325 dso__set_sorted_by_name(self
, type
);
326 return symbols__sort_by_name(&self
->symbol_names
[type
],
327 &self
->symbols
[type
]);
330 int build_id__sprintf(const u8
*self
, int len
, char *bf
)
333 const u8
*raw
= self
;
336 for (i
= 0; i
< len
; ++i
) {
337 sprintf(bid
, "%02x", *raw
);
345 size_t dso__fprintf_buildid(struct dso
*self
, FILE *fp
)
347 char sbuild_id
[BUILD_ID_SIZE
* 2 + 1];
349 build_id__sprintf(self
->build_id
, sizeof(self
->build_id
), sbuild_id
);
350 return fprintf(fp
, "%s", sbuild_id
);
353 size_t dso__fprintf(struct dso
*self
, enum map_type type
, FILE *fp
)
356 size_t ret
= fprintf(fp
, "dso: %s (", self
->short_name
);
358 if (self
->short_name
!= self
->long_name
)
359 ret
+= fprintf(fp
, "%s, ", self
->long_name
);
360 ret
+= fprintf(fp
, "%s, %sloaded, ", map_type__name
[type
],
361 self
->loaded
? "" : "NOT ");
362 ret
+= dso__fprintf_buildid(self
, fp
);
363 ret
+= fprintf(fp
, ")\n");
364 for (nd
= rb_first(&self
->symbols
[type
]); nd
; nd
= rb_next(nd
)) {
365 struct symbol
*pos
= rb_entry(nd
, struct symbol
, rb_node
);
366 ret
+= symbol__fprintf(pos
, fp
);
372 int kallsyms__parse(const char *filename
, void *arg
,
373 int (*process_symbol
)(void *arg
, const char *name
,
374 char type
, u64 start
))
379 FILE *file
= fopen(filename
, "r");
384 while (!feof(file
)) {
390 line_len
= getline(&line
, &n
, file
);
397 line
[--line_len
] = '\0'; /* \n */
399 len
= hex2u64(line
, &start
);
402 if (len
+ 2 >= line_len
)
405 symbol_type
= toupper(line
[len
]);
406 symbol_name
= line
+ len
+ 2;
408 err
= process_symbol(arg
, symbol_name
, symbol_type
, start
);
421 struct process_kallsyms_args
{
426 static int map__process_kallsym_symbol(void *arg
, const char *name
,
427 char type
, u64 start
)
430 struct process_kallsyms_args
*a
= arg
;
431 struct rb_root
*root
= &a
->dso
->symbols
[a
->map
->type
];
433 if (!symbol_type__is_a(type
, a
->map
->type
))
437 * Will fix up the end later, when we have all symbols sorted.
439 sym
= symbol__new(start
, 0, name
);
444 * We will pass the symbols to the filter later, in
445 * map__split_kallsyms, when we have split the maps per module
447 symbols__insert(root
, sym
);
452 * Loads the function entries in /proc/kallsyms into kernel_map->dso,
453 * so that we can in the next step set the symbol ->end address and then
454 * call kernel_maps__split_kallsyms.
456 static int dso__load_all_kallsyms(struct dso
*self
, const char *filename
,
459 struct process_kallsyms_args args
= { .map
= map
, .dso
= self
, };
460 return kallsyms__parse(filename
, &args
, map__process_kallsym_symbol
);
464 * Split the symbols into maps, making sure there are no overlaps, i.e. the
465 * kernel range is broken in several maps, named [kernel].N, as we don't have
466 * the original ELF section names vmlinux have.
468 static int dso__split_kallsyms(struct dso
*self
, struct map
*map
,
469 symbol_filter_t filter
)
471 struct map_groups
*kmaps
= map__kmap(map
)->kmaps
;
472 struct map
*curr_map
= map
;
475 struct rb_root
*root
= &self
->symbols
[map
->type
];
476 struct rb_node
*next
= rb_first(root
);
477 int kernel_range
= 0;
482 pos
= rb_entry(next
, struct symbol
, rb_node
);
483 next
= rb_next(&pos
->rb_node
);
485 module
= strchr(pos
->name
, '\t');
487 if (!symbol_conf
.use_modules
)
492 if (strcmp(curr_map
->dso
->short_name
, module
)) {
493 curr_map
= map_groups__find_by_name(kmaps
, map
->type
, module
);
494 if (curr_map
== NULL
) {
495 pr_debug("/proc/{kallsyms,modules} "
496 "inconsistency while looking "
497 "for \"%s\" module!\n", module
);
501 if (curr_map
->dso
->loaded
)
505 * So that we look just like we get from .ko files,
506 * i.e. not prelinked, relative to map->start.
508 pos
->start
= curr_map
->map_ip(curr_map
, pos
->start
);
509 pos
->end
= curr_map
->map_ip(curr_map
, pos
->end
);
510 } else if (curr_map
!= map
) {
511 char dso_name
[PATH_MAX
];
514 snprintf(dso_name
, sizeof(dso_name
), "[kernel].%d",
517 dso
= dso__new(dso_name
);
521 curr_map
= map__new2(pos
->start
, dso
, map
->type
);
522 if (curr_map
== NULL
) {
527 curr_map
->map_ip
= curr_map
->unmap_ip
= identity__map_ip
;
528 map_groups__insert(kmaps
, curr_map
);
532 if (filter
&& filter(curr_map
, pos
)) {
533 discard_symbol
: rb_erase(&pos
->rb_node
, root
);
536 if (curr_map
!= map
) {
537 rb_erase(&pos
->rb_node
, root
);
538 symbols__insert(&curr_map
->dso
->symbols
[curr_map
->type
], pos
);
547 int dso__load_kallsyms(struct dso
*self
, const char *filename
,
548 struct map
*map
, symbol_filter_t filter
)
550 if (dso__load_all_kallsyms(self
, filename
, map
) < 0)
553 symbols__fixup_end(&self
->symbols
[map
->type
]);
554 self
->origin
= DSO__ORIG_KERNEL
;
556 return dso__split_kallsyms(self
, map
, filter
);
559 static int dso__load_perf_map(struct dso
*self
, struct map
*map
,
560 symbol_filter_t filter
)
567 file
= fopen(self
->long_name
, "r");
571 while (!feof(file
)) {
576 line_len
= getline(&line
, &n
, file
);
583 line
[--line_len
] = '\0'; /* \n */
585 len
= hex2u64(line
, &start
);
588 if (len
+ 2 >= line_len
)
591 len
+= hex2u64(line
+ len
, &size
);
594 if (len
+ 2 >= line_len
)
597 sym
= symbol__new(start
, size
, line
+ len
);
600 goto out_delete_line
;
602 if (filter
&& filter(map
, sym
))
605 symbols__insert(&self
->symbols
[map
->type
], sym
);
622 * elf_symtab__for_each_symbol - iterate thru all the symbols
624 * @self: struct elf_symtab instance to iterate
626 * @sym: GElf_Sym iterator
628 #define elf_symtab__for_each_symbol(syms, nr_syms, idx, sym) \
629 for (idx = 0, gelf_getsym(syms, idx, &sym);\
631 idx++, gelf_getsym(syms, idx, &sym))
633 static inline uint8_t elf_sym__type(const GElf_Sym
*sym
)
635 return GELF_ST_TYPE(sym
->st_info
);
638 static inline int elf_sym__is_function(const GElf_Sym
*sym
)
640 return elf_sym__type(sym
) == STT_FUNC
&&
642 sym
->st_shndx
!= SHN_UNDEF
;
645 static inline bool elf_sym__is_object(const GElf_Sym
*sym
)
647 return elf_sym__type(sym
) == STT_OBJECT
&&
649 sym
->st_shndx
!= SHN_UNDEF
;
652 static inline int elf_sym__is_label(const GElf_Sym
*sym
)
654 return elf_sym__type(sym
) == STT_NOTYPE
&&
656 sym
->st_shndx
!= SHN_UNDEF
&&
657 sym
->st_shndx
!= SHN_ABS
;
660 static inline const char *elf_sec__name(const GElf_Shdr
*shdr
,
661 const Elf_Data
*secstrs
)
663 return secstrs
->d_buf
+ shdr
->sh_name
;
666 static inline int elf_sec__is_text(const GElf_Shdr
*shdr
,
667 const Elf_Data
*secstrs
)
669 return strstr(elf_sec__name(shdr
, secstrs
), "text") != NULL
;
672 static inline bool elf_sec__is_data(const GElf_Shdr
*shdr
,
673 const Elf_Data
*secstrs
)
675 return strstr(elf_sec__name(shdr
, secstrs
), "data") != NULL
;
678 static inline const char *elf_sym__name(const GElf_Sym
*sym
,
679 const Elf_Data
*symstrs
)
681 return symstrs
->d_buf
+ sym
->st_name
;
684 static Elf_Scn
*elf_section_by_name(Elf
*elf
, GElf_Ehdr
*ep
,
685 GElf_Shdr
*shp
, const char *name
,
691 while ((sec
= elf_nextscn(elf
, sec
)) != NULL
) {
694 gelf_getshdr(sec
, shp
);
695 str
= elf_strptr(elf
, ep
->e_shstrndx
, shp
->sh_name
);
696 if (!strcmp(name
, str
)) {
707 #define elf_section__for_each_rel(reldata, pos, pos_mem, idx, nr_entries) \
708 for (idx = 0, pos = gelf_getrel(reldata, 0, &pos_mem); \
710 ++idx, pos = gelf_getrel(reldata, idx, &pos_mem))
712 #define elf_section__for_each_rela(reldata, pos, pos_mem, idx, nr_entries) \
713 for (idx = 0, pos = gelf_getrela(reldata, 0, &pos_mem); \
715 ++idx, pos = gelf_getrela(reldata, idx, &pos_mem))
718 * We need to check if we have a .dynsym, so that we can handle the
719 * .plt, synthesizing its symbols, that aren't on the symtabs (be it
720 * .dynsym or .symtab).
721 * And always look at the original dso, not at debuginfo packages, that
722 * have the PLT data stripped out (shdr_rel_plt.sh_type == SHT_NOBITS).
724 static int dso__synthesize_plt_symbols(struct dso
*self
, struct map
*map
,
725 symbol_filter_t filter
)
727 uint32_t nr_rel_entries
, idx
;
732 GElf_Shdr shdr_rel_plt
, shdr_dynsym
;
733 Elf_Data
*reldata
, *syms
, *symstrs
;
734 Elf_Scn
*scn_plt_rel
, *scn_symstrs
, *scn_dynsym
;
737 char sympltname
[1024];
739 int nr
= 0, symidx
, fd
, err
= 0;
741 fd
= open(self
->long_name
, O_RDONLY
);
745 elf
= elf_begin(fd
, PERF_ELF_C_READ_MMAP
, NULL
);
749 if (gelf_getehdr(elf
, &ehdr
) == NULL
)
752 scn_dynsym
= elf_section_by_name(elf
, &ehdr
, &shdr_dynsym
,
753 ".dynsym", &dynsym_idx
);
754 if (scn_dynsym
== NULL
)
757 scn_plt_rel
= elf_section_by_name(elf
, &ehdr
, &shdr_rel_plt
,
759 if (scn_plt_rel
== NULL
) {
760 scn_plt_rel
= elf_section_by_name(elf
, &ehdr
, &shdr_rel_plt
,
762 if (scn_plt_rel
== NULL
)
768 if (shdr_rel_plt
.sh_link
!= dynsym_idx
)
771 if (elf_section_by_name(elf
, &ehdr
, &shdr_plt
, ".plt", NULL
) == NULL
)
775 * Fetch the relocation section to find the idxes to the GOT
776 * and the symbols in the .dynsym they refer to.
778 reldata
= elf_getdata(scn_plt_rel
, NULL
);
782 syms
= elf_getdata(scn_dynsym
, NULL
);
786 scn_symstrs
= elf_getscn(elf
, shdr_dynsym
.sh_link
);
787 if (scn_symstrs
== NULL
)
790 symstrs
= elf_getdata(scn_symstrs
, NULL
);
794 nr_rel_entries
= shdr_rel_plt
.sh_size
/ shdr_rel_plt
.sh_entsize
;
795 plt_offset
= shdr_plt
.sh_offset
;
797 if (shdr_rel_plt
.sh_type
== SHT_RELA
) {
798 GElf_Rela pos_mem
, *pos
;
800 elf_section__for_each_rela(reldata
, pos
, pos_mem
, idx
,
802 symidx
= GELF_R_SYM(pos
->r_info
);
803 plt_offset
+= shdr_plt
.sh_entsize
;
804 gelf_getsym(syms
, symidx
, &sym
);
805 snprintf(sympltname
, sizeof(sympltname
),
806 "%s@plt", elf_sym__name(&sym
, symstrs
));
808 f
= symbol__new(plt_offset
, shdr_plt
.sh_entsize
,
813 if (filter
&& filter(map
, f
))
816 symbols__insert(&self
->symbols
[map
->type
], f
);
820 } else if (shdr_rel_plt
.sh_type
== SHT_REL
) {
821 GElf_Rel pos_mem
, *pos
;
822 elf_section__for_each_rel(reldata
, pos
, pos_mem
, idx
,
824 symidx
= GELF_R_SYM(pos
->r_info
);
825 plt_offset
+= shdr_plt
.sh_entsize
;
826 gelf_getsym(syms
, symidx
, &sym
);
827 snprintf(sympltname
, sizeof(sympltname
),
828 "%s@plt", elf_sym__name(&sym
, symstrs
));
830 f
= symbol__new(plt_offset
, shdr_plt
.sh_entsize
,
835 if (filter
&& filter(map
, f
))
838 symbols__insert(&self
->symbols
[map
->type
], f
);
853 pr_debug("%s: problems reading %s PLT info.\n",
854 __func__
, self
->long_name
);
858 static bool elf_sym__is_a(GElf_Sym
*self
, enum map_type type
)
862 return elf_sym__is_function(self
);
864 return elf_sym__is_object(self
);
870 static bool elf_sec__is_a(GElf_Shdr
*self
, Elf_Data
*secstrs
, enum map_type type
)
874 return elf_sec__is_text(self
, secstrs
);
876 return elf_sec__is_data(self
, secstrs
);
882 static int dso__load_sym(struct dso
*self
, struct map
*map
, const char *name
,
883 int fd
, symbol_filter_t filter
, int kmodule
)
885 struct kmap
*kmap
= self
->kernel
? map__kmap(map
) : NULL
;
886 struct map
*curr_map
= map
;
887 struct dso
*curr_dso
= self
;
888 size_t dso_name_len
= strlen(self
->short_name
);
889 Elf_Data
*symstrs
, *secstrs
;
897 Elf_Scn
*sec
, *sec_strndx
;
901 elf
= elf_begin(fd
, PERF_ELF_C_READ_MMAP
, NULL
);
903 pr_err("%s: cannot read %s ELF file.\n", __func__
, name
);
907 if (gelf_getehdr(elf
, &ehdr
) == NULL
) {
908 pr_err("%s: cannot get elf header.\n", __func__
);
912 sec
= elf_section_by_name(elf
, &ehdr
, &shdr
, ".symtab", NULL
);
914 sec
= elf_section_by_name(elf
, &ehdr
, &shdr
, ".dynsym", NULL
);
919 syms
= elf_getdata(sec
, NULL
);
923 sec
= elf_getscn(elf
, shdr
.sh_link
);
927 symstrs
= elf_getdata(sec
, NULL
);
931 sec_strndx
= elf_getscn(elf
, ehdr
.e_shstrndx
);
932 if (sec_strndx
== NULL
)
935 secstrs
= elf_getdata(sec_strndx
, NULL
);
939 nr_syms
= shdr
.sh_size
/ shdr
.sh_entsize
;
941 memset(&sym
, 0, sizeof(sym
));
943 self
->adjust_symbols
= (ehdr
.e_type
== ET_EXEC
||
944 elf_section_by_name(elf
, &ehdr
, &shdr
,
947 } else self
->adjust_symbols
= 0;
949 elf_symtab__for_each_symbol(syms
, nr_syms
, idx
, sym
) {
951 const char *elf_name
= elf_sym__name(&sym
, symstrs
);
952 char *demangled
= NULL
;
953 int is_label
= elf_sym__is_label(&sym
);
954 const char *section_name
;
956 if (kmap
&& kmap
->ref_reloc_sym
&& kmap
->ref_reloc_sym
->name
&&
957 strcmp(elf_name
, kmap
->ref_reloc_sym
->name
) == 0)
958 kmap
->ref_reloc_sym
->unrelocated_addr
= sym
.st_value
;
960 if (!is_label
&& !elf_sym__is_a(&sym
, map
->type
))
963 sec
= elf_getscn(elf
, sym
.st_shndx
);
967 gelf_getshdr(sec
, &shdr
);
969 if (is_label
&& !elf_sec__is_a(&shdr
, secstrs
, map
->type
))
972 section_name
= elf_sec__name(&shdr
, secstrs
);
974 if (self
->kernel
|| kmodule
) {
975 char dso_name
[PATH_MAX
];
977 if (strcmp(section_name
,
978 curr_dso
->short_name
+ dso_name_len
) == 0)
981 if (strcmp(section_name
, ".text") == 0) {
987 snprintf(dso_name
, sizeof(dso_name
),
988 "%s%s", self
->short_name
, section_name
);
990 curr_map
= map_groups__find_by_name(kmap
->kmaps
, map
->type
, dso_name
);
991 if (curr_map
== NULL
) {
992 u64 start
= sym
.st_value
;
995 start
+= map
->start
+ shdr
.sh_offset
;
997 curr_dso
= dso__new(dso_name
);
998 if (curr_dso
== NULL
)
1000 curr_map
= map__new2(start
, curr_dso
,
1002 if (curr_map
== NULL
) {
1003 dso__delete(curr_dso
);
1006 curr_map
->map_ip
= identity__map_ip
;
1007 curr_map
->unmap_ip
= identity__map_ip
;
1008 curr_dso
->origin
= self
->origin
;
1009 map_groups__insert(kmap
->kmaps
, curr_map
);
1010 dsos__add(&dsos__kernel
, curr_dso
);
1011 dso__set_loaded(curr_dso
, map
->type
);
1013 curr_dso
= curr_map
->dso
;
1018 if (curr_dso
->adjust_symbols
) {
1019 pr_debug4("%s: adjusting symbol: st_value: %#Lx "
1020 "sh_addr: %#Lx sh_offset: %#Lx\n", __func__
,
1021 (u64
)sym
.st_value
, (u64
)shdr
.sh_addr
,
1022 (u64
)shdr
.sh_offset
);
1023 sym
.st_value
-= shdr
.sh_addr
- shdr
.sh_offset
;
1026 * We need to figure out if the object was created from C++ sources
1027 * DWARF DW_compile_unit has this, but we don't always have access
1030 demangled
= bfd_demangle(NULL
, elf_name
, DMGL_PARAMS
| DMGL_ANSI
);
1031 if (demangled
!= NULL
)
1032 elf_name
= demangled
;
1034 f
= symbol__new(sym
.st_value
, sym
.st_size
, elf_name
);
1039 if (filter
&& filter(curr_map
, f
))
1042 symbols__insert(&curr_dso
->symbols
[curr_map
->type
], f
);
1048 * For misannotated, zeroed, ASM function sizes.
1051 symbols__fixup_end(&self
->symbols
[map
->type
]);
1054 * We need to fixup this here too because we create new
1055 * maps here, for things like vsyscall sections.
1057 __map_groups__fixup_end(kmap
->kmaps
, map
->type
);
1067 static bool dso__build_id_equal(const struct dso
*self
, u8
*build_id
)
1069 return memcmp(self
->build_id
, build_id
, sizeof(self
->build_id
)) == 0;
1072 static bool __dsos__read_build_ids(struct list_head
*head
, bool with_hits
)
1074 bool have_build_id
= false;
1077 list_for_each_entry(pos
, head
, node
) {
1078 if (with_hits
&& !pos
->hit
)
1080 if (filename__read_build_id(pos
->long_name
, pos
->build_id
,
1081 sizeof(pos
->build_id
)) > 0) {
1082 have_build_id
= true;
1083 pos
->has_build_id
= true;
1087 return have_build_id
;
1090 bool dsos__read_build_ids(bool with_hits
)
1092 bool kbuildids
= __dsos__read_build_ids(&dsos__kernel
, with_hits
),
1093 ubuildids
= __dsos__read_build_ids(&dsos__user
, with_hits
);
1094 return kbuildids
|| ubuildids
;
1098 * Align offset to 4 bytes as needed for note name and descriptor data.
1100 #define NOTE_ALIGN(n) (((n) + 3) & -4U)
1102 int filename__read_build_id(const char *filename
, void *bf
, size_t size
)
1113 if (size
< BUILD_ID_SIZE
)
1116 fd
= open(filename
, O_RDONLY
);
1120 elf
= elf_begin(fd
, PERF_ELF_C_READ_MMAP
, NULL
);
1122 pr_debug2("%s: cannot read %s ELF file.\n", __func__
, filename
);
1127 if (ek
!= ELF_K_ELF
)
1130 if (gelf_getehdr(elf
, &ehdr
) == NULL
) {
1131 pr_err("%s: cannot get elf header.\n", __func__
);
1135 sec
= elf_section_by_name(elf
, &ehdr
, &shdr
,
1136 ".note.gnu.build-id", NULL
);
1138 sec
= elf_section_by_name(elf
, &ehdr
, &shdr
,
1144 data
= elf_getdata(sec
, NULL
);
1149 while (ptr
< (data
->d_buf
+ data
->d_size
)) {
1150 GElf_Nhdr
*nhdr
= ptr
;
1151 int namesz
= NOTE_ALIGN(nhdr
->n_namesz
),
1152 descsz
= NOTE_ALIGN(nhdr
->n_descsz
);
1155 ptr
+= sizeof(*nhdr
);
1158 if (nhdr
->n_type
== NT_GNU_BUILD_ID
&&
1159 nhdr
->n_namesz
== sizeof("GNU")) {
1160 if (memcmp(name
, "GNU", sizeof("GNU")) == 0) {
1161 memcpy(bf
, ptr
, BUILD_ID_SIZE
);
1162 err
= BUILD_ID_SIZE
;
1176 int sysfs__read_build_id(const char *filename
, void *build_id
, size_t size
)
1180 if (size
< BUILD_ID_SIZE
)
1183 fd
= open(filename
, O_RDONLY
);
1192 if (read(fd
, &nhdr
, sizeof(nhdr
)) != sizeof(nhdr
))
1195 namesz
= NOTE_ALIGN(nhdr
.n_namesz
);
1196 descsz
= NOTE_ALIGN(nhdr
.n_descsz
);
1197 if (nhdr
.n_type
== NT_GNU_BUILD_ID
&&
1198 nhdr
.n_namesz
== sizeof("GNU")) {
1199 if (read(fd
, bf
, namesz
) != namesz
)
1201 if (memcmp(bf
, "GNU", sizeof("GNU")) == 0) {
1202 if (read(fd
, build_id
,
1203 BUILD_ID_SIZE
) == BUILD_ID_SIZE
) {
1207 } else if (read(fd
, bf
, descsz
) != descsz
)
1210 int n
= namesz
+ descsz
;
1211 if (read(fd
, bf
, n
) != n
)
1220 char dso__symtab_origin(const struct dso
*self
)
1222 static const char origin
[] = {
1223 [DSO__ORIG_KERNEL
] = 'k',
1224 [DSO__ORIG_JAVA_JIT
] = 'j',
1225 [DSO__ORIG_BUILD_ID_CACHE
] = 'B',
1226 [DSO__ORIG_FEDORA
] = 'f',
1227 [DSO__ORIG_UBUNTU
] = 'u',
1228 [DSO__ORIG_BUILDID
] = 'b',
1229 [DSO__ORIG_DSO
] = 'd',
1230 [DSO__ORIG_KMODULE
] = 'K',
1233 if (self
== NULL
|| self
->origin
== DSO__ORIG_NOT_FOUND
)
1235 return origin
[self
->origin
];
1238 int dso__load(struct dso
*self
, struct map
*map
, symbol_filter_t filter
)
1240 int size
= PATH_MAX
;
1242 u8 build_id
[BUILD_ID_SIZE
];
1243 char build_id_hex
[BUILD_ID_SIZE
* 2 + 1];
1247 dso__set_loaded(self
, map
->type
);
1250 return dso__load_kernel_sym(self
, map
, filter
);
1252 name
= malloc(size
);
1256 self
->adjust_symbols
= 0;
1258 if (strncmp(self
->name
, "/tmp/perf-", 10) == 0) {
1259 ret
= dso__load_perf_map(self
, map
, filter
);
1260 self
->origin
= ret
> 0 ? DSO__ORIG_JAVA_JIT
:
1261 DSO__ORIG_NOT_FOUND
;
1265 self
->origin
= DSO__ORIG_BUILD_ID_CACHE
;
1267 if (self
->has_build_id
) {
1268 build_id__sprintf(self
->build_id
, sizeof(self
->build_id
),
1270 snprintf(name
, size
, "%s/%s/.build-id/%.2s/%s",
1271 getenv("HOME"), DEBUG_CACHE_DIR
,
1272 build_id_hex
, build_id_hex
+ 2);
1278 switch (self
->origin
) {
1279 case DSO__ORIG_FEDORA
:
1280 snprintf(name
, size
, "/usr/lib/debug%s.debug",
1283 case DSO__ORIG_UBUNTU
:
1284 snprintf(name
, size
, "/usr/lib/debug%s",
1287 case DSO__ORIG_BUILDID
:
1288 if (filename__read_build_id(self
->long_name
, build_id
,
1289 sizeof(build_id
))) {
1290 build_id__sprintf(build_id
, sizeof(build_id
),
1292 snprintf(name
, size
,
1293 "/usr/lib/debug/.build-id/%.2s/%s.debug",
1294 build_id_hex
, build_id_hex
+ 2);
1295 if (self
->has_build_id
)
1296 goto compare_build_id
;
1302 snprintf(name
, size
, "%s", self
->long_name
);
1309 if (self
->has_build_id
) {
1310 if (filename__read_build_id(name
, build_id
,
1311 sizeof(build_id
)) < 0)
1314 if (!dso__build_id_equal(self
, build_id
))
1318 fd
= open(name
, O_RDONLY
);
1321 ret
= dso__load_sym(self
, map
, name
, fd
, filter
, 0);
1325 * Some people seem to have debuginfo files _WITHOUT_ debug info!?!?
1331 int nr_plt
= dso__synthesize_plt_symbols(self
, map
, filter
);
1337 if (ret
< 0 && strstr(self
->name
, " (deleted)") != NULL
)
1342 struct map
*map_groups__find_by_name(struct map_groups
*self
,
1343 enum map_type type
, const char *name
)
1347 for (nd
= rb_first(&self
->maps
[type
]); nd
; nd
= rb_next(nd
)) {
1348 struct map
*map
= rb_entry(nd
, struct map
, rb_node
);
1350 if (map
->dso
&& strcmp(map
->dso
->short_name
, name
) == 0)
1357 static int dso__kernel_module_get_build_id(struct dso
*self
)
1359 char filename
[PATH_MAX
];
1361 * kernel module short names are of the form "[module]" and
1362 * we need just "module" here.
1364 const char *name
= self
->short_name
+ 1;
1366 snprintf(filename
, sizeof(filename
),
1367 "/sys/module/%.*s/notes/.note.gnu.build-id",
1368 (int)strlen(name
- 1), name
);
1370 if (sysfs__read_build_id(filename
, self
->build_id
,
1371 sizeof(self
->build_id
)) == 0)
1372 self
->has_build_id
= true;
1377 static int map_groups__set_modules_path_dir(struct map_groups
*self
, char *dirname
)
1379 struct dirent
*dent
;
1380 DIR *dir
= opendir(dirname
);
1383 pr_debug("%s: cannot open %s dir\n", __func__
, dirname
);
1387 while ((dent
= readdir(dir
)) != NULL
) {
1388 char path
[PATH_MAX
];
1390 if (dent
->d_type
== DT_DIR
) {
1391 if (!strcmp(dent
->d_name
, ".") ||
1392 !strcmp(dent
->d_name
, ".."))
1395 snprintf(path
, sizeof(path
), "%s/%s",
1396 dirname
, dent
->d_name
);
1397 if (map_groups__set_modules_path_dir(self
, path
) < 0)
1400 char *dot
= strrchr(dent
->d_name
, '.'),
1405 if (dot
== NULL
|| strcmp(dot
, ".ko"))
1407 snprintf(dso_name
, sizeof(dso_name
), "[%.*s]",
1408 (int)(dot
- dent
->d_name
), dent
->d_name
);
1410 strxfrchar(dso_name
, '-', '_');
1411 map
= map_groups__find_by_name(self
, MAP__FUNCTION
, dso_name
);
1415 snprintf(path
, sizeof(path
), "%s/%s",
1416 dirname
, dent
->d_name
);
1418 long_name
= strdup(path
);
1419 if (long_name
== NULL
)
1421 dso__set_long_name(map
->dso
, long_name
);
1422 dso__kernel_module_get_build_id(map
->dso
);
1432 static int map_groups__set_modules_path(struct map_groups
*self
)
1435 char modules_path
[PATH_MAX
];
1437 if (uname(&uts
) < 0)
1440 snprintf(modules_path
, sizeof(modules_path
), "/lib/modules/%s/kernel",
1443 return map_groups__set_modules_path_dir(self
, modules_path
);
1447 * Constructor variant for modules (where we know from /proc/modules where
1448 * they are loaded) and for vmlinux, where only after we load all the
1449 * symbols we'll know where it starts and ends.
1451 static struct map
*map__new2(u64 start
, struct dso
*dso
, enum map_type type
)
1453 struct map
*self
= zalloc(sizeof(*self
) +
1454 (dso
->kernel
? sizeof(struct kmap
) : 0));
1457 * ->end will be filled after we load all the symbols
1459 map__init(self
, type
, start
, 0, 0, dso
);
1465 struct map
*map_groups__new_module(struct map_groups
*self
, u64 start
,
1466 const char *filename
)
1469 struct dso
*dso
= __dsos__findnew(&dsos__kernel
, filename
);
1474 map
= map__new2(start
, dso
, MAP__FUNCTION
);
1478 dso
->origin
= DSO__ORIG_KMODULE
;
1479 map_groups__insert(self
, map
);
1483 static int map_groups__create_modules(struct map_groups
*self
)
1487 FILE *file
= fopen("/proc/modules", "r");
1493 while (!feof(file
)) {
1494 char name
[PATH_MAX
];
1499 line_len
= getline(&line
, &n
, file
);
1506 line
[--line_len
] = '\0'; /* \n */
1508 sep
= strrchr(line
, 'x');
1512 hex2u64(sep
+ 1, &start
);
1514 sep
= strchr(line
, ' ');
1520 snprintf(name
, sizeof(name
), "[%s]", line
);
1521 map
= map_groups__new_module(self
, start
, name
);
1523 goto out_delete_line
;
1524 dso__kernel_module_get_build_id(map
->dso
);
1530 return map_groups__set_modules_path(self
);
1538 static int dso__load_vmlinux(struct dso
*self
, struct map
*map
,
1539 const char *vmlinux
, symbol_filter_t filter
)
1543 if (self
->has_build_id
) {
1544 u8 build_id
[BUILD_ID_SIZE
];
1546 if (filename__read_build_id(vmlinux
, build_id
,
1547 sizeof(build_id
)) < 0) {
1548 pr_debug("No build_id in %s, ignoring it\n", vmlinux
);
1551 if (!dso__build_id_equal(self
, build_id
)) {
1552 char expected_build_id
[BUILD_ID_SIZE
* 2 + 1],
1553 vmlinux_build_id
[BUILD_ID_SIZE
* 2 + 1];
1555 build_id__sprintf(self
->build_id
,
1556 sizeof(self
->build_id
),
1558 build_id__sprintf(build_id
, sizeof(build_id
),
1560 pr_debug("build_id in %s is %s while expected is %s, "
1561 "ignoring it\n", vmlinux
, vmlinux_build_id
,
1567 fd
= open(vmlinux
, O_RDONLY
);
1571 dso__set_loaded(self
, map
->type
);
1572 err
= dso__load_sym(self
, map
, vmlinux
, fd
, filter
, 0);
1576 pr_debug("Using %s for symbols\n", vmlinux
);
1581 int dso__load_vmlinux_path(struct dso
*self
, struct map
*map
,
1582 symbol_filter_t filter
)
1586 pr_debug("Looking at the vmlinux_path (%d entries long)\n",
1587 vmlinux_path__nr_entries
);
1589 for (i
= 0; i
< vmlinux_path__nr_entries
; ++i
) {
1590 err
= dso__load_vmlinux(self
, map
, vmlinux_path
[i
], filter
);
1592 dso__set_long_name(self
, strdup(vmlinux_path
[i
]));
1600 static int dso__load_kernel_sym(struct dso
*self
, struct map
*map
,
1601 symbol_filter_t filter
)
1604 const char *kallsyms_filename
= NULL
;
1605 char *kallsyms_allocated_filename
= NULL
;
1607 * Step 1: if the user specified a vmlinux filename, use it and only
1608 * it, reporting errors to the user if it cannot be used.
1610 * For instance, try to analyse an ARM perf.data file _without_ a
1611 * build-id, or if the user specifies the wrong path to the right
1612 * vmlinux file, obviously we can't fallback to another vmlinux (a
1613 * x86_86 one, on the machine where analysis is being performed, say),
1614 * or worse, /proc/kallsyms.
1616 * If the specified file _has_ a build-id and there is a build-id
1617 * section in the perf.data file, we will still do the expected
1618 * validation in dso__load_vmlinux and will bail out if they don't
1621 if (symbol_conf
.vmlinux_name
!= NULL
) {
1622 err
= dso__load_vmlinux(self
, map
,
1623 symbol_conf
.vmlinux_name
, filter
);
1627 if (vmlinux_path
!= NULL
) {
1628 err
= dso__load_vmlinux_path(self
, map
, filter
);
1634 * Say the kernel DSO was created when processing the build-id header table,
1635 * we have a build-id, so check if it is the same as the running kernel,
1636 * using it if it is.
1638 if (self
->has_build_id
) {
1639 u8 kallsyms_build_id
[BUILD_ID_SIZE
];
1640 char sbuild_id
[BUILD_ID_SIZE
* 2 + 1];
1642 if (sysfs__read_build_id("/sys/kernel/notes", kallsyms_build_id
,
1643 sizeof(kallsyms_build_id
)) == 0) {
1644 if (dso__build_id_equal(self
, kallsyms_build_id
)) {
1645 kallsyms_filename
= "/proc/kallsyms";
1650 * Now look if we have it on the build-id cache in
1651 * $HOME/.debug/[kernel.kallsyms].
1653 build_id__sprintf(self
->build_id
, sizeof(self
->build_id
),
1656 if (asprintf(&kallsyms_allocated_filename
,
1657 "%s/.debug/[kernel.kallsyms]/%s",
1658 getenv("HOME"), sbuild_id
) == -1) {
1659 pr_err("Not enough memory for kallsyms file lookup\n");
1663 kallsyms_filename
= kallsyms_allocated_filename
;
1665 if (access(kallsyms_filename
, F_OK
)) {
1666 pr_err("No kallsyms or vmlinux with build-id %s "
1667 "was found\n", sbuild_id
);
1668 free(kallsyms_allocated_filename
);
1673 * Last resort, if we don't have a build-id and couldn't find
1674 * any vmlinux file, try the running kernel kallsyms table.
1676 kallsyms_filename
= "/proc/kallsyms";
1680 err
= dso__load_kallsyms(self
, kallsyms_filename
, map
, filter
);
1682 pr_debug("Using %s for symbols\n", kallsyms_filename
);
1683 free(kallsyms_allocated_filename
);
1688 if (kallsyms_filename
!= NULL
)
1689 dso__set_long_name(self
, strdup("[kernel.kallsyms]"));
1690 map__fixup_start(map
);
1691 map__fixup_end(map
);
1697 LIST_HEAD(dsos__user
);
1698 LIST_HEAD(dsos__kernel
);
1700 static void dsos__add(struct list_head
*head
, struct dso
*dso
)
1702 list_add_tail(&dso
->node
, head
);
1705 static struct dso
*dsos__find(struct list_head
*head
, const char *name
)
1709 list_for_each_entry(pos
, head
, node
)
1710 if (strcmp(pos
->long_name
, name
) == 0)
1715 struct dso
*__dsos__findnew(struct list_head
*head
, const char *name
)
1717 struct dso
*dso
= dsos__find(head
, name
);
1720 dso
= dso__new(name
);
1722 dsos__add(head
, dso
);
1723 dso__set_basename(dso
);
1730 static void __dsos__fprintf(struct list_head
*head
, FILE *fp
)
1734 list_for_each_entry(pos
, head
, node
) {
1736 for (i
= 0; i
< MAP__NR_TYPES
; ++i
)
1737 dso__fprintf(pos
, i
, fp
);
1741 void dsos__fprintf(FILE *fp
)
1743 __dsos__fprintf(&dsos__kernel
, fp
);
1744 __dsos__fprintf(&dsos__user
, fp
);
1747 static size_t __dsos__fprintf_buildid(struct list_head
*head
, FILE *fp
,
1753 list_for_each_entry(pos
, head
, node
) {
1754 if (with_hits
&& !pos
->hit
)
1756 ret
+= dso__fprintf_buildid(pos
, fp
);
1757 ret
+= fprintf(fp
, " %s\n", pos
->long_name
);
1762 size_t dsos__fprintf_buildid(FILE *fp
, bool with_hits
)
1764 return (__dsos__fprintf_buildid(&dsos__kernel
, fp
, with_hits
) +
1765 __dsos__fprintf_buildid(&dsos__user
, fp
, with_hits
));
1768 struct dso
*dso__new_kernel(const char *name
)
1770 struct dso
*self
= dso__new(name
?: "[kernel.kallsyms]");
1773 self
->short_name
= "[kernel]";
1780 void dso__read_running_kernel_build_id(struct dso
*self
)
1782 if (sysfs__read_build_id("/sys/kernel/notes", self
->build_id
,
1783 sizeof(self
->build_id
)) == 0)
1784 self
->has_build_id
= true;
1787 static struct dso
*dsos__create_kernel(const char *vmlinux
)
1789 struct dso
*kernel
= dso__new_kernel(vmlinux
);
1791 if (kernel
!= NULL
) {
1792 dso__read_running_kernel_build_id(kernel
);
1793 dsos__add(&dsos__kernel
, kernel
);
1799 int __map_groups__create_kernel_maps(struct map_groups
*self
,
1800 struct map
*vmlinux_maps
[MAP__NR_TYPES
],
1805 for (type
= 0; type
< MAP__NR_TYPES
; ++type
) {
1808 vmlinux_maps
[type
] = map__new2(0, kernel
, type
);
1809 if (vmlinux_maps
[type
] == NULL
)
1812 vmlinux_maps
[type
]->map_ip
=
1813 vmlinux_maps
[type
]->unmap_ip
= identity__map_ip
;
1815 kmap
= map__kmap(vmlinux_maps
[type
]);
1817 map_groups__insert(self
, vmlinux_maps
[type
]);
1823 static void vmlinux_path__exit(void)
1825 while (--vmlinux_path__nr_entries
>= 0) {
1826 free(vmlinux_path
[vmlinux_path__nr_entries
]);
1827 vmlinux_path
[vmlinux_path__nr_entries
] = NULL
;
1831 vmlinux_path
= NULL
;
1834 static int vmlinux_path__init(void)
1839 if (uname(&uts
) < 0)
1842 vmlinux_path
= malloc(sizeof(char *) * 5);
1843 if (vmlinux_path
== NULL
)
1846 vmlinux_path
[vmlinux_path__nr_entries
] = strdup("vmlinux");
1847 if (vmlinux_path
[vmlinux_path__nr_entries
] == NULL
)
1849 ++vmlinux_path__nr_entries
;
1850 vmlinux_path
[vmlinux_path__nr_entries
] = strdup("/boot/vmlinux");
1851 if (vmlinux_path
[vmlinux_path__nr_entries
] == NULL
)
1853 ++vmlinux_path__nr_entries
;
1854 snprintf(bf
, sizeof(bf
), "/boot/vmlinux-%s", uts
.release
);
1855 vmlinux_path
[vmlinux_path__nr_entries
] = strdup(bf
);
1856 if (vmlinux_path
[vmlinux_path__nr_entries
] == NULL
)
1858 ++vmlinux_path__nr_entries
;
1859 snprintf(bf
, sizeof(bf
), "/lib/modules/%s/build/vmlinux", uts
.release
);
1860 vmlinux_path
[vmlinux_path__nr_entries
] = strdup(bf
);
1861 if (vmlinux_path
[vmlinux_path__nr_entries
] == NULL
)
1863 ++vmlinux_path__nr_entries
;
1864 snprintf(bf
, sizeof(bf
), "/usr/lib/debug/lib/modules/%s/vmlinux",
1866 vmlinux_path
[vmlinux_path__nr_entries
] = strdup(bf
);
1867 if (vmlinux_path
[vmlinux_path__nr_entries
] == NULL
)
1869 ++vmlinux_path__nr_entries
;
1874 vmlinux_path__exit();
1878 size_t vmlinux_path__fprintf(FILE *fp
)
1883 for (i
= 0; i
< vmlinux_path__nr_entries
; ++i
)
1884 printed
+= fprintf(fp
, "[%d] %s\n", i
, vmlinux_path
[i
]);
1889 static int setup_list(struct strlist
**list
, const char *list_str
,
1890 const char *list_name
)
1892 if (list_str
== NULL
)
1895 *list
= strlist__new(true, list_str
);
1897 pr_err("problems parsing %s list\n", list_name
);
1903 int symbol__init(void)
1905 elf_version(EV_CURRENT
);
1906 if (symbol_conf
.sort_by_name
)
1907 symbol_conf
.priv_size
+= (sizeof(struct symbol_name_rb_node
) -
1908 sizeof(struct symbol
));
1910 if (symbol_conf
.try_vmlinux_path
&& vmlinux_path__init() < 0)
1913 if (symbol_conf
.field_sep
&& *symbol_conf
.field_sep
== '.') {
1914 pr_err("'.' is the only non valid --field-separator argument\n");
1918 if (setup_list(&symbol_conf
.dso_list
,
1919 symbol_conf
.dso_list_str
, "dso") < 0)
1922 if (setup_list(&symbol_conf
.comm_list
,
1923 symbol_conf
.comm_list_str
, "comm") < 0)
1924 goto out_free_dso_list
;
1926 if (setup_list(&symbol_conf
.sym_list
,
1927 symbol_conf
.sym_list_str
, "symbol") < 0)
1928 goto out_free_comm_list
;
1933 strlist__delete(symbol_conf
.dso_list
);
1935 strlist__delete(symbol_conf
.comm_list
);
1939 int map_groups__create_kernel_maps(struct map_groups
*self
,
1940 struct map
*vmlinux_maps
[MAP__NR_TYPES
])
1942 struct dso
*kernel
= dsos__create_kernel(symbol_conf
.vmlinux_name
);
1947 if (__map_groups__create_kernel_maps(self
, vmlinux_maps
, kernel
) < 0)
1950 if (symbol_conf
.use_modules
&& map_groups__create_modules(self
) < 0)
1951 pr_debug("Problems creating module maps, continuing anyway...\n");
1953 * Now that we have all the maps created, just set the ->end of them:
1955 map_groups__fixup_end(self
);