elf.h

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 #ifndef _ELF_H
00031 #define _ELF_H
00032 
00033 #include <ubixos/types.h>
00034 
00035 #define elfExecutable 0x002
00036 #define elfLibrary    0x003
00037 
00038 #define R_386_NONE      0 /* none    none        */
00039 #define R_386_32        1 /* word32  S + A       */
00040 #define R_386_PC32      2 /* word32  S + A - P   */
00041 #define R_386_GOT32     3 /* word32  G + A - P   */
00042 #define R_386_PLT32     4 /* word32  L + A - P   */
00043 #define R_386_COPY      5 /* none    none        */
00044 #define R_386_GLOB_DAT  6 /* word32  S           */
00045 #define R_386_JMP_SLOT  7 /* word32  S           */
00046 #define R_386_RELATIVE  8 /* word32  B + A       */
00047 #define R_386_GOTOFF    9 /* word32  S + A - GOT */
00048 #define R_386_GOTPC    10 /* word32  GOT + A - P */
00049 
00050 
00051 /* Elf Types */
00052 #define ET_NONE         0  // No file type
00053 #define ET_REL          1  // Relocatable file
00054 #define ET_EXEC         2  // Executable file
00055 #define ET_DYN          3  // Shared object file
00056 #define ET_CORE         4  // Core file
00057 #define ET_LOPROC  0xff00  // Processor-specific
00058 #define ET_HIPROC  0xffff
00059 /* End Elf Types */
00060 
00061 /* Elf Machine Types */
00062 #define EM_NONE       0  // No machine
00063 #define EM_M32        1  // AT&T WE 32100
00064 #define EM_SPARC      2  // SPARC
00065 #define EM_386        3  // Intel 80386
00066 #define EM_68K        4  // Motorola 68000
00067 #define EM_88K        5  // Motorola 88000
00068 #define EM_860        7  // Intel 80860
00069 #define EM_MIPS       8  // MIPS RS3000
00070 /* End Elf Machines Types */
00071 
00072 /* Elf Version */
00073 #define EV_NONE          0  // Invalid version
00074 #define EV_CURRENT       1  // Current version
00075 /* End Elf Version */
00076 
00077 /* Elf Program Header Types */
00078 #define PT_NULL          0
00079 #define PT_LOAD          1
00080 #define PT_DYNAMIC       2
00081 #define PT_INTERP        3
00082 #define PT_NOTE          4
00083 #define PT_SHLIB         5
00084 #define PT_PHDR          6
00085 #define PT_LOOS          0x60000000
00086 #define PT_HIOS          0x6fffffff
00087 #define PT_LOPROC        0x70000000
00088 #define PT_HIPROC        0x7fffffff
00089 #define PT_GNU_EH_FRAME  0x6474e550
00090 #define PT_GNU_STACK     (PT_LOOS + 0x474e551)
00091 #define PT_GNU_RELRO     (PT_LOOS + 0x474e552) 
00092 #define PT_PAX_FLAGS     (PT_LOOS + 0x5041580) 
00093 
00094 /* End Elf Program Header Types */
00095 
00096 typedef struct {
00097   uInt8  eIdent[16]; /* File identification. */
00098   uInt16 eType;      /* File type. */
00099   uInt16 eMachine;   /* Machine architecture. */
00100   uInt32  eVersion;   /* ELF format version. */
00101   uInt32  eEntry;     /* Entry point. */
00102   uInt32  ePhoff;     /* Program header file offset. */
00103   uInt32  eShoff;     /* Section header file offset. */
00104   uInt32  eFlags;     /* Architecture-specific flags. */
00105   uInt16 eEhsize;    /* Size of ELF header in bytes. */
00106   uInt16 ePhentsize; /* Size of program header entry. */
00107   uInt16 ePhnum;     /* Number of program header entries. */
00108   uInt16 eShentsize; /* Size of section header entry. */
00109   uInt16 eShnum;     /* Number of section header entries. */
00110   uInt16 eShstrndx;  /* Section name strings section. */
00111   } elfHeader;
00112 
00113 typedef struct {
00114   uInt32 phType;         /* Entry type. */
00115   uInt32 phOffset;       /* File offset of contents. */
00116   uInt32 phVaddr;        /* Virtual address in memory image. */
00117   uInt32 phPaddr;        /* Physical address (not used). */
00118   uInt32 phFilesz;       /* Size of contents in file. */
00119   uInt32 phMemsz;        /* Size of contents in memory. */
00120   uInt32 phFlags;        /* Access permission flags. */
00121   uInt32 phAlign;        /* Alignment in memory and file. */
00122   } elfProgramHeader;
00123 
00124 typedef struct {
00125   uInt32 shName;        /* Section name (index into the section header string table). */
00126   uInt32 shType;        /* Section type. */
00127   uInt32 shFlags;       /* Section flags. */
00128   uInt32 shAddr;        /* Address in memory image. */
00129   uInt32 shOffset;      /* Offset in file. */
00130   uInt32 shSize;        /* Size in bytes. */
00131   uInt32 shLink;        /* Index of a related section. */
00132   uInt32 shInfo;        /* Depends on section type. */
00133   uInt32 shAddralign;   /* Alignment in bytes. */
00134   uInt32 shEntsize;     /* Size of each entry in section. */
00135   } elfSectionHeader;
00136 
00137 typedef struct {
00138   uInt32 pltOffset;
00139   uInt32 pltInfo;
00140   } elfPltInfo;
00141 
00142 typedef struct {
00143   uInt32 dynName;
00144   uInt32 dynValue;
00145   uInt32 dynSize;
00146   uInt32 dynInfo;
00147   } elfDynSym;
00148 
00149 typedef struct {
00150   uInt32 dynVal;
00151   uInt32 dynPtr;
00152   } elfDynamic;
00153 
00154 char *elfGetShType(int);
00155 char *elfGetPhType(int);
00156 char *elfGetRelType(int);
00157 
00158 #define ELF32_R_SYM(i)      ((i)>>8)
00159 #define ELF32_R_TYPE(i)     ((unsigned char)(i))
00160 #define ELF32_R_INFO(s, t)  ((s)<<8+(unsigned char)(t))
00161 
00162 #endif
00163 
00164 /***
00165  $Log$
00166  Revision 1.1.1.1  2006/06/01 12:46:13  reddawg
00167  ubix2
00168 
00169  Revision 1.2  2005/10/12 00:13:37  reddawg
00170  Removed
00171 
00172  Revision 1.1.1.1  2005/09/26 17:23:54  reddawg
00173  no message
00174 
00175  Revision 1.7  2004/09/11 01:20:08  apwillia
00176  Clean up 'Unhandled Header' printfs when compiled in linux
00177 
00178  Revision 1.6  2004/06/16 14:04:51  reddawg
00179  Renamed a typedef
00180 
00181  Revision 1.5  2004/06/14 12:20:54  reddawg
00182  notes: many bugs repaired and ld works 100% now.
00183 
00184  Revision 1.4  2004/06/12 01:27:26  reddawg
00185  shared objects: yes we almost fully support shared objects
00186 
00187  Revision 1.3  2004/05/21 15:20:00  reddawg
00188  Cleaned up
00189 
00190 
00191  END
00192  ***/

Generated on Tue Dec 5 23:34:57 2006 for UbixOS V2 by  doxygen 1.4.7