zdump: dfi_elf: factor out some ELF functionalities

This makes them reuseable and testable.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Marc Hartmayer
2021-11-17 15:01:06 +01:00
committed by Jan Höppner
parent 8d7e8a87b5
commit 776e5d41d7
3 changed files with 35 additions and 4 deletions
+3 -4
View File
@@ -289,11 +289,10 @@ static int read_elf_hdr(Elf64_Ehdr *ehdr)
if (zg_size(g.fh) < sizeof(*ehdr))
return -ENODEV;
zg_read(g.fh, ehdr, sizeof(*ehdr), ZG_CHECK);
if (memcmp(ehdr->e_ident, ELFMAG, SELFMAG) != 0)
if (!ehdr_is_elf_object(ehdr) || !ehdr_is_vmcore(ehdr))
return -ENODEV;
if (ehdr->e_type != ET_CORE)
return -ENODEV;
if (ehdr->e_machine != EM_S390 || ehdr->e_ident[EI_CLASS] != ELFCLASS64)
if (!ehdr_is_s390x(ehdr))
ERR_EXIT("Only s390x (64 bit) core dump files are supported");
return 0;
}