aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/header.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/header.c')
-rw-r--r--tools/perf/util/header.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index b31e0ae4b8db..1b65fed0dd2d 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -237,11 +237,13 @@ static int dso__cache_build_id(struct dso *self, const char *debugdir)
237 char *filename = malloc(size), 237 char *filename = malloc(size),
238 *linkname = malloc(size), *targetname, *sbuild_id; 238 *linkname = malloc(size), *targetname, *sbuild_id;
239 int len, err = -1; 239 int len, err = -1;
240 bool is_kallsyms = self->kernel && self->long_name[0] != '/';
240 241
241 if (filename == NULL || linkname == NULL) 242 if (filename == NULL || linkname == NULL)
242 goto out_free; 243 goto out_free;
243 244
244 len = snprintf(filename, size, "%s%s", debugdir, self->long_name); 245 len = snprintf(filename, size, "%s%s%s",
246 debugdir, is_kallsyms ? "/" : "", self->long_name);
245 if (mkdir_p(filename, 0755)) 247 if (mkdir_p(filename, 0755))
246 goto out_free; 248 goto out_free;
247 249
@@ -249,9 +251,14 @@ static int dso__cache_build_id(struct dso *self, const char *debugdir)
249 sbuild_id = filename + len; 251 sbuild_id = filename + len;
250 build_id__sprintf(self->build_id, sizeof(self->build_id), sbuild_id); 252 build_id__sprintf(self->build_id, sizeof(self->build_id), sbuild_id);
251 253
252 if (access(filename, F_OK) && link(self->long_name, filename) && 254 if (access(filename, F_OK)) {
253 copyfile(self->long_name, filename)) 255 if (is_kallsyms) {
254 goto out_free; 256 if (copyfile("/proc/kallsyms", filename))
257 goto out_free;
258 } else if (link(self->long_name, filename) &&
259 copyfile(self->long_name, filename))
260 goto out_free;
261 }
255 262
256 len = snprintf(linkname, size, "%s/.build-id/%.2s", 263 len = snprintf(linkname, size, "%s/.build-id/%.2s",
257 debugdir, sbuild_id); 264 debugdir, sbuild_id);