From 4ae9b50914522c9c566211eca9653e0c14d4065f Mon Sep 17 00:00:00 2001 From: emaste Date: Tue, 2 Oct 2018 15:08:41 +0000 Subject: [PATCH] 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 --- contrib/elftoolchain/libelf/gelf_mips64el.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/contrib/elftoolchain/libelf/gelf_mips64el.c b/contrib/elftoolchain/libelf/gelf_mips64el.c index 02131f0d433..24a78a71ed2 100644 --- a/contrib/elftoolchain/libelf/gelf_mips64el.c +++ b/contrib/elftoolchain/libelf/gelf_mips64el.c @@ -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); } /* -- 2.45.0