選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

elf.h 8.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. #ifndef ELF_H
  2. #define ELF_H
  3. FILE_LICENCE ( GPL2_OR_LATER );
  4. #define EI_NIDENT 16 /* Size of e_ident array. */
  5. /* Values for e_type. */
  6. #define ET_NONE 0 /* No file type */
  7. #define ET_REL 1 /* Relocatable file */
  8. #define ET_EXEC 2 /* Executable file */
  9. #define ET_DYN 3 /* Shared object file */
  10. #define ET_CORE 4 /* Core file */
  11. /* Values for e_machine (architecute). */
  12. #define EM_NONE 0 /* No machine */
  13. #define EM_M32 1 /* AT&T WE 32100 */
  14. #define EM_SPARC 2 /* SUN SPARC */
  15. #define EM_386 3 /* Intel 80386+ */
  16. #define EM_68K 4 /* Motorola m68k family */
  17. #define EM_88K 5 /* Motorola m88k family */
  18. #define EM_486 6 /* Perhaps disused */
  19. #define EM_860 7 /* Intel 80860 */
  20. #define EM_MIPS 8 /* MIPS R3000 big-endian */
  21. #define EM_S370 9 /* IBM System/370 */
  22. #define EM_MIPS_RS3_LE 10 /* MIPS R3000 little-endian */
  23. #define EM_PARISC 15 /* HPPA */
  24. #define EM_VPP500 17 /* Fujitsu VPP500 */
  25. #define EM_SPARC32PLUS 18 /* Sun's "v8plus" */
  26. #define EM_960 19 /* Intel 80960 */
  27. #define EM_PPC 20 /* PowerPC */
  28. #define EM_PPC64 21 /* PowerPC 64-bit */
  29. #define EM_S390 22 /* IBM S390 */
  30. #define EM_V800 36 /* NEC V800 series */
  31. #define EM_FR20 37 /* Fujitsu FR20 */
  32. #define EM_RH32 38 /* TRW RH-32 */
  33. #define EM_RCE 39 /* Motorola RCE */
  34. #define EM_ARM 40 /* ARM */
  35. #define EM_FAKE_ALPHA 41 /* Digital Alpha */
  36. #define EM_SH 42 /* Hitachi SH */
  37. #define EM_SPARCV9 43 /* SPARC v9 64-bit */
  38. #define EM_TRICORE 44 /* Siemens Tricore */
  39. #define EM_ARC 45 /* Argonaut RISC Core */
  40. #define EM_H8_300 46 /* Hitachi H8/300 */
  41. #define EM_H8_300H 47 /* Hitachi H8/300H */
  42. #define EM_H8S 48 /* Hitachi H8S */
  43. #define EM_H8_500 49 /* Hitachi H8/500 */
  44. #define EM_IA_64 50 /* Intel Merced */
  45. #define EM_MIPS_X 51 /* Stanford MIPS-X */
  46. #define EM_COLDFIRE 52 /* Motorola Coldfire */
  47. #define EM_68HC12 53 /* Motorola M68HC12 */
  48. #define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator*/
  49. #define EM_PCP 55 /* Siemens PCP */
  50. #define EM_NCPU 56 /* Sony nCPU embeeded RISC */
  51. #define EM_NDR1 57 /* Denso NDR1 microprocessor */
  52. #define EM_STARCORE 58 /* Motorola Start*Core processor */
  53. #define EM_ME16 59 /* Toyota ME16 processor */
  54. #define EM_ST100 60 /* STMicroelectronic ST100 processor */
  55. #define EM_TINYJ 61 /* Advanced Logic Corp. Tinyj emb.fam*/
  56. #define EM_X86_64 62 /* AMD x86-64 architecture */
  57. #define EM_PDSP 63 /* Sony DSP Processor */
  58. #define EM_FX66 66 /* Siemens FX66 microcontroller */
  59. #define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 mc */
  60. #define EM_ST7 68 /* STmicroelectronics ST7 8 bit mc */
  61. #define EM_68HC16 69 /* Motorola MC68HC16 microcontroller */
  62. #define EM_68HC11 70 /* Motorola MC68HC11 microcontroller */
  63. #define EM_68HC08 71 /* Motorola MC68HC08 microcontroller */
  64. #define EM_68HC05 72 /* Motorola MC68HC05 microcontroller */
  65. #define EM_SVX 73 /* Silicon Graphics SVx */
  66. #define EM_AT19 74 /* STMicroelectronics ST19 8 bit mc */
  67. #define EM_VAX 75 /* Digital VAX */
  68. #define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */
  69. #define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded processor */
  70. #define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */
  71. #define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */
  72. #define EM_MMIX 80 /* Donald Knuth's educational 64-bit processor */
  73. #define EM_HUANY 81 /* Harvard University machine-independent object files */
  74. #define EM_PRISM 82 /* SiTera Prism */
  75. #define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */
  76. #define EM_FR30 84 /* Fujitsu FR30 */
  77. #define EM_D10V 85 /* Mitsubishi D10V */
  78. #define EM_D30V 86 /* Mitsubishi D30V */
  79. #define EM_V850 87 /* NEC v850 */
  80. #define EM_M32R 88 /* Mitsubishi M32R */
  81. #define EM_MN10300 89 /* Matsushita MN10300 */
  82. #define EM_MN10200 90 /* Matsushita MN10200 */
  83. #define EM_PJ 91 /* picoJava */
  84. #define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */
  85. #define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */
  86. #define EM_XTENSA 94 /* Tensilica Xtensa Architecture */
  87. #define EM_NUM 95
  88. /* Values for p_type. */
  89. #define PT_NULL 0 /* Unused entry. */
  90. #define PT_LOAD 1 /* Loadable segment. */
  91. #define PT_DYNAMIC 2 /* Dynamic linking information segment. */
  92. #define PT_INTERP 3 /* Pathname of interpreter. */
  93. #define PT_NOTE 4 /* Auxiliary information. */
  94. #define PT_SHLIB 5 /* Reserved (not used). */
  95. #define PT_PHDR 6 /* Location of program header itself. */
  96. /* Values for p_flags. */
  97. #define PF_X 0x1 /* Executable. */
  98. #define PF_W 0x2 /* Writable. */
  99. #define PF_R 0x4 /* Readable. */
  100. #define ELF_PROGRAM_RETURNS_BIT 0x8000000 /* e_flags bit 31 */
  101. #define EI_MAG0 0
  102. #define ELFMAG0 0x7f
  103. #define EI_MAG1 1
  104. #define ELFMAG1 'E'
  105. #define EI_MAG2 2
  106. #define ELFMAG2 'L'
  107. #define EI_MAG3 3
  108. #define ELFMAG3 'F'
  109. #define ELFMAG "\177ELF"
  110. #define SELFMAG 4
  111. #define EI_CLASS 4 /* File class byte index */
  112. #define ELFCLASSNONE 0 /* Invalid class */
  113. #define ELFCLASS32 1 /* 32-bit objects */
  114. #define ELFCLASS64 2 /* 64-bit objects */
  115. #define EI_DATA 5 /* Data encodeing byte index */
  116. #define ELFDATANONE 0 /* Invalid data encoding */
  117. #define ELFDATA2LSB 1 /* 2's complement little endian */
  118. #define ELFDATA2MSB 2 /* 2's complement big endian */
  119. #define EI_VERSION 6 /* File version byte index */
  120. /* Value must be EV_CURRENT */
  121. #define EV_NONE 0 /* Invalid ELF Version */
  122. #define EV_CURRENT 1 /* Current version */
  123. #define ELF32_PHDR_SIZE (8*4) /* Size of an elf program header */
  124. #ifndef ASSEMBLY
  125. #include <stdint.h>
  126. /*
  127. * ELF definitions common to all 32-bit architectures.
  128. */
  129. typedef uint32_t Elf32_Addr;
  130. typedef uint16_t Elf32_Half;
  131. typedef uint32_t Elf32_Off;
  132. typedef int32_t Elf32_Sword;
  133. typedef uint32_t Elf32_Word;
  134. typedef uint32_t Elf32_Size;
  135. typedef uint64_t Elf64_Addr;
  136. typedef uint16_t Elf64_Half;
  137. typedef uint64_t Elf64_Off;
  138. typedef int32_t Elf64_Sword;
  139. typedef uint32_t Elf64_Word;
  140. typedef uint64_t Elf64_Size;
  141. /*
  142. * ELF header.
  143. */
  144. typedef struct {
  145. unsigned char e_ident[EI_NIDENT]; /* File identification. */
  146. Elf32_Half e_type; /* File type. */
  147. Elf32_Half e_machine; /* Machine architecture. */
  148. Elf32_Word e_version; /* ELF format version. */
  149. Elf32_Addr e_entry; /* Entry point. */
  150. Elf32_Off e_phoff; /* Program header file offset. */
  151. Elf32_Off e_shoff; /* Section header file offset. */
  152. Elf32_Word e_flags; /* Architecture-specific flags. */
  153. Elf32_Half e_ehsize; /* Size of ELF header in bytes. */
  154. Elf32_Half e_phentsize; /* Size of program header entry. */
  155. Elf32_Half e_phnum; /* Number of program header entries. */
  156. Elf32_Half e_shentsize; /* Size of section header entry. */
  157. Elf32_Half e_shnum; /* Number of section header entries. */
  158. Elf32_Half e_shstrndx; /* Section name strings section. */
  159. } Elf32_Ehdr;
  160. typedef struct {
  161. unsigned char e_ident[EI_NIDENT]; /* File identification. */
  162. Elf64_Half e_type; /* File type. */
  163. Elf64_Half e_machine; /* Machine architecture. */
  164. Elf64_Word e_version; /* ELF format version. */
  165. Elf64_Addr e_entry; /* Entry point. */
  166. Elf64_Off e_phoff; /* Program header file offset. */
  167. Elf64_Off e_shoff; /* Section header file offset. */
  168. Elf64_Word e_flags; /* Architecture-specific flags. */
  169. Elf64_Half e_ehsize; /* Size of ELF header in bytes. */
  170. Elf64_Half e_phentsize; /* Size of program header entry. */
  171. Elf64_Half e_phnum; /* Number of program header entries. */
  172. Elf64_Half e_shentsize; /* Size of section header entry. */
  173. Elf64_Half e_shnum; /* Number of section header entries. */
  174. Elf64_Half e_shstrndx; /* Section name strings section. */
  175. } Elf64_Ehdr;
  176. /*
  177. * Program header.
  178. */
  179. typedef struct {
  180. Elf32_Word p_type; /* Entry type. */
  181. Elf32_Off p_offset; /* File offset of contents. */
  182. Elf32_Addr p_vaddr; /* Virtual address (not used). */
  183. Elf32_Addr p_paddr; /* Physical address. */
  184. Elf32_Size p_filesz; /* Size of contents in file. */
  185. Elf32_Size p_memsz; /* Size of contents in memory. */
  186. Elf32_Word p_flags; /* Access permission flags. */
  187. Elf32_Size p_align; /* Alignment in memory and file. */
  188. } Elf32_Phdr;
  189. typedef struct {
  190. Elf64_Word p_type; /* Entry type. */
  191. Elf64_Word p_flags; /* Access permission flags. */
  192. Elf64_Off p_offset; /* File offset of contents. */
  193. Elf64_Addr p_vaddr; /* Virtual address (not used). */
  194. Elf64_Addr p_paddr; /* Physical address. */
  195. Elf64_Size p_filesz; /* Size of contents in file. */
  196. Elf64_Size p_memsz; /* Size of contents in memory. */
  197. Elf64_Size p_align; /* Alignment in memory and file. */
  198. } Elf64_Phdr;
  199. /* Standardized Elf image notes for booting... The name for all of these is ELFBoot */
  200. #endif /* ASSEMBLY */
  201. #endif /* ELF_H */