Loading...
Searching...
No Matches
elf.h
1#ifndef _ELF_H
2#define _ELF_H 1
3
4/* Standard ELF types. */
5
6#include <stdint.h>
7
8/* Type for a 16-bit quantity. */
9typedef uint16_t Elf32_Half;
10typedef uint16_t Elf64_Half;
11
12/* Types for signed and unsigned 32-bit quantities. */
13typedef uint32_t Elf32_Word;
14typedef int32_t Elf32_Sword;
15typedef uint32_t Elf64_Word;
16typedef int32_t Elf64_Sword;
17
18/* Types for signed and unsigned 64-bit quantities. */
19typedef uint64_t Elf32_Xword;
20typedef int64_t Elf32_Sxword;
21typedef uint64_t Elf64_Xword;
22typedef int64_t Elf64_Sxword;
23
24/* Type of addresses. */
25typedef uint32_t Elf32_Addr;
26typedef uint64_t Elf64_Addr;
27
28/* Type of file offsets. */
29typedef uint32_t Elf32_Off;
30typedef uint64_t Elf64_Off;
31
32/* Type for section indices, which are 16-bit quantities. */
33typedef uint16_t Elf32_Section;
34typedef uint16_t Elf64_Section;
35
36/* Type for version symbol information. */
37typedef Elf32_Half Elf32_Versym;
38typedef Elf64_Half Elf64_Versym;
39
40/* The ELF file header. This appears at the start of every ELF file. */
41
42#define EI_NIDENT (16)
43
44typedef struct {
45 unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */
46 Elf32_Half e_type; /* Object file type */
47 Elf32_Half e_machine; /* Architecture */
48 Elf32_Word e_version; /* Object file version */
49 Elf32_Addr e_entry; /* Entry point virtual address */
50 Elf32_Off e_phoff; /* Program header table file offset */
51 Elf32_Off e_shoff; /* Section header table file offset */
52 Elf32_Word e_flags; /* Processor-specific flags */
53 Elf32_Half e_ehsize; /* ELF header size in bytes */
54 Elf32_Half e_phentsize; /* Program header table entry size */
55 Elf32_Half e_phnum; /* Program header table entry count */
56 Elf32_Half e_shentsize; /* Section header table entry size */
57 Elf32_Half e_shnum; /* Section header table entry count */
58 Elf32_Half e_shstrndx; /* Section header string table index */
60
61typedef struct {
62 unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */
63 Elf64_Half e_type; /* Object file type */
64 Elf64_Half e_machine; /* Architecture */
65 Elf64_Word e_version; /* Object file version */
66 Elf64_Addr e_entry; /* Entry point virtual address */
67 Elf64_Off e_phoff; /* Program header table file offset */
68 Elf64_Off e_shoff; /* Section header table file offset */
69 Elf64_Word e_flags; /* Processor-specific flags */
70 Elf64_Half e_ehsize; /* ELF header size in bytes */
71 Elf64_Half e_phentsize; /* Program header table entry size */
72 Elf64_Half e_phnum; /* Program header table entry count */
73 Elf64_Half e_shentsize; /* Section header table entry size */
74 Elf64_Half e_shnum; /* Section header table entry count */
75 Elf64_Half e_shstrndx; /* Section header string table index */
77
78/* Fields in the e_ident array. The EI_* macros are indices into the
79 array. The macros under each EI_* macro are the values the byte
80 may have. */
81
82#define EI_MAG0 0 /* File identification byte 0 index */
83#define ELFMAG0 0x7f /* Magic number byte 0 */
84
85#define EI_MAG1 1 /* File identification byte 1 index */
86#define ELFMAG1 'E' /* Magic number byte 1 */
87
88#define EI_MAG2 2 /* File identification byte 2 index */
89#define ELFMAG2 'L' /* Magic number byte 2 */
90
91#define EI_MAG3 3 /* File identification byte 3 index */
92#define ELFMAG3 'F' /* Magic number byte 3 */
93
94/* Conglomeration of the identification bytes, for easy testing as a word. */
95#define ELFMAG "\177ELF"
96#define SELFMAG 4
97
98#define EI_CLASS 4 /* File class byte index */
99#define ELFCLASSNONE 0 /* Invalid class */
100#define ELFCLASS32 1 /* 32-bit objects */
101#define ELFCLASS64 2 /* 64-bit objects */
102#define ELFCLASSNUM 3
103
104#define EI_DATA 5 /* Data encoding byte index */
105#define ELFDATANONE 0 /* Invalid data encoding */
106#define ELFDATA2LSB 1 /* 2's complement, little endian */
107#define ELFDATA2MSB 2 /* 2's complement, big endian */
108#define ELFDATANUM 3
109
110#define EI_VERSION 6 /* File version byte index */
111/* Value must be EV_CURRENT */
112
113#define EI_OSABI 7 /* OS ABI identification */
114#define ELFOSABI_NONE 0 /* UNIX System V ABI */
115#define ELFOSABI_SYSV 0 /* Alias. */
116#define ELFOSABI_HPUX 1 /* HP-UX */
117#define ELFOSABI_NETBSD 2 /* NetBSD. */
118#define ELFOSABI_LINUX 3 /* Linux. */
119#define ELFOSABI_SOLARIS 6 /* Sun Solaris. */
120#define ELFOSABI_AIX 7 /* IBM AIX. */
121#define ELFOSABI_IRIX 8 /* SGI Irix. */
122#define ELFOSABI_FREEBSD 9 /* FreeBSD. */
123#define ELFOSABI_TRU64 10 /* Compaq TRU64 UNIX. */
124#define ELFOSABI_MODESTO 11 /* Novell Modesto. */
125#define ELFOSABI_OPENBSD 12 /* OpenBSD. */
126#define ELFOSABI_ARM 97 /* ARM */
127#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */
128
129#define EI_ABIVERSION 8 /* ABI version */
130
131#define EI_PAD 9 /* Byte index of padding bytes */
132
133/* Legal values for e_type (object file type). */
134
135#define ET_NONE 0 /* No file type */
136#define ET_REL 1 /* Relocatable file */
137#define ET_EXEC 2 /* Executable file */
138#define ET_DYN 3 /* Shared object file */
139#define ET_CORE 4 /* Core file */
140#define ET_NUM 5 /* Number of defined types */
141#define ET_LOOS 0xfe00 /* OS-specific range start */
142#define ET_HIOS 0xfeff /* OS-specific range end */
143#define ET_LOPROC 0xff00 /* Processor-specific range start */
144#define ET_HIPROC 0xffff /* Processor-specific range end */
145
146/* Legal values for e_machine (architecture). */
147
148#define EM_NONE 0 /* No machine */
149#define EM_M32 1 /* AT&T WE 32100 */
150#define EM_SPARC 2 /* SUN SPARC */
151#define EM_386 3 /* Intel 80386 */
152#define EM_68K 4 /* Motorola m68k family */
153#define EM_88K 5 /* Motorola m88k family */
154#define EM_860 7 /* Intel 80860 */
155#define EM_MIPS 8 /* MIPS R3000 big-endian */
156#define EM_S370 9 /* IBM System/370 */
157#define EM_MIPS_RS3_LE 10 /* MIPS R3000 little-endian */
158
159#define EM_PARISC 15 /* HPPA */
160#define EM_VPP500 17 /* Fujitsu VPP500 */
161#define EM_SPARC32PLUS 18 /* Sun's "v8plus" */
162#define EM_960 19 /* Intel 80960 */
163#define EM_PPC 20 /* PowerPC */
164#define EM_PPC64 21 /* PowerPC 64-bit */
165#define EM_S390 22 /* IBM S390 */
166
167#define EM_V800 36 /* NEC V800 series */
168#define EM_FR20 37 /* Fujitsu FR20 */
169#define EM_RH32 38 /* TRW RH-32 */
170#define EM_RCE 39 /* Motorola RCE */
171#define EM_ARM 40 /* ARM */
172#define EM_FAKE_ALPHA 41 /* Digital Alpha */
173#define EM_SH 42 /* Hitachi SH */
174#define EM_SPARCV9 43 /* SPARC v9 64-bit */
175#define EM_TRICORE 44 /* Siemens Tricore */
176#define EM_ARC 45 /* Argonaut RISC Core */
177#define EM_H8_300 46 /* Hitachi H8/300 */
178#define EM_H8_300H 47 /* Hitachi H8/300H */
179#define EM_H8S 48 /* Hitachi H8S */
180#define EM_H8_500 49 /* Hitachi H8/500 */
181#define EM_IA_64 50 /* Intel Merced */
182#define EM_MIPS_X 51 /* Stanford MIPS-X */
183#define EM_COLDFIRE 52 /* Motorola Coldfire */
184#define EM_68HC12 53 /* Motorola M68HC12 */
185#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator*/
186#define EM_PCP 55 /* Siemens PCP */
187#define EM_NCPU 56 /* Sony nCPU embeeded RISC */
188#define EM_NDR1 57 /* Denso NDR1 microprocessor */
189#define EM_STARCORE 58 /* Motorola Start*Core processor */
190#define EM_ME16 59 /* Toyota ME16 processor */
191#define EM_ST100 60 /* STMicroelectronic ST100 processor */
192#define EM_TINYJ 61 /* Advanced Logic Corp. Tinyj emb.fam*/
193#define EM_X86_64 62 /* AMD x86-64 architecture */
194#define EM_PDSP 63 /* Sony DSP Processor */
195
196#define EM_FX66 66 /* Siemens FX66 microcontroller */
197#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 mc */
198#define EM_ST7 68 /* STmicroelectronics ST7 8 bit mc */
199#define EM_68HC16 69 /* Motorola MC68HC16 microcontroller */
200#define EM_68HC11 70 /* Motorola MC68HC11 microcontroller */
201#define EM_68HC08 71 /* Motorola MC68HC08 microcontroller */
202#define EM_68HC05 72 /* Motorola MC68HC05 microcontroller */
203#define EM_SVX 73 /* Silicon Graphics SVx */
204#define EM_ST19 74 /* STMicroelectronics ST19 8 bit mc */
205#define EM_VAX 75 /* Digital VAX */
206#define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */
207#define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded processor */
208#define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */
209#define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */
210#define EM_MMIX 80 /* Donald Knuth's educational 64-bit processor */
211#define EM_HUANY 81 /* Harvard University machine-independent object files */
212#define EM_PRISM 82 /* SiTera Prism */
213#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */
214#define EM_FR30 84 /* Fujitsu FR30 */
215#define EM_D10V 85 /* Mitsubishi D10V */
216#define EM_D30V 86 /* Mitsubishi D30V */
217#define EM_V850 87 /* NEC v850 */
218#define EM_M32R 88 /* Mitsubishi M32R */
219#define EM_MN10300 89 /* Matsushita MN10300 */
220#define EM_MN10200 90 /* Matsushita MN10200 */
221#define EM_PJ 91 /* picoJava */
222#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */
223#define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */
224#define EM_XTENSA 94 /* Tensilica Xtensa Architecture */
225#define EM_NUM 95
226
227/* Legal values for e_version (version). */
228
229#define EV_NONE 0 /* Invalid ELF version */
230#define EV_CURRENT 1 /* Current version */
231#define EV_NUM 2
232
233/* Section header. */
234
235typedef struct {
236 Elf32_Word sh_name; /* Section name (string tbl index) */
237 Elf32_Word sh_type; /* Section type */
238 Elf32_Word sh_flags; /* Section flags */
239 Elf32_Addr sh_addr; /* Section virtual addr at execution */
240 Elf32_Off sh_offset; /* Section file offset */
241 Elf32_Word sh_size; /* Section size in bytes */
242 Elf32_Word sh_link; /* Link to another section */
243 Elf32_Word sh_info; /* Additional section information */
244 Elf32_Word sh_addralign; /* Section alignment */
245 Elf32_Word sh_entsize; /* Entry size if section holds table */
246} Elf32_Shdr;
247
248typedef struct {
249 Elf64_Word sh_name; /* Section name (string tbl index) */
250 Elf64_Word sh_type; /* Section type */
251 Elf64_Xword sh_flags; /* Section flags */
252 Elf64_Addr sh_addr; /* Section virtual addr at execution */
253 Elf64_Off sh_offset; /* Section file offset */
254 Elf64_Xword sh_size; /* Section size in bytes */
255 Elf64_Word sh_link; /* Link to another section */
256 Elf64_Word sh_info; /* Additional section information */
257 Elf64_Xword sh_addralign; /* Section alignment */
258 Elf64_Xword sh_entsize; /* Entry size if section holds table */
259} Elf64_Shdr;
260
261/* Special section indices. */
262
263#define SHN_UNDEF 0 /* Undefined section */
264#define SHN_LORESERVE 0xff00 /* Start of reserved indices */
265#define SHN_LOPROC 0xff00 /* Start of processor-specific */
266#define SHN_BEFORE \
267 0xff00 /* Order section before all others
268 (Solaris). */
269#define SHN_AFTER \
270 0xff01 /* Order section after all others
271 (Solaris). */
272#define SHN_HIPROC 0xff1f /* End of processor-specific */
273#define SHN_LOOS 0xff20 /* Start of OS-specific */
274#define SHN_HIOS 0xff3f /* End of OS-specific */
275#define SHN_ABS 0xfff1 /* Associated symbol is absolute */
276#define SHN_COMMON 0xfff2 /* Associated symbol is common */
277#define SHN_XINDEX 0xffff /* Index is in extra table. */
278#define SHN_HIRESERVE 0xffff /* End of reserved indices */
279
280/* Legal values for sh_type (section type). */
281
282#define SHT_NULL 0 /* Section header table entry unused */
283#define SHT_PROGBITS 1 /* Program data */
284#define SHT_SYMTAB 2 /* Symbol table */
285#define SHT_STRTAB 3 /* String table */
286#define SHT_RELA 4 /* Relocation entries with addends */
287#define SHT_HASH 5 /* Symbol hash table */
288#define SHT_DYNAMIC 6 /* Dynamic linking information */
289#define SHT_NOTE 7 /* Notes */
290#define SHT_NOBITS 8 /* Program space with no data (bss) */
291#define SHT_REL 9 /* Relocation entries, no addends */
292#define SHT_SHLIB 10 /* Reserved */
293#define SHT_DYNSYM 11 /* Dynamic linker symbol table */
294#define SHT_INIT_ARRAY 14 /* Array of constructors */
295#define SHT_FINI_ARRAY 15 /* Array of destructors */
296#define SHT_PREINIT_ARRAY 16 /* Array of pre-constructors */
297#define SHT_GROUP 17 /* Section group */
298#define SHT_SYMTAB_SHNDX 18 /* Extended section indeces */
299#define SHT_NUM 19 /* Number of defined types. */
300#define SHT_LOOS 0x60000000 /* Start OS-specific. */
301#define SHT_GNU_ATTRIBUTES 0x6ffffff5 /* Object attributes. */
302#define SHT_GNU_HASH 0x6ffffff6 /* GNU-style hash table. */
303#define SHT_GNU_LIBLIST 0x6ffffff7 /* Prelink library list */
304#define SHT_CHECKSUM 0x6ffffff8 /* Checksum for DSO content. */
305#define SHT_LOSUNW 0x6ffffffa /* Sun-specific low bound. */
306#define SHT_SUNW_move 0x6ffffffa
307#define SHT_SUNW_COMDAT 0x6ffffffb
308#define SHT_SUNW_syminfo 0x6ffffffc
309#define SHT_GNU_verdef 0x6ffffffd /* Version definition section. */
310#define SHT_GNU_verneed 0x6ffffffe /* Version needs section. */
311#define SHT_GNU_versym 0x6fffffff /* Version symbol table. */
312#define SHT_HISUNW 0x6fffffff /* Sun-specific high bound. */
313#define SHT_HIOS 0x6fffffff /* End OS-specific type */
314#define SHT_LOPROC 0x70000000 /* Start of processor-specific */
315#define SHT_HIPROC 0x7fffffff /* End of processor-specific */
316#define SHT_LOUSER 0x80000000 /* Start of application-specific */
317#define SHT_HIUSER 0x8fffffff /* End of application-specific */
318
319/* Legal values for sh_flags (section flags). */
320
321#define SHF_WRITE (1 << 0) /* Writable */
322#define SHF_ALLOC (1 << 1) /* Occupies memory during execution */
323#define SHF_EXECINSTR (1 << 2) /* Executable */
324#define SHF_MERGE (1 << 4) /* Might be merged */
325#define SHF_STRINGS (1 << 5) /* Contains nul-terminated strings */
326#define SHF_INFO_LINK (1 << 6) /* `sh_info' contains SHT index */
327#define SHF_LINK_ORDER (1 << 7) /* Preserve order after combining */
328#define SHF_OS_NONCONFORMING \
329 (1 << 8) /* Non-standard OS specific handling
330 required */
331#define SHF_GROUP (1 << 9) /* Section is member of a group. */
332#define SHF_TLS (1 << 10) /* Section hold thread-local data. */
333#define SHF_MASKOS 0x0ff00000 /* OS-specific. */
334#define SHF_MASKPROC 0xf0000000 /* Processor-specific */
335#define SHF_ORDERED \
336 (1 << 30) /* Special ordering requirement
337 (Solaris). */
338#define SHF_EXCLUDE \
339 (1 << 31) /* Section is excluded unless
340 referenced or allocated (Solaris).*/
341
342/* Section group handling. */
343#define GRP_COMDAT 0x1 /* Mark group as COMDAT. */
344
345/* Symbol table entry. */
346
347typedef struct {
348 Elf32_Word st_name; /* Symbol name (string tbl index) */
349 Elf32_Addr st_value; /* Symbol value */
350 Elf32_Word st_size; /* Symbol size */
351 unsigned char st_info; /* Symbol type and binding */
352 unsigned char st_other; /* Symbol visibility */
353 Elf32_Section st_shndx; /* Section index */
354} Elf32_Sym;
355
356typedef struct {
357 Elf64_Word st_name; /* Symbol name (string tbl index) */
358 unsigned char st_info; /* Symbol type and binding */
359 unsigned char st_other; /* Symbol visibility */
360 Elf64_Section st_shndx; /* Section index */
361 Elf64_Addr st_value; /* Symbol value */
362 Elf64_Xword st_size; /* Symbol size */
364
365/* The syminfo section if available contains additional information about
366 every dynamic symbol. */
367
368typedef struct {
369 Elf32_Half si_boundto; /* Direct bindings, symbol bound to */
370 Elf32_Half si_flags; /* Per symbol flags */
372
373typedef struct {
374 Elf64_Half si_boundto; /* Direct bindings, symbol bound to */
375 Elf64_Half si_flags; /* Per symbol flags */
377
378/* Possible values for si_boundto. */
379#define SYMINFO_BT_SELF 0xffff /* Symbol bound to self */
380#define SYMINFO_BT_PARENT 0xfffe /* Symbol bound to parent */
381#define SYMINFO_BT_LOWRESERVE 0xff00 /* Beginning of reserved entries */
382
383/* Possible bitmasks for si_flags. */
384#define SYMINFO_FLG_DIRECT 0x0001 /* Direct bound symbol */
385#define SYMINFO_FLG_PASSTHRU 0x0002 /* Pass-thru symbol for translator */
386#define SYMINFO_FLG_COPY 0x0004 /* Symbol is a copy-reloc */
387#define SYMINFO_FLG_LAZYLOAD \
388 0x0008 /* Symbol bound to object to be lazy
389 loaded */
390/* Syminfo version values. */
391#define SYMINFO_NONE 0
392#define SYMINFO_CURRENT 1
393#define SYMINFO_NUM 2
394
395/* How to extract and insert information held in the st_info field. */
396
397#define ELF32_ST_BIND(val) (((unsigned char)(val)) >> 4)
398#define ELF32_ST_TYPE(val) ((val)&0xf)
399#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type)&0xf))
400
401/* Both Elf32_Sym and Elf64_Sym use the same one-byte st_info field. */
402#define ELF64_ST_BIND(val) ELF32_ST_BIND(val)
403#define ELF64_ST_TYPE(val) ELF32_ST_TYPE(val)
404#define ELF64_ST_INFO(bind, type) ELF32_ST_INFO((bind), (type))
405
406/* Legal values for ST_BIND subfield of st_info (symbol binding). */
407
408#define STB_LOCAL 0 /* Local symbol */
409#define STB_GLOBAL 1 /* Global symbol */
410#define STB_WEAK 2 /* Weak symbol */
411#define STB_NUM 3 /* Number of defined types. */
412#define STB_LOOS 10 /* Start of OS-specific */
413#define STB_GNU_UNIQUE 10 /* Unique symbol. */
414#define STB_HIOS 12 /* End of OS-specific */
415#define STB_LOPROC 13 /* Start of processor-specific */
416#define STB_HIPROC 15 /* End of processor-specific */
417
418/* Legal values for ST_TYPE subfield of st_info (symbol type). */
419
420#define STT_NOTYPE 0 /* Symbol type is unspecified */
421#define STT_OBJECT 1 /* Symbol is a data object */
422#define STT_FUNC 2 /* Symbol is a code object */
423#define STT_SECTION 3 /* Symbol associated with a section */
424#define STT_FILE 4 /* Symbol's name is file name */
425#define STT_COMMON 5 /* Symbol is a common data object */
426#define STT_TLS 6 /* Symbol is thread-local data object*/
427#define STT_NUM 7 /* Number of defined types. */
428#define STT_LOOS 10 /* Start of OS-specific */
429#define STT_GNU_IFUNC 10 /* Symbol is indirect code object */
430#define STT_HIOS 12 /* End of OS-specific */
431#define STT_LOPROC 13 /* Start of processor-specific */
432#define STT_HIPROC 15 /* End of processor-specific */
433
434/* Symbol table indices are found in the hash buckets and chain table
435 of a symbol hash table section. This special index value indicates
436 the end of a chain, meaning no further symbols are found in that bucket. */
437
438#define STN_UNDEF 0 /* End of a chain. */
439
440/* How to extract and insert information held in the st_other field. */
441
442#define ELF32_ST_VISIBILITY(o) ((o)&0x03)
443
444/* For ELF64 the definitions are the same. */
445#define ELF64_ST_VISIBILITY(o) ELF32_ST_VISIBILITY(o)
446
447/* Symbol visibility specification encoded in the st_other field. */
448#define STV_DEFAULT 0 /* Default symbol visibility rules */
449#define STV_INTERNAL 1 /* Processor specific hidden class */
450#define STV_HIDDEN 2 /* Sym unavailable in other modules */
451#define STV_PROTECTED 3 /* Not preemptible, not exported */
452
453/* Relocation table entry without addend (in section of type SHT_REL). */
454
455typedef struct {
456 Elf32_Addr r_offset; /* Address */
457 Elf32_Word r_info; /* Relocation type and symbol index */
458} Elf32_Rel;
460/* I have seen two different definitions of the Elf64_Rel and
461 Elf64_Rela structures, so we'll leave them out until Novell (or
462 whoever) gets their act together. */
463/* The following, at least, is used on Sparc v9, MIPS, and Alpha. */
464
465typedef struct {
466 Elf64_Addr r_offset; /* Address */
467 Elf64_Xword r_info; /* Relocation type and symbol index */
468} Elf64_Rel;
469
470/* Relocation table entry with addend (in section of type SHT_RELA). */
471
472typedef struct {
473 Elf32_Addr r_offset; /* Address */
474 Elf32_Word r_info; /* Relocation type and symbol index */
475 Elf32_Sword r_addend; /* Addend */
476} Elf32_Rela;
477
478typedef struct {
479 Elf64_Addr r_offset; /* Address */
480 Elf64_Xword r_info; /* Relocation type and symbol index */
481 Elf64_Sxword r_addend; /* Addend */
482} Elf64_Rela;
483
484/* How to extract and insert information held in the r_info field. */
485
486#define ELF32_R_SYM(val) ((val) >> 8)
487#define ELF32_R_TYPE(val) ((val)&0xff)
488#define ELF32_R_INFO(sym, type) (((sym) << 8) + ((type)&0xff))
489
490#define ELF64_R_SYM(i) ((i) >> 32)
491#define ELF64_R_TYPE(i) ((i)&0xffffffff)
492#define ELF64_R_INFO(sym, type) ((((Elf64_Xword)(sym)) << 32) + (type))
493
494/* Program segment header. */
495
496typedef struct {
497 Elf32_Word p_type; /* Segment type */
498 Elf32_Off p_offset; /* Segment file offset */
499 Elf32_Addr p_vaddr; /* Segment virtual address */
500 Elf32_Addr p_paddr; /* Segment physical address */
501 Elf32_Word p_filesz; /* Segment size in file */
502 Elf32_Word p_memsz; /* Segment size in memory */
503 Elf32_Word p_flags; /* Segment flags */
504 Elf32_Word p_align; /* Segment alignment */
505} Elf32_Phdr;
506
507typedef struct {
508 Elf64_Word p_type; /* Segment type */
509 Elf64_Word p_flags; /* Segment flags */
510 Elf64_Off p_offset; /* Segment file offset */
511 Elf64_Addr p_vaddr; /* Segment virtual address */
512 Elf64_Addr p_paddr; /* Segment physical address */
513 Elf64_Xword p_filesz; /* Segment size in file */
514 Elf64_Xword p_memsz; /* Segment size in memory */
515 Elf64_Xword p_align; /* Segment alignment */
516} Elf64_Phdr;
517
518/* Legal values for p_type (segment type). */
519
520#define PT_NULL 0 /* Program header table entry unused */
521#define PT_LOAD 1 /* Loadable program segment */
522#define PT_DYNAMIC 2 /* Dynamic linking information */
523#define PT_INTERP 3 /* Program interpreter */
524#define PT_NOTE 4 /* Auxiliary information */
525#define PT_SHLIB 5 /* Reserved */
526#define PT_PHDR 6 /* Entry for header table itself */
527#define PT_TLS 7 /* Thread-local storage segment */
528#define PT_NUM 8 /* Number of defined types */
529#define PT_LOOS 0x60000000 /* Start of OS-specific */
530#define PT_GNU_EH_FRAME 0x6474e550 /* GCC .eh_frame_hdr segment */
531#define PT_GNU_STACK 0x6474e551 /* Indicates stack executability */
532#define PT_GNU_RELRO 0x6474e552 /* Read-only after relocation */
533#define PT_LOSUNW 0x6ffffffa
534#define PT_SUNWBSS 0x6ffffffa /* Sun Specific segment */
535#define PT_SUNWSTACK 0x6ffffffb /* Stack segment */
536#define PT_HISUNW 0x6fffffff
537#define PT_HIOS 0x6fffffff /* End of OS-specific */
538#define PT_LOPROC 0x70000000 /* Start of processor-specific */
539#define PT_HIPROC 0x7fffffff /* End of processor-specific */
540
541/* Legal values for p_flags (segment flags). */
542
543#define PF_X (1 << 0) /* Segment is executable */
544#define PF_W (1 << 1) /* Segment is writable */
545#define PF_R (1 << 2) /* Segment is readable */
546#define PF_MASKOS 0x0ff00000 /* OS-specific */
547#define PF_MASKPROC 0xf0000000 /* Processor-specific */
548
549/* Legal values for note segment descriptor types for core files. */
550
551#define NT_PRSTATUS 1 /* Contains copy of prstatus struct */
552#define NT_FPREGSET 2 /* Contains copy of fpregset struct */
553#define NT_PRPSINFO 3 /* Contains copy of prpsinfo struct */
554#define NT_PRXREG 4 /* Contains copy of prxregset struct */
555#define NT_TASKSTRUCT 4 /* Contains copy of task structure */
556#define NT_PLATFORM 5 /* String from sysinfo(SI_PLATFORM) */
557#define NT_AUXV 6 /* Contains copy of auxv array */
558#define NT_GWINDOWS 7 /* Contains copy of gwindows struct */
559#define NT_ASRS 8 /* Contains copy of asrset struct */
560#define NT_PSTATUS 10 /* Contains copy of pstatus struct */
561#define NT_PSINFO 13 /* Contains copy of psinfo struct */
562#define NT_PRCRED 14 /* Contains copy of prcred struct */
563#define NT_UTSNAME 15 /* Contains copy of utsname struct */
564#define NT_LWPSTATUS 16 /* Contains copy of lwpstatus struct */
565#define NT_LWPSINFO 17 /* Contains copy of lwpinfo struct */
566#define NT_PRFPXREG 20 /* Contains copy of fprxregset struct */
567#define NT_PRXFPREG 0x46e62b7f /* Contains copy of user_fxsr_struct */
568#define NT_PPC_VMX 0x100 /* PowerPC Altivec/VMX registers */
569#define NT_PPC_SPE 0x101 /* PowerPC SPE/EVR registers */
570#define NT_PPC_VSX 0x102 /* PowerPC VSX registers */
571#define NT_386_TLS 0x200 /* i386 TLS slots (struct user_desc) */
572#define NT_386_IOPERM 0x201 /* x86 io permission bitmap (1=deny) */
573
574/* Legal values for the note segment descriptor types for object files. */
575
576#define NT_VERSION 1 /* Contains a version string. */
577
578/* Dynamic section entry. */
579
580typedef struct {
581 Elf32_Sword d_tag; /* Dynamic entry type */
582 union {
583 Elf32_Word d_val; /* Integer value */
584 Elf32_Addr d_ptr; /* Address value */
585 } d_un;
586} Elf32_Dyn;
587
588typedef struct {
589 Elf64_Sxword d_tag; /* Dynamic entry type */
590 union {
591 Elf64_Xword d_val; /* Integer value */
592 Elf64_Addr d_ptr; /* Address value */
593 } d_un;
594} Elf64_Dyn;
595
596/* Legal values for d_tag (dynamic entry type). */
597
598#define DT_NULL 0 /* Marks end of dynamic section */
599#define DT_NEEDED 1 /* Name of needed library */
600#define DT_PLTRELSZ 2 /* Size in bytes of PLT relocs */
601#define DT_PLTGOT 3 /* Processor defined value */
602#define DT_HASH 4 /* Address of symbol hash table */
603#define DT_STRTAB 5 /* Address of string table */
604#define DT_SYMTAB 6 /* Address of symbol table */
605#define DT_RELA 7 /* Address of Rela relocs */
606#define DT_RELASZ 8 /* Total size of Rela relocs */
607#define DT_RELAENT 9 /* Size of one Rela reloc */
608#define DT_STRSZ 10 /* Size of string table */
609#define DT_SYMENT 11 /* Size of one symbol table entry */
610#define DT_INIT 12 /* Address of init function */
611#define DT_FINI 13 /* Address of termination function */
612#define DT_SONAME 14 /* Name of shared object */
613#define DT_RPATH 15 /* Library search path (deprecated) */
614#define DT_SYMBOLIC 16 /* Start symbol search here */
615#define DT_REL 17 /* Address of Rel relocs */
616#define DT_RELSZ 18 /* Total size of Rel relocs */
617#define DT_RELENT 19 /* Size of one Rel reloc */
618#define DT_PLTREL 20 /* Type of reloc in PLT */
619#define DT_DEBUG 21 /* For debugging; unspecified */
620#define DT_TEXTREL 22 /* Reloc might modify .text */
621#define DT_JMPREL 23 /* Address of PLT relocs */
622#define DT_BIND_NOW 24 /* Process relocations of object */
623#define DT_INIT_ARRAY 25 /* Array with addresses of init fct */
624#define DT_FINI_ARRAY 26 /* Array with addresses of fini fct */
625#define DT_INIT_ARRAYSZ 27 /* Size in bytes of DT_INIT_ARRAY */
626#define DT_FINI_ARRAYSZ 28 /* Size in bytes of DT_FINI_ARRAY */
627#define DT_RUNPATH 29 /* Library search path */
628#define DT_FLAGS 30 /* Flags for the object being loaded */
629#define DT_ENCODING 32 /* Start of encoded range */
630#define DT_PREINIT_ARRAY 32 /* Array with addresses of preinit fct*/
631#define DT_PREINIT_ARRAYSZ 33 /* size in bytes of DT_PREINIT_ARRAY */
632#define DT_NUM 34 /* Number used */
633#define DT_LOOS 0x6000000d /* Start of OS-specific */
634#define DT_HIOS 0x6ffff000 /* End of OS-specific */
635#define DT_LOPROC 0x70000000 /* Start of processor-specific */
636#define DT_HIPROC 0x7fffffff /* End of processor-specific */
637#define DT_PROCNUM DT_MIPS_NUM /* Most used by any processor */
638
639/* DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the
640 Dyn.d_un.d_val field of the Elf*_Dyn structure. This follows Sun's
641 approach. */
642#define DT_VALRNGLO 0x6ffffd00
643#define DT_GNU_PRELINKED 0x6ffffdf5 /* Prelinking timestamp */
644#define DT_GNU_CONFLICTSZ 0x6ffffdf6 /* Size of conflict section */
645#define DT_GNU_LIBLISTSZ 0x6ffffdf7 /* Size of library list */
646#define DT_CHECKSUM 0x6ffffdf8
647#define DT_PLTPADSZ 0x6ffffdf9
648#define DT_MOVEENT 0x6ffffdfa
649#define DT_MOVESZ 0x6ffffdfb
650#define DT_FEATURE_1 0x6ffffdfc /* Feature selection (DTF_*). */
651#define DT_POSFLAG_1 \
652 0x6ffffdfd /* Flags for DT_* entries, effecting
653 the following DT_* entry. */
654#define DT_SYMINSZ 0x6ffffdfe /* Size of syminfo table (in bytes) */
655#define DT_SYMINENT 0x6ffffdff /* Entry size of syminfo */
656#define DT_VALRNGHI 0x6ffffdff
657#define DT_VALTAGIDX(tag) (DT_VALRNGHI - (tag)) /* Reverse order! */
658#define DT_VALNUM 12
659
660/* DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the
661 Dyn.d_un.d_ptr field of the Elf*_Dyn structure.
662
663 If any adjustment is made to the ELF object after it has been
664 built these entries will need to be adjusted. */
665#define DT_ADDRRNGLO 0x6ffffe00
666#define DT_GNU_HASH 0x6ffffef5 /* GNU-style hash table. */
667#define DT_TLSDESC_PLT 0x6ffffef6
668#define DT_TLSDESC_GOT 0x6ffffef7
669#define DT_GNU_CONFLICT 0x6ffffef8 /* Start of conflict section */
670#define DT_GNU_LIBLIST 0x6ffffef9 /* Library list */
671#define DT_CONFIG 0x6ffffefa /* Configuration information. */
672#define DT_DEPAUDIT 0x6ffffefb /* Dependency auditing. */
673#define DT_AUDIT 0x6ffffefc /* Object auditing. */
674#define DT_PLTPAD 0x6ffffefd /* PLT padding. */
675#define DT_MOVETAB 0x6ffffefe /* Move table. */
676#define DT_SYMINFO 0x6ffffeff /* Syminfo table. */
677#define DT_ADDRRNGHI 0x6ffffeff
678#define DT_ADDRTAGIDX(tag) (DT_ADDRRNGHI - (tag)) /* Reverse order! */
679#define DT_ADDRNUM 11
680
681/* The versioning entry types. The next are defined as part of the
682 GNU extension. */
683#define DT_VERSYM 0x6ffffff0
684
685#define DT_RELACOUNT 0x6ffffff9
686#define DT_RELCOUNT 0x6ffffffa
687
688/* These were chosen by Sun. */
689#define DT_FLAGS_1 0x6ffffffb /* State flags, see DF_1_* below. */
690#define DT_VERDEF \
691 0x6ffffffc /* Address of version definition
692 table */
693#define DT_VERDEFNUM 0x6ffffffd /* Number of version definitions */
694#define DT_VERNEED \
695 0x6ffffffe /* Address of table with needed
696 versions */
697#define DT_VERNEEDNUM 0x6fffffff /* Number of needed versions */
698#define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */
699#define DT_VERSIONTAGNUM 16
700
701/* Sun added these machine-independent extensions in the "processor-specific"
702 range. Be compatible. */
703#define DT_AUXILIARY 0x7ffffffd /* Shared object to load before self */
704#define DT_FILTER 0x7fffffff /* Shared object to get values from */
705#define DT_EXTRATAGIDX(tag) ((Elf32_Word) - ((Elf32_Sword)(tag) << 1 >> 1) - 1)
706#define DT_EXTRANUM 3
707
708/* Values of `d_un.d_val' in the DT_FLAGS entry. */
709#define DF_ORIGIN 0x00000001 /* Object may use DF_ORIGIN */
710#define DF_SYMBOLIC 0x00000002 /* Symbol resolutions starts here */
711#define DF_TEXTREL 0x00000004 /* Object contains text relocations */
712#define DF_BIND_NOW 0x00000008 /* No lazy binding for this object */
713#define DF_STATIC_TLS 0x00000010 /* Module uses the static TLS model */
714
715/* State flags selectable in the `d_un.d_val' element of the DT_FLAGS_1
716 entry in the dynamic section. */
717#define DF_1_NOW 0x00000001 /* Set RTLD_NOW for this object. */
718#define DF_1_GLOBAL 0x00000002 /* Set RTLD_GLOBAL for this object. */
719#define DF_1_GROUP 0x00000004 /* Set RTLD_GROUP for this object. */
720#define DF_1_NODELETE 0x00000008 /* Set RTLD_NODELETE for this object.*/
721#define DF_1_LOADFLTR 0x00000010 /* Trigger filtee loading at runtime.*/
722#define DF_1_INITFIRST 0x00000020 /* Set RTLD_INITFIRST for this object*/
723#define DF_1_NOOPEN 0x00000040 /* Set RTLD_NOOPEN for this object. */
724#define DF_1_ORIGIN 0x00000080 /* $ORIGIN must be handled. */
725#define DF_1_DIRECT 0x00000100 /* Direct binding enabled. */
726#define DF_1_TRANS 0x00000200
727#define DF_1_INTERPOSE 0x00000400 /* Object is used to interpose. */
728#define DF_1_NODEFLIB 0x00000800 /* Ignore default lib search path. */
729#define DF_1_NODUMP 0x00001000 /* Object can't be dldump'ed. */
730#define DF_1_CONFALT 0x00002000 /* Configuration alternative created.*/
731#define DF_1_ENDFILTEE 0x00004000 /* Filtee terminates filters search. */
732#define DF_1_DISPRELDNE 0x00008000 /* Disp reloc applied at build time. */
733#define DF_1_DISPRELPND 0x00010000 /* Disp reloc applied at run-time. */
734
735/* Flags for the feature selection in DT_FEATURE_1. */
736#define DTF_1_PARINIT 0x00000001
737#define DTF_1_CONFEXP 0x00000002
738
739/* Flags in the DT_POSFLAG_1 entry effecting only the next DT_* entry. */
740#define DF_P1_LAZYLOAD 0x00000001 /* Lazyload following object. */
741#define DF_P1_GROUPPERM \
742 0x00000002 /* Symbols from next object are not
743 generally available. */
744
745/* Version definition sections. */
746
747typedef struct {
748 Elf32_Half vd_version; /* Version revision */
749 Elf32_Half vd_flags; /* Version information */
750 Elf32_Half vd_ndx; /* Version Index */
751 Elf32_Half vd_cnt; /* Number of associated aux entries */
752 Elf32_Word vd_hash; /* Version name hash value */
753 Elf32_Word vd_aux; /* Offset in bytes to verdaux array */
754 Elf32_Word vd_next; /* Offset in bytes to next verdef
755 entry */
757
758typedef struct {
759 Elf64_Half vd_version; /* Version revision */
760 Elf64_Half vd_flags; /* Version information */
761 Elf64_Half vd_ndx; /* Version Index */
762 Elf64_Half vd_cnt; /* Number of associated aux entries */
763 Elf64_Word vd_hash; /* Version name hash value */
764 Elf64_Word vd_aux; /* Offset in bytes to verdaux array */
765 Elf64_Word vd_next; /* Offset in bytes to next verdef
766 entry */
768
769/* Legal values for vd_version (version revision). */
770#define VER_DEF_NONE 0 /* No version */
771#define VER_DEF_CURRENT 1 /* Current version */
772#define VER_DEF_NUM 2 /* Given version number */
773
774/* Legal values for vd_flags (version information flags). */
775#define VER_FLG_BASE 0x1 /* Version definition of file itself */
776#define VER_FLG_WEAK 0x2 /* Weak version identifier */
777
778/* Versym symbol index values. */
779#define VER_NDX_LOCAL 0 /* Symbol is local. */
780#define VER_NDX_GLOBAL 1 /* Symbol is global. */
781#define VER_NDX_LORESERVE 0xff00 /* Beginning of reserved entries. */
782#define VER_NDX_ELIMINATE 0xff01 /* Symbol is to be eliminated. */
783
784/* Auxialiary version information. */
785
786typedef struct {
787 Elf32_Word vda_name; /* Version or dependency names */
788 Elf32_Word vda_next; /* Offset in bytes to next verdaux
789 entry */
791
792typedef struct {
793 Elf64_Word vda_name; /* Version or dependency names */
794 Elf64_Word vda_next; /* Offset in bytes to next verdaux
795 entry */
797
798/* Version dependency section. */
799
800typedef struct {
801 Elf32_Half vn_version; /* Version of structure */
802 Elf32_Half vn_cnt; /* Number of associated aux entries */
803 Elf32_Word vn_file; /* Offset of filename for this
804 dependency */
805 Elf32_Word vn_aux; /* Offset in bytes to vernaux array */
806 Elf32_Word vn_next; /* Offset in bytes to next verneed
807 entry */
809
810typedef struct {
811 Elf64_Half vn_version; /* Version of structure */
812 Elf64_Half vn_cnt; /* Number of associated aux entries */
813 Elf64_Word vn_file; /* Offset of filename for this
814 dependency */
815 Elf64_Word vn_aux; /* Offset in bytes to vernaux array */
816 Elf64_Word vn_next; /* Offset in bytes to next verneed
817 entry */
819
820/* Legal values for vn_version (version revision). */
821#define VER_NEED_NONE 0 /* No version */
822#define VER_NEED_CURRENT 1 /* Current version */
823#define VER_NEED_NUM 2 /* Given version number */
824
825/* Auxiliary needed version information. */
827typedef struct {
828 Elf32_Word vna_hash; /* Hash value of dependency name */
829 Elf32_Half vna_flags; /* Dependency specific information */
830 Elf32_Half vna_other; /* Unused */
831 Elf32_Word vna_name; /* Dependency name string offset */
832 Elf32_Word vna_next; /* Offset in bytes to next vernaux
833 entry */
835
836typedef struct {
837 Elf64_Word vna_hash; /* Hash value of dependency name */
838 Elf64_Half vna_flags; /* Dependency specific information */
839 Elf64_Half vna_other; /* Unused */
840 Elf64_Word vna_name; /* Dependency name string offset */
841 Elf64_Word vna_next; /* Offset in bytes to next vernaux
842 entry */
844
845/* Legal values for vna_flags. */
846#define VER_FLG_WEAK 0x2 /* Weak version identifier */
848/* Auxiliary vector. */
849
850/* This vector is normally only used by the program interpreter. The
851 usual definition in an ABI supplement uses the name auxv_t. The
852 vector is not usually defined in a standard <elf.h> file, but it
853 can't hurt. We rename it to avoid conflicts. The sizes of these
854 types are an arrangement between the exec server and the program
855 interpreter, so we don't fully specify them here. */
856
857typedef struct {
858 uint32_t a_type; /* Entry type */
859 union {
860 uint32_t a_val; /* Integer value */
861 /* We use to have pointer elements added here. We cannot do that,
862 though, since it does not work when using 32-bit definitions
863 on 64-bit platforms and vice versa. */
864 } a_un;
866
867typedef struct {
868 uint64_t a_type; /* Entry type */
869 union {
870 uint64_t a_val; /* Integer value */
871 /* We use to have pointer elements added here. We cannot do that,
872 though, since it does not work when using 32-bit definitions
873 on 64-bit platforms and vice versa. */
874 } a_un;
876
877/* Legal values for a_type (entry type). */
878
879#define AT_NULL 0 /* End of vector */
880#define AT_IGNORE 1 /* Entry should be ignored */
881#define AT_EXECFD 2 /* File descriptor of program */
882#define AT_PHDR 3 /* Program headers for program */
883#define AT_PHENT 4 /* Size of program header entry */
884#define AT_PHNUM 5 /* Number of program headers */
885#define AT_PAGESZ 6 /* System page size */
886#define AT_BASE 7 /* Base address of interpreter */
887#define AT_FLAGS 8 /* Flags */
888#define AT_ENTRY 9 /* Entry point of program */
889#define AT_NOTELF 10 /* Program is not ELF */
890#define AT_UID 11 /* Real uid */
891#define AT_EUID 12 /* Effective uid */
892#define AT_GID 13 /* Real gid */
893#define AT_EGID 14 /* Effective gid */
894#define AT_CLKTCK 17 /* Frequency of times() */
895
896/* Some more special a_type values describing the hardware. */
897#define AT_PLATFORM 15 /* String identifying platform. */
898#define AT_HWCAP \
899 16 /* Machine dependent hints about
900 processor capabilities. */
901
902/* This entry gives some information about the FPU initialization
903 performed by the kernel. */
904#define AT_FPUCW 18 /* Used FPU control word. */
905
906/* Cache block sizes. */
907#define AT_DCACHEBSIZE 19 /* Data cache block size. */
908#define AT_ICACHEBSIZE 20 /* Instruction cache block size. */
909#define AT_UCACHEBSIZE 21 /* Unified cache block size. */
910
911/* A special ignored value for PPC, used by the kernel to control the
912 interpretation of the AUXV. Must be > 16. */
913#define AT_IGNOREPPC 22 /* Entry should be ignored. */
914
915#define AT_SECURE 23 /* Boolean, was exec setuid-like? */
916
917#define AT_BASE_PLATFORM 24 /* String identifying real platforms.*/
918
919#define AT_RANDOM 25 /* Address of 16 random bytes. */
920
921#define AT_EXECFN 31 /* Filename of executable. */
922
923/* Pointer to the global system page used for system calls and other
924 nice things. */
925#define AT_SYSINFO 32
926#define AT_SYSINFO_EHDR 33
928/* Shapes of the caches. Bits 0-3 contains associativity; bits 4-7 contains
929 log2 of line size; mask those to get cache size. */
930#define AT_L1I_CACHESHAPE 34
931#define AT_L1D_CACHESHAPE 35
932#define AT_L2_CACHESHAPE 36
933#define AT_L3_CACHESHAPE 37
934
935/* Note section contents. Each entry in the note section begins with
936 a header of a fixed form. */
937
938typedef struct {
939 Elf32_Word n_namesz; /* Length of the note's name. */
940 Elf32_Word n_descsz; /* Length of the note's descriptor. */
941 Elf32_Word n_type; /* Type of the note. */
942} Elf32_Nhdr;
943
944typedef struct {
945 Elf64_Word n_namesz; /* Length of the note's name. */
946 Elf64_Word n_descsz; /* Length of the note's descriptor. */
947 Elf64_Word n_type; /* Type of the note. */
948} Elf64_Nhdr;
949
950/* Known names of notes. */
951
952/* Solaris entries in the note section have this name. */
953#define ELF_NOTE_SOLARIS "SUNW Solaris"
954
955/* Note entries for GNU systems have this name. */
956#define ELF_NOTE_GNU "GNU"
957
958/* Defined types of notes for Solaris. */
959
960/* Value of descriptor (one word) is desired pagesize for the binary. */
961#define ELF_NOTE_PAGESIZE_HINT 1
962
963/* Defined note types for GNU systems. */
964
965/* ABI information. The descriptor consists of words:
966 word 0: OS descriptor
967 word 1: major version of the ABI
968 word 2: minor version of the ABI
969 word 3: subminor version of the ABI
970*/
971#define NT_GNU_ABI_TAG 1
972#define ELF_NOTE_ABI NT_GNU_ABI_TAG /* Old name. */
973
974/* Known OSes. These values can appear in word 0 of an
975 NT_GNU_ABI_TAG note section entry. */
976#define ELF_NOTE_OS_LINUX 0
977#define ELF_NOTE_OS_GNU 1
978#define ELF_NOTE_OS_SOLARIS2 2
979#define ELF_NOTE_OS_FREEBSD 3
980
981/* Synthetic hwcap information. The descriptor begins with two words:
982 word 0: number of entries
983 word 1: bitmask of enabled entries
984 Then follow variable-length entries, one byte followed by a
985 '\0'-terminated hwcap name string. The byte gives the bit
986 number to test if enabled, (1U << bit) & bitmask. */
987#define NT_GNU_HWCAP 2
988
989/* Build ID bits as generated by ld --build-id.
990 The descriptor consists of any nonzero number of bytes. */
991#define NT_GNU_BUILD_ID 3
992
993/* Version note generated by GNU gold containing a version string. */
994#define NT_GNU_GOLD_VERSION 4
995
996/* Move records. */
997typedef struct {
998 Elf32_Xword m_value; /* Symbol value. */
999 Elf32_Word m_info; /* Size and index. */
1000 Elf32_Word m_poffset; /* Symbol offset. */
1001 Elf32_Half m_repeat; /* Repeat count. */
1002 Elf32_Half m_stride; /* Stride info. */
1003} Elf32_Move;
1004
1005typedef struct {
1006 Elf64_Xword m_value; /* Symbol value. */
1007 Elf64_Xword m_info; /* Size and index. */
1008 Elf64_Xword m_poffset; /* Symbol offset. */
1009 Elf64_Half m_repeat; /* Repeat count. */
1010 Elf64_Half m_stride; /* Stride info. */
1011} Elf64_Move;
1012
1013/* Macro to construct move records. */
1014#define ELF32_M_SYM(info) ((info) >> 8)
1015#define ELF32_M_SIZE(info) ((unsigned char)(info))
1016#define ELF32_M_INFO(sym, size) (((sym) << 8) + (unsigned char)(size))
1017
1018#define ELF64_M_SYM(info) ELF32_M_SYM(info)
1019#define ELF64_M_SIZE(info) ELF32_M_SIZE(info)
1020#define ELF64_M_INFO(sym, size) ELF32_M_INFO(sym, size)
1021
1022/* ARM specific declarations */
1023
1024/* Processor specific flags for the ELF header e_flags field. */
1025#define EF_ARM_RELEXEC 0x01
1026#define EF_ARM_HASENTRY 0x02
1027#define EF_ARM_INTERWORK 0x04
1028#define EF_ARM_APCS_26 0x08
1029#define EF_ARM_APCS_FLOAT 0x10
1030#define EF_ARM_PIC 0x20
1031#define EF_ARM_ALIGN8 0x40 /* 8-bit structure alignment is in use */
1032#define EF_ARM_NEW_ABI 0x80
1033#define EF_ARM_OLD_ABI 0x100
1034#define EF_ARM_SOFT_FLOAT 0x200
1035#define EF_ARM_VFP_FLOAT 0x400
1036#define EF_ARM_MAVERICK_FLOAT 0x800
1037
1038/* Other constants defined in the ARM ELF spec. version B-01. */
1039/* NB. These conflict with values defined above. */
1040#define EF_ARM_SYMSARESORTED 0x04
1041#define EF_ARM_DYNSYMSUSESEGIDX 0x08
1042#define EF_ARM_MAPSYMSFIRST 0x10
1043#define EF_ARM_EABIMASK 0XFF000000
1044
1045/* Constants defined in AAELF. */
1046#define EF_ARM_BE8 0x00800000
1047#define EF_ARM_LE8 0x00400000
1048
1049#define EF_ARM_EABI_VERSION(flags) ((flags)&EF_ARM_EABIMASK)
1050#define EF_ARM_EABI_UNKNOWN 0x00000000
1051#define EF_ARM_EABI_VER1 0x01000000
1052#define EF_ARM_EABI_VER2 0x02000000
1053#define EF_ARM_EABI_VER3 0x03000000
1054#define EF_ARM_EABI_VER4 0x04000000
1055#define EF_ARM_EABI_VER5 0x05000000
1056
1057/* Additional symbol types for Thumb. */
1058#define STT_ARM_TFUNC STT_LOPROC /* A Thumb function. */
1059#define STT_ARM_16BIT STT_HIPROC /* A Thumb label. */
1060
1061/* ARM-specific values for sh_flags */
1062#define SHF_ARM_ENTRYSECT 0x10000000 /* Section contains an entry point */
1063#define SHF_ARM_COMDEF \
1064 0x80000000 /* Section may be multiply defined
1065 in the input to a link step. */
1066
1067/* ARM-specific program header flags */
1068#define PF_ARM_SB \
1069 0x10000000 /* Segment contains the location
1070 addressed by the static base. */
1071#define PF_ARM_PI 0x20000000 /* Position-independent segment. */
1072#define PF_ARM_ABS 0x40000000 /* Absolute segment. */
1073
1074/* Processor specific values for the Phdr p_type field. */
1075#define PT_ARM_EXIDX (PT_LOPROC + 1) /* ARM unwind segment. */
1076
1077/* Processor specific values for the Shdr sh_type field. */
1078#define SHT_ARM_EXIDX (SHT_LOPROC + 1) /* ARM unwind section. */
1079#define SHT_ARM_PREEMPTMAP (SHT_LOPROC + 2) /* Preemption details. */
1080#define SHT_ARM_ATTRIBUTES (SHT_LOPROC + 3) /* ARM attributes section. */
1081
1082/* ARM relocs. */
1083
1084#define R_ARM_NONE 0 /* No reloc */
1085#define R_ARM_PC24 1 /* PC relative 26 bit branch */
1086#define R_ARM_ABS32 2 /* Direct 32 bit */
1087#define R_ARM_REL32 3 /* PC relative 32 bit */
1088#define R_ARM_PC13 4
1089#define R_ARM_ABS16 5 /* Direct 16 bit */
1090#define R_ARM_ABS12 6 /* Direct 12 bit */
1091#define R_ARM_THM_ABS5 7
1092#define R_ARM_ABS8 8 /* Direct 8 bit */
1093#define R_ARM_SBREL32 9
1094#define R_ARM_THM_PC22 10
1095#define R_ARM_THM_PC8 11
1096#define R_ARM_AMP_VCALL9 12
1097#define R_ARM_SWI24 13
1098#define R_ARM_THM_SWI8 14
1099#define R_ARM_XPC25 15
1100#define R_ARM_THM_XPC22 16
1101#define R_ARM_TLS_DTPMOD32 17 /* ID of module containing symbol */
1102#define R_ARM_TLS_DTPOFF32 18 /* Offset in TLS block */
1103#define R_ARM_TLS_TPOFF32 19 /* Offset in static TLS block */
1104#define R_ARM_COPY 20 /* Copy symbol at runtime */
1105#define R_ARM_GLOB_DAT 21 /* Create GOT entry */
1106#define R_ARM_JUMP_SLOT 22 /* Create PLT entry */
1107#define R_ARM_RELATIVE 23 /* Adjust by program base */
1108#define R_ARM_GOTOFF 24 /* 32 bit offset to GOT */
1109#define R_ARM_GOTPC 25 /* 32 bit PC relative offset to GOT */
1110#define R_ARM_GOT32 26 /* 32 bit GOT entry */
1111#define R_ARM_PLT32 27 /* 32 bit PLT address */
1112#define R_ARM_THM_JUMP24 30 /* Thumb32 ((S + A) | T) - P */
1113#define R_ARM_ALU_PCREL_7_0 32
1114#define R_ARM_ALU_PCREL_15_8 33
1115#define R_ARM_ALU_PCREL_23_15 34
1116#define R_ARM_LDR_SBREL_11_0 35
1117#define R_ARM_ALU_SBREL_19_12 36
1118#define R_ARM_ALU_SBREL_27_20 37
1119#define R_ARM_THM_MOVW_ABS_NC 47 /* Direct 16 bit (Thumb32 MOVW) */
1120#define R_ARM_THM_MOVT_ABS 48 /* Direct high 16 bit */
1121#define R_ARM_GNU_VTENTRY 100
1122#define R_ARM_GNU_VTINHERIT 101
1123#define R_ARM_THM_PC11 102 /* thumb unconditional branch */
1124#define R_ARM_THM_PC9 103 /* thumb conditional branch */
1125#define R_ARM_TLS_GD32 \
1126 104 /* PC-rel 32 bit for global dynamic
1127 thread local data */
1128#define R_ARM_TLS_LDM32 \
1129 105 /* PC-rel 32 bit for local dynamic
1130 thread local data */
1131#define R_ARM_TLS_LDO32 \
1132 106 /* 32 bit offset relative to TLS
1133 block */
1134#define R_ARM_TLS_IE32 \
1135 107 /* PC-rel 32 bit for GOT entry of
1136 static TLS block offset */
1137#define R_ARM_TLS_LE32 \
1138 108 /* 32 bit offset relative to static
1139 TLS block */
1140#define R_ARM_RXPC25 249
1141#define R_ARM_RSBREL32 250
1142#define R_ARM_THM_RPC22 251
1143#define R_ARM_RREL32 252
1144#define R_ARM_RABS22 253
1145#define R_ARM_RPC24 254
1146#define R_ARM_RBASE 255
1147/* Keep this the last entry. */
1148#define R_ARM_NUM 256
1149
1150#endif /* elf.h */
Definition elf.h:574
Definition elf.h:44
Definition elf.h:986
Definition elf.h:927
Definition elf.h:490
Definition elf.h:449
Definition elf.h:466
Definition elf.h:235
Definition elf.h:342
Definition elf.h:363
Definition elf.h:776
Definition elf.h:737
Definition elf.h:817
Definition elf.h:790
Definition elf.h:847
Definition elf.h:582
Definition elf.h:61
Definition elf.h:994
Definition elf.h:933
Definition elf.h:501
Definition elf.h:459
Definition elf.h:472
Definition elf.h:248
Definition elf.h:351
Definition elf.h:368
Definition elf.h:782
Definition elf.h:748
Definition elf.h:826
Definition elf.h:800
Definition elf.h:857