Merged in ccondurache/nuttx/fix_elf_arm_checkarch (pull request #422)
Fix ELF loader up_checkarch on ARM arch Approved-by: Gregory Nutt <gnutt@nuttx.org>
This commit is contained in:
commit
2ea054fead
@ -110,7 +110,7 @@ int elf_verifyheader(FAR const Elf32_Ehdr *ehdr)
|
|||||||
|
|
||||||
/* Verify that this file works with the currently configured architecture */
|
/* Verify that this file works with the currently configured architecture */
|
||||||
|
|
||||||
if (up_checkarch(ehdr))
|
if (!up_checkarch(ehdr))
|
||||||
{
|
{
|
||||||
berr("Not a supported architecture\n");
|
berr("Not a supported architecture\n");
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
|
@ -87,7 +87,7 @@ bool up_checkarch(FAR const Elf32_Ehdr *ehdr)
|
|||||||
if (ehdr->e_machine != EM_ARM)
|
if (ehdr->e_machine != EM_ARM)
|
||||||
{
|
{
|
||||||
berr("ERROR: Not for ARM: e_machine=%04x\n", ehdr->e_machine);
|
berr("ERROR: Not for ARM: e_machine=%04x\n", ehdr->e_machine);
|
||||||
return -ENOEXEC;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure that 32-bit objects are supported */
|
/* Make sure that 32-bit objects are supported */
|
||||||
@ -95,7 +95,7 @@ bool up_checkarch(FAR const Elf32_Ehdr *ehdr)
|
|||||||
if (ehdr->e_ident[EI_CLASS] != ELFCLASS32)
|
if (ehdr->e_ident[EI_CLASS] != ELFCLASS32)
|
||||||
{
|
{
|
||||||
berr("ERROR: Need 32-bit objects: e_ident[EI_CLASS]=%02x\n", ehdr->e_ident[EI_CLASS]);
|
berr("ERROR: Need 32-bit objects: e_ident[EI_CLASS]=%02x\n", ehdr->e_ident[EI_CLASS]);
|
||||||
return -ENOEXEC;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Verify endian-ness */
|
/* Verify endian-ness */
|
||||||
@ -107,7 +107,7 @@ bool up_checkarch(FAR const Elf32_Ehdr *ehdr)
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
berr("ERROR: Wrong endian-ness: e_ident[EI_DATA]=%02x\n", ehdr->e_ident[EI_DATA]);
|
berr("ERROR: Wrong endian-ness: e_ident[EI_DATA]=%02x\n", ehdr->e_ident[EI_DATA]);
|
||||||
return -ENOEXEC;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure the entry point address is properly aligned */
|
/* Make sure the entry point address is properly aligned */
|
||||||
@ -115,11 +115,11 @@ bool up_checkarch(FAR const Elf32_Ehdr *ehdr)
|
|||||||
if ((ehdr->e_entry & 3) != 0)
|
if ((ehdr->e_entry & 3) != 0)
|
||||||
{
|
{
|
||||||
berr("ERROR: Entry point is not properly aligned: %08x\n", ehdr->e_entry);
|
berr("ERROR: Entry point is not properly aligned: %08x\n", ehdr->e_entry);
|
||||||
return -ENOEXEC;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: Check ABI here. */
|
/* TODO: Check ABI here. */
|
||||||
return OK;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -87,7 +87,7 @@ bool up_checkarch(FAR const Elf32_Ehdr *ehdr)
|
|||||||
if (ehdr->e_machine != EM_ARM)
|
if (ehdr->e_machine != EM_ARM)
|
||||||
{
|
{
|
||||||
berr("ERROR: Not for ARM: e_machine=%04x\n", ehdr->e_machine);
|
berr("ERROR: Not for ARM: e_machine=%04x\n", ehdr->e_machine);
|
||||||
return -ENOEXEC;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure that 32-bit objects are supported */
|
/* Make sure that 32-bit objects are supported */
|
||||||
@ -95,7 +95,7 @@ bool up_checkarch(FAR const Elf32_Ehdr *ehdr)
|
|||||||
if (ehdr->e_ident[EI_CLASS] != ELFCLASS32)
|
if (ehdr->e_ident[EI_CLASS] != ELFCLASS32)
|
||||||
{
|
{
|
||||||
berr("ERROR: Need 32-bit objects: e_ident[EI_CLASS]=%02x\n", ehdr->e_ident[EI_CLASS]);
|
berr("ERROR: Need 32-bit objects: e_ident[EI_CLASS]=%02x\n", ehdr->e_ident[EI_CLASS]);
|
||||||
return -ENOEXEC;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Verify endian-ness */
|
/* Verify endian-ness */
|
||||||
@ -107,11 +107,11 @@ bool up_checkarch(FAR const Elf32_Ehdr *ehdr)
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
berr("ERROR: Wrong endian-ness: e_ident[EI_DATA]=%02x\n", ehdr->e_ident[EI_DATA]);
|
berr("ERROR: Wrong endian-ness: e_ident[EI_DATA]=%02x\n", ehdr->e_ident[EI_DATA]);
|
||||||
return -ENOEXEC;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: Check ABI here. */
|
/* TODO: Check ABI here. */
|
||||||
return OK;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -75,7 +75,7 @@ bool up_checkarch(FAR const Elf32_Ehdr *ehdr)
|
|||||||
if (ehdr->e_machine != EM_ARM)
|
if (ehdr->e_machine != EM_ARM)
|
||||||
{
|
{
|
||||||
berr("ERROR: Not for ARM: e_machine=%04x\n", ehdr->e_machine);
|
berr("ERROR: Not for ARM: e_machine=%04x\n", ehdr->e_machine);
|
||||||
return -ENOEXEC;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure that 32-bit objects are supported */
|
/* Make sure that 32-bit objects are supported */
|
||||||
@ -83,7 +83,7 @@ bool up_checkarch(FAR const Elf32_Ehdr *ehdr)
|
|||||||
if (ehdr->e_ident[EI_CLASS] != ELFCLASS32)
|
if (ehdr->e_ident[EI_CLASS] != ELFCLASS32)
|
||||||
{
|
{
|
||||||
berr("ERROR: Need 32-bit objects: e_ident[EI_CLASS]=%02x\n", ehdr->e_ident[EI_CLASS]);
|
berr("ERROR: Need 32-bit objects: e_ident[EI_CLASS]=%02x\n", ehdr->e_ident[EI_CLASS]);
|
||||||
return -ENOEXEC;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Verify endian-ness */
|
/* Verify endian-ness */
|
||||||
@ -95,7 +95,7 @@ bool up_checkarch(FAR const Elf32_Ehdr *ehdr)
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
berr("ERROR: Wrong endian-ness: e_ident[EI_DATA]=%02x\n", ehdr->e_ident[EI_DATA]);
|
berr("ERROR: Wrong endian-ness: e_ident[EI_DATA]=%02x\n", ehdr->e_ident[EI_DATA]);
|
||||||
return -ENOEXEC;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure the entry point address is properly aligned */
|
/* Make sure the entry point address is properly aligned */
|
||||||
@ -103,11 +103,11 @@ bool up_checkarch(FAR const Elf32_Ehdr *ehdr)
|
|||||||
if ((ehdr->e_entry & 3) != 0)
|
if ((ehdr->e_entry & 3) != 0)
|
||||||
{
|
{
|
||||||
berr("ERROR: Entry point is not properly aligned: %08x\n", ehdr->e_entry);
|
berr("ERROR: Entry point is not properly aligned: %08x\n", ehdr->e_entry);
|
||||||
return -ENOEXEC;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: Check ABI here. */
|
/* TODO: Check ABI here. */
|
||||||
return OK;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -83,7 +83,7 @@ bool up_checkarch(FAR const Elf32_Ehdr *ehdr)
|
|||||||
if (ehdr->e_machine != EM_ARM)
|
if (ehdr->e_machine != EM_ARM)
|
||||||
{
|
{
|
||||||
berr("ERROR: Not for ARM: e_machine=%04x\n", ehdr->e_machine);
|
berr("ERROR: Not for ARM: e_machine=%04x\n", ehdr->e_machine);
|
||||||
return -ENOEXEC;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure that 32-bit objects are supported */
|
/* Make sure that 32-bit objects are supported */
|
||||||
@ -91,7 +91,7 @@ bool up_checkarch(FAR const Elf32_Ehdr *ehdr)
|
|||||||
if (ehdr->e_ident[EI_CLASS] != ELFCLASS32)
|
if (ehdr->e_ident[EI_CLASS] != ELFCLASS32)
|
||||||
{
|
{
|
||||||
berr("ERROR: Need 32-bit objects: e_ident[EI_CLASS]=%02x\n", ehdr->e_ident[EI_CLASS]);
|
berr("ERROR: Need 32-bit objects: e_ident[EI_CLASS]=%02x\n", ehdr->e_ident[EI_CLASS]);
|
||||||
return -ENOEXEC;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Verify endian-ness */
|
/* Verify endian-ness */
|
||||||
@ -103,11 +103,11 @@ bool up_checkarch(FAR const Elf32_Ehdr *ehdr)
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
berr("ERROR: Wrong endian-ness: e_ident[EI_DATA]=%02x\n", ehdr->e_ident[EI_DATA]);
|
berr("ERROR: Wrong endian-ness: e_ident[EI_DATA]=%02x\n", ehdr->e_ident[EI_DATA]);
|
||||||
return -ENOEXEC;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: Check ABI here. */
|
/* TODO: Check ABI here. */
|
||||||
return OK;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -87,7 +87,7 @@ bool up_checkarch(FAR const Elf32_Ehdr *ehdr)
|
|||||||
if (ehdr->e_machine != EM_ARM)
|
if (ehdr->e_machine != EM_ARM)
|
||||||
{
|
{
|
||||||
berr("ERROR: Not for ARM: e_machine=%04x\n", ehdr->e_machine);
|
berr("ERROR: Not for ARM: e_machine=%04x\n", ehdr->e_machine);
|
||||||
return -ENOEXEC;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure that 32-bit objects are supported */
|
/* Make sure that 32-bit objects are supported */
|
||||||
@ -95,7 +95,7 @@ bool up_checkarch(FAR const Elf32_Ehdr *ehdr)
|
|||||||
if (ehdr->e_ident[EI_CLASS] != ELFCLASS32)
|
if (ehdr->e_ident[EI_CLASS] != ELFCLASS32)
|
||||||
{
|
{
|
||||||
berr("ERROR: Need 32-bit objects: e_ident[EI_CLASS]=%02x\n", ehdr->e_ident[EI_CLASS]);
|
berr("ERROR: Need 32-bit objects: e_ident[EI_CLASS]=%02x\n", ehdr->e_ident[EI_CLASS]);
|
||||||
return -ENOEXEC;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Verify endian-ness */
|
/* Verify endian-ness */
|
||||||
@ -107,7 +107,7 @@ bool up_checkarch(FAR const Elf32_Ehdr *ehdr)
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
berr("ERROR: Wrong endian-ness: e_ident[EI_DATA]=%02x\n", ehdr->e_ident[EI_DATA]);
|
berr("ERROR: Wrong endian-ness: e_ident[EI_DATA]=%02x\n", ehdr->e_ident[EI_DATA]);
|
||||||
return -ENOEXEC;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure the entry point address is properly aligned */
|
/* Make sure the entry point address is properly aligned */
|
||||||
@ -115,11 +115,11 @@ bool up_checkarch(FAR const Elf32_Ehdr *ehdr)
|
|||||||
if ((ehdr->e_entry & 3) != 0)
|
if ((ehdr->e_entry & 3) != 0)
|
||||||
{
|
{
|
||||||
berr("ERROR: Entry point is not properly aligned: %08x\n", ehdr->e_entry);
|
berr("ERROR: Entry point is not properly aligned: %08x\n", ehdr->e_entry);
|
||||||
return -ENOEXEC;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: Check ABI here. */
|
/* TODO: Check ABI here. */
|
||||||
return OK;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
Loading…
Reference in New Issue
Block a user