1/* Special checks on libraries for ldconfig. Linux/PowerPC version.
2 Copyright (C) 2002-2022 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
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.
9
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.
14
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/>. */
18
19
20int process_elf32_file (const char *file_name, const char *lib,
21 int *flag, unsigned int *osversion,
22 unsigned int *isa_level, char **soname,
23 void *file_contents, size_t file_length);
24int process_elf64_file (const char *file_name, const char *lib,
25 int *flag, unsigned int *osversion,
26 unsigned int *isa_level, char **soname,
27 void *file_contents, size_t file_length);
28
29/* Returns 0 if everything is ok, != 0 in case of error. */
30int
31process_elf_file (const char *file_name, const char *lib, int *flag,
32 unsigned int *osversion, unsigned int *isa_level,
33 char **soname, void *file_contents, size_t file_length)
34{
35 ElfW(Ehdr) *elf_header = (ElfW(Ehdr) *) file_contents;
36 int ret;
37
38 if (elf_header->e_ident [EI_CLASS] == ELFCLASS32)
39 return process_elf32_file (file_name, lib, flag, osversion, isa_level,
40 soname, file_contents, file_length);
41 else
42 {
43 ret = process_elf64_file (file_name, lib, flag, osversion, isa_level,
44 soname, file_contents, file_length);
45 /* PowerPC 64bit libraries are always libc.so.6+. */
46 if (!ret)
47 *flag = FLAG_POWERPC_LIB64|FLAG_ELF_LIBC6;
48 return ret;
49 }
50}
51
52#undef __ELF_NATIVE_CLASS
53#undef process_elf_file
54#define process_elf_file process_elf32_file
55#define __ELF_NATIVE_CLASS 32
56#include "elf/readelflib.c"
57
58#undef __ELF_NATIVE_CLASS
59#undef process_elf_file
60#define process_elf_file process_elf64_file
61#define __ELF_NATIVE_CLASS 64
62#include "elf/readelflib.c"
63

source code of glibc/sysdeps/unix/sysv/linux/powerpc/readelflib.c