root/include/linux/elf.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 #ifndef _LINUX_ELF_H
   2 #define _LINUX_ELF_H
   3 
   4 typedef unsigned long   Elf32_Addr;
   5 typedef unsigned short  Elf32_Half;
   6 typedef unsigned long   Elf32_Off;
   7 typedef long            Elf32_Sword;
   8 typedef unsigned long   Elf32_Word;
   9 
  10 /* These constants are for the segment types stored in the image headers */
  11 #define PT_NULL    0
  12 #define PT_LOAD    1
  13 #define PT_DYNAMIC 2
  14 #define PT_INTERP  3
  15 #define PT_NOTE    4
  16 #define PT_SHLIB   5
  17 #define PT_PHDR    6
  18 #define PT_LOPROC  0x70000000
  19 #define PT_HIPROC  0x7fffffff
  20 
  21 /* These constants define the different elf file types */
  22 #define ET_NONE   0
  23 #define ET_REL    1
  24 #define ET_EXEC   2
  25 #define ET_DYN    3
  26 #define ET_CORE   4
  27 #define ET_LOPROC 5
  28 #define ET_HIPROC 6
  29 
  30 /* These constants define the various ELF target machines */
  31 #define EM_NONE  0
  32 #define EM_M32   1
  33 #define EM_SPARC 2
  34 #define EM_386   3
  35 #define EM_68K   4
  36 #define EM_88K   5
  37 #define EM_486   6   /* Perhaps disused */
  38 #define EM_860   7
  39 
  40 /* This is the info that is needed to parse the dynamic section of the file */
  41 #define DT_NULL         0
  42 #define DT_NEEDED       1
  43 #define DT_PLTRELSZ     2
  44 #define DT_PLTGOT       3
  45 #define DT_HASH         4
  46 #define DT_STRTAB       5
  47 #define DT_SYMTAB       6
  48 #define DT_RELA         7
  49 #define DT_RELASZ       8
  50 #define DT_RELAENT      9
  51 #define DT_STRSZ        10
  52 #define DT_SYMENT       11
  53 #define DT_INIT         12
  54 #define DT_FINI         13
  55 #define DT_SONAME       14
  56 #define DT_RPATH        15
  57 #define DT_SYMBOLIC     16
  58 #define DT_REL          17
  59 #define DT_RELSZ        18
  60 #define DT_RELENT       19
  61 #define DT_PLTREL       20
  62 #define DT_DEBUG        21
  63 #define DT_TEXTREL      22
  64 #define DT_JMPREL       23
  65 #define DT_LOPROC       0x70000000
  66 #define DT_HIPROC       0x7fffffff
  67 
  68 /* This info is needed when parsing the symbol table */
  69 #define STB_LOCAL  0
  70 #define STB_GLOBAL 1
  71 #define STB_WEAK   2
  72 
  73 #define STT_NOTYPE  0
  74 #define STT_OBJECT  1
  75 #define STT_FUNC    2
  76 #define STT_SECTION 3
  77 #define STT_FILE    4
  78 
  79 #define ELF32_ST_BIND(x) ((x) >> 4)
  80 #define ELF32_ST_TYPE(x) (((unsigned int) x) & 0xf)
  81 
  82 
  83 
  84 typedef struct dynamic{
  85   Elf32_Sword d_tag;
  86   union{
  87     Elf32_Sword d_val;
  88     Elf32_Addr  d_ptr;
  89   } d_un;
  90 } Elf32_Dyn;
  91 
  92 extern Elf32_Dyn _DYNAMIC [];
  93 
  94 /* The following are used with relocations */
  95 #define ELF32_R_SYM(x) ((x) >> 8)
  96 #define ELF32_R_TYPE(x) ((x) & 0xff)
  97 
  98 #define R_386_NONE      0
  99 #define R_386_32        1
 100 #define R_386_PC32      2
 101 #define R_386_GOT32     3
 102 #define R_386_PLT32     4
 103 #define R_386_COPY      5
 104 #define R_386_GLOB_DAT  6
 105 #define R_386_JMP_SLOT  7
 106 #define R_386_RELATIVE  8
 107 #define R_386_GOTOFF    9
 108 #define R_386_GOTPC     10
 109 #define R_386_NUM       11
 110 
 111 typedef struct elf32_rel {
 112   Elf32_Addr    r_offset;
 113   Elf32_Word    r_info;
 114 } Elf32_Rel;
 115 
 116 typedef struct elf32_rela{
 117   Elf32_Addr    r_offset;
 118   Elf32_Word    r_info;
 119   Elf32_Sword   r_addend;
 120 } Elf32_Rela;
 121 
 122 typedef struct elf32_sym{
 123   Elf32_Word    st_name;
 124   Elf32_Addr    st_value;
 125   Elf32_Word    st_size;
 126   unsigned char st_info;
 127   unsigned char st_other;
 128   Elf32_Half    st_shndx;
 129 } Elf32_Sym;
 130 
 131 
 132 #define EI_NIDENT       16
 133 
 134 typedef struct elfhdr{
 135   unsigned char e_ident[EI_NIDENT];
 136   Elf32_Half    e_type;
 137   Elf32_Half    e_machine;
 138   Elf32_Word    e_version;
 139   Elf32_Addr    e_entry;  /* Entry point */
 140   Elf32_Off     e_phoff;
 141   Elf32_Off     e_shoff;
 142   Elf32_Word    e_flags;
 143   Elf32_Half    e_ehsize;
 144   Elf32_Half    e_phentsize;
 145   Elf32_Half    e_phnum;
 146   Elf32_Half    e_shentsize;
 147   Elf32_Half    e_shnum;
 148   Elf32_Half    e_shstrndx;
 149 } Elf32_Ehdr;
 150 
 151 typedef struct elf_phdr{
 152   Elf32_Word    p_type;
 153   Elf32_Off     p_offset;
 154   Elf32_Addr    p_vaddr;
 155   Elf32_Addr    p_paddr;
 156   Elf32_Word    p_filesz;
 157   Elf32_Word    p_memsz;
 158   Elf32_Word    p_flags;
 159   Elf32_Word    p_align;
 160 } Elf32_Phdr;
 161 
 162 /* sh_type */
 163 #define SHT_NULL        0
 164 #define SHT_PROGBITS    1
 165 #define SHT_SYMTAB      2
 166 #define SHT_STRTAB      3
 167 #define SHT_RELA        4
 168 #define SHT_HASH        5
 169 #define SHT_DYNAMIC     6
 170 #define SHT_NOTE        7
 171 #define SHT_NOBITS      8
 172 #define SHT_REL         9
 173 #define SHT_SHLIB       10
 174 #define SHT_DYNSYM      11
 175 #define SHT_NUM         12
 176 #define SHT_LOPROC      0x70000000
 177 #define SHT_HIPROC      0x7fffffff
 178 #define SHT_LOUSER      0x80000000
 179 #define SHT_HIUSER      0xffffffff
 180 
 181 /* sh_flags */
 182 #define SHF_WRITE       0x1
 183 #define SHF_ALLOC       0x2
 184 #define SHF_EXECINSTR   0x4
 185 #define SHF_MASKPROC    0xf0000000
 186 
 187 /* special section indexes */
 188 #define SHN_UNDEF       0
 189 #define SHN_LORESERVE   0xff00
 190 #define SHN_LOPROC      0xff00
 191 #define SHN_HIPROC      0xff1f
 192 #define SHN_ABS         0xfff1
 193 #define SHN_COMMON      0xfff2
 194 #define SHN_HIRESERVE   0xffff
 195  
 196 typedef struct {
 197   Elf32_Word    sh_name;
 198   Elf32_Word    sh_type;
 199   Elf32_Word    sh_flags;
 200   Elf32_Addr    sh_addr;
 201   Elf32_Off     sh_offset;
 202   Elf32_Word    sh_size;
 203   Elf32_Word    sh_link;
 204   Elf32_Word    sh_info;
 205   Elf32_Word    sh_addralign;
 206   Elf32_Word    sh_entsize;
 207 } Elf32_Shdr;
 208 
 209 #define EI_MAG0         0               /* e_ident[] indexes */
 210 #define EI_MAG1         1
 211 #define EI_MAG2         2
 212 #define EI_MAG3         3
 213 #define EI_CLASS        4
 214 #define EI_DATA         5
 215 #define EI_VERSION      6
 216 #define EI_PAD          7
 217 
 218 #define ELFMAG0         0x7f            /* EI_MAG */
 219 #define ELFMAG1         'E'
 220 #define ELFMAG2         'L'
 221 #define ELFMAG3         'F'
 222 #define ELFMAG          "\177ELF"
 223 #define SELFMAG         4
 224 
 225 #define ELFCLASSNONE    0               /* EI_CLASS */
 226 #define ELFCLASS32      1
 227 #define ELFCLASS64      2
 228 #define ELFCLASSNUM     3
 229 
 230 #define ELF_START_MMAP 0x80000000
 231 
 232 #endif /* _LINUX_ELF_H */

/* [previous][next][first][last][top][bottom][index][help] */