Changes in abi/include/abi/elf.h [84176f3:4805495] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
abi/include/abi/elf.h
r84176f3 r4805495 42 42 * Current ELF version 43 43 */ 44 enum { 45 EV_CURRENT = 1, 46 }; 44 #define EV_CURRENT 1 47 45 48 46 /** 49 47 * ELF types 50 48 */ 51 enum elf_type { 52 ET_NONE = 0, /* No type */ 53 ET_REL = 1, /* Relocatable file */ 54 ET_EXEC = 2, /* Executable */ 55 ET_DYN = 3, /* Shared object */ 56 ET_CORE = 4, /* Core */ 57 }; 58 59 enum { 60 ET_LOPROC = 0xff00, /* Lowest processor specific */ 61 ET_HIPROC = 0xffff, /* Highest processor specific */ 62 }; 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 */ 63 56 64 57 /** 65 58 * ELF machine types 66 59 */ 67 enum elf_machine { 68 EM_NO = 0, /* No machine */ 69 EM_SPARC = 2, /* SPARC */ 70 EM_386 = 3, /* i386 */ 71 EM_MIPS = 8, /* MIPS RS3000 */ 72 EM_MIPS_RS3_LE = 10, /* MIPS RS3000 LE */ 73 EM_PPC = 20, /* PPC32 */ 74 EM_PPC64 = 21, /* PPC64 */ 75 EM_ARM = 40, /* ARM */ 76 EM_SPARCV9 = 43, /* SPARC64 */ 77 EM_IA_64 = 50, /* IA-64 */ 78 EM_X86_64 = 62, /* AMD64/EMT64 */ 79 EM_AARCH64 = 183, /* ARM 64-bit architecture */ 80 EM_RISCV = 243, /* RISC-V */ 81 }; 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 #define EM_RISCV 243 /* RISC-V */ 82 72 83 73 /** 84 74 * ELF identification indexes 85 75 */ 86 enum { 87 EI_MAG0 = 0, 88 EI_MAG1 = 1, 89 EI_MAG2 = 2, 90 EI_MAG3 = 3, 91 EI_CLASS = 4, /* File class */ 92 EI_DATA = 5, /* Data encoding */ 93 EI_VERSION = 6, /* File version */ 94 EI_OSABI = 7, 95 EI_ABIVERSION = 8, 96 EI_PAD = 9, /* Start of padding bytes */ 97 EI_NIDENT = 16, /* ELF identification table size */ 98 }; 76 #define EI_MAG0 0 77 #define EI_MAG1 1 78 #define EI_MAG2 2 79 #define EI_MAG3 3 80 #define EI_CLASS 4 /* File class */ 81 #define EI_DATA 5 /* Data encoding */ 82 #define EI_VERSION 6 /* File version */ 83 #define EI_OSABI 7 84 #define EI_ABIVERSION 8 85 #define EI_PAD 9 /* Start of padding bytes */ 86 #define EI_NIDENT 16 /* ELF identification table size */ 99 87 100 88 /** 101 89 * ELF magic number 102 90 */ 103 enum { 104 ELFMAG0 = 0x7f, 105 ELFMAG1 = 'E', 106 ELFMAG2 = 'L', 107 ELFMAG3 = 'F', 108 }; 91 #define ELFMAG0 0x7f 92 #define ELFMAG1 'E' 93 #define ELFMAG2 'L' 94 #define ELFMAG3 'F' 109 95 110 96 /** 111 97 * ELF file classes 112 98 */ 113 enum elf_class { 114 ELFCLASSNONE = 0, 115 ELFCLASS32 = 1, 116 ELFCLASS64 = 2, 117 }; 99 #define ELFCLASSNONE 0 100 #define ELFCLASS32 1 101 #define ELFCLASS64 2 118 102 119 103 /** 120 104 * ELF data encoding types 121 105 */ 122 enum elf_data_encoding { 123 ELFDATANONE = 0, 124 ELFDATA2LSB = 1, /* Least significant byte first (little endian) */ 125 ELFDATA2MSB = 2, /* Most signigicant byte first (big endian) */ 126 }; 106 #define ELFDATANONE 0 107 #define ELFDATA2LSB 1 /* Least significant byte first (little endian) */ 108 #define ELFDATA2MSB 2 /* Most signigicant byte first (big endian) */ 127 109 128 110 /** 129 111 * ELF section types 130 112 */ 131 enum elf_section_type { 132 SHT_NULL = 0, 133 SHT_PROGBITS = 1, 134 SHT_SYMTAB = 2, 135 SHT_STRTAB = 3, 136 SHT_RELA = 4, 137 SHT_HASH = 5, 138 SHT_DYNAMIC = 6, 139 SHT_NOTE = 7, 140 SHT_NOBITS = 8, 141 SHT_REL = 9, 142 SHT_SHLIB = 10, 143 SHT_DYNSYM = 11, 144 }; 145 146 enum { 147 SHT_LOOS = 0x60000000, 148 SHT_HIOS = 0x6fffffff, 149 SHT_LOPROC = 0x70000000, 150 SHT_HIPROC = 0x7fffffff, 151 SHT_LOUSER = 0x80000000, 152 SHT_HIUSER = 0xffffffff, 153 }; 113 #define SHT_NULL 0 114 #define SHT_PROGBITS 1 115 #define SHT_SYMTAB 2 116 #define SHT_STRTAB 3 117 #define SHT_RELA 4 118 #define SHT_HASH 5 119 #define SHT_DYNAMIC 6 120 #define SHT_NOTE 7 121 #define SHT_NOBITS 8 122 #define SHT_REL 9 123 #define SHT_SHLIB 10 124 #define SHT_DYNSYM 11 125 #define SHT_LOOS 0x60000000 126 #define SHT_HIOS 0x6fffffff 127 #define SHT_LOPROC 0x70000000 128 #define SHT_HIPROC 0x7fffffff 129 #define SHT_LOUSER 0x80000000 130 #define SHT_HIUSER 0xffffffff 154 131 155 132 /** 156 133 * ELF section flags 157 134 */ 158 enum { 159 SHF_WRITE = 0x1, 160 SHF_ALLOC = 0x2, 161 SHF_EXECINSTR = 0x4, 162 SHF_TLS = 0x400, 163 SHF_MASKPROC = 0xf0000000, 164 }; 165 166 /** Functions for decomposing elf_symbol.st_info into binding and type */ 167 static inline uint8_t elf_st_bind(uint8_t info) 168 { 169 return info >> 4; 170 } 171 172 static inline uint8_t elf_st_type(uint8_t info) 173 { 174 return info & 0x0f; 175 } 176 177 static inline uint8_t elf_st_info(uint8_t bind, uint8_t type) 178 { 179 return (bind << 4) | (type & 0x0f); 180 } 135 #define SHF_WRITE 0x1 136 #define SHF_ALLOC 0x2 137 #define SHF_EXECINSTR 0x4 138 #define SHF_TLS 0x400 139 #define SHF_MASKPROC 0xf0000000 140 141 /** Macros for decomposing elf_symbol.st_info into binging and type */ 142 #define ELF_ST_BIND(i) ((i) >> 4) 143 #define ELF_ST_TYPE(i) ((i) & 0x0f) 144 #define ELF_ST_INFO(b, t) (((b) << 4) + ((t) & 0x0f)) 181 145 182 146 /** 183 147 * Symbol binding 184 148 */ 185 enum elf_symbol_binding { 186 STB_LOCAL = 0, 187 STB_GLOBAL = 1, 188 STB_WEAK = 2, 189 }; 190 191 enum { 192 STB_LOPROC = 13, 193 STB_HIPROC = 15, 194 }; 149 #define STB_LOCAL 0 150 #define STB_GLOBAL 1 151 #define STB_WEAK 2 152 #define STB_LOPROC 13 153 #define STB_HIPROC 15 195 154 196 155 /** 197 156 * Symbol types 198 157 */ 199 enum elf_symbol_type { 200 STT_NOTYPE = 0, 201 STT_OBJECT = 1, 202 STT_FUNC = 2, 203 STT_SECTION = 3, 204 STT_FILE = 4, 205 STT_TLS = 6, 206 }; 207 208 enum { 209 STT_LOPROC = 13, 210 STT_HIPROC = 15, 211 }; 158 #define STT_NOTYPE 0 159 #define STT_OBJECT 1 160 #define STT_FUNC 2 161 #define STT_SECTION 3 162 #define STT_FILE 4 163 #define STT_TLS 6 164 #define STT_LOPROC 13 165 #define STT_HIPROC 15 212 166 213 167 /** 214 168 * Program segment types 215 169 */ 216 enum elf_segment_type { 217 PT_NULL = 0, 218 PT_LOAD = 1, 219 PT_DYNAMIC = 2, 220 PT_INTERP = 3, 221 PT_NOTE = 4, 222 PT_SHLIB = 5, 223 PT_PHDR = 6, 224 PT_TLS = 7, 225 226 PT_GNU_EH_FRAME = 0x6474e550, 227 PT_GNU_STACK = 0x6474e551, 228 PT_GNU_RELRO = 0x6474e552, 229 }; 230 231 enum { 232 PT_LOOS = 0x60000000, 233 PT_HIOS = 0x6fffffff, 234 PT_LOPROC = 0x70000000, 235 PT_HIPROC = 0x7fffffff, 236 }; 170 #define PT_NULL 0 171 #define PT_LOAD 1 172 #define PT_DYNAMIC 2 173 #define PT_INTERP 3 174 #define PT_NOTE 4 175 #define PT_SHLIB 5 176 #define PT_PHDR 6 177 #define PT_TLS 7 178 #define PT_LOOS 0x60000000 179 #define PT_GNU_EH_FRAME 0x6474e550 180 #define PT_GNU_STACK 0x6474e551 181 #define PT_GNU_RELRO 0x6474e552 182 #define PT_HIOS 0x6fffffff 183 #define PT_LOPROC 0x70000000 184 #define PT_HIPROC 0x7fffffff 237 185 238 186 /** 239 187 * Program segment attributes. 240 188 */ 241 enum elf_segment_access { 242 PF_X = 1, 243 PF_W = 2, 244 PF_R = 4, 245 }; 246 247 /** 248 * Dynamic array tags 249 */ 250 enum elf_dynamic_tag { 251 DT_NULL = 0, 252 DT_NEEDED = 1, 253 DT_PLTRELSZ = 2, 254 DT_PLTGOT = 3, 255 DT_HASH = 4, 256 DT_STRTAB = 5, 257 DT_SYMTAB = 6, 258 DT_RELA = 7, 259 DT_RELASZ = 8, 260 DT_RELAENT = 9, 261 DT_STRSZ = 10, 262 DT_SYMENT = 11, 263 DT_INIT = 12, 264 DT_FINI = 13, 265 DT_SONAME = 14, 266 DT_RPATH = 15, 267 DT_SYMBOLIC = 16, 268 DT_REL = 17, 269 DT_RELSZ = 18, 270 DT_RELENT = 19, 271 DT_PLTREL = 20, 272 DT_DEBUG = 21, 273 DT_TEXTREL = 22, 274 DT_JMPREL = 23, 275 DT_BIND_NOW = 24, 276 DT_LOPROC = 0x70000000, 277 DT_HIPROC = 0x7fffffff, 278 }; 279 280 /** 281 * Special section indexes 282 */ 283 enum { 284 SHN_UNDEF = 0, 285 SHN_LORESERVE = 0xff00, 286 SHN_LOPROC = 0xff00, 287 SHN_HIPROC = 0xff1f, 288 SHN_ABS = 0xfff1, 289 SHN_COMMON = 0xfff2, 290 SHN_HIRESERVE = 0xffff, 291 }; 292 293 /** 294 * Special symbol table index 295 */ 296 enum { 297 STN_UNDEF = 0, 298 }; 189 #define PF_X 1 190 #define PF_W 2 191 #define PF_R 4 299 192 300 193 /** … … 460 353 }; 461 354 462 /**463 * Dynamic structure464 */465 struct elf32_dyn {466 elf_sword d_tag;467 union {468 elf_word d_val;469 elf32_addr d_ptr;470 } d_un;471 };472 473 struct elf64_dyn {474 elf_sxword d_tag;475 union {476 elf_xword d_val;477 elf64_addr d_ptr;478 } d_un;479 };480 481 struct elf32_rel {482 elf32_addr r_offset;483 elf_word r_info;484 };485 486 struct elf32_rela {487 elf32_addr r_offset;488 elf_word r_info;489 elf_sword r_addend;490 };491 492 struct elf64_rel {493 elf64_addr r_offset;494 elf_xword r_info;495 };496 497 struct elf64_rela {498 elf64_addr r_offset;499 elf_xword r_info;500 elf_sxword r_addend;501 };502 503 #define ELF32_R_SYM(i) ((i) >> 8)504 #define ELF32_R_TYPE(i) ((unsigned char)(i))505 506 #define ELF64_R_SYM(i) ((i) >> 32)507 #define ELF64_R_TYPE(i) ((i) & 0xffffffffL)508 509 355 #ifdef __32_BITS__ 510 356 typedef struct elf32_header elf_header_t; … … 513 359 typedef struct elf32_symbol elf_symbol_t; 514 360 typedef struct elf32_note elf_note_t; 515 typedef struct elf32_dyn elf_dyn_t;516 typedef struct elf32_rel elf_rel_t;517 typedef struct elf32_rela elf_rela_t;518 #define ELF_R_TYPE(i) ELF32_R_TYPE(i)519 361 #endif 520 362 … … 525 367 typedef struct elf64_symbol elf_symbol_t; 526 368 typedef struct elf64_note elf_note_t; 527 typedef struct elf64_dyn elf_dyn_t;528 typedef struct elf64_rel elf_rel_t;529 typedef struct elf64_rela elf_rela_t;530 #define ELF_R_TYPE(i) ELF64_R_TYPE(i)531 369 #endif 532 370
Note:
See TracChangeset
for help on using the changeset viewer.