Skip to content

Commit f683820

Browse files
ahunter6acmel
authored andcommitted
perf kcore_copy: Keep phdr data in a list
Currently, kcore_copy makes 2 program headers, one for the kernel text (namely kernel_map) and one for the modules (namely modules_map). Now more program headers are needed, but treating each program header as a special case results in much more code. Instead, in preparation to add more program headers, change to keep program header data (phdr_data) in a list. 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 787e4da commit f683820

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tools/perf/util/symbol-elf.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,6 +1388,7 @@ struct phdr_data {
13881388
off_t offset;
13891389
u64 addr;
13901390
u64 len;
1391+
struct list_head node;
13911392
};
13921393

13931394
struct kcore_copy_info {
@@ -1399,6 +1400,7 @@ struct kcore_copy_info {
13991400
u64 last_module_symbol;
14001401
struct phdr_data kernel_map;
14011402
struct phdr_data modules_map;
1403+
struct list_head phdrs;
14021404
};
14031405

14041406
static int kcore_copy__process_kallsyms(void *arg, const char *name, char type,
@@ -1510,6 +1512,11 @@ static int kcore_copy__read_maps(struct kcore_copy_info *kci, Elf *elf)
15101512
if (elf_read_maps(elf, true, kcore_copy__read_map, kci) < 0)
15111513
return -1;
15121514

1515+
if (kci->kernel_map.len)
1516+
list_add_tail(&kci->kernel_map.node, &kci->phdrs);
1517+
if (kci->modules_map.len)
1518+
list_add_tail(&kci->modules_map.node, &kci->phdrs);
1519+
15131520
return 0;
15141521
}
15151522

@@ -1678,6 +1685,8 @@ int kcore_copy(const char *from_dir, const char *to_dir)
16781685
char kcore_filename[PATH_MAX];
16791686
char extract_filename[PATH_MAX];
16801687

1688+
INIT_LIST_HEAD(&kci.phdrs);
1689+
16811690
if (kcore_copy__copy_file(from_dir, to_dir, "kallsyms"))
16821691
return -1;
16831692

0 commit comments

Comments
 (0)