From: Adrian Hunter <adrian.hun...@intel.com>

[ Upstream commit 61f82e3fb697a8e85f22fdec786528af73dc36d1 ]

In the absence of any modules, no "modules" map is created, but there
are other executable pages to map, due to eBPF JIT, kprobe or ftrace.
Map them by recognizing that the first "module" symbol is not
necessarily from a module, and adjust the map accordingly.

Signed-off-by: Adrian Hunter <adrian.hun...@intel.com>
Cc: Alexander Shishkin <alexander.shish...@linux.intel.com>
Cc: Borislav Petkov <b...@alien8.de>
Cc: H. Peter Anvin <h...@zytor.com>
Cc: Jiri Olsa <jo...@redhat.com>
Cc: Leo Yan <leo....@linaro.org>
Cc: Mark Rutland <mark.rutl...@arm.com>
Cc: Masami Hiramatsu <mhira...@kernel.org>
Cc: Mathieu Poirier <mathieu.poir...@linaro.org>
Cc: Peter Zijlstra <pet...@infradead.org>
Cc: Steven Rostedt (VMware) <rost...@goodmis.org>
Cc: x...@kernel.org
Link: http://lore.kernel.org/lkml/20200512121922.8997-10-adrian.hun...@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <a...@redhat.com>
Signed-off-by: Sasha Levin <sas...@kernel.org>
---
 tools/perf/util/symbol-elf.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index 66f4be1df573e..2ec0a32da5793 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -1449,6 +1449,7 @@ struct kcore_copy_info {
        u64 first_symbol;
        u64 last_symbol;
        u64 first_module;
+       u64 first_module_symbol;
        u64 last_module_symbol;
        size_t phnum;
        struct list_head phdrs;
@@ -1525,6 +1526,8 @@ static int kcore_copy__process_kallsyms(void *arg, const 
char *name, char type,
                return 0;
 
        if (strchr(name, '[')) {
+               if (!kci->first_module_symbol || start < 
kci->first_module_symbol)
+                       kci->first_module_symbol = start;
                if (start > kci->last_module_symbol)
                        kci->last_module_symbol = start;
                return 0;
@@ -1722,6 +1725,10 @@ static int kcore_copy__calc_maps(struct kcore_copy_info 
*kci, const char *dir,
                kci->etext += page_size;
        }
 
+       if (kci->first_module_symbol &&
+           (!kci->first_module || kci->first_module_symbol < 
kci->first_module))
+               kci->first_module = kci->first_module_symbol;
+
        kci->first_module = round_down(kci->first_module, page_size);
 
        if (kci->last_module_symbol) {
-- 
2.25.1



Reply via email to