Back to index

glibc  2.9
readelflib.c
Go to the documentation of this file.
00001 /* Copyright (C) 1999, 2001, 2005 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003    Contributed by Andreas Jaeger <aj@suse.de>, 1999 and
00004                 Jakub Jelinek <jakub@redhat.com>, 1999.
00005 
00006    The GNU C Library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Lesser General Public
00008    License as published by the Free Software Foundation; either
00009    version 2.1 of the License, or (at your option) any later version.
00010 
00011    The GNU C Library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Lesser General Public License for more details.
00015 
00016    You should have received a copy of the GNU Lesser General Public
00017    License along with the GNU C Library; if not, write to the Free
00018    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00019    02111-1307 USA.  */
00020 
00021 
00022 int process_elf32_file (const char *file_name, const char *lib, int *flag,
00023                      unsigned int *osversion, char **soname,
00024                      void *file_contents, size_t file_length);
00025 int process_elf64_file (const char *file_name, const char *lib, int *flag,
00026                      unsigned int *osversion, char **soname,
00027                      void *file_contents, size_t file_length);
00028 
00029 /* Returns 0 if everything is ok, != 0 in case of error.  */
00030 int
00031 process_elf_file (const char *file_name, const char *lib, int *flag,
00032                 unsigned int *osversion, char **soname, void *file_contents,
00033                 size_t file_length)
00034 {
00035   ElfW(Ehdr) *elf_header = (ElfW(Ehdr) *) file_contents;
00036   int ret;
00037 
00038   if (elf_header->e_ident [EI_CLASS] == ELFCLASS32)
00039     return process_elf32_file (file_name, lib, flag, osversion, soname,
00040                             file_contents, file_length);
00041   else
00042     {
00043       ret = process_elf64_file (file_name, lib, flag, osversion, soname,
00044                             file_contents, file_length);
00045       /* Sparc 64bit libraries are always libc.so.6+.  */
00046       if (!ret)
00047        *flag = FLAG_SPARC_LIB64|FLAG_ELF_LIBC6;
00048       return ret;
00049     }
00050 }
00051 
00052 #undef __ELF_NATIVE_CLASS
00053 #undef process_elf_file
00054 #define process_elf_file process_elf32_file
00055 #define __ELF_NATIVE_CLASS 32
00056 #include "elf/readelflib.c"
00057 
00058 #undef __ELF_NATIVE_CLASS
00059 #undef process_elf_file
00060 #define process_elf_file process_elf64_file
00061 #define __ELF_NATIVE_CLASS 64
00062 #include "elf/readelflib.c"