/*****************************************************************************************
 Copyright (c) 2002-2004 The UbixOS Project
 All rights reserved.

 Redistribution and use in source and binary forms, with or without modification, are
 permitted provided that the following conditions are met:

 Redistributions of source code must retain the above copyright notice, this list of
 conditions, the following disclaimer and the list of authors.  Redistributions in binary
 form must reproduce the above copyright notice, this list of conditions, the following
 disclaimer and the list of authors in the documentation and/or other materials provided
 with the distribution. Neither the name of the UbixOS Project nor the names of its
 contributors may be used to endorse or promote products derived from this software
 without specific prior written permission.

 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
 THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
 OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
 TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

 $Id$

*****************************************************************************************/

#include <ubixos/elf.h>

const struct {
  char  *elfTypeName;
  uInt32 id;
  } elfType[] = {
    { "ET_NONE",         0 },
    { "ET_REL",          1 },
    { "ET_EXEC",         2 },
    { "ET_DYN",          3 },
    { "ET_CORE",         4 },
    { "ET_LOPROC",  0xff00 },
    { "ET_HIPROC",  0xffff },
    };
    
const struct {
  char   *phTypeName;
  uInt32 id;
  } elfPhType[] = {
    { "PT_NULL",              0 },
    { "PT_LOAD",              1 },
    { "PT_DYNAMIC",           2 },
    { "PT_INTERP",            3 },
    { "PT_NOTE",              4 },
    { "PT_SHLIB",             5 },
    { "PT_PHDR",              6 },
    { "PT_LOPROC",   0x70000000 },
    { "PT_HIPROC",   0x7fffffff },
    };

const struct {
  char   *shTypeName;
  uInt32 id;
  } elfShType[] = {
    {"SHT_NULL",     0 },
    {"SHT_PROGBITS", 1 },
    {"SHT_SYMTAB",   2 },
    {"SHT_STRTAB",   3 },
    {"SHT_RELA",     4 },
    {"SHT_HASH",     5 },
    {"SHT_DYNAMIC",  6 },
    {"SHT_NOTE",     7 },
    {"SHT_NOBITS",   8 },
    {"SHT_REL",      9 },
    {"SHT_SHLIB",   10 },
    {"SHT_DYNSYM",  11 },
    };

const struct {
  char *relTypeName;
  uInt32 id;
  } elfRelType[] = {
    {"R_386_NONE",        0 },
    {"R_386_32",          1 },
    {"R_386_PC32",        2 },
    {"R_386_GOT32",       3 },
    {"R_386_PLT32",       4 },
    {"R_386_COPY",        5 },
    {"R_386_GLOB_DAT",    6 },
    {"R_386_JMP_SLOT",    7 },
    {"R_386_RELATIVE",    8 },
    {"R_386_GOTOFF",      9 },
    {"R_386_GOTPC",      10 },
    };


char *elfGetShType(int shType) {
  return((char *)elfShType[shType].shTypeName);
  }

char *elfGetPhType(int phType) {
  return((char *)elfPhType[phType].phTypeName);
  }

char *elfGetRelType(int relType) {
  return((char *)elfRelType[relType].relTypeName);
  }
 
/***
 $Log$
 Revision 1.4  2004/06/15 12:24:07  reddawg
 Cleaned Up

 Revision 1.3  2004/06/12 01:27:26  reddawg
 shared objects: yes we almost fully support shared objects

 Revision 1.2  2004/05/15 02:30:28  reddawg
 Lots of changes
 END
 ***/

