Initial import of binutils 2.22 on the new vendor branch
[dragonfly.git] / contrib / binutils-2.22 / include / elf / mips.h
1 /* MIPS ELF support for BFD.
2    Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
3    2003, 2004, 2005, 2008, 2009, 2010
4    Free Software Foundation, Inc.
5
6    By Ian Lance Taylor, Cygnus Support, <ian@cygnus.com>, from
7    information in the System V Application Binary Interface, MIPS
8    Processor Supplement.
9
10    This file is part of BFD, the Binary File Descriptor library.
11
12    This program is free software; you can redistribute it and/or modify
13    it under the terms of the GNU General Public License as published by
14    the Free Software Foundation; either version 3 of the License, or
15    (at your option) any later version.
16
17    This program is distributed in the hope that it will be useful,
18    but WITHOUT ANY WARRANTY; without even the implied warranty of
19    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20    GNU General Public License for more details.
21
22    You should have received a copy of the GNU General Public License
23    along with this program; if not, write to the Free Software
24    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
25    MA 02110-1301, USA.  */
26
27 /* This file holds definitions specific to the MIPS ELF ABI.  Note
28    that most of this is not actually implemented by BFD.  */
29
30 #ifndef _ELF_MIPS_H
31 #define _ELF_MIPS_H
32
33 #include "elf/reloc-macros.h"
34
35 /* Relocation types.  */
36 START_RELOC_NUMBERS (elf_mips_reloc_type)
37   RELOC_NUMBER (R_MIPS_NONE, 0)
38   RELOC_NUMBER (R_MIPS_16, 1)
39   RELOC_NUMBER (R_MIPS_32, 2)           /* In Elf 64: alias R_MIPS_ADD */
40   RELOC_NUMBER (R_MIPS_REL32, 3)        /* In Elf 64: alias R_MIPS_REL */
41   RELOC_NUMBER (R_MIPS_26, 4)
42   RELOC_NUMBER (R_MIPS_HI16, 5)
43   RELOC_NUMBER (R_MIPS_LO16, 6)
44   RELOC_NUMBER (R_MIPS_GPREL16, 7)      /* In Elf 64: alias R_MIPS_GPREL */
45   RELOC_NUMBER (R_MIPS_LITERAL, 8)
46   RELOC_NUMBER (R_MIPS_GOT16, 9)        /* In Elf 64: alias R_MIPS_GOT */
47   RELOC_NUMBER (R_MIPS_PC16, 10)
48   RELOC_NUMBER (R_MIPS_CALL16, 11)      /* In Elf 64: alias R_MIPS_CALL */
49   RELOC_NUMBER (R_MIPS_GPREL32, 12)
50   /* The remaining relocs are defined on Irix, although they are not
51      in the MIPS ELF ABI.  */
52   RELOC_NUMBER (R_MIPS_UNUSED1, 13)
53   RELOC_NUMBER (R_MIPS_UNUSED2, 14)
54   RELOC_NUMBER (R_MIPS_UNUSED3, 15)
55   RELOC_NUMBER (R_MIPS_SHIFT5, 16)
56   RELOC_NUMBER (R_MIPS_SHIFT6, 17)
57   RELOC_NUMBER (R_MIPS_64, 18)
58   RELOC_NUMBER (R_MIPS_GOT_DISP, 19)
59   RELOC_NUMBER (R_MIPS_GOT_PAGE, 20)
60   RELOC_NUMBER (R_MIPS_GOT_OFST, 21)
61   RELOC_NUMBER (R_MIPS_GOT_HI16, 22)
62   RELOC_NUMBER (R_MIPS_GOT_LO16, 23)
63   RELOC_NUMBER (R_MIPS_SUB, 24)
64   RELOC_NUMBER (R_MIPS_INSERT_A, 25)
65   RELOC_NUMBER (R_MIPS_INSERT_B, 26)
66   RELOC_NUMBER (R_MIPS_DELETE, 27)
67   RELOC_NUMBER (R_MIPS_HIGHER, 28)
68   RELOC_NUMBER (R_MIPS_HIGHEST, 29)
69   RELOC_NUMBER (R_MIPS_CALL_HI16, 30)
70   RELOC_NUMBER (R_MIPS_CALL_LO16, 31)
71   RELOC_NUMBER (R_MIPS_SCN_DISP, 32)
72   RELOC_NUMBER (R_MIPS_REL16, 33)
73   RELOC_NUMBER (R_MIPS_ADD_IMMEDIATE, 34)
74   RELOC_NUMBER (R_MIPS_PJUMP, 35)
75   RELOC_NUMBER (R_MIPS_RELGOT, 36)
76   RELOC_NUMBER (R_MIPS_JALR, 37)
77   /* TLS relocations.  */
78   RELOC_NUMBER (R_MIPS_TLS_DTPMOD32, 38)
79   RELOC_NUMBER (R_MIPS_TLS_DTPREL32, 39)
80   RELOC_NUMBER (R_MIPS_TLS_DTPMOD64, 40)
81   RELOC_NUMBER (R_MIPS_TLS_DTPREL64, 41)
82   RELOC_NUMBER (R_MIPS_TLS_GD, 42)
83   RELOC_NUMBER (R_MIPS_TLS_LDM, 43)
84   RELOC_NUMBER (R_MIPS_TLS_DTPREL_HI16, 44)
85   RELOC_NUMBER (R_MIPS_TLS_DTPREL_LO16, 45)
86   RELOC_NUMBER (R_MIPS_TLS_GOTTPREL, 46)
87   RELOC_NUMBER (R_MIPS_TLS_TPREL32, 47)
88   RELOC_NUMBER (R_MIPS_TLS_TPREL64, 48)
89   RELOC_NUMBER (R_MIPS_TLS_TPREL_HI16, 49)
90   RELOC_NUMBER (R_MIPS_TLS_TPREL_LO16, 50)
91   RELOC_NUMBER (R_MIPS_GLOB_DAT, 51)
92   FAKE_RELOC (R_MIPS_max, 52)
93   /* These relocs are used for the mips16.  */
94   FAKE_RELOC (R_MIPS16_min, 100)
95   RELOC_NUMBER (R_MIPS16_26, 100)
96   RELOC_NUMBER (R_MIPS16_GPREL, 101)
97   RELOC_NUMBER (R_MIPS16_GOT16, 102)
98   RELOC_NUMBER (R_MIPS16_CALL16, 103)
99   RELOC_NUMBER (R_MIPS16_HI16, 104)
100   RELOC_NUMBER (R_MIPS16_LO16, 105)
101   FAKE_RELOC (R_MIPS16_max, 106)
102   /* These relocations are specific to VxWorks.  */
103   RELOC_NUMBER (R_MIPS_COPY, 126)
104   RELOC_NUMBER (R_MIPS_JUMP_SLOT, 127)
105
106   /* These relocations are specific to microMIPS.  */
107   FAKE_RELOC (R_MICROMIPS_min, 130)
108   RELOC_NUMBER (R_MICROMIPS_26_S1, 133)
109   RELOC_NUMBER (R_MICROMIPS_HI16, 134)
110   RELOC_NUMBER (R_MICROMIPS_LO16, 135)
111   RELOC_NUMBER (R_MICROMIPS_GPREL16, 136)       /* In Elf 64:
112                                                    alias R_MICROMIPS_GPREL */
113   RELOC_NUMBER (R_MICROMIPS_LITERAL, 137)
114   RELOC_NUMBER (R_MICROMIPS_GOT16, 138)         /* In Elf 64:
115                                                    alias R_MICROMIPS_GOT */
116   RELOC_NUMBER (R_MICROMIPS_PC7_S1, 139)
117   RELOC_NUMBER (R_MICROMIPS_PC10_S1, 140)
118   RELOC_NUMBER (R_MICROMIPS_PC16_S1, 141)
119   RELOC_NUMBER (R_MICROMIPS_CALL16, 142)        /* In Elf 64:
120                                                    alias R_MICROMIPS_CALL */
121   RELOC_NUMBER (R_MICROMIPS_GOT_DISP, 145)
122   RELOC_NUMBER (R_MICROMIPS_GOT_PAGE, 146)
123   RELOC_NUMBER (R_MICROMIPS_GOT_OFST, 147)
124   RELOC_NUMBER (R_MICROMIPS_GOT_HI16, 148)
125   RELOC_NUMBER (R_MICROMIPS_GOT_LO16, 149)
126   RELOC_NUMBER (R_MICROMIPS_SUB, 150)
127   RELOC_NUMBER (R_MICROMIPS_HIGHER, 151)
128   RELOC_NUMBER (R_MICROMIPS_HIGHEST, 152)
129   RELOC_NUMBER (R_MICROMIPS_CALL_HI16, 153)
130   RELOC_NUMBER (R_MICROMIPS_CALL_LO16, 154)
131   RELOC_NUMBER (R_MICROMIPS_SCN_DISP, 155)
132   RELOC_NUMBER (R_MICROMIPS_JALR, 156)
133   RELOC_NUMBER (R_MICROMIPS_HI0_LO16, 157)
134   /* TLS relocations.  */
135   RELOC_NUMBER (R_MICROMIPS_TLS_GD, 162)
136   RELOC_NUMBER (R_MICROMIPS_TLS_LDM, 163)
137   RELOC_NUMBER (R_MICROMIPS_TLS_DTPREL_HI16, 164)
138   RELOC_NUMBER (R_MICROMIPS_TLS_DTPREL_LO16, 165)
139   RELOC_NUMBER (R_MICROMIPS_TLS_GOTTPREL, 166)
140   RELOC_NUMBER (R_MICROMIPS_TLS_TPREL_HI16, 169)
141   RELOC_NUMBER (R_MICROMIPS_TLS_TPREL_LO16, 170)
142   /* microMIPS GP- and PC-relative relocations. */
143   RELOC_NUMBER (R_MICROMIPS_GPREL7_S2, 172)
144   RELOC_NUMBER (R_MICROMIPS_PC23_S2, 173)
145   FAKE_RELOC (R_MICROMIPS_max, 174)
146
147   /* This was a GNU extension used by embedded-PIC.  It was co-opted by
148      mips-linux for exception-handling data.  It is no longer used, but
149      should continue to be supported by the linker for backward
150      compatibility.  (GCC stopped using it in May, 2004.)  */
151   RELOC_NUMBER (R_MIPS_PC32, 248)
152   /* FIXME: this relocation is used internally by gas.  */
153   RELOC_NUMBER (R_MIPS_GNU_REL16_S2, 250)
154   /* These are GNU extensions to enable C++ vtable garbage collection.  */
155   RELOC_NUMBER (R_MIPS_GNU_VTINHERIT, 253)
156   RELOC_NUMBER (R_MIPS_GNU_VTENTRY, 254)
157 END_RELOC_NUMBERS (R_MIPS_maxext)
158
159 /* Processor specific flags for the ELF header e_flags field.  */
160
161 /* At least one .noreorder directive appears in the source.  */
162 #define EF_MIPS_NOREORDER       0x00000001
163
164 /* File contains position independent code.  */
165 #define EF_MIPS_PIC             0x00000002
166
167 /* Code in file uses the standard calling sequence for calling
168    position independent code.  */
169 #define EF_MIPS_CPIC            0x00000004
170
171 /* ???  Unknown flag, set in IRIX 6's BSDdup2.o in libbsd.a.  */
172 #define EF_MIPS_XGOT            0x00000008
173
174 /* Code in file uses UCODE (obsolete) */
175 #define EF_MIPS_UCODE           0x00000010
176
177 /* Code in file uses new ABI (-n32 on Irix 6).  */
178 #define EF_MIPS_ABI2            0x00000020
179
180 /* Process the .MIPS.options section first by ld */
181 #define EF_MIPS_OPTIONS_FIRST   0x00000080
182
183 /* Architectural Extensions used by this file */
184 #define EF_MIPS_ARCH_ASE        0x0f000000
185
186 /* Use MDMX multimedia extensions */
187 #define EF_MIPS_ARCH_ASE_MDMX   0x08000000
188
189 /* Use MIPS-16 ISA extensions */
190 #define EF_MIPS_ARCH_ASE_M16    0x04000000
191
192 /* Use MICROMIPS ISA extensions.  */
193 #define EF_MIPS_ARCH_ASE_MICROMIPS      0x02000000
194
195 /* Indicates code compiled for a 64-bit machine in 32-bit mode.
196    (regs are 32-bits wide.) */
197 #define EF_MIPS_32BITMODE       0x00000100
198
199 /* Four bit MIPS architecture field.  */
200 #define EF_MIPS_ARCH            0xf0000000
201
202 /* -mips1 code.  */
203 #define E_MIPS_ARCH_1           0x00000000
204
205 /* -mips2 code.  */
206 #define E_MIPS_ARCH_2           0x10000000
207
208 /* -mips3 code.  */
209 #define E_MIPS_ARCH_3           0x20000000
210
211 /* -mips4 code.  */
212 #define E_MIPS_ARCH_4           0x30000000
213
214 /* -mips5 code.  */
215 #define E_MIPS_ARCH_5           0x40000000
216
217 /* -mips32 code.  */
218 #define E_MIPS_ARCH_32          0x50000000
219
220 /* -mips64 code.  */
221 #define E_MIPS_ARCH_64          0x60000000
222
223 /* -mips32r2 code.  */
224 #define E_MIPS_ARCH_32R2        0x70000000
225
226 /* -mips64r2 code.  */
227 #define E_MIPS_ARCH_64R2        0x80000000
228
229 /* The ABI of the file.  Also see EF_MIPS_ABI2 above. */
230 #define EF_MIPS_ABI             0x0000F000
231
232 /* The original o32 abi. */
233 #define E_MIPS_ABI_O32          0x00001000
234
235 /* O32 extended to work on 64 bit architectures */
236 #define E_MIPS_ABI_O64          0x00002000
237
238 /* EABI in 32 bit mode */
239 #define E_MIPS_ABI_EABI32       0x00003000
240
241 /* EABI in 64 bit mode */
242 #define E_MIPS_ABI_EABI64       0x00004000
243
244
245 /* Machine variant if we know it.  This field was invented at Cygnus,
246    but it is hoped that other vendors will adopt it.  If some standard
247    is developed, this code should be changed to follow it. */
248
249 #define EF_MIPS_MACH            0x00FF0000
250
251 /* Cygnus is choosing values between 80 and 9F;
252    00 - 7F should be left for a future standard;
253    the rest are open. */
254
255 #define E_MIPS_MACH_3900        0x00810000
256 #define E_MIPS_MACH_4010        0x00820000
257 #define E_MIPS_MACH_4100        0x00830000
258 #define E_MIPS_MACH_4650        0x00850000
259 #define E_MIPS_MACH_4120        0x00870000
260 #define E_MIPS_MACH_4111        0x00880000
261 #define E_MIPS_MACH_SB1         0x008a0000
262 #define E_MIPS_MACH_OCTEON      0x008b0000
263 #define E_MIPS_MACH_XLR         0x008c0000
264 #define E_MIPS_MACH_OCTEON2     0x008d0000
265 #define E_MIPS_MACH_5400        0x00910000
266 #define E_MIPS_MACH_5500        0x00980000
267 #define E_MIPS_MACH_9000        0x00990000
268 #define E_MIPS_MACH_LS2E        0x00A00000
269 #define E_MIPS_MACH_LS2F        0x00A10000
270 #define E_MIPS_MACH_LS3A        0x00A20000
271 \f
272 /* Processor specific section indices.  These sections do not actually
273    exist.  Symbols with a st_shndx field corresponding to one of these
274    values have a special meaning.  */
275
276 /* Defined and allocated common symbol.  Value is virtual address.  If
277    relocated, alignment must be preserved.  */
278 #define SHN_MIPS_ACOMMON        SHN_LORESERVE
279
280 /* Defined and allocated text symbol.  Value is virtual address.
281    Occur in the dynamic symbol table of Alpha OSF/1 and Irix 5 executables.  */
282 #define SHN_MIPS_TEXT           (SHN_LORESERVE + 1)
283
284 /* Defined and allocated data symbol.  Value is virtual address.
285    Occur in the dynamic symbol table of Alpha OSF/1 and Irix 5 executables.  */
286 #define SHN_MIPS_DATA           (SHN_LORESERVE + 2)
287
288 /* Small common symbol.  */
289 #define SHN_MIPS_SCOMMON        (SHN_LORESERVE + 3)
290
291 /* Small undefined symbol.  */
292 #define SHN_MIPS_SUNDEFINED     (SHN_LORESERVE + 4)
293 \f
294 /* Processor specific section types.  */
295
296 /* Section contains the set of dynamic shared objects used when
297    statically linking.  */
298 #define SHT_MIPS_LIBLIST        0x70000000
299
300 /* I'm not sure what this is, but it's used on Irix 5.  */
301 #define SHT_MIPS_MSYM           0x70000001
302
303 /* Section contains list of symbols whose definitions conflict with
304    symbols defined in shared objects.  */
305 #define SHT_MIPS_CONFLICT       0x70000002
306
307 /* Section contains the global pointer table.  */
308 #define SHT_MIPS_GPTAB          0x70000003
309
310 /* Section contains microcode information.  The exact format is
311    unspecified.  */
312 #define SHT_MIPS_UCODE          0x70000004
313
314 /* Section contains some sort of debugging information.  The exact
315    format is unspecified.  It's probably ECOFF symbols.  */
316 #define SHT_MIPS_DEBUG          0x70000005
317
318 /* Section contains register usage information.  */
319 #define SHT_MIPS_REGINFO        0x70000006
320
321 /* ??? */
322 #define SHT_MIPS_PACKAGE        0x70000007
323
324 /* ??? */
325 #define SHT_MIPS_PACKSYM        0x70000008
326
327 /* ??? */
328 #define SHT_MIPS_RELD           0x70000009
329
330 /* Section contains interface information.  */
331 #define SHT_MIPS_IFACE          0x7000000b
332
333 /* Section contains description of contents of another section.  */
334 #define SHT_MIPS_CONTENT        0x7000000c
335
336 /* Section contains miscellaneous options.  */
337 #define SHT_MIPS_OPTIONS        0x7000000d
338
339 /* ??? */
340 #define SHT_MIPS_SHDR           0x70000010
341
342 /* ??? */
343 #define SHT_MIPS_FDESC          0x70000011
344
345 /* ??? */
346 #define SHT_MIPS_EXTSYM         0x70000012
347
348 /* ??? */
349 #define SHT_MIPS_DENSE          0x70000013
350
351 /* ??? */
352 #define SHT_MIPS_PDESC          0x70000014
353
354 /* ??? */
355 #define SHT_MIPS_LOCSYM         0x70000015
356
357 /* ??? */
358 #define SHT_MIPS_AUXSYM         0x70000016
359
360 /* ??? */
361 #define SHT_MIPS_OPTSYM         0x70000017
362
363 /* ??? */
364 #define SHT_MIPS_LOCSTR         0x70000018
365
366 /* ??? */
367 #define SHT_MIPS_LINE           0x70000019
368
369 /* ??? */
370 #define SHT_MIPS_RFDESC         0x7000001a
371
372 /* Delta C++: symbol table */
373 #define SHT_MIPS_DELTASYM       0x7000001b
374
375 /* Delta C++: instance table */
376 #define SHT_MIPS_DELTAINST      0x7000001c
377
378 /* Delta C++: class table */
379 #define SHT_MIPS_DELTACLASS     0x7000001d
380
381 /* DWARF debugging section.  */
382 #define SHT_MIPS_DWARF          0x7000001e
383
384 /* Delta C++: declarations */
385 #define SHT_MIPS_DELTADECL      0x7000001f
386
387 /* List of libraries the binary depends on.  Includes a time stamp, version
388    number.  */
389 #define SHT_MIPS_SYMBOL_LIB     0x70000020
390
391 /* Events section.  */
392 #define SHT_MIPS_EVENTS         0x70000021
393
394 /* ??? */
395 #define SHT_MIPS_TRANSLATE      0x70000022
396
397 /* Special pixie sections */
398 #define SHT_MIPS_PIXIE          0x70000023
399
400 /* Address translation table (for debug info) */
401 #define SHT_MIPS_XLATE          0x70000024
402
403 /* SGI internal address translation table (for debug info) */
404 #define SHT_MIPS_XLATE_DEBUG    0x70000025
405
406 /* Intermediate code */
407 #define SHT_MIPS_WHIRL          0x70000026
408
409 /* C++ exception handling region info */
410 #define SHT_MIPS_EH_REGION      0x70000027
411
412 /* Obsolete address translation table (for debug info) */
413 #define SHT_MIPS_XLATE_OLD      0x70000028
414
415 /* Runtime procedure descriptor table exception information (ucode) ??? */
416 #define SHT_MIPS_PDR_EXCEPTION  0x70000029
417
418
419 /* A section of type SHT_MIPS_LIBLIST contains an array of the
420    following structure.  The sh_link field is the section index of the
421    string table.  The sh_info field is the number of entries in the
422    section.  */
423 typedef struct
424 {
425   /* String table index for name of shared object.  */
426   unsigned long l_name;
427   /* Time stamp.  */
428   unsigned long l_time_stamp;
429   /* Checksum of symbol names and common sizes.  */
430   unsigned long l_checksum;
431   /* String table index for version.  */
432   unsigned long l_version;
433   /* Flags.  */
434   unsigned long l_flags;
435 } Elf32_Lib;
436
437 /* The external version of Elf32_Lib.  */
438 typedef struct
439 {
440   unsigned char l_name[4];
441   unsigned char l_time_stamp[4];
442   unsigned char l_checksum[4];
443   unsigned char l_version[4];
444   unsigned char l_flags[4];
445 } Elf32_External_Lib;
446
447 /* The l_flags field of an Elf32_Lib structure may contain the
448    following flags.  */
449
450 /* Require an exact match at runtime.  */
451 #define LL_EXACT_MATCH          0x00000001
452
453 /* Ignore version incompatibilities at runtime.  */
454 #define LL_IGNORE_INT_VER       0x00000002
455
456 /* Require matching minor version number.  */
457 #define LL_REQUIRE_MINOR        0x00000004
458
459 /* ??? */
460 #define LL_EXPORTS              0x00000008
461
462 /* Delay loading of this library until really needed.  */
463 #define LL_DELAY_LOAD           0x00000010
464
465 /* ??? Delta C++ stuff ??? */
466 #define LL_DELTA                0x00000020
467
468
469 /* A section of type SHT_MIPS_CONFLICT is an array of indices into the
470    .dynsym section.  Each element has the following type.  */
471 typedef unsigned long Elf32_Conflict;
472 typedef unsigned char Elf32_External_Conflict[4];
473
474 typedef unsigned long Elf64_Conflict;
475 typedef unsigned char Elf64_External_Conflict[8];
476
477 /* A section of type SHT_MIPS_GPTAB contains information about how
478    much GP space would be required for different -G arguments.  This
479    information is only used so that the linker can provide informative
480    suggestions as to the best -G value to use.  The sh_info field is
481    the index of the section for which this information applies.  The
482    contents of the section are an array of the following union.  The
483    first element uses the gt_header field.  The remaining elements use
484    the gt_entry field.  */
485 typedef union
486 {
487   struct
488     {
489       /* -G value actually used for this object file.  */
490       unsigned long gt_current_g_value;
491       /* Unused.  */
492       unsigned long gt_unused;
493     } gt_header;
494   struct
495     {
496       /* If this -G argument has been used...  */
497       unsigned long gt_g_value;
498       /* ...this many GP section bytes would be required.  */
499       unsigned long gt_bytes;
500     } gt_entry;
501 } Elf32_gptab;
502
503 /* The external version of Elf32_gptab.  */
504
505 typedef union
506 {
507   struct
508     {
509       unsigned char gt_current_g_value[4];
510       unsigned char gt_unused[4];
511     } gt_header;
512   struct
513     {
514       unsigned char gt_g_value[4];
515       unsigned char gt_bytes[4];
516     } gt_entry;
517 } Elf32_External_gptab;
518
519 /* A section of type SHT_MIPS_REGINFO contains the following
520    structure.  */
521 typedef struct
522 {
523   /* Mask of general purpose registers used.  */
524   unsigned long ri_gprmask;
525   /* Mask of co-processor registers used.  */
526   unsigned long ri_cprmask[4];
527   /* GP register value for this object file.  */
528   long ri_gp_value;
529 } Elf32_RegInfo;
530
531 /* The external version of the Elf_RegInfo structure.  */
532 typedef struct
533 {
534   unsigned char ri_gprmask[4];
535   unsigned char ri_cprmask[4][4];
536   unsigned char ri_gp_value[4];
537 } Elf32_External_RegInfo;
538
539 /* MIPS ELF .reginfo swapping routines.  */
540 extern void bfd_mips_elf32_swap_reginfo_in
541   (bfd *, const Elf32_External_RegInfo *, Elf32_RegInfo *);
542 extern void bfd_mips_elf32_swap_reginfo_out
543   (bfd *, const Elf32_RegInfo *, Elf32_External_RegInfo *);
544 \f
545 /* Processor specific section flags.  */
546
547 /* This section must be in the global data area.  */
548 #define SHF_MIPS_GPREL          0x10000000
549
550 /* This section should be merged.  */
551 #define SHF_MIPS_MERGE          0x20000000
552
553 /* This section contains address data of size implied by section
554    element size.  */
555 #define SHF_MIPS_ADDR           0x40000000
556
557 /* This section contains string data.  */
558 #define SHF_MIPS_STRING         0x80000000
559
560 /* This section may not be stripped.  */
561 #define SHF_MIPS_NOSTRIP        0x08000000
562
563 /* This section is local to threads.  */
564 #define SHF_MIPS_LOCAL          0x04000000
565
566 /* Linker should generate implicit weak names for this section.  */
567 #define SHF_MIPS_NAMES          0x02000000
568
569 /* Section contais text/data which may be replicated in other sections.
570    Linker should retain only one copy.  */
571 #define SHF_MIPS_NODUPES        0x01000000
572 \f
573 /* Processor specific program header types.  */
574
575 /* Register usage information.  Identifies one .reginfo section.  */
576 #define PT_MIPS_REGINFO         0x70000000
577
578 /* Runtime procedure table.  */
579 #define PT_MIPS_RTPROC          0x70000001
580
581 /* .MIPS.options section.  */
582 #define PT_MIPS_OPTIONS         0x70000002
583 \f
584 /* Processor specific dynamic array tags.  */
585
586 /* 32 bit version number for runtime linker interface.  */
587 #define DT_MIPS_RLD_VERSION     0x70000001
588
589 /* Time stamp.  */
590 #define DT_MIPS_TIME_STAMP      0x70000002
591
592 /* Checksum of external strings and common sizes.  */
593 #define DT_MIPS_ICHECKSUM       0x70000003
594
595 /* Index of version string in string table.  */
596 #define DT_MIPS_IVERSION        0x70000004
597
598 /* 32 bits of flags.  */
599 #define DT_MIPS_FLAGS           0x70000005
600
601 /* Base address of the segment.  */
602 #define DT_MIPS_BASE_ADDRESS    0x70000006
603
604 /* ??? */
605 #define DT_MIPS_MSYM            0x70000007
606
607 /* Address of .conflict section.  */
608 #define DT_MIPS_CONFLICT        0x70000008
609
610 /* Address of .liblist section.  */
611 #define DT_MIPS_LIBLIST         0x70000009
612
613 /* Number of local global offset table entries.  */
614 #define DT_MIPS_LOCAL_GOTNO     0x7000000a
615
616 /* Number of entries in the .conflict section.  */
617 #define DT_MIPS_CONFLICTNO      0x7000000b
618
619 /* Number of entries in the .liblist section.  */
620 #define DT_MIPS_LIBLISTNO       0x70000010
621
622 /* Number of entries in the .dynsym section.  */
623 #define DT_MIPS_SYMTABNO        0x70000011
624
625 /* Index of first external dynamic symbol not referenced locally.  */
626 #define DT_MIPS_UNREFEXTNO      0x70000012
627
628 /* Index of first dynamic symbol in global offset table.  */
629 #define DT_MIPS_GOTSYM          0x70000013
630
631 /* Number of page table entries in global offset table.  */
632 #define DT_MIPS_HIPAGENO        0x70000014
633
634 /* Address of run time loader map, used for debugging.  */
635 #define DT_MIPS_RLD_MAP         0x70000016
636
637 /* Delta C++ class definition.  */
638 #define DT_MIPS_DELTA_CLASS     0x70000017
639
640 /* Number of entries in DT_MIPS_DELTA_CLASS.  */
641 #define DT_MIPS_DELTA_CLASS_NO  0x70000018
642
643 /* Delta C++ class instances.  */
644 #define DT_MIPS_DELTA_INSTANCE  0x70000019
645
646 /* Number of entries in DT_MIPS_DELTA_INSTANCE.  */
647 #define DT_MIPS_DELTA_INSTANCE_NO       0x7000001a
648
649 /* Delta relocations.  */
650 #define DT_MIPS_DELTA_RELOC     0x7000001b
651
652 /* Number of entries in DT_MIPS_DELTA_RELOC.  */
653 #define DT_MIPS_DELTA_RELOC_NO  0x7000001c
654
655 /* Delta symbols that Delta relocations refer to.  */
656 #define DT_MIPS_DELTA_SYM       0x7000001d
657
658 /* Number of entries in DT_MIPS_DELTA_SYM.  */
659 #define DT_MIPS_DELTA_SYM_NO    0x7000001e
660
661 /* Delta symbols that hold class declarations.  */
662 #define DT_MIPS_DELTA_CLASSSYM  0x70000020
663
664 /* Number of entries in DT_MIPS_DELTA_CLASSSYM.  */
665 #define DT_MIPS_DELTA_CLASSSYM_NO       0x70000021
666
667 /* Flags indicating information about C++ flavor.  */
668 #define DT_MIPS_CXX_FLAGS       0x70000022
669
670 /* Pixie information (???).  */
671 #define DT_MIPS_PIXIE_INIT      0x70000023
672
673 /* Address of .MIPS.symlib */
674 #define DT_MIPS_SYMBOL_LIB      0x70000024
675
676 /* The GOT index of the first PTE for a segment */
677 #define DT_MIPS_LOCALPAGE_GOTIDX        0x70000025
678
679 /* The GOT index of the first PTE for a local symbol */
680 #define DT_MIPS_LOCAL_GOTIDX    0x70000026
681
682 /* The GOT index of the first PTE for a hidden symbol */
683 #define DT_MIPS_HIDDEN_GOTIDX   0x70000027
684
685 /* The GOT index of the first PTE for a protected symbol */
686 #define DT_MIPS_PROTECTED_GOTIDX        0x70000028
687
688 /* Address of `.MIPS.options'.  */
689 #define DT_MIPS_OPTIONS         0x70000029
690
691 /* Address of `.interface'.  */
692 #define DT_MIPS_INTERFACE       0x7000002a
693
694 /* ??? */
695 #define DT_MIPS_DYNSTR_ALIGN    0x7000002b
696
697 /* Size of the .interface section.  */
698 #define DT_MIPS_INTERFACE_SIZE  0x7000002c
699
700 /* Size of rld_text_resolve function stored in the GOT.  */
701 #define DT_MIPS_RLD_TEXT_RESOLVE_ADDR   0x7000002d
702
703 /* Default suffix of DSO to be added by rld on dlopen() calls.  */
704 #define DT_MIPS_PERF_SUFFIX     0x7000002e
705
706 /* Size of compact relocation section (O32).  */
707 #define DT_MIPS_COMPACT_SIZE    0x7000002f
708
709 /* GP value for auxiliary GOTs.  */
710 #define DT_MIPS_GP_VALUE        0x70000030
711
712 /* Address of auxiliary .dynamic.  */
713 #define DT_MIPS_AUX_DYNAMIC     0x70000031
714
715 /* Address of the base of the PLTGOT.  */
716 #define DT_MIPS_PLTGOT         0x70000032
717
718 /* Points to the base of a writable PLT.  */
719 #define DT_MIPS_RWPLT          0x70000034
720 \f
721 /* Flags which may appear in a DT_MIPS_FLAGS entry.  */
722
723 /* No flags.  */
724 #define RHF_NONE                0x00000000
725
726 /* Uses shortcut pointers.  */
727 #define RHF_QUICKSTART          0x00000001
728
729 /* Hash size is not a power of two.  */
730 #define RHF_NOTPOT              0x00000002
731
732 /* Ignore LD_LIBRARY_PATH.  */
733 #define RHS_NO_LIBRARY_REPLACEMENT 0x00000004
734
735 /* DSO address may not be relocated. */
736 #define RHF_NO_MOVE             0x00000008
737
738 /* SGI specific features. */
739 #define RHF_SGI_ONLY            0x00000010
740
741 /* Guarantee that .init will finish executing before any non-init
742    code in DSO is called. */
743 #define RHF_GUARANTEE_INIT         0x00000020
744
745 /* Contains Delta C++ code. */
746 #define RHF_DELTA_C_PLUS_PLUS      0x00000040
747
748 /* Guarantee that .init will start executing before any non-init
749    code in DSO is called. */
750 #define RHF_GUARANTEE_START_INIT   0x00000080
751
752 /* Generated by pixie. */
753 #define RHF_PIXIE                  0x00000100
754
755 /* Delay-load DSO by default. */
756 #define RHF_DEFAULT_DELAY_LOAD     0x00000200
757
758 /* Object may be requickstarted */
759 #define RHF_REQUICKSTART           0x00000400
760
761 /* Object has been requickstarted */
762 #define RHF_REQUICKSTARTED         0x00000800
763
764 /* Generated by cord. */
765 #define RHF_CORD                   0x00001000
766
767 /* Object contains no unresolved undef symbols. */
768 #define RHF_NO_UNRES_UNDEF         0x00002000
769
770 /* Symbol table is in a safe order. */
771 #define RHF_RLD_ORDER_SAFE         0x00004000
772 \f
773 /* Special values for the st_other field in the symbol table.  These
774    are used in an Irix 5 dynamic symbol table.  */
775
776 #define STO_DEFAULT             STV_DEFAULT
777 #define STO_INTERNAL            STV_INTERNAL
778 #define STO_HIDDEN              STV_HIDDEN
779 #define STO_PROTECTED           STV_PROTECTED
780
781 /* Two topmost bits denote the MIPS ISA for .text symbols:
782    + 00 -- standard MIPS code,
783    + 10 -- microMIPS code,
784    + 11 -- MIPS16 code; requires the following two bits to be set too.
785    Note that one of the MIPS16 bits overlaps with STO_MIPS_PIC.  See below
786    for details.  */
787 #define STO_MIPS_ISA            (3 << 6)
788
789 /* The mask spanning the rest of MIPS psABI flags.  At most one is expected
790    to be set except for STO_MIPS16.  */
791 #define STO_MIPS_FLAGS          (~(STO_MIPS_ISA | ELF_ST_VISIBILITY (-1)))
792
793 /* The MIPS psABI was updated in 2008 with support for PLTs and copy
794    relocs.  There are therefore two types of nonzero SHN_UNDEF functions:
795    PLT entries and traditional MIPS lazy binding stubs.  We mark the former
796    with STO_MIPS_PLT to distinguish them from the latter.  */
797 #define STO_MIPS_PLT            0x8
798 #define ELF_ST_IS_MIPS_PLT(other) (((other) & STO_MIPS_FLAGS) == STO_MIPS_PLT)
799 #define ELF_ST_SET_MIPS_PLT(other) (((other) & ~STO_MIPS_FLAGS) | STO_MIPS_PLT)
800
801 /* This value is used to mark PIC functions in an object that mixes
802    PIC and non-PIC.  Note that this bit overlaps with STO_MIPS16,
803    although MIPS16 symbols are never considered to be MIPS_PIC.  */
804 #define STO_MIPS_PIC            0x20
805 #define ELF_ST_IS_MIPS_PIC(other) (((other) & STO_MIPS_FLAGS) == STO_MIPS_PIC)
806 #define ELF_ST_SET_MIPS_PIC(other) (((other) & ~STO_MIPS_FLAGS) | STO_MIPS_PIC)
807
808 /* This value is used for a mips16 .text symbol.  */
809 #define STO_MIPS16              0xf0
810 #define ELF_ST_IS_MIPS16(other) (((other) & STO_MIPS16) == STO_MIPS16)
811 #define ELF_ST_SET_MIPS16(other) ((other) | STO_MIPS16)
812
813 /* This value is used for a microMIPS .text symbol.  To distinguish from
814    STO_MIPS16, we set top two bits to be 10 to denote STO_MICROMIPS.  The
815    mask is STO_MIPS_ISA.  */
816 #define STO_MICROMIPS           (2 << 6)
817 #define ELF_ST_IS_MICROMIPS(other) (((other) & STO_MIPS_ISA) == STO_MICROMIPS)
818 #define ELF_ST_SET_MICROMIPS(other) (((other) & ~STO_MIPS_ISA) | STO_MICROMIPS)
819
820 /* Whether code compression (either of the MIPS16 or the microMIPS ASEs)
821    has been indicated for a .text symbol.  */
822 #define ELF_ST_IS_COMPRESSED(other) \
823   (ELF_ST_IS_MIPS16 (other) || ELF_ST_IS_MICROMIPS (other))
824
825 /* This bit is used on Irix to indicate a symbol whose definition
826    is optional - if, at final link time, it cannot be found, no
827    error message should be produced.  */
828 #define STO_OPTIONAL            (1 << 2)
829 /* A macro to examine the STO_OPTIONAL bit.  */
830 #define ELF_MIPS_IS_OPTIONAL(other)     ((other) & STO_OPTIONAL)
831 \f
832 /* The 64-bit MIPS ELF ABI uses an unusual reloc format.  Each
833    relocation entry specifies up to three actual relocations, all at
834    the same address.  The first relocation which required a symbol
835    uses the symbol in the r_sym field.  The second relocation which
836    requires a symbol uses the symbol in the r_ssym field.  If all
837    three relocations require a symbol, the third one uses a zero
838    value.  */
839
840 /* An entry in a 64 bit SHT_REL section.  */
841
842 typedef struct
843 {
844   /* Address of relocation.  */
845   unsigned char r_offset[8];
846   /* Symbol index.  */
847   unsigned char r_sym[4];
848   /* Special symbol.  */
849   unsigned char r_ssym[1];
850   /* Third relocation.  */
851   unsigned char r_type3[1];
852   /* Second relocation.  */
853   unsigned char r_type2[1];
854   /* First relocation.  */
855   unsigned char r_type[1];
856 } Elf64_Mips_External_Rel;
857
858 typedef struct
859 {
860   /* Address of relocation.  */
861   bfd_vma r_offset;
862   /* Symbol index.  */
863   unsigned long r_sym;
864   /* Special symbol.  */
865   unsigned char r_ssym;
866   /* Third relocation.  */
867   unsigned char r_type3;
868   /* Second relocation.  */
869   unsigned char r_type2;
870   /* First relocation.  */
871   unsigned char r_type;
872 } Elf64_Mips_Internal_Rel;
873
874 /* An entry in a 64 bit SHT_RELA section.  */
875
876 typedef struct
877 {
878   /* Address of relocation.  */
879   unsigned char r_offset[8];
880   /* Symbol index.  */
881   unsigned char r_sym[4];
882   /* Special symbol.  */
883   unsigned char r_ssym[1];
884   /* Third relocation.  */
885   unsigned char r_type3[1];
886   /* Second relocation.  */
887   unsigned char r_type2[1];
888   /* First relocation.  */
889   unsigned char r_type[1];
890   /* Addend.  */
891   unsigned char r_addend[8];
892 } Elf64_Mips_External_Rela;
893
894 typedef struct
895 {
896   /* Address of relocation.  */
897   bfd_vma r_offset;
898   /* Symbol index.  */
899   unsigned long r_sym;
900   /* Special symbol.  */
901   unsigned char r_ssym;
902   /* Third relocation.  */
903   unsigned char r_type3;
904   /* Second relocation.  */
905   unsigned char r_type2;
906   /* First relocation.  */
907   unsigned char r_type;
908   /* Addend.  */
909   bfd_signed_vma r_addend;
910 } Elf64_Mips_Internal_Rela;
911
912 /* MIPS ELF 64 relocation info access macros.  */
913 #define ELF64_MIPS_R_SSYM(i) (((i) >> 24) & 0xff)
914 #define ELF64_MIPS_R_TYPE3(i) (((i) >> 16) & 0xff)
915 #define ELF64_MIPS_R_TYPE2(i) (((i) >> 8) & 0xff)
916 #define ELF64_MIPS_R_TYPE(i) ((i) & 0xff)
917
918 /* Values found in the r_ssym field of a relocation entry.  */
919
920 /* No relocation.  */
921 #define RSS_UNDEF       0
922
923 /* Value of GP.  */
924 #define RSS_GP          1
925
926 /* Value of GP in object being relocated.  */
927 #define RSS_GP0         2
928
929 /* Address of location being relocated.  */
930 #define RSS_LOC         3
931 \f
932 /* A SHT_MIPS_OPTIONS section contains a series of options, each of
933    which starts with this header.  */
934
935 typedef struct
936 {
937   /* Type of option.  */
938   unsigned char kind[1];
939   /* Size of option descriptor, including header.  */
940   unsigned char size[1];
941   /* Section index of affected section, or 0 for global option.  */
942   unsigned char section[2];
943   /* Information specific to this kind of option.  */
944   unsigned char info[4];
945 } Elf_External_Options;
946
947 typedef struct
948 {
949   /* Type of option.  */
950   unsigned char kind;
951   /* Size of option descriptor, including header.  */
952   unsigned char size;
953   /* Section index of affected section, or 0 for global option.  */
954   unsigned short section;
955   /* Information specific to this kind of option.  */
956   unsigned long info;
957 } Elf_Internal_Options;
958
959 /* MIPS ELF option header swapping routines.  */
960 extern void bfd_mips_elf_swap_options_in
961   (bfd *, const Elf_External_Options *, Elf_Internal_Options *);
962 extern void bfd_mips_elf_swap_options_out
963   (bfd *, const Elf_Internal_Options *, Elf_External_Options *);
964
965 /* Values which may appear in the kind field of an Elf_Options
966    structure.  */
967
968 /* Undefined.  */
969 #define ODK_NULL        0
970
971 /* Register usage and GP value.  */
972 #define ODK_REGINFO     1
973
974 /* Exception processing information.  */
975 #define ODK_EXCEPTIONS  2
976
977 /* Section padding information.  */
978 #define ODK_PAD         3
979
980 /* Hardware workarounds performed.  */
981 #define ODK_HWPATCH     4
982
983 /* Fill value used by the linker.  */
984 #define ODK_FILL        5
985
986 /* Reserved space for desktop tools.  */
987 #define ODK_TAGS        6
988
989 /* Hardware workarounds, AND bits when merging.  */
990 #define ODK_HWAND       7
991
992 /* Hardware workarounds, OR bits when merging.  */
993 #define ODK_HWOR        8
994
995 /* GP group to use for text/data sections.  */
996 #define ODK_GP_GROUP    9
997
998 /* ID information.  */
999 #define ODK_IDENT       10
1000
1001 /* In the 32 bit ABI, an ODK_REGINFO option is just a Elf32_RegInfo
1002    structure.  In the 64 bit ABI, it is the following structure.  The
1003    info field of the options header is not used.  */
1004
1005 typedef struct
1006 {
1007   /* Mask of general purpose registers used.  */
1008   unsigned char ri_gprmask[4];
1009   /* Padding.  */
1010   unsigned char ri_pad[4];
1011   /* Mask of co-processor registers used.  */
1012   unsigned char ri_cprmask[4][4];
1013   /* GP register value for this object file.  */
1014   unsigned char ri_gp_value[8];
1015 } Elf64_External_RegInfo;
1016
1017 typedef struct
1018 {
1019   /* Mask of general purpose registers used.  */
1020   unsigned long ri_gprmask;
1021   /* Padding.  */
1022   unsigned long ri_pad;
1023   /* Mask of co-processor registers used.  */
1024   unsigned long ri_cprmask[4];
1025   /* GP register value for this object file.  */
1026   bfd_vma ri_gp_value;
1027 } Elf64_Internal_RegInfo;
1028
1029 typedef struct
1030 {
1031   /* The hash value computed from the name of the corresponding
1032      dynamic symbol.  */
1033   unsigned char ms_hash_value[4];
1034   /* Contains both the dynamic relocation index and the symbol flags
1035      field.  The macros ELF32_MS_REL_INDEX and ELF32_MS_FLAGS are used
1036      to access the individual values.  The dynamic relocation index
1037      identifies the first entry in the .rel.dyn section that
1038      references the dynamic symbol corresponding to this msym entry.
1039      If the index is 0, no dynamic relocations are associated with the
1040      symbol.  The symbol flags field is reserved for future use.  */
1041   unsigned char ms_info[4];
1042 } Elf32_External_Msym;
1043
1044 typedef struct
1045 {
1046   /* The hash value computed from the name of the corresponding
1047      dynamic symbol.  */
1048   unsigned long ms_hash_value;
1049   /* Contains both the dynamic relocation index and the symbol flags
1050      field.  The macros ELF32_MS_REL_INDEX and ELF32_MS_FLAGS are used
1051      to access the individual values.  The dynamic relocation index
1052      identifies the first entry in the .rel.dyn section that
1053      references the dynamic symbol corresponding to this msym entry.
1054      If the index is 0, no dynamic relocations are associated with the
1055      symbol.  The symbol flags field is reserved for future use.  */
1056   unsigned long ms_info;
1057 } Elf32_Internal_Msym;
1058
1059 #define ELF32_MS_REL_INDEX(i) ((i) >> 8)
1060 #define ELF32_MS_FLAGS(i)     (i) & 0xff)
1061 #define ELF32_MS_INFO(r, f)   (((r) << 8) + ((f) & 0xff))
1062
1063 /* MIPS ELF reginfo swapping routines.  */
1064 extern void bfd_mips_elf64_swap_reginfo_in
1065   (bfd *, const Elf64_External_RegInfo *, Elf64_Internal_RegInfo *);
1066 extern void bfd_mips_elf64_swap_reginfo_out
1067   (bfd *, const Elf64_Internal_RegInfo *, Elf64_External_RegInfo *);
1068
1069 /* Masks for the info work of an ODK_EXCEPTIONS descriptor.  */
1070 #define OEX_FPU_MIN     0x1f    /* FPEs which must be enabled.  */
1071 #define OEX_FPU_MAX     0x1f00  /* FPEs which may be enabled.  */
1072 #define OEX_PAGE0       0x10000 /* Page zero must be mapped.  */
1073 #define OEX_SMM         0x20000 /* Force sequential memory mode.  */
1074 #define OEX_FPDBUG      0x40000 /* Force precise floating-point
1075                                    exceptions (debug mode).  */
1076 #define OEX_DISMISS     0x80000 /* Dismiss invalid address faults.  */
1077
1078 /* Masks of the FP exceptions for OEX_FPU_MIN and OEX_FPU_MAX.  */
1079 #define OEX_FPU_INVAL   0x10    /* Invalid operation exception.  */
1080 #define OEX_FPU_DIV0    0x08    /* Division by zero exception.  */
1081 #define OEX_FPU_OFLO    0x04    /* Overflow exception.  */
1082 #define OEX_FPU_UFLO    0x02    /* Underflow exception.  */
1083 #define OEX_FPU_INEX    0x01    /* Inexact exception.  */
1084
1085 /* Masks for the info word of an ODK_PAD descriptor.  */
1086 #define OPAD_PREFIX     0x01
1087 #define OPAD_POSTFIX    0x02
1088 #define OPAD_SYMBOL     0x04
1089
1090 /* Masks for the info word of an ODK_HWPATCH descriptor.  */
1091 #define OHW_R4KEOP      0x00000001      /* R4000 end-of-page patch.  */
1092 #define OHW_R8KPFETCH   0x00000002      /* May need R8000 prefetch patch.  */
1093 #define OHW_R5KEOP      0x00000004      /* R5000 end-of-page patch.  */
1094 #define OHW_R5KCVTL     0x00000008      /* R5000 cvt.[ds].l bug
1095                                            (clean == 1).  */
1096 #define OHW_R10KLDL     0x00000010      /* Needs R10K misaligned
1097                                            load patch. */
1098
1099 /* Masks for the info word of an ODK_IDENT/ODK_GP_GROUP descriptor.  */
1100 #define OGP_GROUP       0x0000ffff      /* GP group number.  */
1101 #define OGP_SELF        0xffff0000      /* Self-contained GP groups.  */
1102
1103 /* Masks for the info word of an ODK_HWAND/ODK_HWOR descriptor.  */
1104 #define OHWA0_R4KEOP_CHECKED    0x00000001
1105 #define OHWA0_R4KEOP_CLEAN      0x00000002
1106 \f
1107
1108 /* Object attribute tags.  */
1109 enum
1110 {
1111   /* 0-3 are generic.  */
1112   Tag_GNU_MIPS_ABI_FP = 4, /* Value 1 for hard-float -mdouble-float, 2
1113                               for hard-float -msingle-float, 3 for
1114                               soft-float, 4 for -mips32r2 -mfp64; 0 for
1115                               not tagged or not using any ABIs affected
1116                               by the differences.  */
1117 };
1118
1119 #endif /* _ELF_MIPS_H */