+2018-11-03 H.J. Lu <hongjiu.lu@intel.com>
+
+ * elfedit.c (update_elf_header): Move EI_MAG? check to ...
+ (get_file_header): Here.
+
2018-11-02 H.J. Lu <hongjiu.lu@intel.com>
* configure.ac (AC_FUNC_MMAP): New.
{
int class, machine, type, status, osabi;
- if (elf_header.e_ident[EI_MAG0] != ELFMAG0
- || elf_header.e_ident[EI_MAG1] != ELFMAG1
- || elf_header.e_ident[EI_MAG2] != ELFMAG2
- || elf_header.e_ident[EI_MAG3] != ELFMAG3)
- {
- error
- (_("%s: Not an ELF file - wrong magic bytes at the start\n"),
- file_name);
- return 0;
- }
-
if (elf_header.e_ident[EI_VERSION] != EV_CURRENT)
{
error
if (fread (elf_header.e_ident, EI_NIDENT, 1, file) != 1)
return 0;
+ if (elf_header.e_ident[EI_MAG0] != ELFMAG0
+ || elf_header.e_ident[EI_MAG1] != ELFMAG1
+ || elf_header.e_ident[EI_MAG2] != ELFMAG2
+ || elf_header.e_ident[EI_MAG3] != ELFMAG3)
+ return 0;
+
/* Determine how to read the rest of the header. */
switch (elf_header.e_ident[EI_DATA])
{
switch (elf_header.e_ident[EI_CLASS])
{
default:
- error (_("Unsupported EI_CLASS: %d\n"),
- elf_header.e_ident[EI_CLASS]);
return 0;
case ELFCLASS32: