Skip to content

Commit

Permalink
ldelf: aarch32: Accept ELFOSABI_ARM as OS ABI
Browse files Browse the repository at this point in the history
Rust TAs built for no-std mode targeting 32-bit Arm architecture use
ELFOSABI_ARM as the OS ABI within ELF header. So allow ldelf to load
those Rust TAs built for 32-bit Arm.

Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Tested-by: Jerome Forissier <jerome.forissier@linaro.org> (vexpress-qemu_armv8a)
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>
Signed-off-by: Sumit Garg <sumit.garg@linaro.org>
  • Loading branch information
b49020 authored and jforissier committed Jan 19, 2024
1 parent 29b4cb6 commit 5f7f88c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
12 changes: 10 additions & 2 deletions ldelf/ta_elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,24 @@ static TEE_Result e32_parse_ehdr(struct ta_elf *elf, Elf32_Ehdr *ehdr)
if (ehdr->e_ident[EI_VERSION] != EV_CURRENT ||
ehdr->e_ident[EI_CLASS] != ELFCLASS32 ||
ehdr->e_ident[EI_DATA] != ELFDATA2LSB ||
ehdr->e_ident[EI_OSABI] != ELFOSABI_NONE ||
(ehdr->e_ident[EI_OSABI] != ELFOSABI_NONE &&
ehdr->e_ident[EI_OSABI] != ELFOSABI_ARM) ||
ehdr->e_type != ET_DYN || ehdr->e_machine != EM_ARM ||
(ehdr->e_flags & EF_ARM_ABIMASK) != EF_ARM_ABI_VERSION ||
#ifndef CFG_WITH_VFP
(ehdr->e_flags & EF_ARM_ABI_FLOAT_HARD) ||
#endif
ehdr->e_phentsize != sizeof(Elf32_Phdr) ||
ehdr->e_shentsize != sizeof(Elf32_Shdr))
return TEE_ERROR_BAD_FORMAT;

if (ehdr->e_ident[EI_OSABI] == ELFOSABI_NONE &&
(ehdr->e_flags & EF_ARM_ABIMASK) != EF_ARM_ABI_V5)
return TEE_ERROR_BAD_FORMAT;

if (ehdr->e_ident[EI_OSABI] == ELFOSABI_ARM &&
(ehdr->e_flags & EF_ARM_ABIMASK) != EF_ARM_ABI_UNKNOWN)
return TEE_ERROR_BAD_FORMAT;

elf->is_32bit = true;
elf->e_entry = ehdr->e_entry;
elf->e_phoff = ehdr->e_phoff;
Expand Down
3 changes: 2 additions & 1 deletion lib/libutee/include/elf_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ typedef struct {
#define EM_ALPHA 0x9026 /* Alpha (written in the absence of an ABI) */

/* e_flags for EM_ARM */
#define EF_ARM_ABI_VERSION 0x05000000 /* ABI version 5 */
#define EF_ARM_ABI_UNKNOWN 0x00000000
#define EF_ARM_ABI_V5 0x05000000 /* ABI version 5 */
#define EF_ARM_ABIMASK 0xFF000000
#define EF_ARM_BE8 0x00800000
#define EF_ARM_ABI_FLOAT_HARD 0x00000400 /* ABI version 5 and later */
Expand Down

0 comments on commit 5f7f88c

Please sign in to comment.