CLRX  1
An unofficial OpenCL extensions designed for Radeon GPUs
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
Elf.h
1 /* This file defines standard ELF types, structures, and macros.
2  Copyright (C) 1995-2014 Free Software Foundation, Inc.
3  This file is part of the GNU C Library.
4 
5  The GNU C Library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  The GNU C Library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with the GNU C Library; if not, see
17  <http://www.gnu.org/licenses/>. */
18 
19 /* Original file 'elf.h' from GLIBC 2.2. Adapted for CLRadeonExtender */
20 
21 #ifndef _ELF_H
22 #define _ELF_H 1
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 /* Standard ELF types. */
29 
30 #include <stdint.h>
31 
32 /* Type for a 16-bit quantity. */
33 typedef uint16_t Elf32_Half;
34 typedef uint16_t Elf64_Half;
35 
36 /* Types for signed and unsigned 32-bit quantities. */
37 typedef uint32_t Elf32_Word;
38 typedef int32_t Elf32_Sword;
39 typedef uint32_t Elf64_Word;
40 typedef int32_t Elf64_Sword;
41 
42 /* Types for signed and unsigned 64-bit quantities. */
43 typedef uint64_t Elf32_Xword;
44 typedef int64_t Elf32_Sxword;
45 typedef uint64_t Elf64_Xword;
46 typedef int64_t Elf64_Sxword;
47 
48 /* Type of addresses. */
49 typedef uint32_t Elf32_Addr;
50 typedef uint64_t Elf64_Addr;
51 
52 /* Type of file offsets. */
53 typedef uint32_t Elf32_Off;
54 typedef uint64_t Elf64_Off;
55 
56 /* Type for section indices, which are 16-bit quantities. */
57 typedef uint16_t Elf32_Section;
58 typedef uint16_t Elf64_Section;
59 
60 /* Type for version symbol information. */
61 typedef Elf32_Half Elf32_Versym;
62 typedef Elf64_Half Elf64_Versym;
63 
64 
65 /* The ELF file header. This appears at the start of every ELF file. */
66 
67 #define EI_NIDENT (16)
68 
69 typedef struct
70 {
71  unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */
72  Elf32_Half e_type; /* Object file type */
73  Elf32_Half e_machine; /* Architecture */
74  Elf32_Word e_version; /* Object file version */
75  Elf32_Addr e_entry; /* Entry point virtual address */
76  Elf32_Off e_phoff; /* Program header table file offset */
77  Elf32_Off e_shoff; /* Section header table file offset */
78  Elf32_Word e_flags; /* Processor-specific flags */
79  Elf32_Half e_ehsize; /* ELF header size in bytes */
80  Elf32_Half e_phentsize; /* Program header table entry size */
81  Elf32_Half e_phnum; /* Program header table entry count */
82  Elf32_Half e_shentsize; /* Section header table entry size */
83  Elf32_Half e_shnum; /* Section header table entry count */
84  Elf32_Half e_shstrndx; /* Section header string table index */
85 } Elf32_Ehdr;
86 
87 typedef struct
88 {
89  unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */
90  Elf64_Half e_type; /* Object file type */
91  Elf64_Half e_machine; /* Architecture */
92  Elf64_Word e_version; /* Object file version */
93  Elf64_Addr e_entry; /* Entry point virtual address */
94  Elf64_Off e_phoff; /* Program header table file offset */
95  Elf64_Off e_shoff; /* Section header table file offset */
96  Elf64_Word e_flags; /* Processor-specific flags */
97  Elf64_Half e_ehsize; /* ELF header size in bytes */
98  Elf64_Half e_phentsize; /* Program header table entry size */
99  Elf64_Half e_phnum; /* Program header table entry count */
100  Elf64_Half e_shentsize; /* Section header table entry size */
101  Elf64_Half e_shnum; /* Section header table entry count */
102  Elf64_Half e_shstrndx; /* Section header string table index */
103 } Elf64_Ehdr;
104 
105 /* Fields in the e_ident array. The EI_* macros are indices into the
106  array. The macros under each EI_* macro are the values the byte
107  may have. */
108 
109 #define EI_MAG0 0 /* File identification byte 0 index */
110 #define ELFMAG0 0x7f /* Magic number byte 0 */
111 
112 #define EI_MAG1 1 /* File identification byte 1 index */
113 #define ELFMAG1 'E' /* Magic number byte 1 */
114 
115 #define EI_MAG2 2 /* File identification byte 2 index */
116 #define ELFMAG2 'L' /* Magic number byte 2 */
117 
118 #define EI_MAG3 3 /* File identification byte 3 index */
119 #define ELFMAG3 'F' /* Magic number byte 3 */
120 
121 /* Conglomeration of the identification bytes, for easy testing as a word. */
122 #define ELFMAG "\177ELF"
123 #define SELFMAG 4
124 
125 #define EI_CLASS 4 /* File class byte index */
126 #define ELFCLASSNONE 0 /* Invalid class */
127 #define ELFCLASS32 1 /* 32-bit objects */
128 #define ELFCLASS64 2 /* 64-bit objects */
129 #define ELFCLASSNUM 3
130 
131 #define EI_DATA 5 /* Data encoding byte index */
132 #define ELFDATANONE 0 /* Invalid data encoding */
133 #define ELFDATA2LSB 1 /* 2's complement, little endian */
134 #define ELFDATA2MSB 2 /* 2's complement, big endian */
135 #define ELFDATANUM 3
136 
137 #define EI_VERSION 6 /* File version byte index */
138  /* Value must be EV_CURRENT */
139 
140 #define EI_OSABI 7 /* OS ABI identification */
141 #define ELFOSABI_NONE 0 /* UNIX System V ABI */
142 #define ELFOSABI_SYSV 0 /* Alias. */
143 #define ELFOSABI_HPUX 1 /* HP-UX */
144 #define ELFOSABI_NETBSD 2 /* NetBSD. */
145 #define ELFOSABI_GNU 3 /* Object uses GNU ELF extensions. */
146 #define ELFOSABI_LINUX ELFOSABI_GNU /* Compatibility alias. */
147 #define ELFOSABI_SOLARIS 6 /* Sun Solaris. */
148 #define ELFOSABI_AIX 7 /* IBM AIX. */
149 #define ELFOSABI_IRIX 8 /* SGI Irix. */
150 #define ELFOSABI_FREEBSD 9 /* FreeBSD. */
151 #define ELFOSABI_TRU64 10 /* Compaq TRU64 UNIX. */
152 #define ELFOSABI_MODESTO 11 /* Novell Modesto. */
153 #define ELFOSABI_OPENBSD 12 /* OpenBSD. */
154 #define ELFOSABI_ARM_AEABI 64 /* ARM EABI */
155 #define ELFOSABI_ARM 97 /* ARM */
156 #define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */
157 
158 #define EI_ABIVERSION 8 /* ABI version */
159 
160 #define EI_PAD 9 /* Byte index of padding bytes */
161 
162 /* Legal values for e_type (object file type). */
163 
164 #define ET_NONE 0 /* No file type */
165 #define ET_REL 1 /* Relocatable file */
166 #define ET_EXEC 2 /* Executable file */
167 #define ET_DYN 3 /* Shared object file */
168 #define ET_CORE 4 /* Core file */
169 #define ET_NUM 5 /* Number of defined types */
170 #define ET_LOOS 0xfe00 /* OS-specific range start */
171 #define ET_HIOS 0xfeff /* OS-specific range end */
172 #define ET_LOPROC 0xff00 /* Processor-specific range start */
173 #define ET_HIPROC 0xffff /* Processor-specific range end */
174 
175 /* Legal values for e_machine (architecture). */
176 
177 #define EM_NONE 0 /* No machine */
178 #define EM_M32 1 /* AT&T WE 32100 */
179 #define EM_SPARC 2 /* SUN SPARC */
180 #define EM_386 3 /* Intel 80386 */
181 #define EM_68K 4 /* Motorola m68k family */
182 #define EM_88K 5 /* Motorola m88k family */
183 #define EM_860 7 /* Intel 80860 */
184 #define EM_MIPS 8 /* MIPS R3000 big-endian */
185 #define EM_S370 9 /* IBM System/370 */
186 #define EM_MIPS_RS3_LE 10 /* MIPS R3000 little-endian */
187 
188 #define EM_PARISC 15 /* HPPA */
189 #define EM_VPP500 17 /* Fujitsu VPP500 */
190 #define EM_SPARC32PLUS 18 /* Sun's "v8plus" */
191 #define EM_960 19 /* Intel 80960 */
192 #define EM_PPC 20 /* PowerPC */
193 #define EM_PPC64 21 /* PowerPC 64-bit */
194 #define EM_S390 22 /* IBM S390 */
195 
196 #define EM_V800 36 /* NEC V800 series */
197 #define EM_FR20 37 /* Fujitsu FR20 */
198 #define EM_RH32 38 /* TRW RH-32 */
199 #define EM_RCE 39 /* Motorola RCE */
200 #define EM_ARM 40 /* ARM */
201 #define EM_FAKE_ALPHA 41 /* Digital Alpha */
202 #define EM_SH 42 /* Hitachi SH */
203 #define EM_SPARCV9 43 /* SPARC v9 64-bit */
204 #define EM_TRICORE 44 /* Siemens Tricore */
205 #define EM_ARC 45 /* Argonaut RISC Core */
206 #define EM_H8_300 46 /* Hitachi H8/300 */
207 #define EM_H8_300H 47 /* Hitachi H8/300H */
208 #define EM_H8S 48 /* Hitachi H8S */
209 #define EM_H8_500 49 /* Hitachi H8/500 */
210 #define EM_IA_64 50 /* Intel Merced */
211 #define EM_MIPS_X 51 /* Stanford MIPS-X */
212 #define EM_COLDFIRE 52 /* Motorola Coldfire */
213 #define EM_68HC12 53 /* Motorola M68HC12 */
214 #define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator*/
215 #define EM_PCP 55 /* Siemens PCP */
216 #define EM_NCPU 56 /* Sony nCPU embeeded RISC */
217 #define EM_NDR1 57 /* Denso NDR1 microprocessor */
218 #define EM_STARCORE 58 /* Motorola Start*Core processor */
219 #define EM_ME16 59 /* Toyota ME16 processor */
220 #define EM_ST100 60 /* STMicroelectronic ST100 processor */
221 #define EM_TINYJ 61 /* Advanced Logic Corp. Tinyj emb.fam*/
222 #define EM_X86_64 62 /* AMD x86-64 architecture */
223 #define EM_PDSP 63 /* Sony DSP Processor */
224 #define EM_NUM 192
225 
226 /* If it is necessary to assign new unofficial EM_* values, please
227  pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the
228  chances of collision with official or non-GNU unofficial values. */
229 
230 #define EM_ALPHA 0x9026
231 
232 /* Legal values for e_version (version). */
233 
234 #define EV_NONE 0 /* Invalid ELF version */
235 #define EV_CURRENT 1 /* Current version */
236 #define EV_NUM 2
237 
238 /* Section header. */
239 
240 typedef struct
241 {
242  Elf32_Word sh_name; /* Section name (string tbl index) */
243  Elf32_Word sh_type; /* Section type */
244  Elf32_Word sh_flags; /* Section flags */
245  Elf32_Addr sh_addr; /* Section virtual addr at execution */
246  Elf32_Off sh_offset; /* Section file offset */
247  Elf32_Word sh_size; /* Section size in bytes */
248  Elf32_Word sh_link; /* Link to another section */
249  Elf32_Word sh_info; /* Additional section information */
250  Elf32_Word sh_addralign; /* Section alignment */
251  Elf32_Word sh_entsize; /* Entry size if section holds table */
252 } Elf32_Shdr;
253 
254 typedef struct
255 {
256  Elf64_Word sh_name; /* Section name (string tbl index) */
257  Elf64_Word sh_type; /* Section type */
258  Elf64_Xword sh_flags; /* Section flags */
259  Elf64_Addr sh_addr; /* Section virtual addr at execution */
260  Elf64_Off sh_offset; /* Section file offset */
261  Elf64_Xword sh_size; /* Section size in bytes */
262  Elf64_Word sh_link; /* Link to another section */
263  Elf64_Word sh_info; /* Additional section information */
264  Elf64_Xword sh_addralign; /* Section alignment */
265  Elf64_Xword sh_entsize; /* Entry size if section holds table */
266 } Elf64_Shdr;
267 
268 /* Special section indices. */
269 
270 #define SHN_UNDEF 0 /* Undefined section */
271 #define SHN_LORESERVE 0xff00 /* Start of reserved indices */
272 #define SHN_LOPROC 0xff00 /* Start of processor-specific */
273 #define SHN_BEFORE 0xff00 /* Order section before all others
274  (Solaris). */
275 #define SHN_AFTER 0xff01 /* Order section after all others
276  (Solaris). */
277 #define SHN_HIPROC 0xff1f /* End of processor-specific */
278 #define SHN_LOOS 0xff20 /* Start of OS-specific */
279 #define SHN_HIOS 0xff3f /* End of OS-specific */
280 #define SHN_ABS 0xfff1 /* Associated symbol is absolute */
281 #define SHN_COMMON 0xfff2 /* Associated symbol is common */
282 #define SHN_XINDEX 0xffff /* Index is in extra table. */
283 #define SHN_HIRESERVE 0xffff /* End of reserved indices */
284 
285 /* Legal values for sh_type (section type). */
286 
287 #define SHT_NULL 0 /* Section header table entry unused */
288 #define SHT_PROGBITS 1 /* Program data */
289 #define SHT_SYMTAB 2 /* Symbol table */
290 #define SHT_STRTAB 3 /* String table */
291 #define SHT_RELA 4 /* Relocation entries with addends */
292 #define SHT_HASH 5 /* Symbol hash table */
293 #define SHT_DYNAMIC 6 /* Dynamic linking information */
294 #define SHT_NOTE 7 /* Notes */
295 #define SHT_NOBITS 8 /* Program space with no data (bss) */
296 #define SHT_REL 9 /* Relocation entries, no addends */
297 #define SHT_SHLIB 10 /* Reserved */
298 #define SHT_DYNSYM 11 /* Dynamic linker symbol table */
299 #define SHT_INIT_ARRAY 14 /* Array of constructors */
300 #define SHT_FINI_ARRAY 15 /* Array of destructors */
301 #define SHT_PREINIT_ARRAY 16 /* Array of pre-constructors */
302 #define SHT_GROUP 17 /* Section group */
303 #define SHT_SYMTAB_SHNDX 18 /* Extended section indeces */
304 #define SHT_NUM 19 /* Number of defined types. */
305 #define SHT_LOOS 0x60000000 /* Start OS-specific. */
306 #define SHT_GNU_ATTRIBUTES 0x6ffffff5 /* Object attributes. */
307 #define SHT_GNU_HASH 0x6ffffff6 /* GNU-style hash table. */
308 #define SHT_GNU_LIBLIST 0x6ffffff7 /* Prelink library list */
309 #define SHT_CHECKSUM 0x6ffffff8 /* Checksum for DSO content. */
310 #define SHT_LOSUNW 0x6ffffffa /* Sun-specific low bound. */
311 #define SHT_SUNW_move 0x6ffffffa
312 #define SHT_SUNW_COMDAT 0x6ffffffb
313 #define SHT_SUNW_syminfo 0x6ffffffc
314 #define SHT_GNU_verdef 0x6ffffffd /* Version definition section. */
315 #define SHT_GNU_verneed 0x6ffffffe /* Version needs section. */
316 #define SHT_GNU_versym 0x6fffffff /* Version symbol table. */
317 #define SHT_HISUNW 0x6fffffff /* Sun-specific high bound. */
318 #define SHT_HIOS 0x6fffffff /* End OS-specific type */
319 #define SHT_LOPROC 0x70000000 /* Start of processor-specific */
320 #define SHT_HIPROC 0x7fffffff /* End of processor-specific */
321 #define SHT_LOUSER 0x80000000 /* Start of application-specific */
322 #define SHT_HIUSER 0x8fffffff /* End of application-specific */
323 
324 /* Legal values for sh_flags (section flags). */
325 
326 #define SHF_WRITE (1 << 0) /* Writable */
327 #define SHF_ALLOC (1 << 1) /* Occupies memory during execution */
328 #define SHF_EXECINSTR (1 << 2) /* Executable */
329 #define SHF_MERGE (1 << 4) /* Might be merged */
330 #define SHF_STRINGS (1 << 5) /* Contains nul-terminated strings */
331 #define SHF_INFO_LINK (1 << 6) /* `sh_info' contains SHT index */
332 #define SHF_LINK_ORDER (1 << 7) /* Preserve order after combining */
333 #define SHF_OS_NONCONFORMING (1 << 8) /* Non-standard OS specific handling
334  required */
335 #define SHF_GROUP (1 << 9) /* Section is member of a group. */
336 #define SHF_TLS (1 << 10) /* Section hold thread-local data. */
337 #define SHF_MASKOS 0x0ff00000 /* OS-specific. */
338 #define SHF_MASKPROC 0xf0000000 /* Processor-specific */
339 #define SHF_ORDERED (1 << 30) /* Special ordering requirement
340  (Solaris). */
341 #define SHF_EXCLUDE (1 << 31) /* Section is excluded unless
342  referenced or allocated (Solaris).*/
343 
344 /* Section group handling. */
345 #define GRP_COMDAT 0x1 /* Mark group as COMDAT. */
346 
347 /* Symbol table entry. */
348 
349 typedef struct
350 {
351  Elf32_Word st_name; /* Symbol name (string tbl index) */
352  Elf32_Addr st_value; /* Symbol value */
353  Elf32_Word st_size; /* Symbol size */
354  unsigned char st_info; /* Symbol type and binding */
355  unsigned char st_other; /* Symbol visibility */
356  Elf32_Section st_shndx; /* Section index */
357 } Elf32_Sym;
358 
359 typedef struct
360 {
361  Elf64_Word st_name; /* Symbol name (string tbl index) */
362  unsigned char st_info; /* Symbol type and binding */
363  unsigned char st_other; /* Symbol visibility */
364  Elf64_Section st_shndx; /* Section index */
365  Elf64_Addr st_value; /* Symbol value */
366  Elf64_Xword st_size; /* Symbol size */
367 } Elf64_Sym;
368 
369 /* How to extract and insert information held in the st_info field. */
370 
371 #define ELF32_ST_BIND(val) (((unsigned char) (val)) >> 4)
372 #define ELF32_ST_TYPE(val) ((val) & 0xf)
373 #define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf))
374 
375 /* Both Elf32_Sym and Elf64_Sym use the same one-byte st_info field. */
376 #define ELF64_ST_BIND(val) ELF32_ST_BIND (val)
377 #define ELF64_ST_TYPE(val) ELF32_ST_TYPE (val)
378 #define ELF64_ST_INFO(bind, type) ELF32_ST_INFO ((bind), (type))
379 
380 /* Legal values for ST_BIND subfield of st_info (symbol binding). */
381 
382 #define STB_LOCAL 0 /* Local symbol */
383 #define STB_GLOBAL 1 /* Global symbol */
384 #define STB_WEAK 2 /* Weak symbol */
385 #define STB_NUM 3 /* Number of defined types. */
386 #define STB_LOOS 10 /* Start of OS-specific */
387 #define STB_GNU_UNIQUE 10 /* Unique symbol. */
388 #define STB_HIOS 12 /* End of OS-specific */
389 #define STB_LOPROC 13 /* Start of processor-specific */
390 #define STB_HIPROC 15 /* End of processor-specific */
391 
392 /* Legal values for ST_TYPE subfield of st_info (symbol type). */
393 
394 #define STT_NOTYPE 0 /* Symbol type is unspecified */
395 #define STT_OBJECT 1 /* Symbol is a data object */
396 #define STT_FUNC 2 /* Symbol is a code object */
397 #define STT_SECTION 3 /* Symbol associated with a section */
398 #define STT_FILE 4 /* Symbol's name is file name */
399 #define STT_COMMON 5 /* Symbol is a common data object */
400 #define STT_TLS 6 /* Symbol is thread-local data object*/
401 #define STT_NUM 7 /* Number of defined types. */
402 #define STT_LOOS 10 /* Start of OS-specific */
403 #define STT_GNU_IFUNC 10 /* Symbol is indirect code object */
404 #define STT_HIOS 12 /* End of OS-specific */
405 #define STT_LOPROC 13 /* Start of processor-specific */
406 #define STT_HIPROC 15 /* End of processor-specific */
407 
408 
409 /* Symbol table indices are found in the hash buckets and chain table
410  of a symbol hash table section. This special index value indicates
411  the end of a chain, meaning no further symbols are found in that bucket. */
412 
413 #define STN_UNDEF 0 /* End of a chain. */
414 
415 
416 /* How to extract and insert information held in the st_other field. */
417 
418 #define ELF32_ST_VISIBILITY(o) ((o) & 0x03)
419 
420 /* For ELF64 the definitions are the same. */
421 #define ELF64_ST_VISIBILITY(o) ELF32_ST_VISIBILITY (o)
422 
423 /* Symbol visibility specification encoded in the st_other field. */
424 #define STV_DEFAULT 0 /* Default symbol visibility rules */
425 #define STV_INTERNAL 1 /* Processor specific hidden class */
426 #define STV_HIDDEN 2 /* Sym unavailable in other modules */
427 #define STV_PROTECTED 3 /* Not preemptible, not exported */
428 
429 
430 /* Relocation table entry without addend (in section of type SHT_REL). */
431 
432 typedef struct
433 {
434  Elf32_Addr r_offset; /* Address */
435  Elf32_Word r_info; /* Relocation type and symbol index */
436 } Elf32_Rel;
437 
438 /* I have seen two different definitions of the Elf64_Rel and
439  Elf64_Rela structures, so we'll leave them out until Novell (or
440  whoever) gets their act together. */
441 /* The following, at least, is used on Sparc v9, MIPS, and Alpha. */
442 
443 typedef struct
444 {
445  Elf64_Addr r_offset; /* Address */
446  Elf64_Xword r_info; /* Relocation type and symbol index */
447 } Elf64_Rel;
448 
449 /* Relocation table entry with addend (in section of type SHT_RELA). */
450 
451 typedef struct
452 {
453  Elf32_Addr r_offset; /* Address */
454  Elf32_Word r_info; /* Relocation type and symbol index */
455  Elf32_Sword r_addend; /* Addend */
456 } Elf32_Rela;
457 
458 typedef struct
459 {
460  Elf64_Addr r_offset; /* Address */
461  Elf64_Xword r_info; /* Relocation type and symbol index */
462  Elf64_Sxword r_addend; /* Addend */
463 } Elf64_Rela;
464 
465 /* How to extract and insert information held in the r_info field. */
466 
467 #define ELF32_R_SYM(val) ((val) >> 8)
468 #define ELF32_R_TYPE(val) ((val) & 0xff)
469 #define ELF32_R_INFO(sym, type) (((sym) << 8) + ((type) & 0xff))
470 
471 #define ELF64_R_SYM(i) ((i) >> 32)
472 #define ELF64_R_TYPE(i) ((i) & 0xffffffff)
473 #define ELF64_R_INFO(sym,type) ((((Elf64_Xword) (sym)) << 32) + (type))
474 
475 /* Program segment header. */
476 
477 typedef struct
478 {
479  Elf32_Word p_type; /* Segment type */
480  Elf32_Off p_offset; /* Segment file offset */
481  Elf32_Addr p_vaddr; /* Segment virtual address */
482  Elf32_Addr p_paddr; /* Segment physical address */
483  Elf32_Word p_filesz; /* Segment size in file */
484  Elf32_Word p_memsz; /* Segment size in memory */
485  Elf32_Word p_flags; /* Segment flags */
486  Elf32_Word p_align; /* Segment alignment */
487 } Elf32_Phdr;
488 
489 typedef struct
490 {
491  Elf64_Word p_type; /* Segment type */
492  Elf64_Word p_flags; /* Segment flags */
493  Elf64_Off p_offset; /* Segment file offset */
494  Elf64_Addr p_vaddr; /* Segment virtual address */
495  Elf64_Addr p_paddr; /* Segment physical address */
496  Elf64_Xword p_filesz; /* Segment size in file */
497  Elf64_Xword p_memsz; /* Segment size in memory */
498  Elf64_Xword p_align; /* Segment alignment */
499 } Elf64_Phdr;
500 
501 /* Special value for e_phnum. This indicates that the real number of
502  program headers is too large to fit into e_phnum. Instead the real
503  value is in the field sh_info of section 0. */
504 
505 #define PN_XNUM 0xffff
506 
507 /* Legal values for p_type (segment type). */
508 
509 #define PT_NULL 0 /* Program header table entry unused */
510 #define PT_LOAD 1 /* Loadable program segment */
511 #define PT_DYNAMIC 2 /* Dynamic linking information */
512 #define PT_INTERP 3 /* Program interpreter */
513 #define PT_NOTE 4 /* Auxiliary information */
514 #define PT_SHLIB 5 /* Reserved */
515 #define PT_PHDR 6 /* Entry for header table itself */
516 #define PT_TLS 7 /* Thread-local storage segment */
517 #define PT_NUM 8 /* Number of defined types */
518 #define PT_LOOS 0x60000000 /* Start of OS-specific */
519 #define PT_GNU_EH_FRAME 0x6474e550 /* GCC .eh_frame_hdr segment */
520 #define PT_GNU_STACK 0x6474e551 /* Indicates stack executability */
521 #define PT_GNU_RELRO 0x6474e552 /* Read-only after relocation */
522 #define PT_LOSUNW 0x6ffffffa
523 #define PT_SUNWBSS 0x6ffffffa /* Sun Specific segment */
524 #define PT_SUNWSTACK 0x6ffffffb /* Stack segment */
525 #define PT_HISUNW 0x6fffffff
526 #define PT_HIOS 0x6fffffff /* End of OS-specific */
527 #define PT_LOPROC 0x70000000 /* Start of processor-specific */
528 #define PT_HIPROC 0x7fffffff /* End of processor-specific */
529 
530 /* Legal values for p_flags (segment flags). */
531 
532 #define PF_X (1 << 0) /* Segment is executable */
533 #define PF_W (1 << 1) /* Segment is writable */
534 #define PF_R (1 << 2) /* Segment is readable */
535 #define PF_MASKOS 0x0ff00000 /* OS-specific */
536 #define PF_MASKPROC 0xf0000000 /* Processor-specific */
537 
538 /* Note section contents. Each entry in the note section begins with
539  a header of a fixed form. */
540 
541 typedef struct
542 {
543  Elf32_Word n_namesz; /* Length of the note's name. */
544  Elf32_Word n_descsz; /* Length of the note's descriptor. */
545  Elf32_Word n_type; /* Type of the note. */
546 } Elf32_Nhdr;
547 
548 typedef struct
549 {
550  Elf64_Word n_namesz; /* Length of the note's name. */
551  Elf64_Word n_descsz; /* Length of the note's descriptor. */
552  Elf64_Word n_type; /* Type of the note. */
553 } Elf64_Nhdr;
554 
555 /* Known names of notes. */
556 
557 /* Solaris entries in the note section have this name. */
558 #define ELF_NOTE_SOLARIS "SUNW Solaris"
559 
560 /* Note entries for GNU systems have this name. */
561 #define ELF_NOTE_GNU "GNU"
562 
563 
564 /* Defined types of notes for Solaris. */
565 
566 /* Value of descriptor (one word) is desired pagesize for the binary. */
567 #define ELF_NOTE_PAGESIZE_HINT 1
568 
569 
570 /* Defined note types for GNU systems. */
571 
572 /* ABI information. The descriptor consists of words:
573  word 0: OS descriptor
574  word 1: major version of the ABI
575  word 2: minor version of the ABI
576  word 3: subminor version of the ABI
577 */
578 #define NT_GNU_ABI_TAG 1
579 #define ELF_NOTE_ABI NT_GNU_ABI_TAG /* Old name. */
580 
581 /* Known OSes. These values can appear in word 0 of an
582  NT_GNU_ABI_TAG note section entry. */
583 #define ELF_NOTE_OS_LINUX 0
584 #define ELF_NOTE_OS_GNU 1
585 #define ELF_NOTE_OS_SOLARIS2 2
586 #define ELF_NOTE_OS_FREEBSD 3
587 
588 /* Synthetic hwcap information. The descriptor begins with two words:
589  word 0: number of entries
590  word 1: bitmask of enabled entries
591  Then follow variable-length entries, one byte followed by a
592  '\0'-terminated hwcap name string. The byte gives the bit
593  number to test if enabled, (1U << bit) & bitmask. */
594 #define NT_GNU_HWCAP 2
595 
596 /* Build ID bits as generated by ld --build-id.
597  The descriptor consists of any nonzero number of bytes. */
598 #define NT_GNU_BUILD_ID 3
599 
600 /* Version note generated by GNU gold containing a version string. */
601 #define NT_GNU_GOLD_VERSION 4
602 
603 /* NOTE: Further definitions has been deleted from this file, because was obsolete */
604 
605 #ifdef __cplusplus
606 }
607 #endif
608 
609 #endif /* elf.h */
Definition: Elf.h:69
Definition: Elf.h:240
Definition: Elf.h:349
Definition: Elf.h:451
Definition: Elf.h:458
Definition: Elf.h:432
Definition: Elf.h:548
Definition: Elf.h:541
Definition: Elf.h:443
Definition: Elf.h:489
Definition: Elf.h:359
Definition: Elf.h:477
Definition: Elf.h:87
Definition: Elf.h:254