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 <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Andy Lutomirski <luto@kernel.org> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Joerg Roedel <joro@8bytes.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: x86@kernel.org Link: http://lkml.kernel.org/r/1526986485-6562-13-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
6e97957d3d
commit
c9dd1d8949
|
@ -1682,7 +1682,7 @@ int kcore_copy(const char *from_dir, const char *to_dir)
|
||||||
struct kcore kcore;
|
struct kcore kcore;
|
||||||
struct kcore extract;
|
struct kcore extract;
|
||||||
int idx = 0, err = -1;
|
int idx = 0, err = -1;
|
||||||
off_t offset = page_size, sz, modules_offset = 0;
|
off_t offset, sz, modules_offset = 0;
|
||||||
struct kcore_copy_info kci = { .stext = 0, };
|
struct kcore_copy_info kci = { .stext = 0, };
|
||||||
char kcore_filename[PATH_MAX];
|
char kcore_filename[PATH_MAX];
|
||||||
char extract_filename[PATH_MAX];
|
char extract_filename[PATH_MAX];
|
||||||
|
@ -1710,6 +1710,10 @@ int kcore_copy(const char *from_dir, const char *to_dir)
|
||||||
if (kcore__copy_hdr(&kcore, &extract, kci.phnum))
|
if (kcore__copy_hdr(&kcore, &extract, kci.phnum))
|
||||||
goto out_extract_close;
|
goto out_extract_close;
|
||||||
|
|
||||||
|
offset = gelf_fsize(extract.elf, ELF_T_EHDR, 1, EV_CURRENT) +
|
||||||
|
gelf_fsize(extract.elf, ELF_T_PHDR, kci.phnum, EV_CURRENT);
|
||||||
|
offset = round_up(offset, page_size);
|
||||||
|
|
||||||
if (kcore__add_phdr(&extract, idx++, offset, kci.kernel_map.addr,
|
if (kcore__add_phdr(&extract, idx++, offset, kci.kernel_map.addr,
|
||||||
kci.kernel_map.len))
|
kci.kernel_map.len))
|
||||||
goto out_extract_close;
|
goto out_extract_close;
|
||||||
|
|
Loading…
Reference in a new issue