1 /* Support for reading ELF files.
2 Copyright (C) 2022-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
20 int process_elf64_file (const char *file_name
, const char *lib
,
21 int *flag
, unsigned int *isa_level
, char **soname
,
22 void *file_contents
, size_t file_length
);
24 #define SUPPORTED_ELF_FLAGS \
25 (EF_LARCH_ABI_DOUBLE_FLOAT | EF_LARCH_ABI_SOFT_FLOAT)
27 /* Returns 0 if everything is ok, != 0 in case of error. */
29 process_elf_file (const char *file_name
, const char *lib
, int *flag
,
30 unsigned int *isa_level
, char **soname
, void *file_contents
,
33 ElfW(Ehdr
) *elf_header
= (ElfW(Ehdr
) *) file_contents
;
34 Elf64_Ehdr
*elf64_header
= (Elf64_Ehdr
*) elf_header
;
38 /* LoongArch libraries are always libc.so.6+. */
39 *flag
= FLAG_ELF_LIBC6
;
41 ret
= process_elf64_file (file_name
, lib
, flag
, isa_level
, soname
,
42 file_contents
, file_length
);
43 flags
= elf64_header
->e_flags
;
45 /* LoongArch linkers encode the floating point ABI as part of the ELF headers. */
46 switch (flags
& SUPPORTED_ELF_FLAGS
)
48 case EF_LARCH_ABI_SOFT_FLOAT
:
49 *flag
|= FLAG_LARCH_FLOAT_ABI_SOFT
;
51 case EF_LARCH_ABI_DOUBLE_FLOAT
:
52 *flag
|= FLAG_LARCH_FLOAT_ABI_DOUBLE
;
58 /* If there are any other ELF flags set then glibc doesn't support this
60 if (flags
& ~SUPPORTED_ELF_FLAGS
)
66 #undef __ELF_NATIVE_CLASS
67 #undef process_elf_file
68 #define process_elf_file process_elf64_file
69 #define __ELF_NATIVE_CLASS 64
70 #include "elf/readelflib.c"