1 /* 2 * This header was generated from the Linux kernel headers by update_headers.py, 3 * to provide necessary information from kernel to userspace, such as constants, 4 * structures, and macros, and thus, contains no copyrightable information. 5 */ 6 #ifndef _UAPI_LINUX_ELF_H 7 #define _UAPI_LINUX_ELF_H 8 #include <linux/types.h> 9 #include <linux/elf-em.h> 10 typedef __u32 Elf32_Addr; 11 typedef __u16 Elf32_Half; 12 typedef __u32 Elf32_Off; 13 typedef __s32 Elf32_Sword; 14 typedef __u32 Elf32_Word; 15 typedef __u64 Elf64_Addr; 16 typedef __u16 Elf64_Half; 17 typedef __s16 Elf64_SHalf; 18 typedef __u64 Elf64_Off; 19 typedef __s32 Elf64_Sword; 20 typedef __u32 Elf64_Word; 21 typedef __u64 Elf64_Xword; 22 typedef __s64 Elf64_Sxword; 23 #define PT_NULL 0 24 #define PT_LOAD 1 25 #define PT_DYNAMIC 2 26 #define PT_INTERP 3 27 #define PT_NOTE 4 28 #define PT_SHLIB 5 29 #define PT_PHDR 6 30 #define PT_TLS 7 31 #define PT_LOOS 0x60000000 32 #define PT_HIOS 0x6fffffff 33 #define PT_LOPROC 0x70000000 34 #define PT_HIPROC 0x7fffffff 35 #define PT_GNU_EH_FRAME 0x6474e550 36 #define PT_GNU_STACK (PT_LOOS + 0x474e551) 37 #define PN_XNUM 0xffff 38 #define ET_NONE 0 39 #define ET_REL 1 40 #define ET_EXEC 2 41 #define ET_DYN 3 42 #define ET_CORE 4 43 #define ET_LOPROC 0xff00 44 #define ET_HIPROC 0xffff 45 #define DT_NULL 0 46 #define DT_NEEDED 1 47 #define DT_PLTRELSZ 2 48 #define DT_PLTGOT 3 49 #define DT_HASH 4 50 #define DT_STRTAB 5 51 #define DT_SYMTAB 6 52 #define DT_RELA 7 53 #define DT_RELASZ 8 54 #define DT_RELAENT 9 55 #define DT_STRSZ 10 56 #define DT_SYMENT 11 57 #define DT_INIT 12 58 #define DT_FINI 13 59 #define DT_SONAME 14 60 #define DT_RPATH 15 61 #define DT_SYMBOLIC 16 62 #define DT_REL 17 63 #define DT_RELSZ 18 64 #define DT_RELENT 19 65 #define DT_PLTREL 20 66 #define DT_DEBUG 21 67 #define DT_TEXTREL 22 68 #define DT_JMPREL 23 69 #define DT_ENCODING 32 70 #define OLD_DT_LOOS 0x60000000 71 #define DT_LOOS 0x6000000d 72 #define DT_HIOS 0x6ffff000 73 #define DT_VALRNGLO 0x6ffffd00 74 #define DT_VALRNGHI 0x6ffffdff 75 #define DT_ADDRRNGLO 0x6ffffe00 76 #define DT_ADDRRNGHI 0x6ffffeff 77 #define DT_VERSYM 0x6ffffff0 78 #define DT_RELACOUNT 0x6ffffff9 79 #define DT_RELCOUNT 0x6ffffffa 80 #define DT_FLAGS_1 0x6ffffffb 81 #define DT_VERDEF 0x6ffffffc 82 #define DT_VERDEFNUM 0x6ffffffd 83 #define DT_VERNEED 0x6ffffffe 84 #define DT_VERNEEDNUM 0x6fffffff 85 #define OLD_DT_HIOS 0x6fffffff 86 #define DT_LOPROC 0x70000000 87 #define DT_HIPROC 0x7fffffff 88 #define STB_LOCAL 0 89 #define STB_GLOBAL 1 90 #define STB_WEAK 2 91 #define STT_NOTYPE 0 92 #define STT_OBJECT 1 93 #define STT_FUNC 2 94 #define STT_SECTION 3 95 #define STT_FILE 4 96 #define STT_COMMON 5 97 #define STT_TLS 6 98 #define ELF_ST_BIND(x) ((x) >> 4) 99 #define ELF_ST_TYPE(x) (((unsigned int) x) & 0xf) 100 #define ELF32_ST_BIND(x) ELF_ST_BIND(x) 101 #define ELF32_ST_TYPE(x) ELF_ST_TYPE(x) 102 #define ELF64_ST_BIND(x) ELF_ST_BIND(x) 103 #define ELF64_ST_TYPE(x) ELF_ST_TYPE(x) 104 typedef struct dynamic{ 105 Elf32_Sword d_tag; 106 union{ 107 Elf32_Sword d_val; 108 Elf32_Addr d_ptr; 109 } d_un; 110 } Elf32_Dyn; 111 typedef struct { 112 Elf64_Sxword d_tag; 113 union { 114 Elf64_Xword d_val; 115 Elf64_Addr d_ptr; 116 } d_un; 117 } Elf64_Dyn; 118 #define ELF32_R_SYM(x) ((x) >> 8) 119 #define ELF32_R_TYPE(x) ((x) & 0xff) 120 #define ELF64_R_SYM(i) ((i) >> 32) 121 #define ELF64_R_TYPE(i) ((i) & 0xffffffff) 122 typedef struct elf32_rel { 123 Elf32_Addr r_offset; 124 Elf32_Word r_info; 125 } Elf32_Rel; 126 typedef struct elf64_rel { 127 Elf64_Addr r_offset; 128 Elf64_Xword r_info; 129 } Elf64_Rel; 130 typedef struct elf32_rela{ 131 Elf32_Addr r_offset; 132 Elf32_Word r_info; 133 Elf32_Sword r_addend; 134 } Elf32_Rela; 135 typedef struct elf64_rela { 136 Elf64_Addr r_offset; 137 Elf64_Xword r_info; 138 Elf64_Sxword r_addend; 139 } Elf64_Rela; 140 typedef struct elf32_sym{ 141 Elf32_Word st_name; 142 Elf32_Addr st_value; 143 Elf32_Word st_size; 144 unsigned char st_info; 145 unsigned char st_other; 146 Elf32_Half st_shndx; 147 } Elf32_Sym; 148 typedef struct elf64_sym { 149 Elf64_Word st_name; 150 unsigned char st_info; 151 unsigned char st_other; 152 Elf64_Half st_shndx; 153 Elf64_Addr st_value; 154 Elf64_Xword st_size; 155 } Elf64_Sym; 156 #define EI_NIDENT 16 157 typedef struct elf32_hdr{ 158 unsigned char e_ident[EI_NIDENT]; 159 Elf32_Half e_type; 160 Elf32_Half e_machine; 161 Elf32_Word e_version; 162 Elf32_Addr e_entry; 163 Elf32_Off e_phoff; 164 Elf32_Off e_shoff; 165 Elf32_Word e_flags; 166 Elf32_Half e_ehsize; 167 Elf32_Half e_phentsize; 168 Elf32_Half e_phnum; 169 Elf32_Half e_shentsize; 170 Elf32_Half e_shnum; 171 Elf32_Half e_shstrndx; 172 } Elf32_Ehdr; 173 typedef struct elf64_hdr { 174 unsigned char e_ident[EI_NIDENT]; 175 Elf64_Half e_type; 176 Elf64_Half e_machine; 177 Elf64_Word e_version; 178 Elf64_Addr e_entry; 179 Elf64_Off e_phoff; 180 Elf64_Off e_shoff; 181 Elf64_Word e_flags; 182 Elf64_Half e_ehsize; 183 Elf64_Half e_phentsize; 184 Elf64_Half e_phnum; 185 Elf64_Half e_shentsize; 186 Elf64_Half e_shnum; 187 Elf64_Half e_shstrndx; 188 } Elf64_Ehdr; 189 #define PF_R 0x4 190 #define PF_W 0x2 191 #define PF_X 0x1 192 typedef struct elf32_phdr{ 193 Elf32_Word p_type; 194 Elf32_Off p_offset; 195 Elf32_Addr p_vaddr; 196 Elf32_Addr p_paddr; 197 Elf32_Word p_filesz; 198 Elf32_Word p_memsz; 199 Elf32_Word p_flags; 200 Elf32_Word p_align; 201 } Elf32_Phdr; 202 typedef struct elf64_phdr { 203 Elf64_Word p_type; 204 Elf64_Word p_flags; 205 Elf64_Off p_offset; 206 Elf64_Addr p_vaddr; 207 Elf64_Addr p_paddr; 208 Elf64_Xword p_filesz; 209 Elf64_Xword p_memsz; 210 Elf64_Xword p_align; 211 } Elf64_Phdr; 212 #define SHT_NULL 0 213 #define SHT_PROGBITS 1 214 #define SHT_SYMTAB 2 215 #define SHT_STRTAB 3 216 #define SHT_RELA 4 217 #define SHT_HASH 5 218 #define SHT_DYNAMIC 6 219 #define SHT_NOTE 7 220 #define SHT_NOBITS 8 221 #define SHT_REL 9 222 #define SHT_SHLIB 10 223 #define SHT_DYNSYM 11 224 #define SHT_NUM 12 225 #define SHT_LOPROC 0x70000000 226 #define SHT_HIPROC 0x7fffffff 227 #define SHT_LOUSER 0x80000000 228 #define SHT_HIUSER 0xffffffff 229 #define SHF_WRITE 0x1 230 #define SHF_ALLOC 0x2 231 #define SHF_EXECINSTR 0x4 232 #define SHF_RELA_LIVEPATCH 0x00100000 233 #define SHF_RO_AFTER_INIT 0x00200000 234 #define SHF_MASKPROC 0xf0000000 235 #define SHN_UNDEF 0 236 #define SHN_LORESERVE 0xff00 237 #define SHN_LOPROC 0xff00 238 #define SHN_HIPROC 0xff1f 239 #define SHN_LIVEPATCH 0xff20 240 #define SHN_ABS 0xfff1 241 #define SHN_COMMON 0xfff2 242 #define SHN_HIRESERVE 0xffff 243 244 typedef struct elf32_shdr { 245 Elf32_Word sh_name; 246 Elf32_Word sh_type; 247 Elf32_Word sh_flags; 248 Elf32_Addr sh_addr; 249 Elf32_Off sh_offset; 250 Elf32_Word sh_size; 251 Elf32_Word sh_link; 252 Elf32_Word sh_info; 253 Elf32_Word sh_addralign; 254 Elf32_Word sh_entsize; 255 } Elf32_Shdr; 256 typedef struct elf64_shdr { 257 Elf64_Word sh_name; 258 Elf64_Word sh_type; 259 Elf64_Xword sh_flags; 260 Elf64_Addr sh_addr; 261 Elf64_Off sh_offset; 262 Elf64_Xword sh_size; 263 Elf64_Word sh_link; 264 Elf64_Word sh_info; 265 Elf64_Xword sh_addralign; 266 Elf64_Xword sh_entsize; 267 } Elf64_Shdr; 268 #define EI_MAG0 0 269 #define EI_MAG1 1 270 #define EI_MAG2 2 271 #define EI_MAG3 3 272 #define EI_CLASS 4 273 #define EI_DATA 5 274 #define EI_VERSION 6 275 #define EI_OSABI 7 276 #define EI_PAD 8 277 #define ELFMAG0 0x7f 278 #define ELFMAG1 'E' 279 #define ELFMAG2 'L' 280 #define ELFMAG3 'F' 281 #define ELFMAG "\177ELF" 282 #define SELFMAG 4 283 #define ELFCLASSNONE 0 284 #define ELFCLASS32 1 285 #define ELFCLASS64 2 286 #define ELFCLASSNUM 3 287 #define ELFDATANONE 0 288 #define ELFDATA2LSB 1 289 #define ELFDATA2MSB 2 290 #define EV_NONE 0 291 #define EV_CURRENT 1 292 #define EV_NUM 2 293 #define ELFOSABI_NONE 0 294 #define ELFOSABI_LINUX 3 295 #ifndef ELF_OSABI 296 #define ELF_OSABI ELFOSABI_NONE 297 #endif 298 #define NT_PRSTATUS 1 299 #define NT_PRFPREG 2 300 #define NT_PRPSINFO 3 301 #define NT_TASKSTRUCT 4 302 #define NT_AUXV 6 303 #define NT_SIGINFO 0x53494749 304 #define NT_FILE 0x46494c45 305 #define NT_PRXFPREG 0x46e62b7f 306 #define NT_PPC_VMX 0x100 307 #define NT_PPC_SPE 0x101 308 #define NT_PPC_VSX 0x102 309 #define NT_PPC_TAR 0x103 310 #define NT_PPC_PPR 0x104 311 #define NT_PPC_DSCR 0x105 312 #define NT_PPC_EBB 0x106 313 #define NT_PPC_PMU 0x107 314 #define NT_PPC_TM_CGPR 0x108 315 #define NT_PPC_TM_CFPR 0x109 316 #define NT_PPC_TM_CVMX 0x10a 317 #define NT_PPC_TM_CVSX 0x10b 318 #define NT_PPC_TM_SPR 0x10c 319 #define NT_PPC_TM_CTAR 0x10d 320 #define NT_PPC_TM_CPPR 0x10e 321 #define NT_PPC_TM_CDSCR 0x10f 322 #define NT_PPC_PKEY 0x110 323 #define NT_386_TLS 0x200 324 #define NT_386_IOPERM 0x201 325 #define NT_X86_XSTATE 0x202 326 #define NT_S390_HIGH_GPRS 0x300 327 #define NT_S390_TIMER 0x301 328 #define NT_S390_TODCMP 0x302 329 #define NT_S390_TODPREG 0x303 330 #define NT_S390_CTRS 0x304 331 #define NT_S390_PREFIX 0x305 332 #define NT_S390_LAST_BREAK 0x306 333 #define NT_S390_SYSTEM_CALL 0x307 334 #define NT_S390_TDB 0x308 335 #define NT_S390_VXRS_LOW 0x309 336 #define NT_S390_VXRS_HIGH 0x30a 337 #define NT_S390_GS_CB 0x30b 338 #define NT_S390_GS_BC 0x30c 339 #define NT_S390_RI_CB 0x30d 340 #define NT_ARM_VFP 0x400 341 #define NT_ARM_TLS 0x401 342 #define NT_ARM_HW_BREAK 0x402 343 #define NT_ARM_HW_WATCH 0x403 344 #define NT_ARM_SYSTEM_CALL 0x404 345 #define NT_ARM_SVE 0x405 346 #define NT_ARC_V2 0x600 347 #define NT_VMCOREDD 0x700 348 #define NT_MIPS_DSP 0x800 349 #define NT_MIPS_FP_MODE 0x801 350 typedef struct elf32_note { 351 Elf32_Word n_namesz; 352 Elf32_Word n_descsz; 353 Elf32_Word n_type; 354 } Elf32_Nhdr; 355 typedef struct elf64_note { 356 Elf64_Word n_namesz; 357 Elf64_Word n_descsz; 358 Elf64_Word n_type; 359 } Elf64_Nhdr; 360 #endif 361