Skip to content

Commit e5a1845

Browse files
Namhyung Kimacmel
authored andcommitted
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: Namhyung Kim <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Paul Mackerras <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/[email protected] [ committer note: removed blank line at symbol-elf.c EOF ] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 166ccc9 commit e5a1845

File tree

6 files changed

+817
-797
lines changed

6 files changed

+817
-797
lines changed

tools/perf/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ LIB_OBJS += $(OUTPUT)util/usage.o
356356
LIB_OBJS += $(OUTPUT)util/wrapper.o
357357
LIB_OBJS += $(OUTPUT)util/sigchain.o
358358
LIB_OBJS += $(OUTPUT)util/symbol.o
359+
LIB_OBJS += $(OUTPUT)util/symbol-elf.o
359360
LIB_OBJS += $(OUTPUT)util/dso-test-data.o
360361
LIB_OBJS += $(OUTPUT)util/color.o
361362
LIB_OBJS += $(OUTPUT)util/pager.o

tools/perf/util/map.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,25 @@ struct map *map__new(struct list_head *dsos__list, u64 start, u64 len,
8686
return NULL;
8787
}
8888

89+
/*
90+
* Constructor variant for modules (where we know from /proc/modules where
91+
* they are loaded) and for vmlinux, where only after we load all the
92+
* symbols we'll know where it starts and ends.
93+
*/
94+
struct map *map__new2(u64 start, struct dso *dso, enum map_type type)
95+
{
96+
struct map *map = calloc(1, (sizeof(*map) +
97+
(dso->kernel ? sizeof(struct kmap) : 0)));
98+
if (map != NULL) {
99+
/*
100+
* ->end will be filled after we load all the symbols
101+
*/
102+
map__init(map, type, start, 0, 0, dso);
103+
}
104+
105+
return map;
106+
}
107+
89108
void map__delete(struct map *self)
90109
{
91110
free(self);

tools/perf/util/map.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ void map__init(struct map *self, enum map_type type,
115115
struct map *map__new(struct list_head *dsos__list, u64 start, u64 len,
116116
u64 pgoff, u32 pid, char *filename,
117117
enum map_type type);
118+
struct map *map__new2(u64 start, struct dso *dso, enum map_type type);
118119
void map__delete(struct map *self);
119120
struct map *map__clone(struct map *self);
120121
int map__overlap(struct map *l, struct map *r);

0 commit comments

Comments
 (0)