libelf: correct mips64el test to use ELF header

libelf maintains two views of endianness: e_byteorder, and
e_ident[EI_DATA] in the ELF header itself.  e_byteorder is not always
kept in sync, so use the ELF header endianness to test for mips64el.

PR:		231790
Bisected by:	sbruno
Reviewed by:	jhb
Approved by:	re (kib)
MFC with:	r338478
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D17380
This commit is contained in:
Ed Maste 2018-10-02 15:08:41 +00:00
parent 7462fc7f56
commit 1c45d770a7
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=339083

View file

@ -34,8 +34,9 @@ int
_libelf_is_mips64el(Elf *e)
{
return (e->e_kind == ELF_K_ELF && e->e_byteorder == ELFDATA2LSB &&
e->e_u.e_elf.e_ehdr.e_ehdr64->e_machine == EM_MIPS);
return (e->e_kind == ELF_K_ELF &&
e->e_u.e_elf.e_ehdr.e_ehdr64->e_machine == EM_MIPS &&
e->e_u.e_elf.e_ehdr.e_ehdr64->e_ident[EI_DATA] == ELFDATA2LSB);
}
/*