Move all files into ports/ subdirectory in preparation for merge with glibc
[glibc.git] / ports / sysdeps / unix / sysv / linux / mips / readelflib.c
blob56eecd24cfd5f428c1f2bcb49f5eec288e070932
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, see
21 <http://www.gnu.org/licenses/>. */
24 int process_elf32_file (const char *file_name, const char *lib, int *flag,
25 unsigned int *osversion, char **soname,
26 void *file_contents, size_t file_length);
27 int process_elf64_file (const char *file_name, const char *lib, int *flag,
28 unsigned int *osversion, char **soname,
29 void *file_contents, size_t file_length);
31 /* Returns 0 if everything is ok, != 0 in case of error. */
32 int
33 process_elf_file (const char *file_name, const char *lib, int *flag,
34 unsigned int *osversion, char **soname, void *file_contents,
35 size_t file_length)
37 ElfW(Ehdr) *elf_header = (ElfW(Ehdr) *) file_contents;
38 int ret;
40 if (elf_header->e_ident [EI_CLASS] == ELFCLASS32)
42 Elf32_Ehdr *elf32_header = (Elf32_Ehdr *) elf_header;
44 ret = process_elf32_file (file_name, lib, flag, osversion, soname,
45 file_contents, file_length);
47 /* n32 libraries are always libc.so.6+. */
48 if (!ret && (elf32_header->e_flags & EF_MIPS_ABI2) != 0)
49 *flag = FLAG_MIPS64_LIBN32|FLAG_ELF_LIBC6;
51 else
53 ret = process_elf64_file (file_name, lib, flag, osversion, soname,
54 file_contents, file_length);
55 /* n64 libraries are always libc.so.6+. */
56 if (!ret)
57 *flag = FLAG_MIPS64_LIBN64|FLAG_ELF_LIBC6;
60 return ret;
63 #undef __ELF_NATIVE_CLASS
64 #undef process_elf_file
65 #define process_elf_file process_elf32_file
66 #define __ELF_NATIVE_CLASS 32
67 #include "elf/readelflib.c"
69 #undef __ELF_NATIVE_CLASS
70 #undef process_elf_file
71 #define process_elf_file process_elf64_file
72 #define __ELF_NATIVE_CLASS 64
73 #include "elf/readelflib.c"