root/trunk/freewrt/scripts/elf.h

Revision 3080, 104.2 kB (checked in by tg, 1 year ago)

--

Line 
1 /* This file defines standard ELF types, structures, and macros.
2    Copyright (C) 1995-2003, 2004 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, write to the Free
17    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18    02111-1307 USA.  */
19
20 #ifndef _ELF_H
21 #define _ELF_H 1
22
23 #include <sys/param.h>
24 #if !defined(BSD) && !defined(__APPLE__)
25 #include <features.h>
26 #endif
27
28 __BEGIN_DECLS
29
30 /* Standard ELF types.  */
31
32 #include <stdint.h>
33
34 /* Type for a 16-bit quantity.  */
35 typedef uint16_t Elf32_Half;
36 typedef uint16_t Elf64_Half;
37
38 /* Types for signed and unsigned 32-bit quantities.  */
39 typedef uint32_t Elf32_Word;
40 typedef int32_t  Elf32_Sword;
41 typedef uint32_t Elf64_Word;
42 typedef int32_t  Elf64_Sword;
43
44 /* Types for signed and unsigned 64-bit quantities.  */
45 typedef uint64_t Elf32_Xword;
46 typedef int64_t  Elf32_Sxword;
47 typedef uint64_t Elf64_Xword;
48 typedef int64_t  Elf64_Sxword;
49
50 /* Type of addresses.  */
51 typedef uint32_t Elf32_Addr;
52 typedef uint64_t Elf64_Addr;
53
54 /* Type of file offsets.  */
55 typedef uint32_t Elf32_Off;
56 typedef uint64_t Elf64_Off;
57
58 /* Type for section indices, which are 16-bit quantities.  */
59 typedef uint16_t Elf32_Section;
60 typedef uint16_t Elf64_Section;
61
62 /* Type for version symbol information.  */
63 typedef Elf32_Half Elf32_Versym;
64 typedef Elf64_Half Elf64_Versym;
65
66
67 /* The ELF file header.  This appears at the start of every ELF file.  */
68
69 #define EI_NIDENT (16)
70
71 typedef struct
72 {
73   unsigned char e_ident[EI_NIDENT];     /* Magic number and other info */
74   Elf32_Half    e_type;                 /* Object file type */
75   Elf32_Half    e_machine;              /* Architecture */
76   Elf32_Word    e_version;              /* Object file version */
77   Elf32_Addr    e_entry;                /* Entry point virtual address */
78   Elf32_Off     e_phoff;                /* Program header table file offset */
79   Elf32_Off     e_shoff;                /* Section header table file offset */
80   Elf32_Word    e_flags;                /* Processor-specific flags */
81   Elf32_Half    e_ehsize;               /* ELF header size in bytes */
82   Elf32_Half    e_phentsize;            /* Program header table entry size */
83   Elf32_Half    e_phnum;                /* Program header table entry count */
84   Elf32_Half    e_shentsize;            /* Section header table entry size */
85   Elf32_Half    e_shnum;                /* Section header table entry count */
86   Elf32_Half    e_shstrndx;             /* Section header string table index */
87 } Elf32_Ehdr;
88
89 typedef struct
90 {
91   unsigned char e_ident[EI_NIDENT];     /* Magic number and other info */
92   Elf64_Half    e_type;                 /* Object file type */
93   Elf64_Half    e_machine;              /* Architecture */
94   Elf64_Word    e_version;              /* Object file version */
95   Elf64_Addr    e_entry;                /* Entry point virtual address */
96   Elf64_Off     e_phoff;                /* Program header table file offset */
97   Elf64_Off     e_shoff;                /* Section header table file offset */
98   Elf64_Word    e_flags;                /* Processor-specific flags */
99   Elf64_Half    e_ehsize;               /* ELF header size in bytes */
100   Elf64_Half    e_phentsize;            /* Program header table entry size */
101   Elf64_Half    e_phnum;                /* Program header table entry count */
102   Elf64_Half    e_shentsize;            /* Section header table entry size */
103   Elf64_Half    e_shnum;                /* Section header table entry count */
104   Elf64_Half    e_shstrndx;             /* Section header string table index */
105 } Elf64_Ehdr;
106
107 /* Fields in the e_ident array.  The EI_* macros are indices into the
108    array.  The macros under each EI_* macro are the values the byte
109    may have.  */
110
111 #define EI_MAG0         0               /* File identification byte 0 index */
112 #define ELFMAG0         0x7f            /* Magic number byte 0 */
113
114 #define EI_MAG1         1               /* File identification byte 1 index */
115 #define ELFMAG1         'E'             /* Magic number byte 1 */
116
117 #define EI_MAG2         2               /* File identification byte 2 index */
118 #define ELFMAG2         'L'             /* Magic number byte 2 */
119
120 #define EI_MAG3         3               /* File identification byte 3 index */
121 #define ELFMAG3         'F'             /* Magic number byte 3 */
122
123 /* Conglomeration of the identification bytes, for easy testing as a word.  */
124 #define ELFMAG          "\177ELF"
125 #define SELFMAG         4
126
127 #define EI_CLASS        4               /* File class byte index */
128 #define ELFCLASSNONE    0               /* Invalid class */
129 #define ELFCLASS32      1               /* 32-bit objects */
130 #define ELFCLASS64      2               /* 64-bit objects */
131 #define ELFCLASSNUM     3
132
133 #define EI_DATA         5               /* Data encoding byte index */
134 #define ELFDATANONE     0               /* Invalid data encoding */
135 #define ELFDATA2LSB     1               /* 2's complement, little endian */
136 #define ELFDATA2MSB     2               /* 2's complement, big endian */
137 #define ELFDATANUM      3
138
139 #define EI_VERSION      6               /* File version byte index */
140                                         /* Value must be EV_CURRENT */
141
142 #define EI_OSABI        7               /* OS ABI identification */
143 #define ELFOSABI_NONE           0       /* UNIX System V ABI */
144 #define ELFOSABI_SYSV           0       /* Alias.  */
145 #define ELFOSABI_HPUX           1       /* HP-UX */
146 #define ELFOSABI_NETBSD         2       /* NetBSD.  */
147 #define ELFOSABI_LINUX          3       /* Linux.  */
148 #define ELFOSABI_SOLARIS        6       /* Sun Solaris.  */
149 #define ELFOSABI_AIX            7       /* IBM AIX.  */
150 #define ELFOSABI_IRIX           8       /* SGI Irix.  */
151 #define ELFOSABI_FREEBSD        9       /* FreeBSD.  */
152 #define ELFOSABI_TRU64          10      /* Compaq TRU64 UNIX.  */
153 #define ELFOSABI_MODESTO        11      /* Novell Modesto.  */
154 #define ELFOSABI_OPENBSD        12      /* OpenBSD.  */
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
225 #define EM_FX66         66              /* Siemens FX66 microcontroller */
226 #define EM_ST9PLUS      67              /* STMicroelectronics ST9+ 8/16 mc */
227 #define EM_ST7          68              /* STmicroelectronics ST7 8 bit mc */
228 #define EM_68HC16       69              /* Motorola MC68HC16 microcontroller */
229 #define EM_68HC11       70              /* Motorola MC68HC11 microcontroller */
230 #define EM_68HC08       71              /* Motorola MC68HC08 microcontroller */
231 #define EM_68HC05       72              /* Motorola MC68HC05 microcontroller */
232 #define EM_SVX          73              /* Silicon Graphics SVx */
233 #define EM_ST19         74              /* STMicroelectronics ST19 8 bit mc */
234 #define EM_VAX          75              /* Digital VAX */
235 #define EM_CRIS         76              /* Axis Communications 32-bit embedded processor */
236 #define EM_JAVELIN      77              /* Infineon Technologies 32-bit embedded processor */
237 #define EM_FIREPATH     78              /* Element 14 64-bit DSP Processor */
238 #define EM_ZSP          79              /* LSI Logic 16-bit DSP Processor */
239 #define EM_MMIX         80              /* Donald Knuth's educational 64-bit processor */
240 #define EM_HUANY        81              /* Harvard University machine-independent object files */
241 #define EM_PRISM        82              /* SiTera Prism */
242 #define EM_AVR          83              /* Atmel AVR 8-bit microcontroller */
243 #define EM_FR30         84              /* Fujitsu FR30 */
244 #define EM_D10V         85              /* Mitsubishi D10V */
245 #define EM_D30V         86              /* Mitsubishi D30V */
246 #define EM_V850         87              /* NEC v850 */
247 #define EM_M32R         88              /* Mitsubishi M32R */
248 #define EM_MN10300      89              /* Matsushita MN10300 */
249 #define EM_MN10200      90              /* Matsushita MN10200 */
250 #define EM_PJ           91              /* picoJava */
251 #define EM_OPENRISC     92              /* OpenRISC 32-bit embedded processor */
252 #define EM_ARC_A5       93              /* ARC Cores Tangent-A5 */
253 #define EM_XTENSA       94              /* Tensilica Xtensa Architecture */
254 #define EM_NUM          95
255
256 /* If it is necessary to assign new unofficial EM_* values, please
257    pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the
258    chances of collision with official or non-GNU unofficial values.  */
259
260 #define EM_ALPHA        0x9026
261
262 /* Legal values for e_version (version).  */
263
264 #define EV_NONE         0               /* Invalid ELF version */
265 #define EV_CURRENT      1               /* Current version */
266 #define EV_NUM          2
267
268 /* Section header.  */
269
270 typedef struct
271 {
272   Elf32_Word    sh_name;                /* Section name (string tbl index) */
273   Elf32_Word    sh_type;                /* Section type */
274   Elf32_Word    sh_flags;               /* Section flags */
275   Elf32_Addr    sh_addr;                /* Section virtual addr at execution */
276   Elf32_Off     sh_offset;              /* Section file offset */
277   Elf32_Word    sh_size;                /* Section size in bytes */
278   Elf32_Word    sh_link;                /* Link to another section */
279   Elf32_Word    sh_info;                /* Additional section information */
280   Elf32_Word    sh_addralign;           /* Section alignment */
281   Elf32_Word    sh_entsize;             /* Entry size if section holds table */
282 } Elf32_Shdr;
283
284 typedef struct
285 {
286   Elf64_Word    sh_name;                /* Section name (string tbl index) */
287   Elf64_Word    sh_type;                /* Section type */
288   Elf64_Xword   sh_flags;               /* Section flags */
289   Elf64_Addr    sh_addr;                /* Section virtual addr at execution */
290   Elf64_Off     sh_offset;              /* Section file offset */
291   Elf64_Xword   sh_size;                /* Section size in bytes */
292   Elf64_Word    sh_link;                /* Link to another section */
293   Elf64_Word    sh_info;                /* Additional section information */
294   Elf64_Xword   sh_addralign;           /* Section alignment */
295   Elf64_Xword   sh_entsize;             /* Entry size if section holds table */
296 } Elf64_Shdr;
297
298 /* Special section indices.  */
299
300 #define SHN_UNDEF       0               /* Undefined section */
301 #define SHN_LORESERVE   0xff00          /* Start of reserved indices */
302 #define SHN_LOPROC      0xff00          /* Start of processor-specific */
303 #define SHN_BEFORE      0xff00          /* Order section before all others
304                                            (Solaris).  */
305 #define SHN_AFTER       0xff01          /* Order section after all others
306                                            (Solaris).  */
307 #define SHN_HIPROC      0xff1f          /* End of processor-specific */
308 #define SHN_LOOS        0xff20          /* Start of OS-specific */
309 #define SHN_HIOS        0xff3f          /* End of OS-specific */
310 #define SHN_ABS         0xfff1          /* Associated symbol is absolute */
311 #define SHN_COMMON      0xfff2          /* Associated symbol is common */
312 #define SHN_XINDEX      0xffff          /* Index is in extra table.  */
313 #define SHN_HIRESERVE   0xffff          /* End of reserved indices */
314
315 /* Legal values for sh_type (section type).  */
316
317 #define SHT_NULL          0             /* Section header table entry unused */
318 #define SHT_PROGBITS      1             /* Program data */
319 #define SHT_SYMTAB        2             /* Symbol table */
320 #define SHT_STRTAB        3             /* String table */
321 #define SHT_RELA          4             /* Relocation entries with addends */
322 #define SHT_HASH          5             /* Symbol hash table */
323 #define SHT_DYNAMIC       6             /* Dynamic linking information */
324 #define SHT_NOTE          7             /* Notes */
325 #define SHT_NOBITS        8             /* Program space with no data (bss) */
326 #define SHT_REL           9             /* Relocation entries, no addends */
327 #define SHT_SHLIB         10            /* Reserved */
328 #define SHT_DYNSYM        11            /* Dynamic linker symbol table */
329 #define SHT_INIT_ARRAY    14            /* Array of constructors */
330 #define SHT_FINI_ARRAY    15            /* Array of destructors */
331 #define SHT_PREINIT_ARRAY 16            /* Array of pre-constructors */
332 #define SHT_GROUP         17            /* Section group */
333 #define SHT_SYMTAB_SHNDX  18            /* Extended section indeces */
334 #define SHT_NUM           19            /* Number of defined types.  */
335 #define SHT_LOOS          0x60000000    /* Start OS-specific */
336 #define SHT_GNU_LIBLIST   0x6ffffff7    /* Prelink library list */
337 #define SHT_CHECKSUM      0x6ffffff8    /* Checksum for DSO content.  */
338 #define SHT_LOSUNW        0x6ffffffa    /* Sun-specific low bound.  */
339 #define SHT_SUNW_move     0x6ffffffa
340 #define SHT_SUNW_COMDAT   0x6ffffffb
341 #define SHT_SUNW_syminfo  0x6ffffffc
342 #define SHT_GNU_verdef    0x6ffffffd    /* Version definition section.  */
343 #define SHT_GNU_verneed   0x6ffffffe    /* Version needs section.  */
344 #define SHT_GNU_versym    0x6fffffff    /* Version symbol table.  */
345 #define SHT_HISUNW        0x6fffffff    /* Sun-specific high bound.  */
346 #define SHT_HIOS          0x6fffffff    /* End OS-specific type */
347 #define SHT_LOPROC        0x70000000    /* Start of processor-specific */
348 #define SHT_HIPROC        0x7fffffff    /* End of processor-specific */
349 #define SHT_LOUSER        0x80000000    /* Start of application-specific */
350 #define SHT_HIUSER        0x8fffffff    /* End of application-specific */
351
352 /* Legal values for sh_flags (section flags).  */
353
354 #define SHF_WRITE            (1 << 0)   /* Writable */
355 #define SHF_ALLOC            (1 << 1)   /* Occupies memory during execution */
356 #define SHF_EXECINSTR        (1 << 2)   /* Executable */
357 #define SHF_MERGE            (1 << 4)   /* Might be merged */
358 #define SHF_STRINGS          (1 << 5)   /* Contains nul-terminated strings */
359 #define SHF_INFO_LINK        (1 << 6)   /* `sh_info' contains SHT index */
360 #define SHF_LINK_ORDER       (1 << 7)   /* Preserve order after combining */
361 #define SHF_OS_NONCONFORMING (1 << 8)   /* Non-standard OS specific handling
362                                            required */
363 #define SHF_GROUP            (1 << 9)   /* Section is member of a group.  */
364 #define SHF_TLS              (1 << 10)  /* Section hold thread-local data.  */
365 #define SHF_MASKOS           0x0ff00000 /* OS-specific.  */
366 #define SHF_MASKPROC         0xf0000000 /* Processor-specific */
367 #define SHF_ORDERED          (1 << 30)  /* Special ordering requirement
368                                            (Solaris).  */
369 #define SHF_EXCLUDE          (1 << 31)  /* Section is excluded unless
370                                            referenced or allocated (Solaris).*/
371
372 /* Section group handling.  */
373 #define GRP_COMDAT      0x1             /* Mark group as COMDAT.  */
374
375 /* Symbol table entry.  */
376
377 typedef struct
378 {
379   Elf32_Word    st_name;                /* Symbol name (string tbl index) */
380   Elf32_Addr    st_value;               /* Symbol value */
381   Elf32_Word    st_size;                /* Symbol size */
382   unsigned char st_info;                /* Symbol type and binding */
383   unsigned char st_other;               /* Symbol visibility */
384   Elf32_Section st_shndx;               /* Section index */
385 } Elf32_Sym;
386
387 typedef struct
388 {
389   Elf64_Word    st_name;                /* Symbol name (string tbl index) */
390   unsigned char st_info;                /* Symbol type and binding */
391   unsigned char st_other;               /* Symbol visibility */
392   Elf64_Section st_shndx;               /* Section index */
393   Elf64_Addr    st_value;               /* Symbol value */
394   Elf64_Xword   st_size;                /* Symbol size */
395 } Elf64_Sym;
396
397 /* The syminfo section if available contains additional information about
398    every dynamic symbol.  */
399
400 typedef struct
401 {
402   Elf32_Half si_boundto;                /* Direct bindings, symbol bound to */
403   Elf32_Half si_flags;                  /* Per symbol flags */
404 } Elf32_Syminfo;
405
406 typedef struct
407 {
408   Elf64_Half si_boundto;                /* Direct bindings, symbol bound to */
409   Elf64_Half si_flags;                  /* Per symbol flags */
410 } Elf64_Syminfo;
411
412 /* Possible values for si_boundto.  */
413 #define SYMINFO_BT_SELF         0xffff  /* Symbol bound to self */
414 #define SYMINFO_BT_PARENT       0xfffe  /* Symbol bound to parent */
415 #define SYMINFO_BT_LOWRESERVE   0xff00  /* Beginning of reserved entries */
416
417 /* Possible bitmasks for si_flags.  */
418 #define SYMINFO_FLG_DIRECT      0x0001  /* Direct bound symbol */
419 #define SYMINFO_FLG_PASSTHRU    0x0002  /* Pass-thru symbol for translator */
420 #define SYMINFO_FLG_COPY        0x0004  /* Symbol is a copy-reloc */
421 #define SYMINFO_FLG_LAZYLOAD    0x0008  /* Symbol bound to object to be lazy
422                                            loaded */
423 /* Syminfo version values.  */
424 #define SYMINFO_NONE            0
425 #define SYMINFO_CURRENT         1
426 #define SYMINFO_NUM             2
427
428
429 /* How to extract and insert information held in the st_info field.  */
430
431 #define ELF32_ST_BIND(val)              (((unsigned char) (val)) >> 4)
432 #define ELF32_ST_TYPE(val)              ((val) & 0xf)
433 #define ELF32_ST_INFO(bind, type)       (((bind) << 4) + ((type) & 0xf))
434
435 /* Both Elf32_Sym and Elf64_Sym use the same one-byte st_info field.  */
436 #define ELF64_ST_BIND(val)              ELF32_ST_BIND (val)
437 #define ELF64_ST_TYPE(val)              ELF32_ST_TYPE (val)
438 #define ELF64_ST_INFO(bind, type)       ELF32_ST_INFO ((bind), (type))
439
440 /* Legal values for ST_BIND subfield of st_info (symbol binding).  */
441
442 #define STB_LOCAL       0               /* Local symbol */
443 #define STB_GLOBAL      1               /* Global symbol */
444 #define STB_WEAK        2               /* Weak symbol */
445 #define STB_NUM         3               /* Number of defined types.  */
446 #define STB_LOOS        10              /* Start of OS-specific */
447 #define STB_HIOS        12              /* End of OS-specific */
448 #define STB_LOPROC      13              /* Start of processor-specific */
449 #define STB_HIPROC      15              /* End of processor-specific */
450
451 /* Legal values for ST_TYPE subfield of st_info (symbol type).  */
452
453 #define STT_NOTYPE      0               /* Symbol type is unspecified */
454 #define STT_OBJECT      1               /* Symbol is a data object */
455 #define STT_FUNC        2               /* Symbol is a code object */
456 #define STT_SECTION     3               /* Symbol associated with a section */
457 #define STT_FILE        4               /* Symbol's name is file name */
458 #define STT_COMMON      5               /* Symbol is a common data object */
459 #define STT_TLS         6               /* Symbol is thread-local data object*/
460 #define STT_NUM         7               /* Number of defined types.  */
461 #define STT_LOOS        10              /* Start of OS-specific */
462 #define STT_HIOS        12              /* End of OS-specific */
463 #define STT_LOPROC      13              /* Start of processor-specific */
464 #define STT_HIPROC      15              /* End of processor-specific */
465
466
467 /* Symbol table indices are found in the hash buckets and chain table
468    of a symbol hash table section.  This special index value indicates
469    the end of a chain, meaning no further symbols are found in that bucket.  */
470
471 #define STN_UNDEF       0               /* End of a chain.  */
472
473
474 /* How to extract and insert information held in the st_other field.  */
475
476 #define ELF32_ST_VISIBILITY(o)  ((o) & 0x03)
477
478 /* For ELF64 the definitions are the same.  */
479 #define ELF64_ST_VISIBILITY(o)  ELF32_ST_VISIBILITY (o)
480
481 /* Symbol visibility specification encoded in the st_other field.  */
482 #define STV_DEFAULT     0               /* Default symbol visibility rules */
483 #define STV_INTERNAL    1               /* Processor specific hidden class */
484 #define STV_HIDDEN      2               /* Sym unavailable in other modules */
485 #define STV_PROTECTED   3               /* Not preemptible, not exported */
486
487
488 /* Relocation table entry without addend (in section of type SHT_REL).  */
489
490 typedef struct
491 {
492   Elf32_Addr    r_offset;               /* Address */
493   Elf32_Word    r_info;                 /* Relocation type and symbol index */
494 } Elf32_Rel;
495
496 /* I have seen two different definitions of the Elf64_Rel and
497    Elf64_Rela structures, so we'll leave them out until Novell (or
498    whoever) gets their act together.  */
499 /* The following, at least, is used on Sparc v9, MIPS, and Alpha.  */
500
501 typedef struct
502 {
503   Elf64_Addr    r_offset;               /* Address */
504   Elf64_Xword   r_info;                 /* Relocation type and symbol index */
505 } Elf64_Rel;
506
507 /* Relocation table entry with addend (in section of type SHT_RELA).  */
508
509 typedef struct
510 {
511   Elf32_Addr    r_offset;               /* Address */
512   Elf32_Word    r_info;                 /* Relocation type and symbol index */
513   Elf32_Sword   r_addend;               /* Addend */
514 } Elf32_Rela;
515
516 typedef struct
517 {
518   Elf64_Addr    r_offset;               /* Address */
519   Elf64_Xword   r_info;                 /* Relocation type and symbol index */
520   Elf64_Sxword  r_addend;               /* Addend */
521 } Elf64_Rela;
522
523 /* How to extract and insert information held in the r_info field.  */
524
525 #define ELF32_R_SYM(val)                ((val) >> 8)
526 #define ELF32_R_TYPE(val)               ((val) & 0xff)
527 #define ELF32_R_INFO(sym, type)         (((sym) << 8) + ((type) & 0xff))
528
529 #define ELF64_R_SYM(i)                  ((i) >> 32)
530 #define ELF64_R_TYPE(i)                 ((i) & 0xffffffff)
531 #define ELF64_R_INFO(sym,type)          ((((Elf64_Xword) (sym)) << 32) + (type))
532
533 /* Program segment header.  */
534
535 typedef struct
536 {
537   Elf32_Word    p_type;                 /* Segment type */
538   Elf32_Off     p_offset;               /* Segment file offset */
539   Elf32_Addr    p_vaddr;                /* Segment virtual address */
540   Elf32_Addr    p_paddr;                /* Segment physical address */
541   Elf32_Word    p_filesz;               /* Segment size in file */
542   Elf32_Word    p_memsz;                /* Segment size in memory */
543   Elf32_Word    p_flags;                /* Segment flags */
544   Elf32_Word    p_align;                /* Segment alignment */
545 } Elf32_Phdr;
546
547 typedef struct
548 {
549   Elf64_Word    p_type;                 /* Segment type */
550   Elf64_Word    p_flags;                /* Segment flags */
551   Elf64_Off     p_offset;               /* Segment file offset */
552   Elf64_Addr    p_vaddr;                /* Segment virtual address */
553   Elf64_Addr    p_paddr;                /* Segment physical address */
554   Elf64_Xword   p_filesz;               /* Segment size in file */
555   Elf64_Xword   p_memsz;                /* Segment size in memory */
556   Elf64_Xword   p_align;                /* Segment alignment */
557 } Elf64_Phdr;
558
559 /* Legal values for p_type (segment type).  */
560
561 #define PT_NULL         0               /* Program header table entry unused */
562 #define PT_LOAD         1               /* Loadable program segment */
563 #define PT_DYNAMIC      2               /* Dynamic linking information */
564 #define PT_INTERP       3               /* Program interpreter */
565 #define PT_NOTE         4               /* Auxiliary information */
566 #define PT_SHLIB        5               /* Reserved */
567 #define PT_PHDR         6               /* Entry for header table itself */
568 #define PT_TLS          7               /* Thread-local storage segment */
569 #define PT_NUM          8               /* Number of defined types */
570 #define PT_LOOS         0x60000000      /* Start of OS-specific */
571 #define PT_GNU_EH_FRAME 0x6474e550      /* GCC .eh_frame_hdr segment */
572 #define PT_GNU_STACK    0x6474e551      /* Indicates stack executability */
573 #define PT_GNU_RELRO    0x6474e552      /* Read-only after relocation */
574 #define PT_LOSUNW       0x6ffffffa
575 #define PT_SUNWBSS      0x6ffffffa      /* Sun Specific segment */
576 #define PT_SUNWSTACK    0x6ffffffb      /* Stack segment */
577 #define PT_HISUNW       0x6fffffff
578 #define PT_HIOS         0x6fffffff      /* End of OS-specific */
579 #define PT_LOPROC       0x70000000      /* Start of processor-specific */
580 #define PT_HIPROC       0x7fffffff      /* End of processor-specific */
581
582 /* Legal values for p_flags (segment flags).  */
583
584 #define PF_X            (1 << 0)        /* Segment is executable */
585 #define PF_W            (1 << 1)        /* Segment is writable */
586 #define PF_R            (1 << 2)        /* Segment is readable */
587 #define PF_MASKOS       0x0ff00000      /* OS-specific */
588 #define PF_MASKPROC     0xf0000000      /* Processor-specific */
589
590 /* Legal values for note segment descriptor types for core files. */
591
592 #define NT_PRSTATUS     1               /* Contains copy of prstatus struct */
593 #define NT_FPREGSET     2               /* Contains copy of fpregset struct */
594 #define NT_PRPSINFO     3               /* Contains copy of prpsinfo struct */
595 #define NT_PRXREG       4               /* Contains copy of prxregset struct */
596 #define NT_TASKSTRUCT   4               /* Contains copy of task structure */
597 #define NT_PLATFORM     5               /* String from sysinfo(SI_PLATFORM) */
598 #define NT_AUXV         6               /* Contains copy of auxv array */
599 #define NT_GWINDOWS     7               /* Contains copy of gwindows struct */
600 #define NT_ASRS         8               /* Contains copy of asrset struct */
601 #define NT_PSTATUS      10              /* Contains copy of pstatus struct */
602 #define NT_PSINFO       13              /* Contains copy of psinfo struct */
603 #define NT_PRCRED       14              /* Contains copy of prcred struct */
604 #define NT_UTSNAME      15              /* Contains copy of utsname struct */
605 #define NT_LWPSTATUS    16              /* Contains copy of lwpstatus struct */
606 #define NT_LWPSINFO  &