Sat Feb 10 13:09:03 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
[platform/upstream/glibc.git] / elf / elf.h
1 /* This file defines standard ELF types, structures, and macros.
2 Copyright (C) 1995, 1996 Free Software Foundation, Inc.
3 Contributed by Ian Lance Taylor (ian@cygnus.com).
4
5 This file is part of the GNU C Library.
6
7 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public License as
9 published by the Free Software Foundation; either version 2 of the
10 License, or (at your option) any later version.
11
12 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 Library General Public License for more details.
16
17 You should have received a copy of the GNU Library General Public
18 License along with the GNU C Library; see the file COPYING.LIB.  If
19 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
20 Cambridge, MA 02139, USA.  */
21
22 #ifndef _ELF_H
23 #define _ELF_H 1
24
25
26 /* Standard ELF types.
27
28    Using __attribute__ mode ensures that gcc will choose the right for
29    these types.  */
30
31 typedef unsigned int Elf32_Addr    __attribute__ ((mode (SI)));
32 typedef unsigned int Elf32_Half    __attribute__ ((mode (HI)));
33 typedef unsigned int Elf32_Off     __attribute__ ((mode (SI)));
34 typedef          int Elf32_Sword   __attribute__ ((mode (SI)));
35 typedef unsigned int Elf32_Word    __attribute__ ((mode (SI)));
36
37 /* The ELF file header.  This appears at the start of every ELF file.  */
38
39 #define EI_NIDENT (16)
40
41 typedef struct
42 {
43   unsigned char e_ident[EI_NIDENT];     /* Magic number and other info */
44   Elf32_Half    e_type;                 /* Object file type */
45   Elf32_Half    e_machine;              /* Architecture */
46   Elf32_Word    e_version;              /* Object file version */
47   Elf32_Addr    e_entry;                /* Entry point virtual address */
48   Elf32_Off     e_phoff;                /* Program header table file offset */
49   Elf32_Off     e_shoff;                /* Section header table file offset */
50   Elf32_Word    e_flags;                /* Processor-specific flags */
51   Elf32_Half    e_ehsize;               /* ELF header size in bytes */
52   Elf32_Half    e_phentsize;            /* Program header table entry size */
53   Elf32_Half    e_phnum;                /* Program header table entry count */
54   Elf32_Half    e_shentsize;            /* Section header table entry size */
55   Elf32_Half    e_shnum;                /* Section header table entry count */
56   Elf32_Half    e_shstrndx;             /* Section header string table index */
57 } Elf32_Ehdr;
58
59 /* Fields in the e_ident array.  The EI_* macros are indices into the
60    array.  The macros under each EI_* macro are the values the byte
61    may have.  */
62
63 #define EI_MAG0         0               /* File identification byte 0 index */
64 #define ELFMAG0         0x7f            /* Magic number byte 0 */
65
66 #define EI_MAG1         1               /* File identification byte 1 index */
67 #define ELFMAG1         'E'             /* Magic number byte 1 */
68
69 #define EI_MAG2         2               /* File identification byte 2 index */
70 #define ELFMAG2         'L'             /* Magic number byte 2 */
71
72 #define EI_MAG3         3               /* File identification byte 3 index */
73 #define ELFMAG3         'F'             /* Magic number byte 3 */
74
75 /* Conglomeration of the identification bytes, for easy testing as a word.  */
76 #define ELFMAG          "\177ELF"
77 #define SELFMAG         4
78
79 #define EI_CLASS        4               /* File class byte index */
80 #define ELFCLASSNONE    0               /* Invalid class */
81 #define ELFCLASS32      1               /* 32-bit objects */
82 #define ELFCLASS64      2               /* 64-bit objects */
83
84 #define EI_DATA         5               /* Data encoding byte index */
85 #define ELFDATANONE     0               /* Invalid data encoding */
86 #define ELFDATA2LSB     1               /* 2's complement, little endian */
87 #define ELFDATA2MSB     2               /* 2's complement, big endian */
88
89 #define EI_VERSION      6               /* File version byte index */
90                                         /* Value must be EV_CURRENT */
91
92 #define EI_PAD          7               /* Byte index of padding bytes */
93
94 /* Legal values for e_type (object file type).  */
95
96 #define ET_NONE         0               /* No file type */
97 #define ET_REL          1               /* Relocatable file */
98 #define ET_EXEC         2               /* Executable file */
99 #define ET_DYN          3               /* Shared object file */
100 #define ET_CORE         4               /* Core file */
101 #define ET_NUM          5               /* Number of defined types.  */
102 #define ET_LOPROC       0xff00          /* Processor-specific */
103 #define ET_HIPROC       0xffff          /* Processor-specific */
104
105 /* Legal values for e_machine (architecture).  */
106
107 #define EM_NONE         0               /* No machine */
108 #define EM_M32          1               /* AT&T WE 32100 */
109 #define EM_SPARC        2               /* SUN SPARC */
110 #define EM_386          3               /* Intel 80386 */
111 #define EM_68K          4               /* Motorola m68k family */
112 #define EM_88K          5               /* Motorola m88k family */
113 #define EM_486          6               /* Intel 80486 */
114 #define EM_860          7               /* Intel 80860 */
115 #define EM_MIPS         8               /* MIPS R3000 big-endian */
116 #define EM_S370         9               /* Amdahl */
117 #define EM_MIPS_RS4_BE 10               /* MIPS R4000 big-endian */
118
119 #define EM_SPARC64     11               /* SPARC v9 (not official) 64-bit */
120
121 #define EM_PARISC      15               /* HPPA */
122
123 /* If it is necessary to assign new unofficial EM_* values, please
124    pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the
125    chances of collision with official or non-GNU unofficial values.  */
126
127 /* Legal values for e_version (version).  */
128
129 #define EV_NONE         0               /* Invalid ELF version */
130 #define EV_CURRENT      1               /* Current version */
131
132 /* Section header.  */
133
134 typedef struct
135 {
136   Elf32_Word    sh_name;                /* Section name (string tbl index) */
137   Elf32_Word    sh_type;                /* Section type */
138   Elf32_Word    sh_flags;               /* Section flags */
139   Elf32_Addr    sh_addr;                /* Section virtual addr at execution */
140   Elf32_Off     sh_offset;              /* Section file offset */
141   Elf32_Word    sh_size;                /* Section size in bytes */
142   Elf32_Word    sh_link;                /* Link to another section */
143   Elf32_Word    sh_info;                /* Additional section information */
144   Elf32_Word    sh_addralign;           /* Section alignment */
145   Elf32_Word    sh_entsize;             /* Entry size if section holds table */
146 } Elf32_Shdr;
147
148 /* Special section indices.  */
149
150 #define SHN_UNDEF       0               /* Undefined section */
151 #define SHN_LORESERVE   0xff00          /* Start of reserved indices */
152 #define SHN_LOPROC      0xff00          /* Start of processor-specific */
153 #define SHN_HIPROC      0xff1f          /* End of processor-specific */
154 #define SHN_ABS         0xfff1          /* Associated symbol is absolute */
155 #define SHN_COMMON      0xfff2          /* Associated symbol is common */
156 #define SHN_HIRESERVE   0xffff          /* End of reserved indices */
157
158 /* Legal values for sh_type (section type).  */
159
160 #define SHT_NULL        0               /* Section header table entry unused */
161 #define SHT_PROGBITS    1               /* Program data */
162 #define SHT_SYMTAB      2               /* Symbol table */
163 #define SHT_STRTAB      3               /* String table */
164 #define SHT_RELA        4               /* Relocation entries with addends */
165 #define SHT_HASH        5               /* Symbol hash table */
166 #define SHT_DYNAMIC     6               /* Dynamic linking information */
167 #define SHT_NOTE        7               /* Notes */
168 #define SHT_NOBITS      8               /* Program space with no data (bss) */
169 #define SHT_REL         9               /* Relocation entries, no addends */
170 #define SHT_SHLIB       10              /* Reserved */
171 #define SHT_DYNSYM      11              /* Dynamic linker symbol table */
172 #define SHT_NUM         12              /* Number of defined types.  */
173 #define SHT_LOPROC      0x70000000      /* Start of processor-specific */
174 #define SHT_HIPROC      0x7fffffff      /* End of processor-specific */
175 #define SHT_LOUSER      0x80000000      /* Start of application-specific */
176 #define SHT_HIUSER      0x8fffffff      /* End of application-specific */
177
178 /* Legal values for sh_flags (section flags).  */
179
180 #define SHF_WRITE       (1 << 0)        /* Writable */
181 #define SHF_ALLOC       (1 << 1)        /* Occupies memory during execution */
182 #define SHF_EXECINSTR   (1 << 2)        /* Executable */
183 #define SHF_MASKPROC    0xf0000000      /* Processor-specific */
184
185 /* Symbol table entry.  */
186
187 typedef struct
188 {
189   Elf32_Word    st_name;                /* Symbol name (string tbl index) */
190   Elf32_Addr    st_value;               /* Symbol value */
191   Elf32_Word    st_size;                /* Symbol size */
192   unsigned char st_info;                /* Symbol type and binding */
193   unsigned char st_other;               /* No defined meaning, 0 */
194   Elf32_Half    st_shndx;               /* Section index */
195 } Elf32_Sym;
196
197 /* Special section index.  */
198
199 #define SHN_UNDEF       0               /* No section, undefined symbol.  */
200
201 /* How to extract and insert information held in the st_info field.  */
202
203 #define ELF32_ST_BIND(val)              (((unsigned char) (val)) >> 4)
204 #define ELF32_ST_TYPE(val)              ((val) & 0xf)
205 #define ELF32_ST_INFO(bind, type)       (((bind) << 4) + ((type) & 0xf))
206
207 /* Legal values for ST_BIND subfield of st_info (symbol binding).  */
208
209 #define STB_LOCAL       0               /* Local symbol */
210 #define STB_GLOBAL      1               /* Global symbol */
211 #define STB_WEAK        2               /* Weak symbol */
212 #define STB_NUM         3               /* Number of defined types.  */
213 #define STB_LOPROC      13              /* Start of processor-specific */
214 #define STB_HIPROC      15              /* End of processor-specific */
215
216 /* Legal values for ST_TYPE subfield of st_info (symbol type).  */
217
218 #define STT_NOTYPE      0               /* Symbol type is unspecified */
219 #define STT_OBJECT      1               /* Symbol is a data object */
220 #define STT_FUNC        2               /* Symbol is a code object */
221 #define STT_SECTION     3               /* Symbol associated with a section */
222 #define STT_FILE        4               /* Symbol's name is file name */
223 #define STT_NUM         5               /* Number of defined types.  */
224 #define STT_LOPROC      13              /* Start of processor-specific */
225 #define STT_HIPROC      15              /* End of processor-specific */
226
227
228 /* Symbol table indices are found in the hash buckets and chain table
229    of a symbol hash table section.  This special index value indicates
230    the end of a chain, meaning no further symbols are found in that bucket.  */
231
232 #define STN_UNDEF       0               /* End of a chain.  */
233
234
235 /* Relocation table entry without addend (in section of type SHT_REL).  */
236
237 typedef struct
238 {
239   Elf32_Addr    r_offset;               /* Address */
240   Elf32_Word    r_info;                 /* Relocation type and symbol index */
241 } Elf32_Rel;
242
243 /* Relocation table entry with addend (in section of type SHT_RELA).  */
244
245 typedef struct
246 {
247   Elf32_Addr    r_offset;               /* Address */
248   Elf32_Word    r_info;                 /* Relocation type and symbol index */
249   Elf32_Sword   r_addend;               /* Addend */
250 } Elf32_Rela;
251
252 /* How to extract and insert information held in the r_info field.  */
253
254 #define ELF32_R_SYM(val)                ((val) >> 8)
255 #define ELF32_R_TYPE(val)               ((val) & 0xff)
256 #define ELF32_R_INFO(sym, type)         (((sym) << 8) + ((type) & 0xff))
257
258 /* Program segment header.  */
259
260 typedef struct {
261   Elf32_Word    p_type;                 /* Segment type */
262   Elf32_Off     p_offset;               /* Segment file offset */
263   Elf32_Addr    p_vaddr;                /* Segment virtual address */
264   Elf32_Addr    p_paddr;                /* Segment physical address */
265   Elf32_Word    p_filesz;               /* Segment size in file */
266   Elf32_Word    p_memsz;                /* Segment size in memory */
267   Elf32_Word    p_flags;                /* Segment flags */
268   Elf32_Word    p_align;                /* Segment alignment */
269 } Elf32_Phdr;
270
271 /* Legal values for p_type (segment type).  */
272
273 #define PT_NULL         0               /* Program header table entry unused */
274 #define PT_LOAD         1               /* Loadable program segment */
275 #define PT_DYNAMIC      2               /* Dynamic linking information */
276 #define PT_INTERP       3               /* Program interpreter */
277 #define PT_NOTE         4               /* Auxiliary information */
278 #define PT_SHLIB        5               /* Reserved */
279 #define PT_PHDR         6               /* Entry for header table itself */
280 #define PT_NUM          7               /* Number of defined types.  */
281 #define PT_LOPROC       0x70000000      /* Start of processor-specific */
282 #define PT_HIPROC       0x7fffffff      /* End of processor-specific */
283
284 /* Legal values for p_flags (segment flags).  */
285
286 #define PF_X            (1 << 0)        /* Segment is executable */
287 #define PF_W            (1 << 1)        /* Segment is writable */
288 #define PF_R            (1 << 2)        /* Segment is readable */
289 #define PF_MASKPROC     0xf0000000      /* Processor-specific */
290
291 /* Dynamic section entry.  */
292
293 typedef struct
294 {
295   Elf32_Sword   d_tag;                  /* Dynamic entry type */
296   union
297     {
298       Elf32_Word d_val;                 /* Integer value */
299       Elf32_Addr d_ptr;                 /* Address value */
300     } d_un;
301 } Elf32_Dyn;
302
303 /* Legal values for d_tag (dynamic entry type).  */
304
305 #define DT_NULL         0               /* Marks end of dynamic section */
306 #define DT_NEEDED       1               /* Name of needed library */
307 #define DT_PLTRELSZ     2               /* Size in bytes of PLT relocs */
308 #define DT_PLTGOT       3               /* Processor defined value */
309 #define DT_HASH         4               /* Address of symbol hash table */
310 #define DT_STRTAB       5               /* Address of string table */
311 #define DT_SYMTAB       6               /* Address of symbol table */
312 #define DT_RELA         7               /* Address of Rela relocs */
313 #define DT_RELASZ       8               /* Total size of Rela relocs */
314 #define DT_RELAENT      9               /* Size of one Rela reloc */
315 #define DT_STRSZ        10              /* Size of string table */
316 #define DT_SYMENT       11              /* Size of one symbol table entry */
317 #define DT_INIT         12              /* Address of init function */
318 #define DT_FINI         13              /* Address of termination function */
319 #define DT_SONAME       14              /* Name of shared object */
320 #define DT_RPATH        15              /* Library search path */
321 #define DT_SYMBOLIC     16              /* Start symbol search here */
322 #define DT_REL          17              /* Address of Rel relocs */
323 #define DT_RELSZ        18              /* Total size of Rel relocs */
324 #define DT_RELENT       19              /* Size of one Rel reloc */
325 #define DT_PLTREL       20              /* Type of reloc in PLT */
326 #define DT_DEBUG        21              /* For debugging; unspecified */
327 #define DT_TEXTREL      22              /* Reloc might modify .text */
328 #define DT_JMPREL       23              /* Address of PLT relocs */
329 #define DT_NUM          24              /* Number used */
330 #define DT_LOPROC       0x70000000      /* Start of processor-specific */
331 #define DT_HIPROC       0x7fffffff      /* End of processor-specific */
332 #define DT_PROCNUM      DT_MIPS_NUM     /* Most used by any processor */
333
334 /* Standard 64 bit ELF types.  */
335
336 typedef unsigned int Elf64_Addr    __attribute__ ((mode (DI)));
337 typedef unsigned int Elf64_Half    __attribute__ ((mode (HI)));
338 typedef unsigned int Elf64_Off     __attribute__ ((mode (DI)));
339 typedef          int Elf64_Sword   __attribute__ ((mode (SI)));
340 typedef          int Elf64_Sxword  __attribute__ ((mode (DI)));
341 typedef unsigned int Elf64_Word    __attribute__ ((mode (SI)));
342 typedef unsigned int Elf64_Xword   __attribute__ ((mode (DI)));
343 typedef unsigned int Elf64_Byte    __attribute__ ((mode (QI)));
344 typedef unsigned int Elf64_Section __attribute__ ((mode (HI)));
345
346 /* 64 bit ELF file header.  */
347
348 typedef struct
349 {
350   unsigned char e_ident[EI_NIDENT];     /* Magic number and other info */
351   Elf64_Half    e_type;                 /* Object file type */
352   Elf64_Half    e_machine;              /* Architecture */
353   Elf64_Word    e_version;              /* Object file version */
354   Elf64_Addr    e_entry;                /* Entry point virtual address */
355   Elf64_Off     e_phoff;                /* Program header table file offset */
356   Elf64_Off     e_shoff;                /* Section header table file offset */
357   Elf64_Word    e_flags;                /* Processor-specific flags */
358   Elf64_Half    e_ehsize;               /* ELF header size in bytes */
359   Elf64_Half    e_phentsize;            /* Program header table entry size */
360   Elf64_Half    e_phnum;                /* Program header table entry count */
361   Elf64_Half    e_shentsize;            /* Section header table entry size */
362   Elf64_Half    e_shnum;                /* Section header table entry count */
363   Elf64_Half    e_shstrndx;             /* Section header string table index */
364 } Elf64_Ehdr;
365
366 /* 64 bit section header.  */
367
368 typedef struct
369 {
370   Elf64_Word    sh_name;                /* Section name (string tbl index) */
371   Elf64_Word    sh_type;                /* Section type */
372   Elf64_Xword   sh_flags;               /* Section flags */
373   Elf64_Addr    sh_addr;                /* Section virtual addr at execution */
374   Elf64_Off     sh_offset;              /* Section file offset */
375   Elf64_Xword   sh_size;                /* Section size in bytes */
376   Elf64_Word    sh_link;                /* Link to another section */
377   Elf64_Word    sh_info;                /* Additional section information */
378   Elf64_Xword   sh_addralign;           /* Section alignment */
379   Elf64_Xword   sh_entsize;             /* Entry size if section holds table */
380 } Elf64_Shdr;
381
382 /* 64 bit symbol table entry.  */
383
384 typedef struct
385 {
386   Elf64_Word    st_name;                /* Symbol name (string tbl index) */
387   Elf64_Byte    st_info;                /* Symbol type and binding */
388   Elf64_Byte    st_other;               /* No defined meaning, 0 */
389   Elf64_Section st_shndx;               /* Section index */
390   Elf64_Addr    st_value;               /* Symbol value */
391   Elf64_Xword   st_size;                /* Symbol size */
392 } Elf64_Sym;
393
394 /* The 64 bit st_info field is the same as the 32 bit one.  */
395
396 #define ELF64_ST_BIND(val)              (((unsigned char) (val)) >> 4)
397 #define ELF64_ST_TYPE(val)              ((val) & 0xf)
398 #define ELF64_ST_INFO(bind, type)       (((bind) << 4) + ((type) & 0xf))
399
400 /* I have seen two different definitions of the Elf64_Rel and
401    Elf64_Rela structures, so we'll leave them out until Novell (or
402    whoever) gets their act together.  */
403
404 /* Auxiliary vector.  */
405
406 /* This vector is normally only used by the program interpreter.  The
407    usual definition in an ABI supplement uses the name auxv_t.  The
408    vector is not usually defined in a standard <elf.h> file, but it
409    can't hurt.  We rename it to avoid conflicts.  The sizes of these
410    types are an arrangement between the exec server and the program
411    interpreter, so we don't fully specify them here.  */
412
413 typedef struct
414 {
415   int a_type;                           /* Entry type */
416   union
417     {
418       long a_val;                       /* Integer value */
419       void *a_ptr;                      /* Pointer value */
420       void (*a_fcn) ();                 /* Function pointer value */
421     } a_un;
422 } Elf32_auxv_t;
423
424 /* Legal values for a_type (entry type).  */
425
426 #define AT_NULL         0               /* End of vector */
427 #define AT_IGNORE       1               /* Entry should be ignored */
428 #define AT_EXECFD       2               /* File descriptor of program */
429 #define AT_PHDR         3               /* Program headers for program */
430 #define AT_PHENT        4               /* Size of program header entry */
431 #define AT_PHNUM        5               /* Number of program headers */
432 #define AT_PAGESZ       6               /* System page size */
433 #define AT_BASE         7               /* Base address of interpreter */
434 #define AT_FLAGS        8               /* Flags */
435 #define AT_ENTRY        9               /* Entry point of program */
436 #define AT_NOTELF       10              /* Program is not ELF */
437 #define AT_UID          11              /* Real uid */
438 #define AT_EUID         12              /* Effective uid */
439 #define AT_GID          13              /* Real gid */
440 #define AT_EGID         14              /* Effective gid */
441
442 /* Motorola 68k specific definitions.  */
443
444 /* m68k relocs.  */
445
446 #define R_68K_NONE      0               /* No reloc */
447 #define R_68K_32        1               /* Direct 32 bit  */
448 #define R_68K_16        2               /* Direct 16 bit  */
449 #define R_68K_8         3               /* Direct 8 bit  */
450 #define R_68K_PC32      4               /* PC relative 32 bit */
451 #define R_68K_PC16      5               /* PC relative 16 bit */
452 #define R_68K_PC8       6               /* PC relative 8 bit */
453 #define R_68K_GOT32     7               /* 32 bit PC relative GOT entry */
454 #define R_68K_GOT16     8               /* 16 bit PC relative GOT entry */
455 #define R_68K_GOT8      9               /* 8 bit PC relative GOT entry */
456 #define R_68K_GOT32O    10              /* 32 bit GOT offset */
457 #define R_68K_GOT16O    11              /* 16 bit GOT offset */
458 #define R_68K_GOT8O     12              /* 8 bit GOT offset */
459 #define R_68K_PLT32     13              /* 32 bit PC relative PLT address */
460 #define R_68K_PLT16     14              /* 16 bit PC relative PLT address */
461 #define R_68K_PLT8      15              /* 8 bit PC relative PLT address */
462 #define R_68K_PLT32O    16              /* 32 bit PLT offset */
463 #define R_68K_PLT16O    17              /* 16 bit PLT offset */
464 #define R_68K_PLT8O     18              /* 8 bit PLT offset */
465 #define R_68K_COPY      19              /* Copy symbol at runtime */
466 #define R_68K_GLOB_DAT  20              /* Create GOT entry */
467 #define R_68K_JMP_SLOT  21              /* Create PLT entry */
468 #define R_68K_RELATIVE  22              /* Adjust by program base */
469
470 /* Intel 80386 specific definitions.  */
471
472 /* i386 relocs.  */
473
474 #define R_386_NONE      0               /* No reloc */
475 #define R_386_32        1               /* Direct 32 bit  */
476 #define R_386_PC32      2               /* PC relative 32 bit */
477 #define R_386_GOT32     3               /* 32 bit GOT entry */
478 #define R_386_PLT32     4               /* 32 bit PLT address */
479 #define R_386_COPY      5               /* Copy symbol at runtime */
480 #define R_386_GLOB_DAT  6               /* Create GOT entry */
481 #define R_386_JMP_SLOT  7               /* Create PLT entry */
482 #define R_386_RELATIVE  8               /* Adjust by program base */
483 #define R_386_GOTOFF    9               /* 32 bit offset to GOT */
484 #define R_386_GOTPC     10              /* 32 bit PC relative offset to GOT */
485
486 /* SUN SPARC specific definitions.  */
487
488 /* SPARC relocs.  */
489
490 #define R_SPARC_NONE    0               /* No reloc */
491 #define R_SPARC_8       1               /* Direct 8 bit */
492 #define R_SPARC_16      2               /* Direct 16 bit */
493 #define R_SPARC_32      3               /* Direct 32 bit */
494 #define R_SPARC_DISP8   4               /* PC relative 8 bit */
495 #define R_SPARC_DISP16  5               /* PC relative 16 bit */
496 #define R_SPARC_DISP32  6               /* PC relative 32 bit */
497 #define R_SPARC_WDISP30 7               /* PC relative 30 bit shifted */
498 #define R_SPARC_WDISP22 8               /* PC relative 22 bit shifted */
499 #define R_SPARC_HI22    9               /* High 22 bit */
500 #define R_SPARC_22      10              /* Direct 22 bit */
501 #define R_SPARC_13      11              /* Direct 13 bit */
502 #define R_SPARC_LO10    12              /* Truncated 10 bit */
503 #define R_SPARC_GOT10   13              /* Truncated 10 bit GOT entry */
504 #define R_SPARC_GOT13   14              /* 13 bit GOT entry */
505 #define R_SPARC_GOT22   15              /* 22 bit GOT entry shifted */
506 #define R_SPARC_PC10    16              /* PC relative 10 bit truncated */
507 #define R_SPARC_PC22    17              /* PC relative 22 bit shifted */
508 #define R_SPARC_WPLT30  18              /* 30 bit PC relative PLT address */
509 #define R_SPARC_COPY    19              /* Copy symbol at runtime */
510 #define R_SPARC_GLOB_DAT 20             /* Create GOT entry */
511 #define R_SPARC_JMP_SLOT 21             /* Create PLT entry */
512 #define R_SPARC_RELATIVE 22             /* Adjust by program base */
513 #define R_SPARC_UA32    23              /* Direct 32 bit unaligned */
514
515 /* MIPS R3000 specific definitions.  */
516
517 /* Legal values for e_flags field of Elf32_Ehdr.  */
518
519 #define EF_MIPS_NOREORDER 1             /* A .noreorder directive was used */
520 #define EF_MIPS_PIC       2             /* Contains PIC code */
521 #define EF_MIPS_CPIC      4             /* Uses PIC calling sequence */
522 #define EF_MIPS_ARCH      0xf0000000    /* MIPS architecture level */
523
524 /* Special section indices.  */
525
526 #define SHN_MIPS_ACOMMON 0xff00         /* Allocated common symbols */
527 #define SHN_MIPS_SCOMMON 0xff03         /* Small common symbols */
528 #define SHN_MIPS_SUNDEFINED 0xff04      /* Small undefined symbols */
529
530 /* Legal values for sh_type field of Elf32_Shdr.  */
531
532 #define SHT_MIPS_LIBLIST  0x70000000    /* Shared objects used in link */
533 #define SHT_MIPS_CONFLICT 0x70000002    /* Conflicting symbols */
534 #define SHT_MIPS_GPTAB    0x70000003    /* Global data area sizes */
535 #define SHT_MIPS_UCODE    0x70000004    /* Reserved for SGI/MIPS compilers */
536 #define SHT_MIPS_DEBUG    0x70000005    /* MIPS ECOFF debugging information */
537 #define SHT_MIPS_REGINFO  0x70000006    /* Register usage information */
538
539 /* Legal values for sh_flags field of Elf32_Shdr.  */
540
541 #define SHF_MIPS_GPREL  0x10000000      /* Must be part of global data area */
542
543 /* Entries found in sections of type SHT_MIPS_GPTAB.  */
544
545 typedef union
546 {
547   struct
548     {
549       Elf32_Word gt_current_g_value;    /* -G value used for compilation */
550       Elf32_Word gt_unused;             /* Not used */
551     } gt_header;                        /* First entry in section */
552   struct
553     {
554       Elf32_Word gt_g_value;            /* If this value were used for -G */
555       Elf32_Word gt_bytes;              /* This many bytes would be used */
556     } gt_entry;                         /* Subsequent entries in section */
557 } Elf32_gptab;
558
559 /* Entry found in sections of type SHT_MIPS_REGINFO.  */
560
561 typedef struct
562 {
563   Elf32_Word    ri_gprmask;             /* General registers used */
564   Elf32_Word    ri_cprmask[4];          /* Coprocessor registers used */
565   Elf32_Sword   ri_gp_value;            /* $gp register value */
566 } Elf32_RegInfo;
567
568 /* MIPS relocs.  */
569
570 #define R_MIPS_NONE     0               /* No reloc */
571 #define R_MIPS_16       1               /* Direct 16 bit */
572 #define R_MIPS_32       2               /* Direct 32 bit */
573 #define R_MIPS_REL32    3               /* PC relative 32 bit */
574 #define R_MIPS_26       4               /* Direct 26 bit shifted */
575 #define R_MIPS_HI16     5               /* High 16 bit */
576 #define R_MIPS_LO16     6               /* Low 16 bit */
577 #define R_MIPS_GPREL16  7               /* GP relative 16 bit */
578 #define R_MIPS_LITERAL  8               /* 16 bit literal entry */
579 #define R_MIPS_GOT16    9               /* 16 bit GOT entry */
580 #define R_MIPS_PC16     10              /* PC relative 16 bit */
581 #define R_MIPS_CALL16   11              /* 16 bit GOT entry for function */
582 #define R_MIPS_GPREL32  12              /* GP relative 32 bit */
583
584 /* Legal values for p_type field of Elf32_Phdr.  */
585
586 #define PT_MIPS_REGINFO 0x70000000      /* Register usage information */
587
588 /* Legal values for d_tag field of Elf32_Dyn.  */
589
590 #define DT_MIPS_RLD_VERSION  0x70000001 /* Runtime linker interface version */
591 #define DT_MIPS_TIME_STAMP   0x70000002 /* Timestamp */
592 #define DT_MIPS_ICHECKSUM    0x70000003 /* Checksum */
593 #define DT_MIPS_IVERSION     0x70000004 /* Version string (string tbl index) */
594 #define DT_MIPS_FLAGS        0x70000005 /* Flags */
595 #define DT_MIPS_BASE_ADDRESS 0x70000006 /* Base address */
596 #define DT_MIPS_CONFLICT     0x70000008 /* Address of CONFLICT section */
597 #define DT_MIPS_LIBLIST      0x70000009 /* Address of LIBLIST section */
598 #define DT_MIPS_LOCAL_GOTNO  0x7000000a /* Number of local GOT entries */
599 #define DT_MIPS_CONFLICTNO   0x7000000b /* Number of CONFLICT entries */
600 #define DT_MIPS_LIBLISTNO    0x70000010 /* Number of LIBLIST entries */
601 #define DT_MIPS_SYMTABNO     0x70000011 /* Number of DYNSYM entries */
602 #define DT_MIPS_UNREFEXTNO   0x70000012 /* First external DYNSYM */
603 #define DT_MIPS_GOTSYM       0x70000013 /* First GOT entry in DYNSYM */
604 #define DT_MIPS_HIPAGENO     0x70000014 /* Number of GOT page table entries */
605 #define DT_MIPS_NUM          0x15
606
607 /* Legal values for DT_MIPS_FLAG Elf32_Dyn entry.  */
608
609 #define RHF_NONE                   0            /* No flags */
610 #define RHF_QUICKSTART             (1 << 0)     /* Use quickstart */
611 #define RHF_NOTPOT                 (1 << 1)     /* Hash size not power of 2 */
612 #define RHF_NO_LIBRARY_REPLACEMENT (1 << 2)     /* Ignore LD_LIBRARY_PATH */
613
614 /* Entries found in sections of type SHT_MIPS_LIBLIST.  */
615
616 typedef struct
617 {
618   Elf32_Word    l_name;                 /* Name (string table index) */
619   Elf32_Word    l_time_stamp;           /* Timestamp */
620   Elf32_Word    l_checksum;             /* Checksum */
621   Elf32_Word    l_version;              /* Interface version */
622   Elf32_Word    l_flags;                /* Flags */
623 } Elf32_Lib;
624
625 /* Legal values for l_flags.  */
626
627 #define LL_EXACT_MATCH    (1 << 0)      /* Require exact match */
628 #define LL_IGNORE_INT_VER (1 << 1)      /* Ignore interface version */
629
630 /* Entries found in sections of type SHT_MIPS_CONFLICT.  */
631
632 typedef Elf32_Addr Elf32_Conflict;
633
634
635 #endif  /* elf.h */