1 /* Copyright (C) 1999-2024 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
19 int process_elf32_file (const char *file_name
, const char *lib
,
20 int *flag
, unsigned int *isa_level
, char **soname
,
21 void *file_contents
, size_t file_length
);
22 int process_elf64_file (const char *file_name
, const char *lib
,
23 int *flag
, unsigned int *isa_level
, char **soname
,
24 void *file_contents
, size_t file_length
);
26 /* Returns 0 if everything is ok, != 0 in case of error. */
28 process_elf_file (const char *file_name
, const char *lib
, int *flag
,
29 unsigned int *isa_level
, char **soname
, void *file_contents
,
32 ElfW(Ehdr
) *elf_header
= (ElfW(Ehdr
) *) file_contents
;
35 if (elf_header
->e_ident
[EI_CLASS
] == ELFCLASS32
)
37 Elf32_Ehdr
*elf32_header
= (Elf32_Ehdr
*) elf_header
;
39 ret
= process_elf32_file (file_name
, lib
, flag
, isa_level
, soname
,
40 file_contents
, file_length
);
42 if (!ret
&& EF_ARM_EABI_VERSION (elf32_header
->e_flags
) == EF_ARM_EABI_VER5
)
44 if (elf32_header
->e_flags
& EF_ARM_ABI_FLOAT_HARD
)
45 *flag
= FLAG_ARM_LIBHF
|FLAG_ELF_LIBC6
;
46 else if (elf32_header
->e_flags
& EF_ARM_ABI_FLOAT_SOFT
)
47 *flag
= FLAG_ARM_LIBSF
|FLAG_ELF_LIBC6
;
49 /* We must assume the unmarked objects are compatible
50 with all ABI variants. Such objects may have been
51 generated in a transitional period when the ABI
52 tags were not added to all objects. */
53 *flag
= FLAG_ELF_LIBC6
;
58 ret
= process_elf64_file (file_name
, lib
, flag
, isa_level
, soname
,
59 file_contents
, file_length
);
60 /* AArch64 libraries are always libc.so.6+. */
62 *flag
= FLAG_AARCH64_LIB64
|FLAG_ELF_LIBC6
;
67 #undef __ELF_NATIVE_CLASS
68 #undef process_elf_file
69 #define process_elf_file process_elf32_file
70 #define __ELF_NATIVE_CLASS 32
71 #include "elf/readelflib.c"
73 #undef __ELF_NATIVE_CLASS
74 #undef process_elf_file
75 #define process_elf_file process_elf64_file
76 #define __ELF_NATIVE_CLASS 64
77 #include "elf/readelflib.c"