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 /* Symbolic values for the entries in the auxiliary table
  83    put on the initial stack */
  84 #define AT_NULL   0     /* end of vector */
  85 #define AT_IGNORE 1     /* entry should be ignored */
  86 #define AT_EXECFD 2     /* file descriptor of program */
  87 #define AT_PHDR   3     /* program headers for program */
  88 #define AT_PHENT  4     /* size of program header entry */
  89 #define AT_PHNUM  5     /* number of program headers */
  90 #define AT_PAGESZ 6     /* system page size */
  91 #define AT_BASE   7     /* base address of interpreter */
  92 #define AT_FLAGS  8     /* flags */
  93 #define AT_ENTRY  9     /* entry point of program */
  94 #define AT_NOTELF 10    /* program is not ELF */
  95 #define AT_UID    11    /* real uid */
  96 #define AT_EUID   12    /* effective uid */
  97 #define AT_GID    13    /* real gid */
  98 #define AT_EGID   14    /* effective gid */
  99 
 100 
 101 typedef struct dynamic{
 102   Elf32_Sword d_tag;
 103   union{
 104     Elf32_Sword d_val;
 105     Elf32_Addr  d_ptr;
 106   } d_un;
 107 } Elf32_Dyn;
 108 
 109 extern Elf32_Dyn _DYNAMIC [];
 110 
 111 /* The following are used with relocations */
 112 #define ELF32_R_SYM(x) ((x) >> 8)
 113 #define ELF32_R_TYPE(x) ((x) & 0xff)
 114 
 115 #define R_386_NONE      0
 116 #define R_386_32        1
 117 #define R_386_PC32      2
 118 #define R_386_GOT32     3
 119 #define R_386_PLT32     4
 120 #define R_386_COPY      5
 121 #define R_386_GLOB_DAT  6
 122 #define R_386_JMP_SLOT  7
 123 #define R_386_RELATIVE  8
 124 #define R_386_GOTOFF    9
 125 #define R_386_GOTPC     10
 126 #define R_386_NUM       11
 127 
 128 typedef struct elf32_rel {
 129   Elf32_Addr    r_offset;
 130   Elf32_Word    r_info;
 131 } Elf32_Rel;
 132 
 133 typedef struct elf32_rela{
 134   Elf32_Addr    r_offset;
 135   Elf32_Word    r_info;
 136   Elf32_Sword   r_addend;
 137 } Elf32_Rela;
 138 
 139 typedef struct elf32_sym{
 140   Elf32_Word    st_name;
 141   Elf32_Addr    st_value;
 142   Elf32_Word    st_size;
 143   unsigned char st_info;
 144   unsigned char st_other;
 145   Elf32_Half    st_shndx;
 146 } Elf32_Sym;
 147 
 148 
 149 #define EI_NIDENT       16
 150 
 151 typedef struct elfhdr{
 152   unsigned char e_ident[EI_NIDENT];
 153   Elf32_Half    e_type;
 154   Elf32_Half    e_machine;
 155   Elf32_Word    e_version;
 156   Elf32_Addr    e_entry;  /* Entry point */
 157   Elf32_Off     e_phoff;
 158   Elf32_Off     e_shoff;
 159   Elf32_Word    e_flags;
 160   Elf32_Half    e_ehsize;
 161   Elf32_Half    e_phentsize;
 162   Elf32_Half    e_phnum;
 163   Elf32_Half    e_shentsize;
 164   Elf32_Half    e_shnum;
 165   Elf32_Half    e_shstrndx;
 166 } Elf32_Ehdr;
 167 
 168 /* These constants define the permissions on sections in the program
 169    header, p_flags. */
 170 #define PF_R            0x4
 171 #define PF_W            0x2
 172 #define PF_X            0x1
 173 
 174 typedef struct elf_phdr{
 175   Elf32_Word    p_type;
 176   Elf32_Off     p_offset;
 177   Elf32_Addr    p_vaddr;
 178   Elf32_Addr    p_paddr;
 179   Elf32_Word    p_filesz;
 180   Elf32_Word    p_memsz;
 181   Elf32_Word    p_flags;
 182   Elf32_Word    p_align;
 183 } Elf32_Phdr;
 184 
 185 /* sh_type */
 186 #define SHT_NULL        0
 187 #define SHT_PROGBITS    1
 188 #define SHT_SYMTAB      2
 189 #define SHT_STRTAB      3
 190 #define SHT_RELA        4
 191 #define SHT_HASH        5
 192 #define SHT_DYNAMIC     6
 193 #define SHT_NOTE        7
 194 #define SHT_NOBITS      8
 195 #define SHT_REL         9
 196 #define SHT_SHLIB       10
 197 #define SHT_DYNSYM      11
 198 #define SHT_NUM         12
 199 #define SHT_LOPROC      0x70000000
 200 #define SHT_HIPROC      0x7fffffff
 201 #define SHT_LOUSER      0x80000000
 202 #define SHT_HIUSER      0xffffffff
 203 
 204 /* sh_flags */
 205 #define SHF_WRITE       0x1
 206 #define SHF_ALLOC       0x2
 207 #define SHF_EXECINSTR   0x4
 208 #define SHF_MASKPROC    0xf0000000
 209 
 210 /* special section indexes */
 211 #define SHN_UNDEF       0
 212 #define SHN_LORESERVE   0xff00
 213 #define SHN_LOPROC      0xff00
 214 #define SHN_HIPROC      0xff1f
 215 #define SHN_ABS         0xfff1
 216 #define SHN_COMMON      0xfff2
 217 #define SHN_HIRESERVE   0xffff
 218  
 219 typedef struct {
 220   Elf32_Word    sh_name;
 221   Elf32_Word    sh_type;
 222   Elf32_Word    sh_flags;
 223   Elf32_Addr    sh_addr;
 224   Elf32_Off     sh_offset;
 225   Elf32_Word    sh_size;
 226   Elf32_Word    sh_link;
 227   Elf32_Word    sh_info;
 228   Elf32_Word    sh_addralign;
 229   Elf32_Word    sh_entsize;
 230 } Elf32_Shdr;
 231 
 232 #define EI_MAG0         0               /* e_ident[] indexes */
 233 #define EI_MAG1         1
 234 #define EI_MAG2         2
 235 #define EI_MAG3         3
 236 #define EI_CLASS        4
 237 #define EI_DATA         5
 238 #define EI_VERSION      6
 239 #define EI_PAD          7
 240 
 241 #define ELFMAG0         0x7f            /* EI_MAG */
 242 #define ELFMAG1         'E'
 243 #define ELFMAG2         'L'
 244 #define ELFMAG3         'F'
 245 #define ELFMAG          "\177ELF"
 246 #define SELFMAG         4
 247 
 248 #define ELFCLASSNONE    0               /* EI_CLASS */
 249 #define ELFCLASS32      1
 250 #define ELFCLASS64      2
 251 #define ELFCLASSNUM     3
 252 
 253 #define ELFDATANONE     0               /* e_ident[EI_DATA] */
 254 #define ELFDATA2LSB     1
 255 #define ELFDATA2MSB     2
 256 
 257 #define EV_NONE         0               /* e_version, EI_VERSION */
 258 #define EV_CURRENT      1
 259 #define EV_NUM          2
 260 
 261 /* Notes used in ET_CORE */
 262 #define NT_PRSTATUS     1
 263 #define NT_PRFPREG      2
 264 #define NT_PRPSINFO     3
 265 #define NT_TASKSTRUCT   4
 266 
 267 /* Note header in a PT_NOTE section */
 268 typedef struct elf_note {
 269   Elf32_Word    n_namesz;       /* Name size */
 270   Elf32_Word    n_descsz;       /* Content size */
 271   Elf32_Word    n_type;         /* Content type */
 272 } Elf32_Nhdr;
 273 
 274 #define ELF_START_MMAP 0x80000000
 275 
 276 #endif /* _LINUX_ELF_H */

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