9 #include <linux/kernel.h>
14 #include "linux/string.h"
16 static bool vdso_found;
17 static char vdso_file[] = "/tmp/perf-vdso.so-XXXXXX";
19 static int find_vdso_map(void **start, void **end)
25 maps = fopen("/proc/self/maps", "r");
27 pr_err("vdso: cannot open maps\n");
31 while (!found && fgets(line, sizeof(line), maps)) {
34 /* We care only about private r-x mappings. */
35 if (2 != sscanf(line, "%p-%p r-xp %*x %*x:%*x %*u %n",
41 if (!strncmp(&line[m], VDSO__MAP_NAME,
42 sizeof(VDSO__MAP_NAME) - 1))
50 static char *get_file(void)
61 if (find_vdso_map(&start, &end))
66 buf = memdup(start, size);
70 fd = mkstemp(vdso_file);
74 if (size == (size_t) write(fd, buf, size))
82 vdso_found = (vdso != NULL);
92 struct dso *vdso__dso_findnew(struct list_head *head)
94 struct dso *dso = dsos__find(head, VDSO__MAP_NAME);
103 dso = dso__new(VDSO__MAP_NAME);
105 dsos__add(head, dso);
106 dso__set_long_name(dso, file);