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

Generated on Fri Dec 15 11:18:54 2006 for UbixOS V2 by  doxygen 1.4.7