|
@@ -1398,6 +1398,7 @@ struct kcore_copy_info {
|
|
u64 last_symbol;
|
|
u64 last_symbol;
|
|
u64 first_module;
|
|
u64 first_module;
|
|
u64 last_module_symbol;
|
|
u64 last_module_symbol;
|
|
|
|
+ size_t phnum;
|
|
struct phdr_data kernel_map;
|
|
struct phdr_data kernel_map;
|
|
struct phdr_data modules_map;
|
|
struct phdr_data modules_map;
|
|
struct list_head phdrs;
|
|
struct list_head phdrs;
|
|
@@ -1517,6 +1518,8 @@ static int kcore_copy__read_maps(struct kcore_copy_info *kci, Elf *elf)
|
|
if (kci->modules_map.len)
|
|
if (kci->modules_map.len)
|
|
list_add_tail(&kci->modules_map.node, &kci->phdrs);
|
|
list_add_tail(&kci->modules_map.node, &kci->phdrs);
|
|
|
|
|
|
|
|
+ kci->phnum = !!kci->kernel_map.len + !!kci->modules_map.len;
|
|
|
|
+
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1678,7 +1681,6 @@ int kcore_copy(const char *from_dir, const char *to_dir)
|
|
{
|
|
{
|
|
struct kcore kcore;
|
|
struct kcore kcore;
|
|
struct kcore extract;
|
|
struct kcore extract;
|
|
- size_t count = 2;
|
|
|
|
int idx = 0, err = -1;
|
|
int idx = 0, err = -1;
|
|
off_t offset = page_size, sz, modules_offset = 0;
|
|
off_t offset = page_size, sz, modules_offset = 0;
|
|
struct kcore_copy_info kci = { .stext = 0, };
|
|
struct kcore_copy_info kci = { .stext = 0, };
|
|
@@ -1705,10 +1707,7 @@ int kcore_copy(const char *from_dir, const char *to_dir)
|
|
if (kcore__init(&extract, extract_filename, kcore.elfclass, false))
|
|
if (kcore__init(&extract, extract_filename, kcore.elfclass, false))
|
|
goto out_kcore_close;
|
|
goto out_kcore_close;
|
|
|
|
|
|
- if (!kci.modules_map.addr)
|
|
|
|
- count -= 1;
|
|
|
|
-
|
|
|
|
- if (kcore__copy_hdr(&kcore, &extract, count))
|
|
|
|
|
|
+ if (kcore__copy_hdr(&kcore, &extract, kci.phnum))
|
|
goto out_extract_close;
|
|
goto out_extract_close;
|
|
|
|
|
|
if (kcore__add_phdr(&extract, idx++, offset, kci.kernel_map.addr,
|
|
if (kcore__add_phdr(&extract, idx++, offset, kci.kernel_map.addr,
|