elf.c

Go to the documentation of this file.
00001 /*****************************************************************************************
00002  Copyright (c) 2002-2004 The UbixOS Project
00003  All rights reserved.
00004 
00005  Redistribution and use in source and binary forms, with or without modification, are
00006  permitted provided that the following conditions are met:
00007 
00008  Redistributions of source code must retain the above copyright notice, this list of
00009  conditions, the following disclaimer and the list of authors.  Redistributions in binary
00010  form must reproduce the above copyright notice, this list of conditions, the following
00011  disclaimer and the list of authors in the documentation and/or other materials provided
00012  with the distribution. Neither the name of the UbixOS Project nor the names of its
00013  contributors may be used to endorse or promote products derived from this software
00014  without specific prior written permission.
00015 
00016  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
00017  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00018  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
00019  THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00020  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
00021  OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00022  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
00023  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00024  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00025 
00026  $Id$
00027 
00028 *****************************************************************************************/
00029 
00030 #include <ubixos/elf.h>
00031 
00032 const struct {
00033   char  *elfTypeName;
00034   uInt32 id;
00035   } elfType[] = {
00036     { "ET_NONE",         0 },
00037     { "ET_REL",          1 },
00038     { "ET_EXEC",         2 },
00039     { "ET_DYN",          3 },
00040     { "ET_CORE",         4 },
00041     { "ET_LOPROC",  0xff00 },
00042     { "ET_HIPROC",  0xffff },
00043     };
00044     
00045 const struct {
00046   char   *phTypeName;
00047   uInt32 id;
00048   } elfPhType[] = {
00049     { "PT_NULL",              0 },
00050     { "PT_LOAD",              1 },
00051     { "PT_DYNAMIC",           2 },
00052     { "PT_INTERP",            3 },
00053     { "PT_NOTE",              4 },
00054     { "PT_SHLIB",             5 },
00055     { "PT_PHDR",              6 },
00056     { "PT_LOPROC",   0x70000000 },
00057     { "PT_HIPROC",   0x7fffffff },
00058     };
00059 
00060 const struct {
00061   char   *shTypeName;
00062   uInt32 id;
00063   } elfShType[] = {
00064     {"SHT_NULL",     0 },
00065     {"SHT_PROGBITS", 1 },
00066     {"SHT_SYMTAB",   2 },
00067     {"SHT_STRTAB",   3 },
00068     {"SHT_RELA",     4 },
00069     {"SHT_HASH",     5 },
00070     {"SHT_DYNAMIC",  6 },
00071     {"SHT_NOTE",     7 },
00072     {"SHT_NOBITS",   8 },
00073     {"SHT_REL",      9 },
00074     {"SHT_SHLIB",   10 },
00075     {"SHT_DYNSYM",  11 },
00076     };
00077 
00078 const struct {
00079   char *relTypeName;
00080   uInt32 id;
00081   } elfRelType[] = {
00082     {"R_386_NONE",        0 },
00083     {"R_386_32",          1 },
00084     {"R_386_PC32",        2 },
00085     {"R_386_GOT32",       3 },
00086     {"R_386_PLT32",       4 },
00087     {"R_386_COPY",        5 },
00088     {"R_386_GLOB_DAT",    6 },
00089     {"R_386_JMP_SLOT",    7 },
00090     {"R_386_RELATIVE",    8 },
00091     {"R_386_GOTOFF",      9 },
00092     {"R_386_GOTPC",      10 },
00093     };
00094 
00095 
00096 char *elfGetShType(int shType) {
00097   return((char *)elfShType[shType].shTypeName);
00098   }
00099 
00100 char *elfGetPhType(int phType) {
00101   return((char *)elfPhType[phType].phTypeName);
00102   }
00103 
00104 char *elfGetRelType(int relType) {
00105   return((char *)elfRelType[relType].relTypeName);
00106   }
00107  
00108 /***
00109  END
00110  ***/
00111 

Generated on Tue Dec 12 09:59:41 2006 for UbixOS V2 by  doxygen 1.4.7