]>
Commit | Line | Data |
---|---|---|
04277e02 | 1 | /* Copyright (C) 1999-2019 Free Software Foundation, Inc. |
a55bca65 MS |
2 | This file is part of the GNU C Library. |
3 | Contributed by Andreas Jaeger <aj@suse.de>, 1999 and | |
4 | Jakub Jelinek <jakub@redhat.com>, 1999. | |
5 | ||
6 | The GNU C Library is free software; you can redistribute it and/or | |
7 | modify it under the terms of the GNU Lesser General Public | |
8 | License as published by the Free Software Foundation; either | |
9 | version 2.1 of the License, or (at your option) any later version. | |
10 | ||
11 | The GNU C Library is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | Lesser General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU Lesser General Public | |
17 | License along with the GNU C Library; if not, see | |
5a82c748 | 18 | <https://www.gnu.org/licenses/>. */ |
a55bca65 MS |
19 | |
20 | ||
21 | int process_elf32_file (const char *file_name, const char *lib, int *flag, | |
22 | unsigned int *osversion, char **soname, | |
23 | void *file_contents, size_t file_length); | |
24 | int process_elf64_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 | ||
28 | /* Returns 0 if everything is ok, != 0 in case of error. */ | |
29 | int | |
30 | process_elf_file (const char *file_name, const char *lib, int *flag, | |
31 | unsigned int *osversion, char **soname, void *file_contents, | |
32 | size_t file_length) | |
33 | { | |
34 | ElfW(Ehdr) *elf_header = (ElfW(Ehdr) *) file_contents; | |
35 | int ret; | |
36 | ||
37 | if (elf_header->e_ident [EI_CLASS] == ELFCLASS32) | |
38 | { | |
39 | Elf32_Ehdr *elf32_header = (Elf32_Ehdr *) elf_header; | |
40 | ||
41 | ret = process_elf32_file (file_name, lib, flag, osversion, soname, | |
42 | file_contents, file_length); | |
43 | ||
44 | if (!ret && EF_ARM_EABI_VERSION (elf32_header->e_flags) == EF_ARM_EABI_VER5) | |
45 | { | |
46 | if (elf32_header->e_flags & EF_ARM_ABI_FLOAT_HARD) | |
47 | *flag = FLAG_ARM_LIBHF|FLAG_ELF_LIBC6; | |
48 | else if (elf32_header->e_flags & EF_ARM_ABI_FLOAT_SOFT) | |
b39949d2 CD |
49 | *flag = FLAG_ARM_LIBSF|FLAG_ELF_LIBC6; |
50 | else | |
51 | /* We must assume the unmarked objects are compatible | |
52 | with all ABI variants. Such objects may have been | |
53 | generated in a transitional period when the ABI | |
54 | tags were not added to all objects. */ | |
a55bca65 MS |
55 | *flag = FLAG_ELF_LIBC6; |
56 | } | |
57 | } | |
58 | else | |
59 | { | |
60 | ret = process_elf64_file (file_name, lib, flag, osversion, soname, | |
61 | file_contents, file_length); | |
62 | /* AArch64 libraries are always libc.so.6+. */ | |
63 | if (!ret) | |
64 | *flag = FLAG_AARCH64_LIB64|FLAG_ELF_LIBC6; | |
65 | } | |
66 | return ret; | |
67 | } | |
68 | ||
69 | #undef __ELF_NATIVE_CLASS | |
70 | #undef process_elf_file | |
71 | #define process_elf_file process_elf32_file | |
72 | #define __ELF_NATIVE_CLASS 32 | |
73 | #include "elf/readelflib.c" | |
74 | ||
75 | #undef __ELF_NATIVE_CLASS | |
76 | #undef process_elf_file | |
77 | #define process_elf_file process_elf64_file | |
78 | #define __ELF_NATIVE_CLASS 64 | |
79 | #include "elf/readelflib.c" |