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