zgetdump: Adjust zgetdump for ELF formatted dumps

Adjust ELF formatted dump processing by zgetdump tool in order to handle
so-called zero loads using zero memory chunks introduced with s390
extended dump format.

Signed-off-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Mikhail Zaslonko
2018-04-17 21:12:26 +02:00
committed by Jan Höppner
parent 4a223c70f2
commit 45ac847dc9
2 changed files with 21 additions and 10 deletions
+11 -7
View File
@@ -3,7 +3,7 @@
*
* ELF core dump input format
*
* Copyright IBM Corp. 2001, 2017
* Copyright IBM Corp. 2001, 2018
*
* s390-tools is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
@@ -42,12 +42,16 @@ static int pt_load_add(Elf64_Phdr *phdr)
STDERR("Dump file \"%s\" is a user space core dump\n",
g.opts.device);
}
if (phdr->p_filesz == 0) /* Skip null pt loads */
return 0;
off_ptr = zg_alloc(sizeof(*off_ptr));
*off_ptr = phdr->p_offset;
dfi_mem_chunk_add(phdr->p_paddr, phdr->p_filesz, off_ptr,
dfi_elf_mem_chunk_read_fn, zg_free);
if (phdr->p_filesz == 0) {
/* Add zero memory chunk */
dfi_mem_chunk_add(phdr->p_paddr, phdr->p_memsz, NULL,
dfi_mem_chunk_read_zero, NULL);
} else {
off_ptr = zg_alloc(sizeof(*off_ptr));
*off_ptr = phdr->p_offset;
dfi_mem_chunk_add(phdr->p_paddr, phdr->p_memsz, off_ptr,
dfi_elf_mem_chunk_read_fn, zg_free);
}
if (phdr->p_offset + phdr->p_filesz > zg_size(g.fh))
return -EINVAL;
return 0;
+10 -3
View File
@@ -3,7 +3,7 @@
*
* ELF core dump output format
*
* Copyright IBM Corp. 2001, 2017
* Copyright IBM Corp. 2001, 2018
*
* s390-tools is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
@@ -71,8 +71,12 @@ static u64 loads_init(Elf64_Phdr *phdr, u64 loads_offset)
phdr->p_offset = loads_offset;
phdr->p_vaddr = mem_chunk->start;
phdr->p_paddr = mem_chunk->start;
phdr->p_filesz = mem_chunk->end - mem_chunk->start + 1;
phdr->p_memsz = phdr->p_filesz;
phdr->p_memsz = mem_chunk->end - mem_chunk->start + 1;
if (mem_chunk->read_fn == dfi_mem_chunk_read_zero)
/* Zero memory chunk */
phdr->p_filesz = 0;
else
phdr->p_filesz = phdr->p_memsz;
phdr->p_flags = PF_R | PF_W | PF_X;
phdr->p_align = PAGE_SIZE;
loads_offset += phdr->p_filesz;
@@ -277,6 +281,9 @@ static void dump_chunks_init(void)
dfo_chunk_add(0, l.hdr_size, l.hdr, dfo_chunk_buf_fn);
off = l.hdr_size;
dfi_mem_chunk_iterate(mem_chunk) {
if (mem_chunk->read_fn == dfi_mem_chunk_read_zero)
/* Zero memory chunk */
continue;
dfo_chunk_add(off, mem_chunk->size, mem_chunk,
dfo_chunk_mem_fn);
off += mem_chunk->size;