1 /* Copyright (C) 1999-2015 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. */
32 process_elf_file (const char *file_name
, const char *lib
, int *flag
,
33 unsigned int *osversion
, char **soname
, void *file_contents
,
45 elf_header
.eh
= file_contents
;
46 if (elf_header
.eh
->e_ident
[EI_CLASS
] == ELFCLASS32
)
48 ret
= process_elf32_file (file_name
, lib
, flag
, osversion
, soname
,
49 file_contents
, file_length
);
52 Elf32_Word flags
= elf_header
.eh32
->e_flags
;
53 int nan2008
= (flags
& EF_MIPS_NAN2008
) != 0;
55 /* n32 libraries are always libc.so.6+, o32 only if 2008 NaN. */
56 if ((flags
& EF_MIPS_ABI2
) != 0)
57 *flag
= (nan2008
? FLAG_MIPS64_LIBN32_NAN2008
58 : FLAG_MIPS64_LIBN32
) | FLAG_ELF_LIBC6
;
60 *flag
= FLAG_MIPS_LIB32_NAN2008
| FLAG_ELF_LIBC6
;
65 ret
= process_elf64_file (file_name
, lib
, flag
, osversion
, soname
,
66 file_contents
, file_length
);
67 /* n64 libraries are always libc.so.6+. */
70 Elf64_Word flags
= elf_header
.eh64
->e_flags
;
71 int nan2008
= (flags
& EF_MIPS_NAN2008
) != 0;
73 *flag
= (nan2008
? FLAG_MIPS64_LIBN64_NAN2008
74 : FLAG_MIPS64_LIBN64
) | FLAG_ELF_LIBC6
;
81 #undef __ELF_NATIVE_CLASS
82 #undef process_elf_file
83 #define process_elf_file process_elf32_file
84 #define __ELF_NATIVE_CLASS 32
85 #include "elf/readelflib.c"
87 #undef __ELF_NATIVE_CLASS
88 #undef process_elf_file
89 #define process_elf_file process_elf64_file
90 #define __ELF_NATIVE_CLASS 64
91 #include "elf/readelflib.c"