RetroArch
elf_abi.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 1995, 1996, 2001, 2002
3  * Erik Theisen. 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  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. The name of the author may not be used to endorse or promote products
14  * derived from this software without specific prior written permission
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 /* This is the ELF ABI header file formerly known as "elf_abi.h". */
29 
30 #ifndef _ELF_ABI_H
31 #define _ELF_ABI_H
32 
33 #include <stdint.h>
34 
35 #include <gctypes.h>
36 
37 /* This version doesn't work for 64-bit ABIs - Erik. */
38 
39 /* These typedefs need to be handled better. */
40 
41 typedef uint32_t Elf32_Addr; /* Unsigned program address */
42 typedef uint32_t Elf32_Off; /* Unsigned file offset */
43 typedef int32_t Elf32_Sword; /* Signed large integer */
44 typedef uint32_t Elf32_Word; /* Unsigned large integer */
45 typedef uint16_t Elf32_Half; /* Unsigned medium integer */
46 
47 /* e_ident[] identification indexes */
48 
49 #define EI_MAG0 0 /* file ID */
50 #define EI_MAG1 1 /* file ID */
51 #define EI_MAG2 2 /* file ID */
52 #define EI_MAG3 3 /* file ID */
53 #define EI_CLASS 4 /* file class */
54 #define EI_DATA 5 /* data encoding */
55 #define EI_VERSION 6 /* ELF header version */
56 #define EI_OSABI 7 /* OS/ABI specific ELF extensions */
57 #define EI_ABIVERSION 8 /* ABI target version */
58 #define EI_PAD 9 /* start of pad bytes */
59 #define EI_NIDENT 16 /* Size of e_ident[] */
60 
61 /* e_ident[] magic number */
62 
63 #define ELFMAG0 0x7f /* e_ident[EI_MAG0] */
64 #define ELFMAG1 'E' /* e_ident[EI_MAG1] */
65 #define ELFMAG2 'L' /* e_ident[EI_MAG2] */
66 #define ELFMAG3 'F' /* e_ident[EI_MAG3] */
67 #define ELFMAG "\177ELF" /* magic */
68 #define SELFMAG 4 /* size of magic */
69 
70 /* e_ident[] file class */
71 
72 #define ELFCLASSNONE 0 /* invalid */
73 #define ELFCLASS32 1 /* 32-bit objs */
74 #define ELFCLASS64 2 /* 64-bit objs */
75 #define ELFCLASSNUM 3 /* number of classes */
76 
77 /* e_ident[] data encoding */
78 #define ELFDATANONE 0 /* invalid */
79 #define ELFDATA2LSB 1 /* Little-Endian */
80 #define ELFDATA2MSB 2 /* Big-Endian */
81 #define ELFDATANUM 3 /* number of data encode defines */
82 
83 /* e_ident[] OS/ABI specific ELF extensions */
84 
85 #define ELFOSABI_NONE 0 /* No extension specified */
86 #define ELFOSABI_HPUX 1 /* Hewlett-Packard HP-UX */
87 #define ELFOSABI_NETBSD 2 /* NetBSD */
88 #define ELFOSABI_LINUX 3 /* Linux */
89 #define ELFOSABI_SOLARIS 6 /* Sun Solaris */
90 #define ELFOSABI_AIX 7 /* AIX */
91 #define ELFOSABI_IRIX 8 /* IRIX */
92 #define ELFOSABI_FREEBSD 9 /* FreeBSD */
93 #define ELFOSABI_TRU64 10 /* Compaq TRU64 UNIX */
94 #define ELFOSABI_MODESTO 11 /* Novell Modesto */
95 #define ELFOSABI_OPENBSD 12 /* OpenBSD */
96 
97 /* 64-255 Architecture-specific value range */
98 
99 /* e_ident[] ABI Version */
100 
101 #define ELFABIVERSION 0
102 
103 /* e_ident */
104 
105 #define IS_ELF(ehdr) ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \
106  (ehdr).e_ident[EI_MAG1] == ELFMAG1 && \
107  (ehdr).e_ident[EI_MAG2] == ELFMAG2 && \
108  (ehdr).e_ident[EI_MAG3] == ELFMAG3)
109 
110 /* ELF Header */
111 typedef struct elfhdr
112 {
113  unsigned char e_ident[EI_NIDENT]; /* ELF Identification */
114  Elf32_Half e_type; /* object file type */
115  Elf32_Half e_machine; /* machine */
116  Elf32_Word e_version; /* object file version */
117  Elf32_Addr e_entry; /* virtual entry point */
118  Elf32_Off e_phoff; /* program header table offset */
119  Elf32_Off e_shoff; /* section header table offset */
120  Elf32_Word e_flags; /* processor-specific flags */
121  Elf32_Half e_ehsize; /* ELF header size */
122  Elf32_Half e_phentsize; /* program header entry size */
123  Elf32_Half e_phnum; /* number of program header entries */
124  Elf32_Half e_shentsize; /* section header entry size */
125  Elf32_Half e_shnum; /* number of section header entries */
126  Elf32_Half e_shstrndx; /* section header table's "section
127  header string table" entry offset */
128 } Elf32_Ehdr;
129 
130 /* e_type */
131 
132 #define ET_NONE 0 /* No file type */
133 #define ET_REL 1 /* relocatable file */
134 #define ET_EXEC 2 /* executable file */
135 #define ET_DYN 3 /* shared object file */
136 #define ET_CORE 4 /* core file */
137 #define ET_NUM 5 /* number of types */
138 #define ET_LOOS 0xfe00 /* reserved range for operating */
139 #define ET_HIOS 0xfeff /* system specific e_type */
140 #define ET_LOPROC 0xff00 /* reserved range for processor */
141 #define ET_HIPROC 0xffff /* specific e_type */
142 
143 /* e_machine */
144 
145 #define EM_NONE 0 /* No Machine */
146 #define EM_M32 1 /* AT&T WE 32100 */
147 #define EM_SPARC 2 /* SPARC */
148 #define EM_386 3 /* Intel 80386 */
149 #define EM_68K 4 /* Motorola 68000 */
150 #define EM_88K 5 /* Motorola 88000 */
151 #if 0
152 #define EM_486 6 /* RESERVED - was Intel 80486 */
153 #endif
154 #define EM_860 7 /* Intel 80860 */
155 #define EM_MIPS 8 /* MIPS R3000 Big-Endian only */
156 #define EM_S370 9 /* IBM System/370 Processor */
157 #define EM_MIPS_RS4_BE 10 /* MIPS R4000 Big-Endian */
158 #if 0
159 #define EM_SPARC64 11 /* RESERVED - was SPARC v9
160  64-bit unoffical */
161 #endif
162 
163 /* RESERVED 11-14 for future use */
164 
165 #define EM_PARISC 15 /* HPPA */
166  /* RESERVED 16 for future use */
167 #define EM_VPP500 17 /* Fujitsu VPP500 */
168 #define EM_SPARC32PLUS 18 /* Enhanced instruction set SPARC */
169 #define EM_960 19 /* Intel 80960 */
170 #define EM_PPC 20 /* PowerPC */
171 #define EM_PPC64 21 /* 64-bit PowerPC */
172 #define EM_S390 22 /* IBM System/390 Processor */
173  /* RESERVED 23-35 for future use */
174 #define EM_V800 36 /* NEC V800 */
175 #define EM_FR20 37 /* Fujitsu FR20 */
176 #define EM_RH32 38 /* TRW RH-32 */
177 #define EM_RCE 39 /* Motorola RCE */
178 #define EM_ARM 40 /* Advanced Risc Machines ARM */
179 #define EM_ALPHA 41 /* Digital Alpha */
180 #define EM_SH 42 /* Hitachi SH */
181 #define EM_SPARCV9 43 /* SPARC Version 9 */
182 #define EM_TRICORE 44 /* Siemens TriCore embedded processor */
183 #define EM_ARC 45 /* Argonaut RISC Core */
184 #define EM_H8_300 46 /* Hitachi H8/300 */
185 #define EM_H8_300H 47 /* Hitachi H8/300H */
186 #define EM_H8S 48 /* Hitachi H8S */
187 #define EM_H8_500 49 /* Hitachi H8/500 */
188 #define EM_IA_64 50 /* Intel Merced */
189 #define EM_MIPS_X 51 /* Stanford MIPS-X */
190 #define EM_COLDFIRE 52 /* Motorola Coldfire */
191 #define EM_68HC12 53 /* Motorola M68HC12 */
192 #define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator*/
193 #define EM_PCP 55 /* Siemens PCP */
194 #define EM_NCPU 56 /* Sony nCPU embedded RISC */
195 #define EM_NDR1 57 /* Denso NDR1 microprocessor */
196 #define EM_STARCORE 58 /* Motorola Start*Core processor */
197 #define EM_ME16 59 /* Toyota ME16 processor */
198 #define EM_ST100 60 /* STMicroelectronic ST100 processor */
199 #define EM_TINYJ 61 /* Advanced Logic Corp. Tinyj emb.fam*/
200 #define EM_X86_64 62 /* AMD x86-64 */
201 #define EM_PDSP 63 /* Sony DSP Processor */
202  /* RESERVED 64,65 for future use */
203 #define EM_FX66 66 /* Siemens FX66 microcontroller */
204 #define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 mc */
205 #define EM_ST7 68 /* STmicroelectronics ST7 8 bit mc */
206 #define EM_68HC16 69 /* Motorola MC68HC16 microcontroller */
207 #define EM_68HC11 70 /* Motorola MC68HC11 microcontroller */
208 #define EM_68HC08 71 /* Motorola MC68HC08 microcontroller */
209 #define EM_68HC05 72 /* Motorola MC68HC05 microcontroller */
210 #define EM_SVX 73 /* Silicon Graphics SVx */
211 #define EM_ST19 74 /* STMicroelectronics ST19 8 bit mc */
212 #define EM_VAX 75 /* Digital VAX */
213 #define EM_CHRIS 76 /* Axis Communications embedded proc. */
214 #define EM_JAVELIN 77 /* Infineon Technologies emb. proc. */
215 #define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */
216 #define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */
217 #define EM_MMIX 80 /* Donald Knuth's edu 64-bit proc. */
218 #define EM_HUANY 81 /* Harvard University mach-indep objs */
219 #define EM_PRISM 82 /* SiTera Prism */
220 #define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */
221 #define EM_FR30 84 /* Fujitsu FR30 */
222 #define EM_D10V 85 /* Mitsubishi DV10V */
223 #define EM_D30V 86 /* Mitsubishi DV30V */
224 #define EM_V850 87 /* NEC v850 */
225 #define EM_M32R 88 /* Mitsubishi M32R */
226 #define EM_MN10300 89 /* Matsushita MN10200 */
227 #define EM_MN10200 90 /* Matsushita MN10200 */
228 #define EM_PJ 91 /* picoJava */
229 #define EM_NUM 92 /* number of machine types */
230 
231 /* Version */
232 
233 #define EV_NONE 0 /* Invalid */
234 #define EV_CURRENT 1 /* Current */
235 #define EV_NUM 2 /* number of versions */
236 
237 /* Section Header */
238 
239 typedef struct
240 {
241  Elf32_Word sh_name; /* name - index into section header
242  string table section */
243  Elf32_Word sh_type; /* type */
244  Elf32_Word sh_flags; /* flags */
245  Elf32_Addr sh_addr; /* address */
246  Elf32_Off sh_offset; /* file offset */
247  Elf32_Word sh_size; /* section size */
248  Elf32_Word sh_link; /* section header table index link */
249  Elf32_Word sh_info; /* extra information */
250  Elf32_Word sh_addralign; /* address alignment */
251  Elf32_Word sh_entsize; /* section entry size */
252 } Elf32_Shdr;
253 
254 /* Special Section Indexes */
255 
256 #define SHN_UNDEF 0 /* undefined */
257 #define SHN_LORESERVE 0xff00 /* lower bounds of reserved indexes */
258 #define SHN_LOPROC 0xff00 /* reserved range for processor */
259 #define SHN_HIPROC 0xff1f /* specific section indexes */
260 #define SHN_LOOS 0xff20 /* reserved range for operating */
261 #define SHN_HIOS 0xff3f /* specific semantics */
262 #define SHN_ABS 0xfff1 /* absolute value */
263 #define SHN_COMMON 0xfff2 /* common symbol */
264 #define SHN_XINDEX 0xffff /* Index is an extra table */
265 #define SHN_HIRESERVE 0xffff /* upper bounds of reserved indexes */
266 
267 /* sh_type */
268 
269 #define SHT_NULL 0 /* inactive */
270 #define SHT_PROGBITS 1 /* program defined information */
271 #define SHT_SYMTAB 2 /* symbol table section */
272 #define SHT_STRTAB 3 /* string table section */
273 #define SHT_RELA 4 /* relocation section with addends*/
274 #define SHT_HASH 5 /* symbol hash table section */
275 #define SHT_DYNAMIC 6 /* dynamic section */
276 #define SHT_NOTE 7 /* note section */
277 #define SHT_NOBITS 8 /* no space section */
278 #define SHT_REL 9 /* relation section without addends */
279 #define SHT_SHLIB 10 /* reserved - purpose unknown */
280 #define SHT_DYNSYM 11 /* dynamic symbol table section */
281 #define SHT_INIT_ARRAY 14 /* Array of constructors */
282 #define SHT_FINI_ARRAY 15 /* Array of destructors */
283 #define SHT_PREINIT_ARRAY 16 /* Array of pre-constructors */
284 #define SHT_GROUP 17 /* Section group */
285 #define SHT_SYMTAB_SHNDX 18 /* Extended section indeces */
286 #define SHT_NUM 19 /* number of section types */
287 #define SHT_LOOS 0x60000000 /* Start OS-specific */
288 #define SHT_HIOS 0x6fffffff /* End OS-specific */
289 #define SHT_LOPROC 0x70000000 /* reserved range for processor */
290 #define SHT_HIPROC 0x7fffffff /* specific section header types */
291 #define SHT_LOUSER 0x80000000 /* reserved range for application */
292 #define SHT_HIUSER 0xffffffff /* specific indexes */
293 
294 /* Section names */
295 #define ELF_BSS ".bss" /* uninitialized data */
296 #define ELF_COMMENT ".comment" /* version control information */
297 #define ELF_DATA ".data" /* initialized data */
298 #define ELF_DATA1 ".data1" /* initialized data */
299 #define ELF_DEBUG ".debug" /* debug */
300 #define ELF_DYNAMIC ".dynamic" /* dynamic linking information */
301 #define ELF_DYNSTR ".dynstr" /* dynamic string table */
302 #define ELF_DYNSYM ".dynsym" /* dynamic symbol table */
303 #define ELF_FINI ".fini" /* termination code */
304 #define ELF_FINI_ARRAY ".fini_array" /* Array of destructors */
305 #define ELF_GOT ".got" /* global offset table */
306 #define ELF_HASH ".hash" /* symbol hash table */
307 #define ELF_INIT ".init" /* initialization code */
308 #define ELF_INIT_ARRAY ".init_array" /* Array of constuctors */
309 #define ELF_INTERP ".interp" /* Pathname of program interpreter */
310 #define ELF_LINE ".line" /* Symbolic line numnber information */
311 #define ELF_NOTE ".note" /* Contains note section */
312 #define ELF_PLT ".plt" /* Procedure linkage table */
313 #define ELF_PREINIT_ARRAY ".preinit_array" /* Array of pre-constructors */
314 #define ELF_REL_DATA ".rel.data" /* relocation data */
315 #define ELF_REL_FINI ".rel.fini" /* relocation termination code */
316 #define ELF_REL_INIT ".rel.init" /* relocation initialization code */
317 #define ELF_REL_DYN ".rel.dyn" /* relocaltion dynamic link info */
318 #define ELF_REL_RODATA ".rel.rodata" /* relocation read-only data */
319 #define ELF_REL_TEXT ".rel.text" /* relocation code */
320 #define ELF_RODATA ".rodata" /* read-only data */
321 #define ELF_RODATA1 ".rodata1" /* read-only data */
322 #define ELF_SHSTRTAB ".shstrtab" /* section header string table */
323 #define ELF_STRTAB ".strtab" /* string table */
324 #define ELF_SYMTAB ".symtab" /* symbol table */
325 #define ELF_SYMTAB_SHNDX ".symtab_shndx"/* symbol table section index */
326 #define ELF_TBSS ".tbss" /* thread local uninit data */
327 #define ELF_TDATA ".tdata" /* thread local init data */
328 #define ELF_TDATA1 ".tdata1" /* thread local init data */
329 #define ELF_TEXT ".text" /* code */
330 
331 /* Section Attribute Flags - sh_flags */
332 
333 #define SHF_WRITE 0x1 /* Writable */
334 #define SHF_ALLOC 0x2 /* occupies memory */
335 #define SHF_EXECINSTR 0x4 /* executable */
336 #define SHF_MERGE 0x10 /* Might be merged */
337 #define SHF_STRINGS 0x20 /* Contains NULL terminated strings */
338 #define SHF_INFO_LINK 0x40 /* sh_info contains SHT index */
339 #define SHF_LINK_ORDER 0x80 /* Preserve order after combining*/
340 #define SHF_OS_NONCONFORMING 0x100 /* Non-standard OS specific handling */
341 #define SHF_GROUP 0x200 /* Member of section group */
342 #define SHF_TLS 0x400 /* Thread local storage */
343 #define SHF_MASKOS 0x0ff00000 /* OS specific */
344 #define SHF_MASKPROC 0xf0000000 /* reserved bits for processor */
345  /* specific section attributes */
346 
347 /* Section Group Flags */
348 
349 #define GRP_COMDAT 0x1 /* COMDAT group */
350 #define GRP_MASKOS 0x0ff00000 /* Mask OS specific flags */
351 #define GRP_MASKPROC 0xf0000000 /* Mask processor specific flags */
352 
353 /* Symbol Table Entry */
354 
355 typedef struct elf32_sym
356 {
357  Elf32_Word st_name; /* name - index into string table */
358  Elf32_Addr st_value; /* symbol value */
359  Elf32_Word st_size; /* symbol size */
360  unsigned char st_info; /* type and binding */
361  unsigned char st_other; /* 0 - no defined meaning */
362  Elf32_Half st_shndx; /* section header index */
363 } Elf32_Sym;
364 
365 /* Symbol table index */
366 
367 #define STN_UNDEF 0 /* undefined */
368 
369 /* Extract symbol info - st_info */
370 
371 #define ELF32_ST_BIND(x) ((x) >> 4)
372 #define ELF32_ST_TYPE(x) (((unsigned int) x) & 0xf)
373 #define ELF32_ST_INFO(b,t) (((b) << 4) + ((t) & 0xf))
374 #define ELF32_ST_VISIBILITY(x) ((x) & 0x3)
375 
376 /* Symbol Binding - ELF32_ST_BIND - st_info */
377 
378 #define STB_LOCAL 0 /* Local symbol */
379 #define STB_GLOBAL 1 /* Global symbol */
380 #define STB_WEAK 2 /* like global - lower precedence */
381 #define STB_NUM 3 /* number of symbol bindings */
382 #define STB_LOOS 10 /* reserved range for operating */
383 #define STB_HIOS 12 /* system specific symbol bindings */
384 #define STB_LOPROC 13 /* reserved range for processor */
385 #define STB_HIPROC 15 /* specific symbol bindings */
386 
387 /* Symbol type - ELF32_ST_TYPE - st_info */
388 #define STT_NOTYPE 0 /* not specified */
389 #define STT_OBJECT 1 /* data object */
390 #define STT_FUNC 2 /* function */
391 #define STT_SECTION 3 /* section */
392 #define STT_FILE 4 /* file */
393 #define STT_NUM 5 /* number of symbol types */
394 #define STT_TLS 6 /* Thread local storage symbol */
395 #define STT_LOOS 10 /* reserved range for operating */
396 #define STT_HIOS 12 /* system specific symbol types */
397 #define STT_LOPROC 13 /* reserved range for processor */
398 #define STT_HIPROC 15 /* specific symbol types */
399 
400 /* Symbol visibility - ELF32_ST_VISIBILITY - st_other */
401 
402 #define STV_DEFAULT 0 /* Normal visibility rules */
403 #define STV_INTERNAL 1 /* Processor specific hidden class */
404 #define STV_HIDDEN 2 /* Symbol unavailable in other mods */
405 #define STV_PROTECTED 3 /* Not preemptible, not exported */
406 
407 
408 /* Relocation entry with implicit addend */
409 
410 typedef struct
411 {
412  Elf32_Addr r_offset; /* offset of relocation */
413  Elf32_Word r_info; /* symbol table index and type */
414 } Elf32_Rel;
415 
416 /* Relocation entry with explicit addend */
417 
418 typedef struct
419 {
420  Elf32_Addr r_offset; /* offset of relocation */
421  Elf32_Word r_info; /* symbol table index and type */
423 } Elf32_Rela;
424 
425 /* Extract relocation info - r_info */
426 
427 #define ELF32_R_SYM(i) ((i) >> 8)
428 #define ELF32_R_TYPE(i) ((unsigned char) (i))
429 #define ELF32_R_INFO(s,t) (((s) << 8) + (unsigned char)(t))
430 
431 /* Program Header */
432 typedef struct
433 {
434  Elf32_Word p_type; /* segment type */
435  Elf32_Off p_offset; /* segment offset */
436  Elf32_Addr p_vaddr; /* virtual address of segment */
437  Elf32_Addr p_paddr; /* physical address - ignored? */
438  Elf32_Word p_filesz; /* number of bytes in file for seg. */
439  Elf32_Word p_memsz; /* number of bytes in mem. for seg. */
440  Elf32_Word p_flags; /* flags */
441  Elf32_Word p_align; /* memory alignment */
442 } Elf32_Phdr;
443 
444 /* Segment types - p_type */
445 
446 #define PT_NULL 0 /* unused */
447 #define PT_LOAD 1 /* loadable segment */
448 #define PT_DYNAMIC 2 /* dynamic linking section */
449 #define PT_INTERP 3 /* the RTLD */
450 #define PT_NOTE 4 /* auxiliary information */
451 #define PT_SHLIB 5 /* reserved - purpose undefined */
452 #define PT_PHDR 6 /* program header */
453 #define PT_TLS 7 /* Thread local storage template */
454 #define PT_NUM 8 /* Number of segment types */
455 #define PT_LOOS 0x60000000 /* reserved range for operating */
456 #define PT_HIOS 0x6fffffff /* system specific segment types */
457 #define PT_LOPROC 0x70000000 /* reserved range for processor */
458 #define PT_HIPROC 0x7fffffff /* specific segment types */
459 
460 /* Segment flags - p_flags */
461 #define PF_X 0x1 /* Executable */
462 #define PF_W 0x2 /* Writable */
463 #define PF_R 0x4 /* Readable */
464 #define PF_MASKOS 0x0ff00000 /* OS specific segment flags */
465 #define PF_MASKPROC 0xf0000000 /* reserved bits for processor */
466  /* specific segment flags */
467 
468 /* Dynamic structure */
469 typedef struct
470 {
471  Elf32_Sword d_tag; /* controls meaning of d_val */
472  union
473  {
474  Elf32_Word d_val; /* Multiple meanings - see d_tag */
475  Elf32_Addr d_ptr; /* program virtual address */
476  } d_un;
477 } Elf32_Dyn;
478 
479 extern Elf32_Dyn _DYNAMIC[];
480 
481 /* Dynamic Array Tags - d_tag */
482 
483 #define DT_NULL 0 /* marks end of _DYNAMIC array */
484 #define DT_NEEDED 1 /* string table offset of needed lib */
485 #define DT_PLTRELSZ 2 /* size of relocation entries in PLT */
486 #define DT_PLTGOT 3 /* address PLT/GOT */
487 #define DT_HASH 4 /* address of symbol hash table */
488 #define DT_STRTAB 5 /* address of string table */
489 #define DT_SYMTAB 6 /* address of symbol table */
490 #define DT_RELA 7 /* address of relocation table */
491 #define DT_RELASZ 8 /* size of relocation table */
492 #define DT_RELAENT 9 /* size of relocation entry */
493 #define DT_STRSZ 10 /* size of string table */
494 #define DT_SYMENT 11 /* size of symbol table entry */
495 #define DT_INIT 12 /* address of initialization func. */
496 #define DT_FINI 13 /* address of termination function */
497 #define DT_SONAME 14 /* string table offset of shared obj */
498 #define DT_RPATH 15 /* string table offset of library search path */
499 #define DT_SYMBOLIC 16 /* start sym search in shared obj. */
500 #define DT_REL 17 /* address of rel. tbl. w addends */
501 #define DT_RELSZ 18 /* size of DT_REL relocation table */
502 #define DT_RELENT 19 /* size of DT_REL relocation entry */
503 #define DT_PLTREL 20 /* PLT referenced relocation entry */
504 #define DT_DEBUG 21 /* bugger */
505 #define DT_TEXTREL 22 /* Allow rel. mod. to unwritable seg */
506 #define DT_JMPREL 23 /* add. of PLT's relocation entries */
507 #define DT_BIND_NOW 24 /* Process relocations of object */
508 #define DT_INIT_ARRAY 25 /* Array with addresses of init fct */
509 #define DT_FINI_ARRAY 26 /* Array with addresses of fini fct */
510 #define DT_INIT_ARRAYSZ 27 /* Size in bytes of DT_INIT_ARRAY */
511 #define DT_FINI_ARRAYSZ 28 /* Size in bytes of DT_FINI_ARRAY */
512 #define DT_RUNPATH 29 /* Library search path */
513 #define DT_FLAGS 30 /* Flags for the object being loaded */
514 #define DT_ENCODING 32 /* Start of encoded range */
515 #define DT_PREINIT_ARRAY 32 /* Array with addresses of preinit fct*/
516 #define DT_PREINIT_ARRAYSZ 33 /* size in bytes of DT_PREINIT_ARRAY */
517 #define DT_NUM 34 /* Number used. */
518 #define DT_LOOS 0x60000000 /* reserved range for OS */
519 #define DT_HIOS 0x6fffffff /* specific dynamic array tags */
520 #define DT_LOPROC 0x70000000 /* reserved range for processor */
521 #define DT_HIPROC 0x7fffffff /* specific dynamic array tags */
522 
523 /* Dynamic Tag Flags - d_un.d_val */
524 
525 #define DF_ORIGIN 0x01 /* Object may use DF_ORIGIN */
526 #define DF_SYMBOLIC 0x02 /* Symbol resolutions starts here */
527 #define DF_TEXTRE 0x04 /* Object contains text relocations */
528 #define DF_BIND_NOW 0x08 /* No lazy binding for this object */
529 #define DF_STATIC_TLS 0x10 /* Static thread local storage */
530 
531 /* Standard ELF hashing function */
532 
533 unsigned long elf_hash(const unsigned char *name);
534 
535 #define ELF_TARG_VER 1 /* The ver for which this code is intended */
536 
537 /* XXX - PowerPC defines really don't belong in here,
538  * but we'll put them in for simplicity. */
539 
540 /* Values for Elf32/64_Ehdr.e_flags. */
541 #define EF_PPC_EMB 0x80000000 /* PowerPC embedded flag */
542 
543 /* Cygnus local bits below */
544 #define EF_PPC_RELOCATABLE 0x00010000 /* PowerPC -mrelocatable flag*/
545 #define EF_PPC_RELOCATABLE_LIB 0x00008000 /* PowerPC -mrelocatable-lib
546  flag */
547 
548 /* PowerPC relocations defined by the ABIs */
549 
550 #define R_PPC_NONE 0
551 #define R_PPC_ADDR32 1 /* 32bit absolute address */
552 #define R_PPC_ADDR24 2 /* 26bit address, 2 bits ignored. */
553 #define R_PPC_ADDR16 3 /* 16bit absolute address */
554 #define R_PPC_ADDR16_LO 4 /* lower 16bit of absolute address */
555 #define R_PPC_ADDR16_HI 5 /* high 16bit of absolute address */
556 #define R_PPC_ADDR16_HA 6 /* adjusted high 16bit */
557 #define R_PPC_ADDR14 7 /* 16bit address, 2 bits ignored */
558 #define R_PPC_ADDR14_BRTAKEN 8
559 #define R_PPC_ADDR14_BRNTAKEN 9
560 #define R_PPC_REL24 10 /* PC relative 26 bit */
561 #define R_PPC_REL14 11 /* PC relative 16 bit */
562 #define R_PPC_REL14_BRTAKEN 12
563 #define R_PPC_REL14_BRNTAKEN 13
564 #define R_PPC_GOT16 14
565 #define R_PPC_GOT16_LO 15
566 #define R_PPC_GOT16_HI 16
567 #define R_PPC_GOT16_HA 17
568 #define R_PPC_PLTREL24 18
569 #define R_PPC_COPY 19
570 #define R_PPC_GLOB_DAT 20
571 #define R_PPC_JMP_SLOT 21
572 #define R_PPC_RELATIVE 22
573 #define R_PPC_LOCAL24PC 23
574 #define R_PPC_UADDR32 24
575 #define R_PPC_UADDR16 25
576 #define R_PPC_REL32 26
577 #define R_PPC_PLT32 27
578 #define R_PPC_PLTREL32 28
579 #define R_PPC_PLT16_LO 29
580 #define R_PPC_PLT16_HI 30
581 #define R_PPC_PLT16_HA 31
582 #define R_PPC_SDAREL16 32
583 #define R_PPC_SECTOFF 33
584 #define R_PPC_SECTOFF_LO 34
585 #define R_PPC_SECTOFF_HI 35
586 #define R_PPC_SECTOFF_HA 36
587 /* Keep this the last entry. */
588 #define R_PPC_NUM 37
589 
590 /* The remaining relocs are from the Embedded ELF ABI, and are not
591  in the SVR4 ELF ABI. */
592 
593 #define R_PPC_EMB_NADDR32 101
594 #define R_PPC_EMB_NADDR16 102
595 #define R_PPC_EMB_NADDR16_LO 103
596 #define R_PPC_EMB_NADDR16_HI 104
597 #define R_PPC_EMB_NADDR16_HA 105
598 #define R_PPC_EMB_SDAI16 106
599 #define R_PPC_EMB_SDA2I16 107
600 #define R_PPC_EMB_SDA2REL 108
601 #define R_PPC_EMB_SDA21 109 /* 16 bit offset in SDA */
602 #define R_PPC_EMB_MRKREF 110
603 #define R_PPC_EMB_RELSEC16 111
604 #define R_PPC_EMB_RELST_LO 112
605 #define R_PPC_EMB_RELST_HI 113
606 #define R_PPC_EMB_RELST_HA 114
607 #define R_PPC_EMB_BIT_FLD 115
608 #define R_PPC_EMB_RELSDA 116 /* 16 bit relative offset in SDA */
609 
610 /* Diab tool relocations. */
611 #define R_PPC_DIAB_SDA21_LO 180 /* like EMB_SDA21, but lower 16 bit */
612 #define R_PPC_DIAB_SDA21_HI 181 /* like EMB_SDA21, but high 16 bit */
613 #define R_PPC_DIAB_SDA21_HA 182 /* like EMB_SDA21, adjusted high 16 */
614 #define R_PPC_DIAB_RELSDA_LO 183 /* like EMB_RELSDA, but lower 16 bit */
615 #define R_PPC_DIAB_RELSDA_HI 184 /* like EMB_RELSDA, but high 16 bit */
616 #define R_PPC_DIAB_RELSDA_HA 185 /* like EMB_RELSDA, adjusted high 16 */
617 
618 /* This is a phony reloc to handle any old fashioned TOC16 references
619  that may still be in object files. */
620 #define R_PPC_TOC16 255
621 
622 #endif /* _ELF_H */
GLuint const GLchar * name
Definition: glext.h:6671
Elf32_Addr p_paddr
Definition: elf_abi.h:437
Elf32_Word sh_addralign
Definition: elf_abi.h:250
unsigned char st_info
Definition: elf_abi.h:360
Definition: elf_abi.h:410
Elf32_Word p_type
Definition: elf_abi.h:434
Definition: elf_abi.h:111
Elf32_Word p_align
Definition: elf_abi.h:441
Elf32_Off e_phoff
Definition: elf_abi.h:118
Elf32_Word sh_size
Definition: elf_abi.h:247
Data type definitions.
Elf32_Off sh_offset
Definition: elf_abi.h:246
struct elf32_sym Elf32_Sym
unsigned char st_other
Definition: elf_abi.h:361
Elf32_Word st_size
Definition: elf_abi.h:359
uint32_t Elf32_Word
Definition: elf_abi.h:44
Definition: elf_abi.h:432
Elf32_Addr r_offset
Definition: elf_abi.h:412
Elf32_Word sh_flags
Definition: elf_abi.h:244
Definition: elf_abi.h:355
uint16_t Elf32_Half
Definition: elf_abi.h:45
Elf32_Word sh_info
Definition: elf_abi.h:249
#define EI_NIDENT
Definition: elf_abi.h:59
uint32_t Elf32_Addr
Definition: elf_abi.h:41
Definition: elf_abi.h:418
Elf32_Word sh_link
Definition: elf_abi.h:248
Elf32_Word sh_name
Definition: elf_abi.h:241
Elf32_Word p_memsz
Definition: elf_abi.h:439
struct elfhdr Elf32_Ehdr
Elf32_Word p_filesz
Definition: elf_abi.h:438
Elf32_Half st_shndx
Definition: elf_abi.h:362
unsigned char e_ident[EI_NIDENT]
Definition: elf_abi.h:113
Elf32_Half e_shentsize
Definition: elf_abi.h:124
Elf32_Word sh_entsize
Definition: elf_abi.h:251
Elf32_Addr st_value
Definition: elf_abi.h:358
unsigned long elf_hash(const unsigned char *name)
Elf32_Off p_offset
Definition: elf_abi.h:435
int32_t Elf32_Sword
Definition: elf_abi.h:43
Elf32_Half e_machine
Definition: elf_abi.h:115
uint32_t Elf32_Off
Definition: elf_abi.h:42
Elf32_Word st_name
Definition: elf_abi.h:357
Elf32_Addr e_entry
Definition: elf_abi.h:117
Elf32_Word sh_type
Definition: elf_abi.h:243
signed int int32_t
Definition: stdint.h:123
Elf32_Word e_version
Definition: elf_abi.h:116
Elf32_Sword d_tag
Definition: elf_abi.h:471
Elf32_Half e_shnum
Definition: elf_abi.h:125
Elf32_Half e_ehsize
Definition: elf_abi.h:121
Elf32_Half e_phentsize
Definition: elf_abi.h:122
Elf32_Sword r_addend
Definition: elf_abi.h:422
Elf32_Word p_flags
Definition: elf_abi.h:440
Elf32_Word r_info
Definition: elf_abi.h:421
Elf32_Word d_val
Definition: elf_abi.h:474
Elf32_Off e_shoff
Definition: elf_abi.h:119
Elf32_Addr r_offset
Definition: elf_abi.h:420
Definition: elf_abi.h:239
Elf32_Addr sh_addr
Definition: elf_abi.h:245
Elf32_Dyn _DYNAMIC[]
Elf32_Addr d_ptr
Definition: elf_abi.h:475
Elf32_Addr p_vaddr
Definition: elf_abi.h:436
Elf32_Half e_shstrndx
Definition: elf_abi.h:126
Elf32_Word e_flags
Definition: elf_abi.h:120
Definition: elf_abi.h:469
unsigned short uint16_t
Definition: stdint.h:125
unsigned int uint32_t
Definition: stdint.h:126
Elf32_Half e_phnum
Definition: elf_abi.h:123
Elf32_Half e_type
Definition: elf_abi.h:114
Elf32_Word r_info
Definition: elf_abi.h:413