]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
perf tools: Use machine->root_dir to find /proc/kallsyms
authorNamhyung Kim <namhyung@kernel.org>
Tue, 2 Dec 2025 23:57:17 +0000 (15:57 -0800)
committerNamhyung Kim <namhyung@kernel.org>
Wed, 3 Dec 2025 05:59:14 +0000 (21:59 -0800)
This is for test functions to find the kallsyms correctly.  It can find
the machine from the kernel maps and use its root_dir.  This is helpful
to setup fake /proc directory for testing.

Reviewed-by: Ian Rogers <irogers@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/util/symbol.c

index b533fbf17a8b19a32a9920026db4c3de55161780..6ddbf4427c60dacec1f2a20c75215efd14fd3093 100644 (file)
@@ -2002,6 +2002,7 @@ static char *dso__find_kallsyms(struct dso *dso, struct map *map)
        char sbuild_id[SBUILD_ID_SIZE];
        bool is_host = false;
        char path[PATH_MAX];
+       struct maps *kmaps = map__kmaps(map);
 
        if (!dso__has_build_id(dso)) {
                /*
@@ -2038,8 +2039,13 @@ static char *dso__find_kallsyms(struct dso *dso, struct map *map)
                return strdup(path);
 
        /* Use current /proc/kallsyms if possible */
-       if (is_host) {
 proc_kallsyms:
+       if (kmaps) {
+               struct machine *machine = maps__machine(kmaps);
+
+               scnprintf(path, sizeof(path), "%s/proc/kallsyms", machine->root_dir);
+               return strdup(path);
+       } else if (is_host) {
                return strdup("/proc/kallsyms");
        }