Back to index

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