From 18674b26788a9e47f1157170234e32ece2044367 Mon Sep 17 00:00:00 2001 From: Alexey Kardashevskiy Date: Tue, 4 Feb 2014 15:04:18 +1100 Subject: elf-loader: add more return codes The existing load_elf() just returns -1 if it fails to load ELF. However it could be smarter than this and tell more about the failure such as wrong endianness or incompatible platform. This adds additional return codes for wrong architecture, wrong endianness and if the image is not ELF at all. This adds a load_elf_strerror() helper to convert return codes into string messages. This fixes handling of what load_elf() returns for s390x, other callers just check the return value for <0 and this remains unchanged. Signed-off-by: Alexey Kardashevskiy Signed-off-by: Alexander Graf --- hw/s390x/ipl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'hw/s390x') diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c index 04fb1a8e05..32d38a08f6 100644 --- a/hw/s390x/ipl.c +++ b/hw/s390x/ipl.c @@ -98,10 +98,10 @@ static int s390_ipl_init(SysBusDevice *dev) uint64_t pentry = KERN_IMAGE_START; kernel_size = load_elf(ipl->kernel, NULL, NULL, &pentry, NULL, NULL, 1, ELF_MACHINE, 0); - if (kernel_size == -1) { + if (kernel_size < 0) { kernel_size = load_image_targphys(ipl->kernel, 0, ram_size); } - if (kernel_size == -1) { + if (kernel_size < 0) { fprintf(stderr, "could not load kernel '%s'\n", ipl->kernel); return -1; } -- cgit v1.2.3