diff options
Diffstat (limited to 'tools/perf/util/vdso.c')
-rw-r--r-- | tools/perf/util/vdso.c | 37 |
1 files changed, 6 insertions, 31 deletions
diff --git a/tools/perf/util/vdso.c b/tools/perf/util/vdso.c index adca69384fcc..f51390a1ed51 100644 --- a/tools/perf/util/vdso.c +++ b/tools/perf/util/vdso.c | |||
@@ -15,6 +15,12 @@ | |||
15 | #include "linux/string.h" | 15 | #include "linux/string.h" |
16 | #include "debug.h" | 16 | #include "debug.h" |
17 | 17 | ||
18 | /* | ||
19 | * Include definition of find_vdso_map() also used in perf-read-vdso.c for | ||
20 | * building perf-read-vdso32 and perf-read-vdsox32. | ||
21 | */ | ||
22 | #include "find-vdso-map.c" | ||
23 | |||
18 | #define VDSO__TEMP_FILE_NAME "/tmp/perf-vdso.so-XXXXXX" | 24 | #define VDSO__TEMP_FILE_NAME "/tmp/perf-vdso.so-XXXXXX" |
19 | 25 | ||
20 | struct vdso_file { | 26 | struct vdso_file { |
@@ -40,37 +46,6 @@ static struct vdso_info *vdso_info__new(void) | |||
40 | return memdup(&vdso_info_init, sizeof(vdso_info_init)); | 46 | return memdup(&vdso_info_init, sizeof(vdso_info_init)); |
41 | } | 47 | } |
42 | 48 | ||
43 | static int find_vdso_map(void **start, void **end) | ||
44 | { | ||
45 | FILE *maps; | ||
46 | char line[128]; | ||
47 | int found = 0; | ||
48 | |||
49 | maps = fopen("/proc/self/maps", "r"); | ||
50 | if (!maps) { | ||
51 | pr_err("vdso: cannot open maps\n"); | ||
52 | return -1; | ||
53 | } | ||
54 | |||
55 | while (!found && fgets(line, sizeof(line), maps)) { | ||
56 | int m = -1; | ||
57 | |||
58 | /* We care only about private r-x mappings. */ | ||
59 | if (2 != sscanf(line, "%p-%p r-xp %*x %*x:%*x %*u %n", | ||
60 | start, end, &m)) | ||
61 | continue; | ||
62 | if (m < 0) | ||
63 | continue; | ||
64 | |||
65 | if (!strncmp(&line[m], VDSO__MAP_NAME, | ||
66 | sizeof(VDSO__MAP_NAME) - 1)) | ||
67 | found = 1; | ||
68 | } | ||
69 | |||
70 | fclose(maps); | ||
71 | return !found; | ||
72 | } | ||
73 | |||
74 | static char *get_file(struct vdso_file *vdso_file) | 49 | static char *get_file(struct vdso_file *vdso_file) |
75 | { | 50 | { |
76 | char *vdso = NULL; | 51 | char *vdso = NULL; |