]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - sysdeps/unix/sysv/linux/mips/readelflib.c
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / mips / readelflib.c
index baa92fe57c0c6a796f5aef027c214cc974033c2d..1401fddcefae6e4b6e9a981cf42075e2dc301e0a 100644 (file)
@@ -1,4 +1,4 @@
-/* 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,
@@ -16,9 +16,8 @@
    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,
@@ -34,17 +33,32 @@ process_elf_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
     {
@@ -52,7 +66,13 @@ process_elf_file (const char *file_name, const char *lib, int *flag,
                                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;