Skip to content

Commit 6e97957

Browse files
ahunter6acmel
authored andcommitted
perf kcore_copy: Keep a count of phdrs
In preparation to add more program headers, keep a count of phdrs. 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 f683820 commit 6e97957

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

tools/perf/util/symbol-elf.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,6 +1398,7 @@ struct kcore_copy_info {
13981398
u64 last_symbol;
13991399
u64 first_module;
14001400
u64 last_module_symbol;
1401+
size_t phnum;
14011402
struct phdr_data kernel_map;
14021403
struct phdr_data modules_map;
14031404
struct list_head phdrs;
@@ -1517,6 +1518,8 @@ static int kcore_copy__read_maps(struct kcore_copy_info *kci, Elf *elf)
15171518
if (kci->modules_map.len)
15181519
list_add_tail(&kci->modules_map.node, &kci->phdrs);
15191520

1521+
kci->phnum = !!kci->kernel_map.len + !!kci->modules_map.len;
1522+
15201523
return 0;
15211524
}
15221525

@@ -1678,7 +1681,6 @@ int kcore_copy(const char *from_dir, const char *to_dir)
16781681
{
16791682
struct kcore kcore;
16801683
struct kcore extract;
1681-
size_t count = 2;
16821684
int idx = 0, err = -1;
16831685
off_t offset = page_size, sz, modules_offset = 0;
16841686
struct kcore_copy_info kci = { .stext = 0, };
@@ -1705,10 +1707,7 @@ int kcore_copy(const char *from_dir, const char *to_dir)
17051707
if (kcore__init(&extract, extract_filename, kcore.elfclass, false))
17061708
goto out_kcore_close;
17071709

1708-
if (!kci.modules_map.addr)
1709-
count -= 1;
1710-
1711-
if (kcore__copy_hdr(&kcore, &extract, count))
1710+
if (kcore__copy_hdr(&kcore, &extract, kci.phnum))
17121711
goto out_extract_close;
17131712

17141713
if (kcore__add_phdr(&extract, idx++, offset, kci.kernel_map.addr,

0 commit comments

Comments
 (0)