-/* Copyright (C) 1999, 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
+/* Copyright (C) 1999-2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Alexandre Oliva <aoliva@redhat.com>
Based on work ../x86_64/readelflib.c,
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
+ License along with the GNU C Library. If not, see
+ <http://www.gnu.org/licenses/>. */
int process_elf32_file (const char *file_name, const char *lib, int *flag,
unsigned int *osversion, char **soname, void *file_contents,
size_t file_length)
{
- ElfW(Ehdr) *elf_header = (ElfW(Ehdr) *) file_contents;
+ union
+ {
+ Elf64_Ehdr *eh64;
+ Elf32_Ehdr *eh32;
+ ElfW(Ehdr) *eh;
+ }
+ elf_header;
int ret;
- if (elf_header->e_ident [EI_CLASS] == ELFCLASS32)
+ elf_header.eh = file_contents;
+ if (elf_header.eh->e_ident [EI_CLASS] == ELFCLASS32)
{
ret = process_elf32_file (file_name, lib, flag, osversion, soname,
file_contents, file_length);
+ if (!ret)
+ {
+ Elf32_Word flags = elf_header.eh32->e_flags;
+ int nan2008 = (flags & EF_MIPS_NAN2008) != 0;
- /* n32 libraries are always libc.so.6+. */
- if (ret && (elf_header->e_flags & EF_MIPS_ABI2) != 0)
- *flag = FLAG_MIPS64_LIBN32|FLAG_ELF_LIBC6;
+ /* n32 libraries are always libc.so.6+, o32 only if 2008 NaN. */
+ if ((flags & EF_MIPS_ABI2) != 0)
+ *flag = (nan2008 ? FLAG_MIPS64_LIBN32_NAN2008
+ : FLAG_MIPS64_LIBN32) | FLAG_ELF_LIBC6;
+ else if (nan2008)
+ *flag = FLAG_MIPS_LIB32_NAN2008 | FLAG_ELF_LIBC6;
+ }
}
else
{
file_contents, file_length);
/* n64 libraries are always libc.so.6+. */
if (!ret)
- *flag = FLAG_MIPS64_LIBN64|FLAG_ELF_LIBC6;
+ {
+ Elf64_Word flags = elf_header.eh64->e_flags;
+ int nan2008 = (flags & EF_MIPS_NAN2008) != 0;
+
+ *flag = (nan2008 ? FLAG_MIPS64_LIBN64_NAN2008
+ : FLAG_MIPS64_LIBN64) | FLAG_ELF_LIBC6;
+ }
}
return ret;