Index: sys/arm/arm/elf_machdep.c =================================================================== --- sys/arm/arm/elf_machdep.c +++ sys/arm/arm/elf_machdep.c @@ -120,6 +120,23 @@ { } +int +elf32_check_header_md(const Elf_Ehdr *hdr) +{ +#ifdef __ARM_EABI__ + if ((hdr->e_flags & 0xff000000) == 0) { + printf("Unsupported binary, flags %#x, OABI?\n", hdr->e_flags); + return (ENOEXEC); + } +#else + if ((hdr->e_flags & 0xff000000) != 0) { + printf("Unsupported binary, flags %#x, EABI?\n", hdr->e_flags); + return (ENOEXEC); + } +#endif + return 0; +} + /* * It is possible for the compiler to emit relocations for unaligned data. * We handle this situation with these inlines. Index: sys/kern/imgact_elf.c =================================================================== --- sys/kern/imgact_elf.c +++ sys/kern/imgact_elf.c @@ -321,6 +321,12 @@ return (NULL); } +__weak int +__elfN(check_header_md)(const Elf_Ehdr *hdr) +{ + return 0; +} + static int __elfN(check_header)(const Elf_Ehdr *hdr) { @@ -332,9 +338,9 @@ hdr->e_ident[EI_DATA] != ELF_TARG_DATA || hdr->e_ident[EI_VERSION] != EV_CURRENT || hdr->e_phentsize != sizeof(Elf_Phdr) || - hdr->e_version != ELF_TARG_VER) + hdr->e_version != ELF_TARG_VER || + __elfN(check_header_md)(hdr)) return (ENOEXEC); - /* * Make sure we have at least one brand for this machine. */ Index: sys/sys/imgact_elf.h =================================================================== --- sys/sys/imgact_elf.h +++ sys/sys/imgact_elf.h @@ -93,6 +93,9 @@ /* Machine specific function to dump per-thread information. */ void __elfN(dump_thread)(struct thread *, void *, size_t *); +/* Machine specific function to filter out bad, altnerate ABIs */ +int __elfN(check_header_md)(const Elf_Ehdr *hdr); + extern int __elfN(fallback_brand); extern Elf_Brandnote __elfN(freebsd_brandnote); extern Elf_Brandnote __elfN(kfreebsd_brandnote);