Changeset ca0e838 in mainline for abi/include/abi/elf.h
- Timestamp:
- 2019-02-23T17:52:16Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 52b44c6
- Parents:
- ab87db5
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2019-02-11 15:28:25)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2019-02-23 17:52:16)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
abi/include/abi/elf.h
rab87db5 rca0e838 42 42 * Current ELF version 43 43 */ 44 #define EV_CURRENT 1 44 enum { 45 EV_CURRENT = 1, 46 }; 45 47 46 48 /** 47 49 * ELF types 48 50 */ 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 */ 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 }; 56 63 57 64 /** 58 65 * ELF machine types 59 66 */ 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 */ 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_RISCV = 243, /* RISC-V */ 80 }; 72 81 73 82 /** 74 83 * ELF identification indexes 75 84 */ 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 */ 85 enum { 86 EI_MAG0 = 0, 87 EI_MAG1 = 1, 88 EI_MAG2 = 2, 89 EI_MAG3 = 3, 90 EI_CLASS = 4, /* File class */ 91 EI_DATA = 5, /* Data encoding */ 92 EI_VERSION = 6, /* File version */ 93 EI_OSABI = 7, 94 EI_ABIVERSION = 8, 95 EI_PAD = 9, /* Start of padding bytes */ 96 EI_NIDENT = 16, /* ELF identification table size */ 97 }; 87 98 88 99 /** 89 100 * ELF magic number 90 101 */ 91 #define ELFMAG0 0x7f 92 #define ELFMAG1 'E' 93 #define ELFMAG2 'L' 94 #define ELFMAG3 'F' 102 enum { 103 ELFMAG0 = 0x7f, 104 ELFMAG1 = 'E', 105 ELFMAG2 = 'L', 106 ELFMAG3 = 'F', 107 }; 95 108 96 109 /** 97 110 * ELF file classes 98 111 */ 99 #define ELFCLASSNONE 0 100 #define ELFCLASS32 1 101 #define ELFCLASS64 2 112 enum elf_class { 113 ELFCLASSNONE = 0, 114 ELFCLASS32 = 1, 115 ELFCLASS64 = 2, 116 }; 102 117 103 118 /** 104 119 * ELF data encoding types 105 120 */ 106 #define ELFDATANONE 0 107 #define ELFDATA2LSB 1 /* Least significant byte first (little endian) */ 108 #define ELFDATA2MSB 2 /* Most signigicant byte first (big endian) */ 121 enum elf_data_encoding { 122 ELFDATANONE = 0, 123 ELFDATA2LSB = 1, /* Least significant byte first (little endian) */ 124 ELFDATA2MSB = 2, /* Most signigicant byte first (big endian) */ 125 }; 109 126 110 127 /** 111 128 * ELF section types 112 129 */ 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 130 enum elf_section_type { 131 SHT_NULL = 0, 132 SHT_PROGBITS = 1, 133 SHT_SYMTAB = 2, 134 SHT_STRTAB = 3, 135 SHT_RELA = 4, 136 SHT_HASH = 5, 137 SHT_DYNAMIC = 6, 138 SHT_NOTE = 7, 139 SHT_NOBITS = 8, 140 SHT_REL = 9, 141 SHT_SHLIB = 10, 142 SHT_DYNSYM = 11, 143 }; 144 145 enum { 146 SHT_LOOS = 0x60000000, 147 SHT_HIOS = 0x6fffffff, 148 SHT_LOPROC = 0x70000000, 149 SHT_HIPROC = 0x7fffffff, 150 SHT_LOUSER = 0x80000000, 151 SHT_HIUSER = 0xffffffff, 152 }; 131 153 132 154 /** 133 155 * ELF section flags 134 156 */ 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)) 157 enum { 158 SHF_WRITE = 0x1, 159 SHF_ALLOC = 0x2, 160 SHF_EXECINSTR = 0x4, 161 SHF_TLS = 0x400, 162 SHF_MASKPROC = 0xf0000000, 163 }; 164 165 /** Functions for decomposing elf_symbol.st_info into binding and type */ 166 static inline uint8_t elf_st_bind(uint8_t info) 167 { 168 return info >> 4; 169 } 170 171 static inline uint8_t elf_st_type(uint8_t info) 172 { 173 return info & 0x0f; 174 } 175 176 static inline uint8_t elf_st_info(uint8_t bind, uint8_t type) 177 { 178 return (bind << 4) | (type & 0x0f); 179 } 145 180 146 181 /** 147 182 * Symbol binding 148 183 */ 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 184 enum elf_symbol_binding { 185 STB_LOCAL = 0, 186 STB_GLOBAL = 1, 187 STB_WEAK = 2, 188 }; 189 190 enum { 191 STB_LOPROC = 13, 192 STB_HIPROC = 15, 193 }; 154 194 155 195 /** 156 196 * Symbol types 157 197 */ 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 198 enum elf_symbol_type { 199 STT_NOTYPE = 0, 200 STT_OBJECT = 1, 201 STT_FUNC = 2, 202 STT_SECTION = 3, 203 STT_FILE = 4, 204 STT_TLS = 6, 205 }; 206 207 enum { 208 STT_LOPROC = 13, 209 STT_HIPROC = 15, 210 }; 166 211 167 212 /** 168 213 * Program segment types 169 214 */ 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 215 enum elf_segment_type { 216 PT_NULL = 0, 217 PT_LOAD = 1, 218 PT_DYNAMIC = 2, 219 PT_INTERP = 3, 220 PT_NOTE = 4, 221 PT_SHLIB = 5, 222 PT_PHDR = 6, 223 PT_TLS = 7, 224 225 PT_GNU_EH_FRAME = 0x6474e550, 226 PT_GNU_STACK = 0x6474e551, 227 PT_GNU_RELRO = 0x6474e552, 228 }; 229 230 enum { 231 PT_LOOS = 0x60000000, 232 PT_HIOS = 0x6fffffff, 233 PT_LOPROC = 0x70000000, 234 PT_HIPROC = 0x7fffffff, 235 }; 185 236 186 237 /** 187 238 * Program segment attributes. 188 239 */ 189 #define PF_X 1 190 #define PF_W 2 191 #define PF_R 4 240 enum elf_segment_access { 241 PF_X = 1, 242 PF_W = 2, 243 PF_R = 4, 244 }; 192 245 193 246 /**
Note:
See TracChangeset
for help on using the changeset viewer.