Changeset 925a21e in mainline for kernel/generic/include/lib/elf.h
- Timestamp:
- 2011-09-24T14:20:29Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5bf76c1
- Parents:
- 867e2555 (diff), 1ab4aca (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/lib/elf.h
r867e2555 r925a21e 36 36 #define KERN_ELF_H_ 37 37 38 #include <typedefs.h> 39 #include <abi/elf.h> 38 40 #include <arch/elf.h> 39 #include <typedefs.h>40 41 /**42 * current ELF version43 */44 #define EV_CURRENT 145 46 /**47 * ELF types48 */49 #define ET_NONE 0 /* No type */50 #define ET_REL 1 /* Relocatable file */51 #define ET_EXEC 2 /* Executable */52 #define ET_DYN 3 /* Shared object */53 #define ET_CORE 4 /* Core */54 #define ET_LOPROC 0xff00 /* Processor specific */55 #define ET_HIPROC 0xffff /* Processor specific */56 57 /**58 * ELF machine types59 */60 #define EM_NO 0 /* No machine */61 #define EM_SPARC 2 /* SPARC */62 #define EM_386 3 /* i386 */63 #define EM_MIPS 8 /* MIPS RS3000 */64 #define EM_MIPS_RS3_LE 10 /* MIPS RS3000 LE */65 #define EM_PPC 20 /* PPC32 */66 #define EM_PPC64 21 /* PPC64 */67 #define EM_ARM 40 /* ARM */68 #define EM_SPARCV9 43 /* SPARC64 */69 #define EM_IA_64 50 /* IA-64 */70 #define EM_X86_64 62 /* AMD64/EMT64 */71 72 /**73 * ELF identification indexes74 */75 #define EI_MAG0 076 #define EI_MAG1 177 #define EI_MAG2 278 #define EI_MAG3 379 #define EI_CLASS 4 /* File class */80 #define EI_DATA 5 /* Data encoding */81 #define EI_VERSION 6 /* File version */82 #define EI_OSABI 783 #define EI_ABIVERSION 884 #define EI_PAD 9 /* Start of padding bytes */85 #define EI_NIDENT 16 /* ELF identification table size */86 87 /**88 * ELF magic number89 */90 #define ELFMAG0 0x7f91 #define ELFMAG1 'E'92 #define ELFMAG2 'L'93 #define ELFMAG3 'F'94 95 /**96 * ELF file classes97 */98 #define ELFCLASSNONE 099 #define ELFCLASS32 1100 #define ELFCLASS64 2101 102 /**103 * ELF data encoding types104 */105 #define ELFDATANONE 0106 #define ELFDATA2LSB 1 /* Least significant byte first (little endian) */107 #define ELFDATA2MSB 2 /* Most signigicant byte first (big endian) */108 109 /**110 * ELF section types111 */112 #define SHT_NULL 0113 #define SHT_PROGBITS 1114 #define SHT_SYMTAB 2115 #define SHT_STRTAB 3116 #define SHT_RELA 4117 #define SHT_HASH 5118 #define SHT_DYNAMIC 6119 #define SHT_NOTE 7120 #define SHT_NOBITS 8121 #define SHT_REL 9122 #define SHT_SHLIB 10123 #define SHT_DYNSYM 11124 #define SHT_LOOS 0x60000000125 #define SHT_HIOS 0x6fffffff126 #define SHT_LOPROC 0x70000000127 #define SHT_HIPROC 0x7fffffff128 #define SHT_LOUSER 0x80000000129 #define SHT_HIUSER 0xffffffff130 131 /**132 * ELF section flags133 */134 #define SHF_WRITE 0x1135 #define SHF_ALLOC 0x2136 #define SHF_EXECINSTR 0x4137 #define SHF_TLS 0x400138 #define SHF_MASKPROC 0xf0000000139 140 /** Macros for decomposing elf_symbol.st_info into binging and type */141 #define ELF_ST_BIND(i) ((i) >> 4)142 #define ELF_ST_TYPE(i) ((i) & 0x0f)143 #define ELF_ST_INFO(b, t) (((b) << 4) + ((t) & 0x0f))144 145 /**146 * Symbol binding147 */148 #define STB_LOCAL 0149 #define STB_GLOBAL 1150 #define STB_WEAK 2151 #define STB_LOPROC 13152 #define STB_HIPROC 15153 154 /**155 * Symbol types156 */157 #define STT_NOTYPE 0158 #define STT_OBJECT 1159 #define STT_FUNC 2160 #define STT_SECTION 3161 #define STT_FILE 4162 #define STT_LOPROC 13163 #define STT_HIPROC 15164 165 /**166 * Program segment types167 */168 #define PT_NULL 0169 #define PT_LOAD 1170 #define PT_DYNAMIC 2171 #define PT_INTERP 3172 #define PT_NOTE 4173 #define PT_SHLIB 5174 #define PT_PHDR 6175 #define PT_LOPROC 0x70000000176 #define PT_HIPROC 0x7fffffff177 178 /**179 * Program segment attributes.180 */181 #define PF_X 1182 #define PF_W 2183 #define PF_R 4184 185 /**186 * ELF data types187 *188 * These types are found to be identical in both 32-bit and 64-bit189 * ELF object file specifications. They are the only types used190 * in ELF header.191 */192 typedef uint64_t elf_xword;193 typedef int64_t elf_sxword;194 typedef uint32_t elf_word;195 typedef int32_t elf_sword;196 typedef uint16_t elf_half;197 198 /**199 * 32-bit ELF data types.200 *201 * These types are specific for 32-bit format.202 */203 typedef uint32_t elf32_addr;204 typedef uint32_t elf32_off;205 206 /**207 * 64-bit ELF data types.208 *209 * These types are specific for 64-bit format.210 */211 typedef uint64_t elf64_addr;212 typedef uint64_t elf64_off;213 214 /** ELF header */215 struct elf32_header {216 uint8_t e_ident[EI_NIDENT];217 elf_half e_type;218 elf_half e_machine;219 elf_word e_version;220 elf32_addr e_entry;221 elf32_off e_phoff;222 elf32_off e_shoff;223 elf_word e_flags;224 elf_half e_ehsize;225 elf_half e_phentsize;226 elf_half e_phnum;227 elf_half e_shentsize;228 elf_half e_shnum;229 elf_half e_shstrndx;230 };231 struct elf64_header {232 uint8_t e_ident[EI_NIDENT];233 elf_half e_type;234 elf_half e_machine;235 elf_word e_version;236 elf64_addr e_entry;237 elf64_off e_phoff;238 elf64_off e_shoff;239 elf_word e_flags;240 elf_half e_ehsize;241 elf_half e_phentsize;242 elf_half e_phnum;243 elf_half e_shentsize;244 elf_half e_shnum;245 elf_half e_shstrndx;246 };247 248 /*249 * ELF segment header.250 * Segments headers are also known as program headers.251 */252 struct elf32_segment_header {253 elf_word p_type;254 elf32_off p_offset;255 elf32_addr p_vaddr;256 elf32_addr p_paddr;257 elf_word p_filesz;258 elf_word p_memsz;259 elf_word p_flags;260 elf_word p_align;261 };262 struct elf64_segment_header {263 elf_word p_type;264 elf_word p_flags;265 elf64_off p_offset;266 elf64_addr p_vaddr;267 elf64_addr p_paddr;268 elf_xword p_filesz;269 elf_xword p_memsz;270 elf_xword p_align;271 };272 273 /*274 * ELF section header275 */276 struct elf32_section_header {277 elf_word sh_name;278 elf_word sh_type;279 elf_word sh_flags;280 elf32_addr sh_addr;281 elf32_off sh_offset;282 elf_word sh_size;283 elf_word sh_link;284 elf_word sh_info;285 elf_word sh_addralign;286 elf_word sh_entsize;287 };288 struct elf64_section_header {289 elf_word sh_name;290 elf_word sh_type;291 elf_xword sh_flags;292 elf64_addr sh_addr;293 elf64_off sh_offset;294 elf_xword sh_size;295 elf_word sh_link;296 elf_word sh_info;297 elf_xword sh_addralign;298 elf_xword sh_entsize;299 };300 301 /*302 * ELF symbol table entry303 */304 struct elf32_symbol {305 elf_word st_name;306 elf32_addr st_value;307 elf_word st_size;308 uint8_t st_info;309 uint8_t st_other;310 elf_half st_shndx;311 };312 struct elf64_symbol {313 elf_word st_name;314 uint8_t st_info;315 uint8_t st_other;316 elf_half st_shndx;317 elf64_addr st_value;318 elf_xword st_size;319 };320 321 /*322 * ELF note segment entry323 */324 struct elf32_note {325 elf_word namesz;326 elf_word descsz;327 elf_word type;328 };329 struct elf64_note {330 elf_xword namesz;331 elf_xword descsz;332 elf_xword type;333 };334 335 #ifdef __32_BITS__336 typedef struct elf32_header elf_header_t;337 typedef struct elf32_segment_header elf_segment_header_t;338 typedef struct elf32_section_header elf_section_header_t;339 typedef struct elf32_symbol elf_symbol_t;340 typedef struct elf32_note elf_note_t;341 #endif342 #ifdef __64_BITS__343 typedef struct elf64_header elf_header_t;344 typedef struct elf64_segment_header elf_segment_header_t;345 typedef struct elf64_section_header elf_section_header_t;346 typedef struct elf64_symbol elf_symbol_t;347 typedef struct elf64_note elf_note_t;348 #endif349 41 350 42 /** Interpreter string used to recognize the program loader */
Note:
See TracChangeset
for help on using the changeset viewer.