+2020-05-09 Mark Wielaard <mark@klomp.org>
+
+ * elflint.c (process_elf_file): Error out if ebl_openbackend fails.
+ * objdump.c (handle_elf): Likewise.
+ * nm.c (handle_elf): Likewise. Move full name string construction
+ forward, so it can be used in the error message.
+
2020-04-17 Mark Wielaard <mark@klomp.org>
* readelf.c (print_debug): Check .gnu.debuglto_ prefix.
ebl = ebl_openbackend (elf);
/* If there is no appropriate backend library we cannot test
architecture and OS specific features. Any encountered extension
- is an error. */
+ is an error. Often we'll get a "dummy" ebl, except if something
+ really bad happen, like a totally corrupted ELF file or out of
+ memory situation. */
+ if (ebl == NULL)
+ {
+ ERROR (gettext ("cannot create backend for ELF file\n"));
+ return;
+ }
/* Go straight by the gABI, check all the parts in turn. */
check_elf_header (ebl, ehdr, size);
GElf_Ehdr *ehdr;
Ebl *ebl;
+ /* Create the full name of the file. */
+ if (prefix != NULL)
+ cp = mempcpy (cp, prefix, prefix_len);
+ cp = mempcpy (cp, fname, fname_len);
+ if (suffix != NULL)
+ memcpy (cp - 1, suffix, suffix_len + 1);
+
/* Get the backend for this object file type. */
ebl = ebl_openbackend (elf);
+ if (ebl == NULL)
+ INTERNAL_ERROR (fullname);
/* We need the ELF header in a few places. */
ehdr = gelf_getehdr (elf, &ehdr_mem);
goto out;
}
- /* Create the full name of the file. */
- if (prefix != NULL)
- cp = mempcpy (cp, prefix, prefix_len);
- cp = mempcpy (cp, fname, fname_len);
- if (suffix != NULL)
- memcpy (cp - 1, suffix, suffix_len + 1);
-
/* Find the symbol table.
XXX Can there be more than one? Do we print all? Currently we do. */
/* Get the backend for this object file type. */
Ebl *ebl = ebl_openbackend (elf);
+ if (ebl == NULL)
+ error (EXIT_FAILURE, 0,
+ gettext ("cannot create backend for elf file"));
printf ("%s: elf%d-%s\n\n",
fname, gelf_getclass (elf) == ELFCLASS32 ? 32 : 64,