elf.h revision f16b65932bb7adb1568a3a1e11ffa750d18e30ae
1/* 2 * Copyright (C) 2008 The Android Open Source Project 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in 12 * the documentation and/or other materials provided with the 13 * distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 25 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 */ 28 29#ifndef _ELF_H 30#define _ELF_H 31 32#include <sys/cdefs.h> 33 34#include <bits/auxvec.h> 35#include <bits/elf_arm.h> 36#include <bits/elf_arm64.h> 37#include <bits/elf_mips.h> 38#include <bits/elf_x86.h> 39#include <bits/elf_x86_64.h> 40#include <linux/elf.h> 41#include <linux/elf-em.h> 42 43/* http://www.sco.com/developers/gabi/latest/ch4.intro.html */ 44typedef __u64 Elf32_Xword; 45typedef __s64 Elf32_Sxword; 46 47typedef struct { 48 __u32 a_type; 49 union { 50 __u32 a_val; 51 } a_un; 52} Elf32_auxv_t; 53 54typedef struct { 55 __u64 a_type; 56 union { 57 __u64 a_val; 58 } a_un; 59} Elf64_auxv_t; 60 61/* http://www.sco.com/developers/gabi/latest/ch4.sheader.html */ 62typedef struct { 63 Elf32_Word ch_type; 64 Elf32_Word ch_size; 65 Elf32_Word ch_addralign; 66} Elf32_Chdr; 67typedef struct { 68 Elf64_Word ch_type; 69 Elf64_Word ch_reserved; 70 Elf64_Xword ch_size; 71 Elf64_Xword ch_addralign; 72} Elf64_Chdr; 73 74typedef struct { 75 Elf32_Word l_name; 76 Elf32_Word l_time_stamp; 77 Elf32_Word l_checksum; 78 Elf32_Word l_version; 79 Elf32_Word l_flags; 80} Elf32_Lib; 81typedef struct { 82 Elf64_Word l_name; 83 Elf64_Word l_time_stamp; 84 Elf64_Word l_checksum; 85 Elf64_Word l_version; 86 Elf64_Word l_flags; 87} Elf64_Lib; 88/* ElfW(Lib)::l_flags values. */ 89#define LL_NONE 0x0 90#define LL_EXACT_MATCH 0x1 91#define LL_IGNORE_INT_VER 0x2 92#define LL_REQUIRE_MINOR 0x4 93#define LL_EXPORTS 0x8 94#define LL_DELAY_LOAD 0x10 95#define LL_DELTA 0x20 96 97typedef struct { 98 Elf32_Xword m_value; 99 Elf32_Word m_info; 100 Elf32_Word m_poffset; 101 Elf32_Half m_repeat; 102 Elf32_Half m_stride; 103} Elf32_Move; 104typedef struct { 105 Elf64_Xword m_value; 106 Elf64_Xword m_info; 107 Elf64_Xword m_poffset; 108 Elf64_Half m_repeat; 109 Elf64_Half m_stride; 110} Elf64_Move; 111 112typedef __u16 Elf32_Section; 113typedef __u16 Elf64_Section; 114 115typedef struct { 116 Elf32_Half si_boundto; 117 Elf32_Half si_flags; 118} Elf32_Syminfo; 119typedef struct { 120 Elf64_Half si_boundto; 121 Elf64_Half si_flags; 122} Elf64_Syminfo; 123/* ElfW(Syminfo)::si_boundto values. */ 124#define SYMINFO_BT_SELF 0xffff 125#define SYMINFO_BT_PARENT 0xfffe 126/* ElfW(Syminfo)::si_flags values. */ 127#define SYMINFO_FLG_DIRECT 0x1 128#define SYMINFO_FLG_PASSTHRU 0x2 129#define SYMINFO_FLG_COPY 0x4 130#define SYMINFO_FLG_LAZYLOAD 0x8 131 132typedef Elf32_Half Elf32_Versym; 133typedef Elf64_Half Elf64_Versym; 134 135typedef struct { 136 Elf32_Half vd_version; 137 Elf32_Half vd_flags; 138 Elf32_Half vd_ndx; 139 Elf32_Half vd_cnt; 140 Elf32_Word vd_hash; 141 Elf32_Word vd_aux; 142 Elf32_Word vd_next; 143} Elf32_Verdef; 144 145typedef struct { 146 Elf32_Word vda_name; 147 Elf32_Word vda_next; 148} Elf32_Verdaux; 149 150typedef struct { 151 Elf64_Half vd_version; 152 Elf64_Half vd_flags; 153 Elf64_Half vd_ndx; 154 Elf64_Half vd_cnt; 155 Elf64_Word vd_hash; 156 Elf64_Word vd_aux; 157 Elf64_Word vd_next; 158} Elf64_Verdef; 159 160typedef struct { 161 Elf64_Word vda_name; 162 Elf64_Word vda_next; 163} Elf64_Verdaux; 164 165typedef struct { 166 Elf32_Half vn_version; 167 Elf32_Half vn_cnt; 168 Elf32_Word vn_file; 169 Elf32_Word vn_aux; 170 Elf32_Word vn_next; 171} Elf32_Verneed; 172 173typedef struct { 174 Elf32_Word vna_hash; 175 Elf32_Half vna_flags; 176 Elf32_Half vna_other; 177 Elf32_Word vna_name; 178 Elf32_Word vna_next; 179} Elf32_Vernaux; 180 181typedef struct { 182 Elf64_Half vn_version; 183 Elf64_Half vn_cnt; 184 Elf64_Word vn_file; 185 Elf64_Word vn_aux; 186 Elf64_Word vn_next; 187} Elf64_Verneed; 188 189typedef struct { 190 Elf64_Word vna_hash; 191 Elf64_Half vna_flags; 192 Elf64_Half vna_other; 193 Elf64_Word vna_name; 194 Elf64_Word vna_next; 195} Elf64_Vernaux; 196 197/* Relocation table entry for relative (in section of type SHT_RELR). */ 198typedef Elf32_Word Elf32_Relr; 199typedef Elf64_Xword Elf64_Relr; 200 201/* http://www.sco.com/developers/gabi/latest/ch5.dynamic.html */ 202#define DF_ORIGIN 0x00000001 203#define DF_SYMBOLIC 0x00000002 204#define DF_TEXTREL 0x00000004 205#define DF_BIND_NOW 0x00000008 206#define DF_STATIC_TLS 0x00000010 207 208#define DF_1_NOW 0x00000001 /* Perform complete relocation processing. */ 209#define DF_1_GLOBAL 0x00000002 /* implies RTLD_GLOBAL */ 210#define DF_1_GROUP 0x00000004 211#define DF_1_NODELETE 0x00000008 /* implies RTLD_NODELETE */ 212#define DF_1_LOADFLTR 0x00000010 213#define DF_1_INITFIRST 0x00000020 214#define DF_1_NOOPEN 0x00000040 /* Object can not be used with dlopen(3) */ 215#define DF_1_ORIGIN 0x00000080 216#define DF_1_DIRECT 0x00000100 217#define DF_1_TRANS 0x00000200 218#define DF_1_INTERPOSE 0x00000400 219#define DF_1_NODEFLIB 0x00000800 220#define DF_1_NODUMP 0x00001000 /* Object cannot be dumped with dldump(3) */ 221#define DF_1_CONFALT 0x00002000 222#define DF_1_ENDFILTEE 0x00004000 223#define DF_1_DISPRELDNE 0x00008000 224#define DF_1_DISPRELPND 0x00010000 225#define DF_1_NODIRECT 0x00020000 226#define DF_1_IGNMULDEF 0x00040000 /* Internal use */ 227#define DF_1_NOKSYMS 0x00080000 /* Internal use */ 228#define DF_1_NOHDR 0x00100000 /* Internal use */ 229#define DF_1_EDITED 0x00200000 230#define DF_1_NORELOC 0x00400000 /* Internal use */ 231#define DF_1_SYMINTPOSE 0x00800000 232#define DF_1_GLOBAUDIT 0x01000000 233#define DF_1_SINGLETON 0x02000000 234#define DF_1_STUB 0x04000000 235#define DF_1_PIE 0x08000000 236 237/* http://www.sco.com/developers/gabi/latest/ch5.dynamic.html */ 238#define DT_BIND_NOW 24 239#define DT_INIT_ARRAY 25 240#define DT_FINI_ARRAY 26 241#define DT_INIT_ARRAYSZ 27 242#define DT_FINI_ARRAYSZ 28 243#define DT_RUNPATH 29 244#define DT_FLAGS 30 245/* glibc and BSD disagree for DT_ENCODING; glibc looks wrong. */ 246#define DT_PREINIT_ARRAY 32 247#define DT_PREINIT_ARRAYSZ 33 248 249/* Experimental support for SHT_RELR sections. For details, see proposal 250 at https://groups.google.com/forum/#!topic/generic-abi/bX460iggiKg */ 251#define DT_RELR 0x6fffe000 252#define DT_RELRSZ 0x6fffe001 253#define DT_RELRENT 0x6fffe003 254#define DT_RELRCOUNT 0x6fffe005 255 256/* Android compressed rel/rela sections */ 257#define DT_ANDROID_REL (DT_LOOS + 2) 258#define DT_ANDROID_RELSZ (DT_LOOS + 3) 259#define DT_ANDROID_RELA (DT_LOOS + 4) 260#define DT_ANDROID_RELASZ (DT_LOOS + 5) 261 262#define DT_GNU_HASH 0x6ffffef5 263 264/* http://www.sco.com/developers/gabi/latest/ch4.eheader.html */ 265#define EI_ABIVERSION 8 266#undef EI_PAD 267#define EI_PAD 9 268 269/* http://www.sco.com/developers/gabi/latest/ch4.sheader.html */ 270#define ELFCOMPRESS_ZLIB 1 271#define ELFCOMPRESS_LOOS 0x60000000 272#define ELFCOMPRESS_HIOS 0x6fffffff 273#define ELFCOMPRESS_LOPROC 0x70000000 274#define ELFCOMPRESS_HIPROC 0x7fffffff 275 276/* http://www.sco.com/developers/gabi/latest/ch4.eheader.html */ 277#define ELFOSABI_SYSV 0 /* Synonym for ELFOSABI_NONE used by valgrind. */ 278#define ELFOSABI_HPUX 1 279#define ELFOSABI_NETBSD 2 280#define ELFOSABI_GNU 3 /* Synonym for ELFOSABI_LINUX. */ 281#define ELFOSABI_SOLARIS 6 282#define ELFOSABI_AIX 7 283#define ELFOSABI_IRIX 8 284#define ELFOSABI_FREEBSD 9 285#define ELFOSABI_TRU64 10 286#define ELFOSABI_MODESTO 11 287#define ELFOSABI_OPENBSD 12 288#define ELFOSABI_OPENVMS 13 289#define ELFOSABI_NSK 14 290#define ELFOSABI_AROS 15 291#define ELFOSABI_FENIXOS 16 292#define ELFOSABI_CLOUDABI 17 293#define ELFOSABI_OPENVOS 18 294#define ELFOSABI_ARM_AEABI 64 295 296/* http://www.sco.com/developers/gabi/latest/ch4.reloc.html */ 297#define ELF32_R_INFO(sym, type) ((((Elf32_Word)sym) << 8) | ((type) & 0xff)) 298#define ELF64_R_INFO(sym, type) ((((Elf64_Xword)sym) << 32) | ((type) & 0xffffffff)) 299 300/* http://www.sco.com/developers/gabi/latest/ch4.symtab.html */ 301#undef ELF_ST_TYPE 302#define ELF_ST_TYPE(x) ((x) & 0xf) 303#define ELF_ST_INFO(b,t) (((b) << 4) + ((t) & 0xf)) 304#define ELF32_ST_INFO(b,t) ELF_ST_INFO(b,t) 305#define ELF64_ST_INFO(b,t) ELF_ST_INFO(b,t) 306 307/* http://www.sco.com/developers/gabi/latest/ch4.eheader.html */ 308#define EM_S370 9 309#define EM_VPP500 17 310#define EM_960 19 311#define EM_V800 36 312#define EM_FR20 37 313#define EM_RH32 38 314#define EM_RCE 39 315#define EM_FAKE_ALPHA 41 316#define EM_TRICORE 44 317#define EM_ARC 45 318#define EM_H8_300H 47 319#define EM_H8S 48 320#define EM_H8_500 49 321#define EM_MIPS_X 51 322#define EM_COLDFIRE 52 323#define EM_68HC12 53 324#define EM_MMA 54 325#define EM_PCP 55 326#define EM_NCPU 56 327#define EM_NDR1 57 328#define EM_STARCORE 58 329#define EM_ME16 59 330#define EM_ST100 60 331#define EM_TINYJ 61 332#define EM_PDSP 63 333#define EM_PDP10 64 334#define EM_PDP11 65 335#define EM_FX66 66 336#define EM_ST9PLUS 67 337#define EM_ST7 68 338#define EM_68HC16 69 339#define EM_68HC11 70 340#define EM_68HC08 71 341#define EM_68HC05 72 342#define EM_SVX 73 343#define EM_ST19 74 344#define EM_VAX 75 345#define EM_JAVELIN 77 346#define EM_FIREPATH 78 347#define EM_ZSP 79 348#define EM_MMIX 80 349#define EM_HUANY 81 350#define EM_PRISM 82 351#define EM_AVR 83 352#define EM_FR30 84 353#define EM_D10V 85 354#define EM_D30V 86 355#define EM_V850 87 356#define EM_MN10200 90 357#define EM_PJ 91 358#define EM_ARC_COMPACT 93 359#define EM_XTENSA 94 360#define EM_VIDEOCORE 95 361#define EM_TMM_GPP 96 362#define EM_NS32K 97 363#define EM_TPC 98 364#define EM_SNP1K 99 365#define EM_ST200 100 366#define EM_IP2K 101 367#define EM_MAX 102 368#define EM_CR 103 369#define EM_F2MC16 104 370#define EM_MSP430 105 371#define EM_SE_C33 107 372#define EM_SEP 108 373#define EM_ARCA 109 374#define EM_UNICORE 110 375#define EM_EXCESS 111 376#define EM_DXP 112 377#define EM_CRX 114 378#define EM_XGATE 115 379#define EM_C166 116 380#define EM_M16C 117 381#define EM_DSPIC30F 118 382#define EM_CE 119 383#define EM_M32C 120 384#define EM_TSK3000 131 385#define EM_RS08 132 386#define EM_SHARC 133 387#define EM_ECOG2 134 388#define EM_SCORE7 135 389#define EM_DSP24 136 390#define EM_VIDEOCORE3 137 391#define EM_LATTICEMICO32 138 392#define EM_SE_C17 139 393#define EM_TI_C2000 141 394#define EM_TI_C5500 142 395#define EM_MMDSP_PLUS 160 396#define EM_CYPRESS_M8C 161 397#define EM_R32C 162 398#define EM_TRIMEDIA 163 399#define EM_QDSP6 164 400#define EM_8051 165 401#define EM_STXP7X 166 402#define EM_NDS32 167 403#define EM_ECOG1 168 404#define EM_ECOG1X 168 405#define EM_MAXQ30 169 406#define EM_XIMO16 170 407#define EM_MANIK 171 408#define EM_CRAYNV2 172 409#define EM_RX 173 410#define EM_METAG 174 411#define EM_MCST_ELBRUS 175 412#define EM_ECOG16 176 413#define EM_CR16 177 414#define EM_ETPU 178 415#define EM_SLE9X 179 416#define EM_L10M 180 417#define EM_K10M 181 418#define EM_AVR32 185 419#define EM_STM8 186 420#define EM_TILE64 187 421#define EM_CUDA 190 422#define EM_CLOUDSHIELD 192 423#define EM_COREA_1ST 193 424#define EM_COREA_2ND 194 425#define EM_ARC_COMPACT2 195 426#define EM_OPEN8 196 427#define EM_RL78 197 428#define EM_VIDEOCORE5 198 429#define EM_78KOR 199 430#define EM_56800EX 200 431#define EM_BA1 201 432#define EM_BA2 202 433#define EM_XCORE 203 434#define EM_MCHP_PIC 204 435#define EM_INTEL205 205 436#define EM_INTEL206 206 437#define EM_INTEL207 207 438#define EM_INTEL208 208 439#define EM_INTEL209 209 440#define EM_KM32 210 441#define EM_KMX32 211 442#define EM_KMX16 212 443#define EM_KMX8 213 444#define EM_KVARC 214 445#define EM_CDP 215 446#define EM_COGE 216 447#define EM_COOL 217 448#define EM_NORC 218 449#define EM_CSR_KALIMBA 219 450#define EM_Z80 220 451#define EM_VISIUM 221 452#define EM_FT32 222 453#define EM_MOXIE 223 454#define EM_AMDGPU 224 455#define EM_RISCV 243 456 457/* http://www.sco.com/developers/gabi/latest/ch4.eheader.html */ 458#define ET_LOOS 0xfe00 459#define ET_HIOS 0xfeff 460 461/* http://www.sco.com/developers/gabi/latest/ch4.sheader.html */ 462#define GRP_COMDAT 0x1 463#define GRP_MASKOS 0x0ff00000 464#define GRP_MASKPROC 0xf0000000 465 466/* http://www.sco.com/developers/gabi/latest/ch5.pheader.html */ 467#define PF_X 0x1 468#define PF_W 0x2 469#define PF_R 0x4 470#define PF_MASKOS 0x0ff00000 471#define PF_MASKPROC 0xf0000000 472 473#define PT_GNU_RELRO 0x6474e552 474 475#define STB_LOOS 10 476#define STB_HIOS 12 477#define STB_LOPROC 13 478#define STB_HIPROC 15 479 480/* http://www.sco.com/developers/gabi/latest/ch4.sheader.html */ 481#define SHF_MERGE 0x10 482#define SHF_STRINGS 0x20 483#define SHF_INFO_LINK 0x40 484#define SHF_LINK_ORDER 0x80 485#define SHF_OS_NONCONFORMING 0x100 486#define SHF_GROUP 0x200 487#define SHF_TLS 0x400 488#define SHF_COMPRESSED 0x800 489#define SHF_MASKOS 0x0ff00000 490#define SHF_MASKPROC 0xf0000000 491 492/* http://www.sco.com/developers/gabi/latest/ch4.sheader.html */ 493#define SHN_LOOS 0xff20 494#define SHN_HIOS 0xff3f 495#define SHN_XINDEX 0xffff 496 497/* http://www.sco.com/developers/gabi/latest/ch4.sheader.html */ 498#define SHT_INIT_ARRAY 14 499#define SHT_FINI_ARRAY 15 500#define SHT_PREINIT_ARRAY 16 501#define SHT_GROUP 17 502#define SHT_SYMTAB_SHNDX 18 503#undef SHT_NUM 504#define SHT_NUM 19 505#define SHT_LOOS 0x60000000 506#define SHT_HIOS 0x6fffffff 507 508/* Experimental support for SHT_RELR sections. For details, see proposal 509 at https://groups.google.com/forum/#!topic/generic-abi/bX460iggiKg */ 510#define SHT_RELR 0x6fffff00 511 512/* http://www.sco.com/developers/gabi/latest/ch4.symtab.html */ 513#define STN_UNDEF 0 514 515/* http://www.sco.com/developers/gabi/latest/ch4.symtab.html */ 516#define STT_GNU_IFUNC 10 517#define STT_LOOS 10 518#define STT_HIOS 12 519#define STT_LOPROC 13 520#define STT_HIPROC 15 521 522/* http://www.sco.com/developers/gabi/latest/ch4.symtab.html */ 523#define STV_DEFAULT 0 524#define STV_INTERNAL 1 525#define STV_HIDDEN 2 526#define STV_PROTECTED 3 527 528/* The kernel uses NT_PRFPREG but glibc also offers NT_FPREGSET */ 529#define NT_FPREGSET NT_PRFPREG 530 531#define ELF_NOTE_GNU "GNU" 532 533#define NT_GNU_BUILD_ID 3 534 535#define VER_FLG_BASE 0x1 536#define VER_FLG_WEAK 0x2 537 538#define VER_NDX_LOCAL 0 539#define VER_NDX_GLOBAL 1 540 541#endif /* _ELF_H */ 542