1 /* Copyright (C) 1999, 2001, 2002, 2003, 2005, 2009
2 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Alexandre Oliva <aoliva@redhat.com>
5 Based on work ../x86_64/readelflib.c,
6 contributed by Andreas Jaeger <aj@suse.de>, 1999 and
7 Jakub Jelinek <jakub@redhat.com>, 1999.
9 The GNU C Library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 2.1 of the License, or (at your option) any later version.
14 The GNU C Library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
19 You should have received a copy of the GNU Lesser General Public
20 License along with the GNU C Library; if not, write to the Free
21 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
25 int process_elf32_file (const char *file_name, const char *lib, int *flag,
26 unsigned int *osversion, char **soname,
27 void *file_contents, size_t file_length);
28 int process_elf64_file (const char *file_name, const char *lib, int *flag,
29 unsigned int *osversion, char **soname,
30 void *file_contents, size_t file_length);
32 /* Returns 0 if everything is ok, != 0 in case of error. */
34 process_elf_file (const char *file_name, const char *lib, int *flag,
35 unsigned int *osversion, char **soname, void *file_contents,
38 ElfW(Ehdr) *elf_header = (ElfW(Ehdr) *) file_contents;
41 if (elf_header->e_ident [EI_CLASS] == ELFCLASS32)
43 Elf32_Ehdr *elf32_header = (Elf32_Ehdr *) elf_header;
45 ret = process_elf32_file (file_name, lib, flag, osversion, soname,
46 file_contents, file_length);
48 /* n32 libraries are always libc.so.6+. */
49 if (!ret && (elf32_header->e_flags & EF_MIPS_ABI2) != 0)
50 *flag = FLAG_MIPS64_LIBN32|FLAG_ELF_LIBC6;
54 ret = process_elf64_file (file_name, lib, flag, osversion, soname,
55 file_contents, file_length);
56 /* n64 libraries are always libc.so.6+. */
58 *flag = FLAG_MIPS64_LIBN64|FLAG_ELF_LIBC6;
64 #undef __ELF_NATIVE_CLASS
65 #undef process_elf_file
66 #define process_elf_file process_elf32_file
67 #define __ELF_NATIVE_CLASS 32
68 #include "elf/readelflib.c"
70 #undef __ELF_NATIVE_CLASS
71 #undef process_elf_file
72 #define process_elf_file process_elf64_file
73 #define __ELF_NATIVE_CLASS 64
74 #include "elf/readelflib.c"