|
@@ -627,7 +627,7 @@ static int dso__split_kallsyms_for_kcore(struct dso *dso, struct map *map,
|
|
* kernel range is broken in several maps, named [kernel].N, as we don't have
|
|
* kernel range is broken in several maps, named [kernel].N, as we don't have
|
|
* the original ELF section names vmlinux have.
|
|
* the original ELF section names vmlinux have.
|
|
*/
|
|
*/
|
|
-static int dso__split_kallsyms(struct dso *dso, struct map *map,
|
|
|
|
|
|
+static int dso__split_kallsyms(struct dso *dso, struct map *map, u64 delta,
|
|
symbol_filter_t filter)
|
|
symbol_filter_t filter)
|
|
{
|
|
{
|
|
struct map_groups *kmaps = map__kmap(map)->kmaps;
|
|
struct map_groups *kmaps = map__kmap(map)->kmaps;
|
|
@@ -692,6 +692,12 @@ static int dso__split_kallsyms(struct dso *dso, struct map *map,
|
|
char dso_name[PATH_MAX];
|
|
char dso_name[PATH_MAX];
|
|
struct dso *ndso;
|
|
struct dso *ndso;
|
|
|
|
|
|
|
|
+ if (delta) {
|
|
|
|
+ /* Kernel was relocated at boot time */
|
|
|
|
+ pos->start -= delta;
|
|
|
|
+ pos->end -= delta;
|
|
|
|
+ }
|
|
|
|
+
|
|
if (count == 0) {
|
|
if (count == 0) {
|
|
curr_map = map;
|
|
curr_map = map;
|
|
goto filter_symbol;
|
|
goto filter_symbol;
|
|
@@ -721,6 +727,10 @@ static int dso__split_kallsyms(struct dso *dso, struct map *map,
|
|
curr_map->map_ip = curr_map->unmap_ip = identity__map_ip;
|
|
curr_map->map_ip = curr_map->unmap_ip = identity__map_ip;
|
|
map_groups__insert(kmaps, curr_map);
|
|
map_groups__insert(kmaps, curr_map);
|
|
++kernel_range;
|
|
++kernel_range;
|
|
|
|
+ } else if (delta) {
|
|
|
|
+ /* Kernel was relocated at boot time */
|
|
|
|
+ pos->start -= delta;
|
|
|
|
+ pos->end -= delta;
|
|
}
|
|
}
|
|
filter_symbol:
|
|
filter_symbol:
|
|
if (filter && filter(curr_map, pos)) {
|
|
if (filter && filter(curr_map, pos)) {
|
|
@@ -1130,15 +1140,41 @@ out_err:
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/*
|
|
|
|
+ * If the kernel is relocated at boot time, kallsyms won't match. Compute the
|
|
|
|
+ * delta based on the relocation reference symbol.
|
|
|
|
+ */
|
|
|
|
+static int kallsyms__delta(struct map *map, const char *filename, u64 *delta)
|
|
|
|
+{
|
|
|
|
+ struct kmap *kmap = map__kmap(map);
|
|
|
|
+ u64 addr;
|
|
|
|
+
|
|
|
|
+ if (!kmap->ref_reloc_sym || !kmap->ref_reloc_sym->name)
|
|
|
|
+ return 0;
|
|
|
|
+
|
|
|
|
+ addr = kallsyms__get_function_start(filename,
|
|
|
|
+ kmap->ref_reloc_sym->name);
|
|
|
|
+ if (!addr)
|
|
|
|
+ return -1;
|
|
|
|
+
|
|
|
|
+ *delta = addr - kmap->ref_reloc_sym->addr;
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
int dso__load_kallsyms(struct dso *dso, const char *filename,
|
|
int dso__load_kallsyms(struct dso *dso, const char *filename,
|
|
struct map *map, symbol_filter_t filter)
|
|
struct map *map, symbol_filter_t filter)
|
|
{
|
|
{
|
|
|
|
+ u64 delta = 0;
|
|
|
|
+
|
|
if (symbol__restricted_filename(filename, "/proc/kallsyms"))
|
|
if (symbol__restricted_filename(filename, "/proc/kallsyms"))
|
|
return -1;
|
|
return -1;
|
|
|
|
|
|
if (dso__load_all_kallsyms(dso, filename, map) < 0)
|
|
if (dso__load_all_kallsyms(dso, filename, map) < 0)
|
|
return -1;
|
|
return -1;
|
|
|
|
|
|
|
|
+ if (kallsyms__delta(map, filename, &delta))
|
|
|
|
+ return -1;
|
|
|
|
+
|
|
symbols__fixup_duplicate(&dso->symbols[map->type]);
|
|
symbols__fixup_duplicate(&dso->symbols[map->type]);
|
|
symbols__fixup_end(&dso->symbols[map->type]);
|
|
symbols__fixup_end(&dso->symbols[map->type]);
|
|
|
|
|
|
@@ -1150,7 +1186,7 @@ int dso__load_kallsyms(struct dso *dso, const char *filename,
|
|
if (!dso__load_kcore(dso, map, filename))
|
|
if (!dso__load_kcore(dso, map, filename))
|
|
return dso__split_kallsyms_for_kcore(dso, map, filter);
|
|
return dso__split_kallsyms_for_kcore(dso, map, filter);
|
|
else
|
|
else
|
|
- return dso__split_kallsyms(dso, map, filter);
|
|
|
|
|
|
+ return dso__split_kallsyms(dso, map, delta, filter);
|
|
}
|
|
}
|
|
|
|
|
|
static int dso__load_perf_map(struct dso *dso, struct map *map,
|
|
static int dso__load_perf_map(struct dso *dso, struct map *map,
|