root/tools/elf2flt/elf.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 #ifndef __ELF_H__
   2 #define __ELF_H__
   3 #include <stdint.h>
   4 
   5 #define EI_NIDENT 16
   6 
   7 typedef uint32_t elf32_word;
   8 typedef int32_t  elf32_sword;
   9 typedef uint16_t elf32_half;
  10 typedef uint32_t elf32_off;
  11 typedef uint32_t elf32_addr;
  12 
  13 struct elf32_ehdr {
  14   unsigned char e_ident[EI_NIDENT];    /* ident bytes */
  15   elf32_half e_type;                   /* file type */
  16   elf32_half e_machine;                /* target machine */
  17   elf32_word e_version;                /* file version */
  18   elf32_addr e_entry;                  /* start address */
  19   elf32_off e_phoff;                   /* phdr file offset */
  20   elf32_off e_shoff;                   /* shdr file offset */
  21   elf32_word e_flags;                  /* file flags */
  22   elf32_half e_ehsize;                 /* sizeof ehdr */
  23   elf32_half e_phentsize;              /* sizeof phdr */
  24   elf32_half e_phnum;                  /* number phdrs */
  25   elf32_half e_shentsize;              /* sizeof shdr */
  26   elf32_half e_shnum;                  /* number shdrs */
  27   elf32_half e_shstrndx;               /* shdr string index */
  28 };
  29 
  30 /* Values for e_type. */
  31 #define ET_NONE         0       /* Unknown type. */
  32 #define ET_REL          1       /* Relocatable. */
  33 #define ET_EXEC         2       /* Executable. */
  34 #define ET_DYN          3       /* Shared object. */
  35 #define ET_CORE         4       /* Core file. */
  36 
  37 struct elf32_shdr {
  38   elf32_word sh_name;           /* section name */
  39   elf32_word sh_type;           /* SHT_... */
  40   elf32_word sh_flags;          /* SHF_... */
  41   elf32_addr sh_addr;           /* virtual address */
  42   elf32_off sh_offset;          /* file offset */
  43   elf32_word sh_size;           /* section size */
  44   elf32_word sh_link;           /* misc info */
  45   elf32_word sh_info;           /* misc info */
  46   elf32_word sh_addralign;      /* memory alignment */
  47   elf32_word sh_entsize;        /* entry size if table */
  48 };
  49 
  50 /* sh_type */
  51 #define SHT_NULL        0               /* inactive */
  52 #define SHT_PROGBITS    1               /* program defined information */
  53 #define SHT_SYMTAB      2               /* symbol table section */
  54 #define SHT_STRTAB      3               /* string table section */
  55 #define SHT_RELA        4               /* relocation section with addends*/
  56 #define SHT_HASH        5               /* symbol hash table section */
  57 #define SHT_DYNAMIC     6               /* dynamic section */
  58 #define SHT_NOTE        7               /* note section */
  59 #define SHT_NOBITS      8               /* no space section */
  60 #define SHT_REL         9               /* relation section without addends */
  61 #define SHT_SHLIB       10              /* reserved - purpose unknown */
  62 #define SHT_DYNSYM      11              /* dynamic symbol table section */
  63 #define SHT_LOPROC      0x70000000      /* reserved range for processor */
  64 #define SHT_HIPROC      0x7fffffff      /* specific section header types */
  65 #define SHT_LOUSER      0x80000000      /* reserved range for application */
  66 #define SHT_HIUSER      0xffffffff      /* specific indexes */
  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 #define STT_COMMON  5
  79 #define STT_TLS     6
  80 
  81 
  82 struct elf32_rel {
  83   elf32_addr      r_offset;       /* Location to be relocated. */
  84   elf32_word      r_info;         /* Relocation type and symbol index. */
  85 };
  86 
  87 struct elf32_rela {
  88   elf32_addr      r_offset;       /* Location to be relocated. */
  89   elf32_word      r_info;         /* Relocation type and symbol index. */
  90   elf32_sword     r_addend;       /* Addend. */
  91 };
  92 
  93 struct elf32_sym {
  94   elf32_word      st_name;        /* String table index of name. */
  95   elf32_addr      st_value;       /* Symbol value. */
  96   elf32_word      st_size;        /* Size of associated object. */
  97   unsigned char   st_info;        /* Type and binding information. */
  98   unsigned char   st_other;       /* Reserved (not used). */
  99   elf32_half      st_shndx;       /* Section index of symbol. */
 100 };
 101 
 102 #define ELF32_R_SYM(info)       ((info) >> 8)
 103 #define ELF32_R_TYPE(info)      ((unsigned char)(info))
 104 #define ELF32_ST_TYPE(x)          (((unsigned int) x) & 0xf)
 105 
 106 
 107 /* Supported relocations */
 108 #define R_ARM_PC24              1       /* PC relative 26 bit branch */
 109 #define R_ARM_ABS32         2
 110 #define R_ARM_THM_CALL      10
 111 #define R_ARM_PLT32         27
 112 #define R_ARM_CALL          28
 113 #define R_ARM_JUMP24        29
 114 #define R_ARM_THM_JUMP24    30
 115 #define R_ARM_V4BX          40
 116 
 117 #endif /* __ELF_H__ */

/* [<][>][^][v][top][bottom][index][help] */