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 /* These constants define the permissions on sections in the program
 152    header, p_flags. */
 153 #define PF_R            0x4
 154 #define PF_W            0x2
 155 #define PF_X            0x1
 156 
 157 typedef struct elf_phdr{
 158   Elf32_Word    p_type;
 159   Elf32_Off     p_offset;
 160   Elf32_Addr    p_vaddr;
 161   Elf32_Addr    p_paddr;
 162   Elf32_Word    p_filesz;
 163   Elf32_Word    p_memsz;
 164   Elf32_Word    p_flags;
 165   Elf32_Word    p_align;
 166 } Elf32_Phdr;
 167 
 168 /* sh_type */
 169 #define SHT_NULL        0
 170 #define SHT_PROGBITS    1
 171 #define SHT_SYMTAB      2
 172 #define SHT_STRTAB      3
 173 #define SHT_RELA        4
 174 #define SHT_HASH        5
 175 #define SHT_DYNAMIC     6
 176 #define SHT_NOTE        7
 177 #define SHT_NOBITS      8
 178 #define SHT_REL         9
 179 #define SHT_SHLIB       10
 180 #define SHT_DYNSYM      11
 181 #define SHT_NUM         12
 182 #define SHT_LOPROC      0x70000000
 183 #define SHT_HIPROC      0x7fffffff
 184 #define SHT_LOUSER      0x80000000
 185 #define SHT_HIUSER      0xffffffff
 186 
 187 /* sh_flags */
 188 #define SHF_WRITE       0x1
 189 #define SHF_ALLOC       0x2
 190 #define SHF_EXECINSTR   0x4
 191 #define SHF_MASKPROC    0xf0000000
 192 
 193 /* special section indexes */
 194 #define SHN_UNDEF       0
 195 #define SHN_LORESERVE   0xff00
 196 #define SHN_LOPROC      0xff00
 197 #define SHN_HIPROC      0xff1f
 198 #define SHN_ABS         0xfff1
 199 #define SHN_COMMON      0xfff2
 200 #define SHN_HIRESERVE   0xffff
 201  
 202 typedef struct {
 203   Elf32_Word    sh_name;
 204   Elf32_Word    sh_type;
 205   Elf32_Word    sh_flags;
 206   Elf32_Addr    sh_addr;
 207   Elf32_Off     sh_offset;
 208   Elf32_Word    sh_size;
 209   Elf32_Word    sh_link;
 210   Elf32_Word    sh_info;
 211   Elf32_Word    sh_addralign;
 212   Elf32_Word    sh_entsize;
 213 } Elf32_Shdr;
 214 
 215 #define EI_MAG0         0               /* e_ident[] indexes */
 216 #define EI_MAG1         1
 217 #define EI_MAG2         2
 218 #define EI_MAG3         3
 219 #define EI_CLASS        4
 220 #define EI_DATA         5
 221 #define EI_VERSION      6
 222 #define EI_PAD          7
 223 
 224 #define ELFMAG0         0x7f            /* EI_MAG */
 225 #define ELFMAG1         'E'
 226 #define ELFMAG2         'L'
 227 #define ELFMAG3         'F'
 228 #define ELFMAG          "\177ELF"
 229 #define SELFMAG         4
 230 
 231 #define ELFCLASSNONE    0               /* EI_CLASS */
 232 #define ELFCLASS32      1
 233 #define ELFCLASS64      2
 234 #define ELFCLASSNUM     3
 235 
 236 #define ELFDATANONE     0               /* e_ident[EI_DATA] */
 237 #define ELFDATA2LSB     1
 238 #define ELFDATA2MSB     2
 239 
 240 #define EV_NONE         0               /* e_version, EI_VERSION */
 241 #define EV_CURRENT      1
 242 #define EV_NUM          2
 243 
 244 /* Notes used in ET_CORE */
 245 #define NT_PRSTATUS     1
 246 #define NT_PRFPREG      2
 247 #define NT_PRPSINFO     3
 248 #define NT_TASKSTRUCT   4
 249 
 250 /* Note header in a PT_NOTE section */
 251 typedef struct elf_note {
 252   Elf32_Word    n_namesz;       /* Name size */
 253   Elf32_Word    n_descsz;       /* Content size */
 254   Elf32_Word    n_type;         /* Content type */
 255 } Elf32_Nhdr;
 256 
 257 #define ELF_START_MMAP 0x80000000
 258 
 259 #endif /* _LINUX_ELF_H */

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