aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/proc/vmcore.c44
1 files changed, 11 insertions, 33 deletions
diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
index 1082492e02fc..8ec648368985 100644
--- a/fs/proc/vmcore.c
+++ b/fs/proc/vmcore.c
@@ -204,36 +204,15 @@ static struct vmcore* __init get_new_element(void)
204 return kzalloc(sizeof(struct vmcore), GFP_KERNEL); 204 return kzalloc(sizeof(struct vmcore), GFP_KERNEL);
205} 205}
206 206
207static u64 __init get_vmcore_size_elf64(char *elfptr, size_t elfsz) 207static u64 __init get_vmcore_size(size_t elfsz, size_t elfnotesegsz,
208 struct list_head *vc_list)
208{ 209{
209 int i;
210 u64 size; 210 u64 size;
211 Elf64_Ehdr *ehdr_ptr; 211 struct vmcore *m;
212 Elf64_Phdr *phdr_ptr;
213
214 ehdr_ptr = (Elf64_Ehdr *)elfptr;
215 phdr_ptr = (Elf64_Phdr*)(elfptr + sizeof(Elf64_Ehdr));
216 size = elfsz;
217 for (i = 0; i < ehdr_ptr->e_phnum; i++) {
218 size += phdr_ptr->p_memsz;
219 phdr_ptr++;
220 }
221 return size;
222}
223
224static u64 __init get_vmcore_size_elf32(char *elfptr, size_t elfsz)
225{
226 int i;
227 u64 size;
228 Elf32_Ehdr *ehdr_ptr;
229 Elf32_Phdr *phdr_ptr;
230 212
231 ehdr_ptr = (Elf32_Ehdr *)elfptr; 213 size = elfsz + elfnotesegsz;
232 phdr_ptr = (Elf32_Phdr*)(elfptr + sizeof(Elf32_Ehdr)); 214 list_for_each_entry(m, vc_list, list) {
233 size = elfsz; 215 size += m->size;
234 for (i = 0; i < ehdr_ptr->e_phnum; i++) {
235 size += phdr_ptr->p_memsz;
236 phdr_ptr++;
237 } 216 }
238 return size; 217 return size;
239} 218}
@@ -856,20 +835,19 @@ static int __init parse_crash_elf_headers(void)
856 rc = parse_crash_elf64_headers(); 835 rc = parse_crash_elf64_headers();
857 if (rc) 836 if (rc)
858 return rc; 837 return rc;
859
860 /* Determine vmcore size. */
861 vmcore_size = get_vmcore_size_elf64(elfcorebuf, elfcorebuf_sz);
862 } else if (e_ident[EI_CLASS] == ELFCLASS32) { 838 } else if (e_ident[EI_CLASS] == ELFCLASS32) {
863 rc = parse_crash_elf32_headers(); 839 rc = parse_crash_elf32_headers();
864 if (rc) 840 if (rc)
865 return rc; 841 return rc;
866
867 /* Determine vmcore size. */
868 vmcore_size = get_vmcore_size_elf32(elfcorebuf, elfcorebuf_sz);
869 } else { 842 } else {
870 pr_warn("Warning: Core image elf header is not sane\n"); 843 pr_warn("Warning: Core image elf header is not sane\n");
871 return -EINVAL; 844 return -EINVAL;
872 } 845 }
846
847 /* Determine vmcore size. */
848 vmcore_size = get_vmcore_size(elfcorebuf_sz, elfnotes_sz,
849 &vmcore_list);
850
873 return 0; 851 return 0;
874} 852}
875 853