aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/machine.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/machine.c')
-rw-r--r--tools/perf/util/machine.c42
1 files changed, 34 insertions, 8 deletions
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index ded74590b92f..c872991e0f65 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -496,19 +496,22 @@ static int symbol__in_kernel(void *arg, const char *name,
496 return 1; 496 return 1;
497} 497}
498 498
499static void machine__get_kallsyms_filename(struct machine *machine, char *buf,
500 size_t bufsz)
501{
502 if (machine__is_default_guest(machine))
503 scnprintf(buf, bufsz, "%s", symbol_conf.default_guest_kallsyms);
504 else
505 scnprintf(buf, bufsz, "%s/proc/kallsyms", machine->root_dir);
506}
507
499/* Figure out the start address of kernel map from /proc/kallsyms */ 508/* Figure out the start address of kernel map from /proc/kallsyms */
500static u64 machine__get_kernel_start_addr(struct machine *machine) 509static u64 machine__get_kernel_start_addr(struct machine *machine)
501{ 510{
502 const char *filename; 511 char filename[PATH_MAX];
503 char path[PATH_MAX];
504 struct process_args args; 512 struct process_args args;
505 513
506 if (machine__is_default_guest(machine)) 514 machine__get_kallsyms_filename(machine, filename, PATH_MAX);
507 filename = (char *)symbol_conf.default_guest_kallsyms;
508 else {
509 sprintf(path, "%s/proc/kallsyms", machine->root_dir);
510 filename = path;
511 }
512 515
513 if (symbol__restricted_filename(filename, "/proc/kallsyms")) 516 if (symbol__restricted_filename(filename, "/proc/kallsyms"))
514 return 0; 517 return 0;
@@ -829,9 +832,25 @@ static int machine__create_modules(struct machine *machine)
829 return 0; 832 return 0;
830} 833}
831 834
835const char *ref_reloc_sym_names[] = {"_text", "_stext", NULL};
836
832int machine__create_kernel_maps(struct machine *machine) 837int machine__create_kernel_maps(struct machine *machine)
833{ 838{
834 struct dso *kernel = machine__get_kernel(machine); 839 struct dso *kernel = machine__get_kernel(machine);
840 char filename[PATH_MAX];
841 const char *name;
842 u64 addr = 0;
843 int i;
844
845 machine__get_kallsyms_filename(machine, filename, PATH_MAX);
846
847 for (i = 0; (name = ref_reloc_sym_names[i]) != NULL; i++) {
848 addr = kallsyms__get_function_start(filename, name);
849 if (addr)
850 break;
851 }
852 if (!addr)
853 return -1;
835 854
836 if (kernel == NULL || 855 if (kernel == NULL ||
837 __machine__create_kernel_maps(machine, kernel) < 0) 856 __machine__create_kernel_maps(machine, kernel) < 0)
@@ -850,6 +869,13 @@ int machine__create_kernel_maps(struct machine *machine)
850 * Now that we have all the maps created, just set the ->end of them: 869 * Now that we have all the maps created, just set the ->end of them:
851 */ 870 */
852 map_groups__fixup_end(&machine->kmaps); 871 map_groups__fixup_end(&machine->kmaps);
872
873 if (maps__set_kallsyms_ref_reloc_sym(machine->vmlinux_maps, name,
874 addr)) {
875 machine__destroy_kernel_maps(machine);
876 return -1;
877 }
878
853 return 0; 879 return 0;
854} 880}
855 881