Update copyright notices with scripts/update-copyrights.
[glibc.git] / ports / sysdeps / unix / sysv / linux / mips / readelflib.c
blob10f0ff7022d40f2080976a29fc2d00bee2c6cbe8
1 /* Copyright (C) 1999-2013 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Alexandre Oliva <aoliva@redhat.com>
4 Based on work ../x86_64/readelflib.c,
5 contributed by Andreas Jaeger <aj@suse.de>, 1999 and
6 Jakub Jelinek <jakub@redhat.com>, 1999.
8 The GNU C Library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
13 The GNU C Library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public
19 License along with the GNU C Library. If not, see
20 <http://www.gnu.org/licenses/>. */
23 int process_elf32_file (const char *file_name, const char *lib, int *flag,
24 unsigned int *osversion, char **soname,
25 void *file_contents, size_t file_length);
26 int process_elf64_file (const char *file_name, const char *lib, int *flag,
27 unsigned int *osversion, char **soname,
28 void *file_contents, size_t file_length);
30 /* Returns 0 if everything is ok, != 0 in case of error. */
31 int
32 process_elf_file (const char *file_name, const char *lib, int *flag,
33 unsigned int *osversion, char **soname, void *file_contents,
34 size_t file_length)
36 ElfW(Ehdr) *elf_header = (ElfW(Ehdr) *) file_contents;
37 int ret;
39 if (elf_header->e_ident [EI_CLASS] == ELFCLASS32)
41 Elf32_Ehdr *elf32_header = (Elf32_Ehdr *) elf_header;
43 ret = process_elf32_file (file_name, lib, flag, osversion, soname,
44 file_contents, file_length);
46 /* n32 libraries are always libc.so.6+. */
47 if (!ret && (elf32_header->e_flags & EF_MIPS_ABI2) != 0)
48 *flag = FLAG_MIPS64_LIBN32|FLAG_ELF_LIBC6;
50 else
52 ret = process_elf64_file (file_name, lib, flag, osversion, soname,
53 file_contents, file_length);
54 /* n64 libraries are always libc.so.6+. */
55 if (!ret)
56 *flag = FLAG_MIPS64_LIBN64|FLAG_ELF_LIBC6;
59 return ret;
62 #undef __ELF_NATIVE_CLASS
63 #undef process_elf_file
64 #define process_elf_file process_elf32_file
65 #define __ELF_NATIVE_CLASS 32
66 #include "elf/readelflib.c"
68 #undef __ELF_NATIVE_CLASS
69 #undef process_elf_file
70 #define process_elf_file process_elf64_file
71 #define __ELF_NATIVE_CLASS 64
72 #include "elf/readelflib.c"