In ElfFormat::GetElfFormat() in elftools.cpp, it is blindly assumed that all ELF32 headers are associated with AArch32 code. The ILP32 data model of AArch64 also uses a ELF32 header which causes bl31 from ARM Trusted Firmware to incorrectly jump to the contained code in AArch32 mode which, for obvious reasons, does not end well.
In ElfFormat::GetElfFormat() in elftools.cpp, it is blindly assumed that all ELF32 headers are associated with AArch32 code. The ILP32 data model of AArch64 also uses a ELF32 header which causes bl31 from ARM Trusted Firmware to incorrectly jump to the contained code in AArch32 mode which, for obvious reasons, does not end well.