Skip to content

Commit 203d8a4

Browse files
Song Shan Gongacmel
authored andcommitted
perf s390: Fix 'start' address of module's map
At present, when creating module's map, perf gets 'start' address by parsing '/proc/modules', but it's the module base address, it isn't the start address of the '.text' section. In most arches, it's OK. But for s390, it places 'GOT' and 'PLT' relocations before '.text' section. So there exists an offset between module base address and '.text' section, which will incur wrong symbol resolution for modules. Fix this bug by getting 'start' address of module's map from parsing '/sys/module/[module name]/sections/.text', not from '/proc/modules'. Signed-off-by: Song Shan Gong <gongss@linux.vnet.ibm.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: Christian Borntraeger <borntraeger@de.ibm.com> Cc: David Ahern <dsahern@gmail.com> Link: http://lkml.kernel.org/r/1469070651-6447-2-git-send-email-gongss@linux.vnet.ibm.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 9b16137 commit 203d8a4

4 files changed

Lines changed: 30 additions & 0 deletions

File tree

‎tools/perf/arch/s390/util/Build‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ libperf-y += header.o
22
libperf-y += kvm-stat.o
33

44
libperf-$(CONFIG_DWARF) += dwarf-regs.o
5+
6+
libperf-y += machine.o
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include <unistd.h>
2+
#include <stdio.h>
3+
#include <string.h>
4+
#include "util.h"
5+
#include "machine.h"
6+
#include "api/fs/fs.h"
7+
8+
int arch__fix_module_text_start(u64 *start, const char *name)
9+
{
10+
char path[PATH_MAX];
11+
12+
snprintf(path, PATH_MAX, "module/%.*s/sections/.text",
13+
(int)strlen(name) - 2, name + 1);
14+
15+
if (sysfs__read_ull(path, (unsigned long long *)start) < 0)
16+
return -1;
17+
18+
return 0;
19+
}

‎tools/perf/util/machine.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,12 +1093,20 @@ static int machine__set_modules_path(struct machine *machine)
10931093

10941094
return map_groups__set_modules_path_dir(&machine->kmaps, modules_path, 0);
10951095
}
1096+
int __weak arch__fix_module_text_start(u64 *start __maybe_unused,
1097+
const char *name __maybe_unused)
1098+
{
1099+
return 0;
1100+
}
10961101

10971102
static int machine__create_module(void *arg, const char *name, u64 start)
10981103
{
10991104
struct machine *machine = arg;
11001105
struct map *map;
11011106

1107+
if (arch__fix_module_text_start(&start, name) < 0)
1108+
return -1;
1109+
11021110
map = machine__findnew_module_map(machine, start, name);
11031111
if (map == NULL)
11041112
return -1;

‎tools/perf/util/machine.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ struct symbol *machine__find_kernel_function_by_name(struct machine *machine,
216216

217217
struct map *machine__findnew_module_map(struct machine *machine, u64 start,
218218
const char *filename);
219+
int arch__fix_module_text_start(u64 *start, const char *name);
219220

220221
int __machine__load_kallsyms(struct machine *machine, const char *filename,
221222
enum map_type type, bool no_kcore, symbol_filter_t filter);

0 commit comments

Comments
 (0)