Skip to content

Commit 15acef6

Browse files
ahunter6acmel
authored andcommitted
perf kcore_copy: Layout sections
In preparation to add more program headers, layout the relative offset of each section. Signed-off-by: Adrian Hunter <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Dave Hansen <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Joerg Roedel <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent c9dd1d8 commit 15acef6

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

tools/perf/util/symbol-elf.c

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,6 +1386,7 @@ static off_t kcore__write(struct kcore *kcore)
13861386

13871387
struct phdr_data {
13881388
off_t offset;
1389+
off_t rel;
13891390
u64 addr;
13901391
u64 len;
13911392
struct list_head node;
@@ -1404,6 +1405,9 @@ struct kcore_copy_info {
14041405
struct list_head phdrs;
14051406
};
14061407

1408+
#define kcore_copy__for_each_phdr(k, p) \
1409+
list_for_each_entry((p), &(k)->phdrs, node)
1410+
14071411
static int kcore_copy__process_kallsyms(void *arg, const char *name, char type,
14081412
u64 start)
14091413
{
@@ -1518,11 +1522,21 @@ static int kcore_copy__read_maps(struct kcore_copy_info *kci, Elf *elf)
15181522
if (kci->modules_map.len)
15191523
list_add_tail(&kci->modules_map.node, &kci->phdrs);
15201524

1521-
kci->phnum = !!kci->kernel_map.len + !!kci->modules_map.len;
1522-
15231525
return 0;
15241526
}
15251527

1528+
static void kcore_copy__layout(struct kcore_copy_info *kci)
1529+
{
1530+
struct phdr_data *p;
1531+
off_t rel = 0;
1532+
1533+
kcore_copy__for_each_phdr(kci, p) {
1534+
p->rel = rel;
1535+
rel += p->len;
1536+
kci->phnum += 1;
1537+
}
1538+
}
1539+
15261540
static int kcore_copy__calc_maps(struct kcore_copy_info *kci, const char *dir,
15271541
Elf *elf)
15281542
{
@@ -1558,7 +1572,12 @@ static int kcore_copy__calc_maps(struct kcore_copy_info *kci, const char *dir,
15581572
if (kci->first_module && !kci->last_module_symbol)
15591573
return -1;
15601574

1561-
return kcore_copy__read_maps(kci, elf);
1575+
if (kcore_copy__read_maps(kci, elf))
1576+
return -1;
1577+
1578+
kcore_copy__layout(kci);
1579+
1580+
return 0;
15621581
}
15631582

15641583
static int kcore_copy__copy_file(const char *from_dir, const char *to_dir,

0 commit comments

Comments
 (0)