00001 #ifndef ELF_H 00002 #define ELF_H 00003 00004 FILE_LICENCE ( GPL2_OR_LATER ); 00005 00006 #define EI_NIDENT 16 /* Size of e_ident array. */ 00007 00008 /* Values for e_type. */ 00009 #define ET_NONE 0 /* No file type */ 00010 #define ET_REL 1 /* Relocatable file */ 00011 #define ET_EXEC 2 /* Executable file */ 00012 #define ET_DYN 3 /* Shared object file */ 00013 #define ET_CORE 4 /* Core file */ 00014 00015 /* Values for e_machine (architecute). */ 00016 #define EM_NONE 0 /* No machine */ 00017 #define EM_M32 1 /* AT&T WE 32100 */ 00018 #define EM_SPARC 2 /* SUN SPARC */ 00019 #define EM_386 3 /* Intel 80386+ */ 00020 #define EM_68K 4 /* Motorola m68k family */ 00021 #define EM_88K 5 /* Motorola m88k family */ 00022 #define EM_486 6 /* Perhaps disused */ 00023 #define EM_860 7 /* Intel 80860 */ 00024 #define EM_MIPS 8 /* MIPS R3000 big-endian */ 00025 #define EM_S370 9 /* IBM System/370 */ 00026 #define EM_MIPS_RS3_LE 10 /* MIPS R3000 little-endian */ 00027 00028 #define EM_PARISC 15 /* HPPA */ 00029 #define EM_VPP500 17 /* Fujitsu VPP500 */ 00030 #define EM_SPARC32PLUS 18 /* Sun's "v8plus" */ 00031 #define EM_960 19 /* Intel 80960 */ 00032 #define EM_PPC 20 /* PowerPC */ 00033 #define EM_PPC64 21 /* PowerPC 64-bit */ 00034 #define EM_S390 22 /* IBM S390 */ 00035 00036 #define EM_V800 36 /* NEC V800 series */ 00037 #define EM_FR20 37 /* Fujitsu FR20 */ 00038 #define EM_RH32 38 /* TRW RH-32 */ 00039 #define EM_RCE 39 /* Motorola RCE */ 00040 #define EM_ARM 40 /* ARM */ 00041 #define EM_FAKE_ALPHA 41 /* Digital Alpha */ 00042 #define EM_SH 42 /* Hitachi SH */ 00043 #define EM_SPARCV9 43 /* SPARC v9 64-bit */ 00044 #define EM_TRICORE 44 /* Siemens Tricore */ 00045 #define EM_ARC 45 /* Argonaut RISC Core */ 00046 #define EM_H8_300 46 /* Hitachi H8/300 */ 00047 #define EM_H8_300H 47 /* Hitachi H8/300H */ 00048 #define EM_H8S 48 /* Hitachi H8S */ 00049 #define EM_H8_500 49 /* Hitachi H8/500 */ 00050 #define EM_IA_64 50 /* Intel Merced */ 00051 #define EM_MIPS_X 51 /* Stanford MIPS-X */ 00052 #define EM_COLDFIRE 52 /* Motorola Coldfire */ 00053 #define EM_68HC12 53 /* Motorola M68HC12 */ 00054 #define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator*/ 00055 #define EM_PCP 55 /* Siemens PCP */ 00056 #define EM_NCPU 56 /* Sony nCPU embeeded RISC */ 00057 #define EM_NDR1 57 /* Denso NDR1 microprocessor */ 00058 #define EM_STARCORE 58 /* Motorola Start*Core processor */ 00059 #define EM_ME16 59 /* Toyota ME16 processor */ 00060 #define EM_ST100 60 /* STMicroelectronic ST100 processor */ 00061 #define EM_TINYJ 61 /* Advanced Logic Corp. Tinyj emb.fam*/ 00062 #define EM_X86_64 62 /* AMD x86-64 architecture */ 00063 #define EM_PDSP 63 /* Sony DSP Processor */ 00064 00065 #define EM_FX66 66 /* Siemens FX66 microcontroller */ 00066 #define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 mc */ 00067 #define EM_ST7 68 /* STmicroelectronics ST7 8 bit mc */ 00068 #define EM_68HC16 69 /* Motorola MC68HC16 microcontroller */ 00069 #define EM_68HC11 70 /* Motorola MC68HC11 microcontroller */ 00070 #define EM_68HC08 71 /* Motorola MC68HC08 microcontroller */ 00071 #define EM_68HC05 72 /* Motorola MC68HC05 microcontroller */ 00072 #define EM_SVX 73 /* Silicon Graphics SVx */ 00073 #define EM_AT19 74 /* STMicroelectronics ST19 8 bit mc */ 00074 #define EM_VAX 75 /* Digital VAX */ 00075 #define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */ 00076 #define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded processor */ 00077 #define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */ 00078 #define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */ 00079 #define EM_MMIX 80 /* Donald Knuth's educational 64-bit processor */ 00080 #define EM_HUANY 81 /* Harvard University machine-independent object files */ 00081 #define EM_PRISM 82 /* SiTera Prism */ 00082 #define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */ 00083 #define EM_FR30 84 /* Fujitsu FR30 */ 00084 #define EM_D10V 85 /* Mitsubishi D10V */ 00085 #define EM_D30V 86 /* Mitsubishi D30V */ 00086 #define EM_V850 87 /* NEC v850 */ 00087 #define EM_M32R 88 /* Mitsubishi M32R */ 00088 #define EM_MN10300 89 /* Matsushita MN10300 */ 00089 #define EM_MN10200 90 /* Matsushita MN10200 */ 00090 #define EM_PJ 91 /* picoJava */ 00091 #define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */ 00092 #define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */ 00093 #define EM_XTENSA 94 /* Tensilica Xtensa Architecture */ 00094 #define EM_NUM 95 00095 00096 /* Values for p_type. */ 00097 #define PT_NULL 0 /* Unused entry. */ 00098 #define PT_LOAD 1 /* Loadable segment. */ 00099 #define PT_DYNAMIC 2 /* Dynamic linking information segment. */ 00100 #define PT_INTERP 3 /* Pathname of interpreter. */ 00101 #define PT_NOTE 4 /* Auxiliary information. */ 00102 #define PT_SHLIB 5 /* Reserved (not used). */ 00103 #define PT_PHDR 6 /* Location of program header itself. */ 00104 00105 /* Values for p_flags. */ 00106 #define PF_X 0x1 /* Executable. */ 00107 #define PF_W 0x2 /* Writable. */ 00108 #define PF_R 0x4 /* Readable. */ 00109 00110 00111 #define ELF_PROGRAM_RETURNS_BIT 0x8000000 /* e_flags bit 31 */ 00112 00113 #define EI_MAG0 0 00114 #define ELFMAG0 0x7f 00115 00116 #define EI_MAG1 1 00117 #define ELFMAG1 'E' 00118 00119 #define EI_MAG2 2 00120 #define ELFMAG2 'L' 00121 00122 #define EI_MAG3 3 00123 #define ELFMAG3 'F' 00124 00125 #define ELFMAG "\177ELF" 00126 #define SELFMAG 4 00127 00128 #define EI_CLASS 4 /* File class byte index */ 00129 #define ELFCLASSNONE 0 /* Invalid class */ 00130 #define ELFCLASS32 1 /* 32-bit objects */ 00131 #define ELFCLASS64 2 /* 64-bit objects */ 00132 00133 #define EI_DATA 5 /* Data encodeing byte index */ 00134 #define ELFDATANONE 0 /* Invalid data encoding */ 00135 #define ELFDATA2LSB 1 /* 2's complement little endian */ 00136 #define ELFDATA2MSB 2 /* 2's complement big endian */ 00137 00138 #define EI_VERSION 6 /* File version byte index */ 00139 /* Value must be EV_CURRENT */ 00140 00141 #define EV_NONE 0 /* Invalid ELF Version */ 00142 #define EV_CURRENT 1 /* Current version */ 00143 00144 #define ELF32_PHDR_SIZE (8*4) /* Size of an elf program header */ 00145 00146 #ifndef ASSEMBLY 00147 00148 #include <stdint.h> 00149 00150 /* 00151 * ELF definitions common to all 32-bit architectures. 00152 */ 00153 00154 typedef uint32_t Elf32_Addr; 00155 typedef uint16_t Elf32_Half; 00156 typedef uint32_t Elf32_Off; 00157 typedef int32_t Elf32_Sword; 00158 typedef uint32_t Elf32_Word; 00159 typedef uint32_t Elf32_Size; 00160 00161 typedef uint64_t Elf64_Addr; 00162 typedef uint16_t Elf64_Half; 00163 typedef uint64_t Elf64_Off; 00164 typedef int32_t Elf64_Sword; 00165 typedef uint32_t Elf64_Word; 00166 typedef uint64_t Elf64_Size; 00167 00168 /* 00169 * ELF header. 00170 */ 00171 typedef struct { 00172 unsigned char e_ident[EI_NIDENT]; /* File identification. */ 00173 Elf32_Half e_type; /* File type. */ 00174 Elf32_Half e_machine; /* Machine architecture. */ 00175 Elf32_Word e_version; /* ELF format version. */ 00176 Elf32_Addr e_entry; /* Entry point. */ 00177 Elf32_Off e_phoff; /* Program header file offset. */ 00178 Elf32_Off e_shoff; /* Section header file offset. */ 00179 Elf32_Word e_flags; /* Architecture-specific flags. */ 00180 Elf32_Half e_ehsize; /* Size of ELF header in bytes. */ 00181 Elf32_Half e_phentsize; /* Size of program header entry. */ 00182 Elf32_Half e_phnum; /* Number of program header entries. */ 00183 Elf32_Half e_shentsize; /* Size of section header entry. */ 00184 Elf32_Half e_shnum; /* Number of section header entries. */ 00185 Elf32_Half e_shstrndx; /* Section name strings section. */ 00186 } Elf32_Ehdr; 00187 00188 typedef struct { 00189 unsigned char e_ident[EI_NIDENT]; /* File identification. */ 00190 Elf64_Half e_type; /* File type. */ 00191 Elf64_Half e_machine; /* Machine architecture. */ 00192 Elf64_Word e_version; /* ELF format version. */ 00193 Elf64_Addr e_entry; /* Entry point. */ 00194 Elf64_Off e_phoff; /* Program header file offset. */ 00195 Elf64_Off e_shoff; /* Section header file offset. */ 00196 Elf64_Word e_flags; /* Architecture-specific flags. */ 00197 Elf64_Half e_ehsize; /* Size of ELF header in bytes. */ 00198 Elf64_Half e_phentsize; /* Size of program header entry. */ 00199 Elf64_Half e_phnum; /* Number of program header entries. */ 00200 Elf64_Half e_shentsize; /* Size of section header entry. */ 00201 Elf64_Half e_shnum; /* Number of section header entries. */ 00202 Elf64_Half e_shstrndx; /* Section name strings section. */ 00203 } Elf64_Ehdr; 00204 00205 /* 00206 * Program header. 00207 */ 00208 typedef struct { 00209 Elf32_Word p_type; /* Entry type. */ 00210 Elf32_Off p_offset; /* File offset of contents. */ 00211 Elf32_Addr p_vaddr; /* Virtual address (not used). */ 00212 Elf32_Addr p_paddr; /* Physical address. */ 00213 Elf32_Size p_filesz; /* Size of contents in file. */ 00214 Elf32_Size p_memsz; /* Size of contents in memory. */ 00215 Elf32_Word p_flags; /* Access permission flags. */ 00216 Elf32_Size p_align; /* Alignment in memory and file. */ 00217 } Elf32_Phdr; 00218 00219 typedef struct { 00220 Elf64_Word p_type; /* Entry type. */ 00221 Elf64_Word p_flags; /* Access permission flags. */ 00222 Elf64_Off p_offset; /* File offset of contents. */ 00223 Elf64_Addr p_vaddr; /* Virtual address (not used). */ 00224 Elf64_Addr p_paddr; /* Physical address. */ 00225 Elf64_Size p_filesz; /* Size of contents in file. */ 00226 Elf64_Size p_memsz; /* Size of contents in memory. */ 00227 Elf64_Size p_align; /* Alignment in memory and file. */ 00228 } Elf64_Phdr; 00229 00230 /* Standardized Elf image notes for booting... The name for all of these is ELFBoot */ 00231 00232 #endif /* ASSEMBLY */ 00233 00234 #endif /* ELF_H */
1.5.7.1