Skip to content

Commit c9dd1d8

Browse files
ahunter6acmel
authored andcommitted
perf kcore_copy: Calculate offset from phnum
In preparation to add more program headers, calculate offset from the number 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 6e97957 commit c9dd1d8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tools/perf/util/symbol-elf.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1682,7 +1682,7 @@ int kcore_copy(const char *from_dir, const char *to_dir)
16821682
struct kcore kcore;
16831683
struct kcore extract;
16841684
int idx = 0, err = -1;
1685-
off_t offset = page_size, sz, modules_offset = 0;
1685+
off_t offset, sz, modules_offset = 0;
16861686
struct kcore_copy_info kci = { .stext = 0, };
16871687
char kcore_filename[PATH_MAX];
16881688
char extract_filename[PATH_MAX];
@@ -1710,6 +1710,10 @@ int kcore_copy(const char *from_dir, const char *to_dir)
17101710
if (kcore__copy_hdr(&kcore, &extract, kci.phnum))
17111711
goto out_extract_close;
17121712

1713+
offset = gelf_fsize(extract.elf, ELF_T_EHDR, 1, EV_CURRENT) +
1714+
gelf_fsize(extract.elf, ELF_T_PHDR, kci.phnum, EV_CURRENT);
1715+
offset = round_up(offset, page_size);
1716+
17131717
if (kcore__add_phdr(&extract, idx++, offset, kci.kernel_map.addr,
17141718
kci.kernel_map.len))
17151719
goto out_extract_close;

0 commit comments

Comments
 (0)