Commit e5a1845f authored by Namhyung Kim's avatar Namhyung Kim Committed by Arnaldo Carvalho de Melo

perf symbols: Split out util/symbol-elf.c

Factor out the dependency of ELF handling into separate symbol-elf.c
file. It is a preparation of building a minimalistic version perf tools
which doesn't depend on the elfutils.
Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1344228082-15569-3-git-send-email-namhyung@kernel.org
[ committer note: removed blank line at symbol-elf.c EOF ]
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 166ccc9c
...@@ -356,6 +356,7 @@ LIB_OBJS += $(OUTPUT)util/usage.o ...@@ -356,6 +356,7 @@ LIB_OBJS += $(OUTPUT)util/usage.o
LIB_OBJS += $(OUTPUT)util/wrapper.o LIB_OBJS += $(OUTPUT)util/wrapper.o
LIB_OBJS += $(OUTPUT)util/sigchain.o LIB_OBJS += $(OUTPUT)util/sigchain.o
LIB_OBJS += $(OUTPUT)util/symbol.o LIB_OBJS += $(OUTPUT)util/symbol.o
LIB_OBJS += $(OUTPUT)util/symbol-elf.o
LIB_OBJS += $(OUTPUT)util/dso-test-data.o LIB_OBJS += $(OUTPUT)util/dso-test-data.o
LIB_OBJS += $(OUTPUT)util/color.o LIB_OBJS += $(OUTPUT)util/color.o
LIB_OBJS += $(OUTPUT)util/pager.o LIB_OBJS += $(OUTPUT)util/pager.o
......
...@@ -86,6 +86,25 @@ struct map *map__new(struct list_head *dsos__list, u64 start, u64 len, ...@@ -86,6 +86,25 @@ struct map *map__new(struct list_head *dsos__list, u64 start, u64 len,
return NULL; return NULL;
} }
/*
* Constructor variant for modules (where we know from /proc/modules where
* they are loaded) and for vmlinux, where only after we load all the
* symbols we'll know where it starts and ends.
*/
struct map *map__new2(u64 start, struct dso *dso, enum map_type type)
{
struct map *map = calloc(1, (sizeof(*map) +
(dso->kernel ? sizeof(struct kmap) : 0)));
if (map != NULL) {
/*
* ->end will be filled after we load all the symbols
*/
map__init(map, type, start, 0, 0, dso);
}
return map;
}
void map__delete(struct map *self) void map__delete(struct map *self)
{ {
free(self); free(self);
......
...@@ -115,6 +115,7 @@ void map__init(struct map *self, enum map_type type, ...@@ -115,6 +115,7 @@ void map__init(struct map *self, enum map_type type,
struct map *map__new(struct list_head *dsos__list, u64 start, u64 len, struct map *map__new(struct list_head *dsos__list, u64 start, u64 len,
u64 pgoff, u32 pid, char *filename, u64 pgoff, u32 pid, char *filename,
enum map_type type); enum map_type type);
struct map *map__new2(u64 start, struct dso *dso, enum map_type type);
void map__delete(struct map *self); void map__delete(struct map *self);
struct map *map__clone(struct map *self); struct map *map__clone(struct map *self);
int map__overlap(struct map *l, struct map *r); int map__overlap(struct map *l, struct map *r);
......
This diff is collapsed.
This diff is collapsed.
...@@ -254,6 +254,7 @@ static inline void dso__set_loaded(struct dso *dso, enum map_type type) ...@@ -254,6 +254,7 @@ static inline void dso__set_loaded(struct dso *dso, enum map_type type)
void dso__sort_by_name(struct dso *dso, enum map_type type); void dso__sort_by_name(struct dso *dso, enum map_type type);
void dsos__add(struct list_head *head, struct dso *dso);
struct dso *__dsos__findnew(struct list_head *head, const char *name); struct dso *__dsos__findnew(struct list_head *head, const char *name);
int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter); int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter);
...@@ -283,6 +284,7 @@ size_t dso__fprintf(struct dso *dso, enum map_type type, FILE *fp); ...@@ -283,6 +284,7 @@ size_t dso__fprintf(struct dso *dso, enum map_type type, FILE *fp);
char dso__symtab_origin(const struct dso *dso); char dso__symtab_origin(const struct dso *dso);
void dso__set_long_name(struct dso *dso, char *name); void dso__set_long_name(struct dso *dso, char *name);
void dso__set_build_id(struct dso *dso, void *build_id); void dso__set_build_id(struct dso *dso, void *build_id);
bool dso__build_id_equal(const struct dso *dso, u8 *build_id);
void dso__read_running_kernel_build_id(struct dso *dso, void dso__read_running_kernel_build_id(struct dso *dso,
struct machine *machine); struct machine *machine);
struct map *dso__new_map(const char *name); struct map *dso__new_map(const char *name);
...@@ -298,6 +300,8 @@ int build_id__sprintf(const u8 *build_id, int len, char *bf); ...@@ -298,6 +300,8 @@ int build_id__sprintf(const u8 *build_id, int len, char *bf);
int kallsyms__parse(const char *filename, void *arg, int kallsyms__parse(const char *filename, void *arg,
int (*process_symbol)(void *arg, const char *name, int (*process_symbol)(void *arg, const char *name,
char type, u64 start, u64 end)); char type, u64 start, u64 end));
int filename__read_debuglink(const char *filename, char *debuglink,
size_t size);
void machine__destroy_kernel_maps(struct machine *machine); void machine__destroy_kernel_maps(struct machine *machine);
int __machine__create_kernel_maps(struct machine *machine, struct dso *kernel); int __machine__create_kernel_maps(struct machine *machine, struct dso *kernel);
...@@ -310,6 +314,7 @@ void machines__destroy_guest_kernel_maps(struct rb_root *machines); ...@@ -310,6 +314,7 @@ void machines__destroy_guest_kernel_maps(struct rb_root *machines);
int symbol__init(void); int symbol__init(void);
void symbol__exit(void); void symbol__exit(void);
void symbol__elf_init(void); void symbol__elf_init(void);
struct symbol *symbol__new(u64 start, u64 len, u8 binding, const char *name);
size_t symbol__fprintf_symname_offs(const struct symbol *sym, size_t symbol__fprintf_symname_offs(const struct symbol *sym,
const struct addr_location *al, FILE *fp); const struct addr_location *al, FILE *fp);
size_t symbol__fprintf_symname(const struct symbol *sym, FILE *fp); size_t symbol__fprintf_symname(const struct symbol *sym, FILE *fp);
...@@ -327,4 +332,14 @@ ssize_t dso__data_read_addr(struct dso *dso, struct map *map, ...@@ -327,4 +332,14 @@ ssize_t dso__data_read_addr(struct dso *dso, struct map *map,
struct machine *machine, u64 addr, struct machine *machine, u64 addr,
u8 *data, ssize_t size); u8 *data, ssize_t size);
int dso__test_data(void); int dso__test_data(void);
int dso__load_sym(struct dso *dso, struct map *map, const char *name, int fd,
symbol_filter_t filter, int kmodule, int want_symtab);
int dso__synthesize_plt_symbols(struct dso *dso, char *name, struct map *map,
symbol_filter_t filter);
void symbols__insert(struct rb_root *symbols, struct symbol *sym);
void symbols__fixup_duplicate(struct rb_root *symbols);
void symbols__fixup_end(struct rb_root *symbols);
void __map_groups__fixup_end(struct map_groups *mg, enum map_type type);
#endif /* __PERF_SYMBOL */ #endif /* __PERF_SYMBOL */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment