This commit was generated by cvs2svn to track changes on a CVS vendor
[external/binutils.git] / include / elf / mips.h
1 /* MIPS ELF support for BFD.
2    Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
3
4    By Ian Lance Taylor, Cygnus Support, <ian@cygnus.com>, from
5    information in the System V Application Binary Interface, MIPS
6    Processor Supplement.
7
8 This file is part of BFD, the Binary File Descriptor library.
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
23
24 /* This file holds definitions specific to the MIPS ELF ABI.  Note
25    that most of this is not actually implemented by BFD.  */
26
27 #ifndef _ELF_MIPS_H
28 #define _ELF_MIPS_H
29
30 /* Processor specific flags for the ELF header e_flags field.  */
31
32 /* At least one .noreorder directive appears in the source.  */
33 #define EF_MIPS_NOREORDER       0x00000001
34
35 /* File contains position independent code.  */
36 #define EF_MIPS_PIC             0x00000002
37
38 /* Code in file uses the standard calling sequence for calling
39    position independent code.  */
40 #define EF_MIPS_CPIC            0x00000004
41
42 /* Code in file uses new ABI (-n32 on Irix 6).  */
43 #define EF_MIPS_ABI2            0x00000020
44
45 /* Four bit MIPS architecture field.  */
46 #define EF_MIPS_ARCH            0xf0000000
47
48 /* -mips1 code.  */
49 #define E_MIPS_ARCH_1           0x00000000
50
51 /* -mips2 code.  */
52 #define E_MIPS_ARCH_2           0x10000000
53
54 /* -mips3 code.  */
55 #define E_MIPS_ARCH_3           0x20000000
56
57 /* -mips4 code.  */
58 #define E_MIPS_ARCH_4           0x30000000
59 \f
60 /* Processor specific section indices.  These sections do not actually
61    exist.  Symbols with a st_shndx field corresponding to one of these
62    values have a special meaning.  */
63
64 /* Defined and allocated common symbol.  Value is virtual address.  If
65    relocated, alignment must be preserved.  */
66 #define SHN_MIPS_ACOMMON        0xff00
67
68 /* Defined and allocated text symbol.  Value is virtual address.
69    Occur in the dynamic symbol table of Alpha OSF/1 and Irix 5 executables.  */
70 #define SHN_MIPS_TEXT           0xff01
71
72 /* Defined and allocated data symbol.  Value is virtual address.
73    Occur in the dynamic symbol table of Alpha OSF/1 and Irix 5 executables.  */
74 #define SHN_MIPS_DATA           0xff02
75
76 /* Small common symbol.  */
77 #define SHN_MIPS_SCOMMON        0xff03
78
79 /* Small undefined symbol.  */
80 #define SHN_MIPS_SUNDEFINED     0xff04
81 \f
82 /* Processor specific section types.  */
83
84 /* Section contains the set of dynamic shared objects used when
85    statically linking.  */
86 #define SHT_MIPS_LIBLIST        0x70000000
87
88 /* I'm not sure what this is, but it's used on Irix 5.  */
89 #define SHT_MIPS_MSYM           0x70000001
90
91 /* Section contains list of symbols whose definitions conflict with
92    symbols defined in shared objects.  */
93 #define SHT_MIPS_CONFLICT       0x70000002
94
95 /* Section contains the global pointer table.  */
96 #define SHT_MIPS_GPTAB          0x70000003
97
98 /* Section contains microcode information.  The exact format is
99    unspecified.  */
100 #define SHT_MIPS_UCODE          0x70000004
101
102 /* Section contains some sort of debugging information.  The exact
103    format is unspecified.  It's probably ECOFF symbols.  */
104 #define SHT_MIPS_DEBUG          0x70000005
105
106 /* Section contains register usage information.  */
107 #define SHT_MIPS_REGINFO        0x70000006
108
109 /* Section contains interface information.  */
110 #define SHT_MIPS_IFACE          0x7000000b
111
112 /* Section contains description of contents of another section.  */
113 #define SHT_MIPS_CONTENT        0x7000000c
114
115 /* Section contains miscellaneous options.  */
116 #define SHT_MIPS_OPTIONS        0x7000000d
117
118 /* DWARF debugging section.  */
119 #define SHT_MIPS_DWARF          0x7000001e
120
121 /* I'm not sure what this is, but it appears on Irix 6.  */
122 #define SHT_MIPS_SYMBOL_LIB     0x70000020
123
124 /* Events section.  */
125 #define SHT_MIPS_EVENTS         0x70000021
126
127 /* A section of type SHT_MIPS_LIBLIST contains an array of the
128    following structure.  The sh_link field is the section index of the
129    string table.  The sh_info field is the number of entries in the
130    section.  */
131 typedef struct
132 {
133   /* String table index for name of shared object.  */
134   unsigned long l_name;
135   /* Time stamp.  */
136   unsigned long l_time_stamp;
137   /* Checksum of symbol names and common sizes.  */
138   unsigned long l_checksum;
139   /* String table index for version.  */
140   unsigned long l_version;
141   /* Flags.  */
142   unsigned long l_flags;
143 } Elf32_Lib;
144
145 /* The l_flags field of an Elf32_Lib structure may contain the
146    following flags.  */
147
148 /* Require an exact match at runtime.  */
149 #define LL_EXACT_MATCH          0x00000001
150
151 /* Ignore version incompatibilities at runtime.  */
152 #define LL_IGNORE_INT_VER       0x00000002
153
154 /* A section of type SHT_MIPS_CONFLICT is an array of indices into the
155    .dynsym section.  Each element has the following type.  */
156 typedef unsigned long Elf32_Conflict;
157
158 /* A section of type SHT_MIPS_GPTAB contains information about how
159    much GP space would be required for different -G arguments.  This
160    information is only used so that the linker can provide informative
161    suggestions as to the best -G value to use.  The sh_info field is
162    the index of the section for which this information applies.  The
163    contents of the section are an array of the following union.  The
164    first element uses the gt_header field.  The remaining elements use
165    the gt_entry field.  */
166 typedef union
167 {
168   struct
169     {
170       /* -G value actually used for this object file.  */
171       unsigned long gt_current_g_value;
172       /* Unused.  */
173       unsigned long gt_unused;
174     } gt_header;
175   struct
176     {
177       /* If this -G argument has been used...  */
178       unsigned long gt_g_value;
179       /* ...this many GP section bytes would be required.  */
180       unsigned long gt_bytes;
181     } gt_entry;
182 } Elf32_gptab;
183
184 /* The external version of Elf32_gptab.  */
185
186 typedef union
187 {
188   struct
189     {
190       unsigned char gt_current_g_value[4];
191       unsigned char gt_unused[4];
192     } gt_header;
193   struct
194     {
195       unsigned char gt_g_value[4];
196       unsigned char gt_bytes[4];
197     } gt_entry;
198 } Elf32_External_gptab;
199
200 /* A section of type SHT_MIPS_REGINFO contains the following
201    structure.  */
202 typedef struct
203 {
204   /* Mask of general purpose registers used.  */
205   unsigned long ri_gprmask;
206   /* Mask of co-processor registers used.  */
207   unsigned long ri_cprmask[4];
208   /* GP register value for this object file.  */
209   long ri_gp_value;
210 } Elf32_RegInfo;
211
212 /* The external version of the Elf_RegInfo structure.  */
213 typedef struct
214 {
215   unsigned char ri_gprmask[4];
216   unsigned char ri_cprmask[4][4];
217   unsigned char ri_gp_value[4];
218 } Elf32_External_RegInfo;
219
220 /* MIPS ELF .reginfo swapping routines.  */
221 extern void bfd_mips_elf32_swap_reginfo_in
222   PARAMS ((bfd *, const Elf32_External_RegInfo *, Elf32_RegInfo *));
223 extern void bfd_mips_elf32_swap_reginfo_out
224   PARAMS ((bfd *, const Elf32_RegInfo *, Elf32_External_RegInfo *));
225 \f
226 /* Processor specific section flags.  */
227
228 /* This section must be in the global data area.  */
229 #define SHF_MIPS_GPREL          0x10000000
230
231 /* This section should be merged.  */
232 #define SHF_MIPS_MERGE          0x20000000
233
234 /* This section contains 32 bit addresses.  */
235 #define SHF_MIPS_ADDR32         0x40000000
236
237 /* This section contains 64 bit addresses.  */
238 #define SHF_MIPS_ADDR64         0x80000000
239
240 /* This section may not be stripped.  */
241 #define SHF_MIPS_NOSTRIP        0x08000000
242
243 /* This section is local to threads.  */
244 #define SHF_MIPS_LOCAL          0x04000000
245
246 /* Linker should generate implicit weak names for this section.  */
247 #define SHF_MIPS_NAMES          0x02000000
248 \f
249 /* Processor specific program header types.  */
250
251 /* Register usage information.  Identifies one .reginfo section.  */
252 #define PT_MIPS_REGINFO         0x70000000
253
254 /* Runtime procedure table.  */
255 #define PT_MIPS_RTPROC          0x70000001
256 \f
257 /* Processor specific dynamic array tags.  */
258
259 /* 32 bit version number for runtime linker interface.  */
260 #define DT_MIPS_RLD_VERSION     0x70000001
261
262 /* Time stamp.  */
263 #define DT_MIPS_TIME_STAMP      0x70000002
264
265 /* Checksum of external strings and common sizes.  */
266 #define DT_MIPS_ICHECKSUM       0x70000003
267
268 /* Index of version string in string table.  */
269 #define DT_MIPS_IVERSION        0x70000004
270
271 /* 32 bits of flags.  */
272 #define DT_MIPS_FLAGS           0x70000005
273
274 /* Base address of the segment.  */
275 #define DT_MIPS_BASE_ADDRESS    0x70000006
276
277 /* Address of .conflict section.  */
278 #define DT_MIPS_CONFLICT        0x70000008
279
280 /* Address of .liblist section.  */
281 #define DT_MIPS_LIBLIST         0x70000009
282
283 /* Number of local global offset table entries.  */
284 #define DT_MIPS_LOCAL_GOTNO     0x7000000a
285
286 /* Number of entries in the .conflict section.  */
287 #define DT_MIPS_CONFLICTNO      0x7000000b
288
289 /* Number of entries in the .liblist section.  */
290 #define DT_MIPS_LIBLISTNO       0x70000010
291
292 /* Number of entries in the .dynsym section.  */
293 #define DT_MIPS_SYMTABNO        0x70000011
294
295 /* Index of first external dynamic symbol not referenced locally.  */
296 #define DT_MIPS_UNREFEXTNO      0x70000012
297
298 /* Index of first dynamic symbol in global offset table.  */
299 #define DT_MIPS_GOTSYM          0x70000013
300
301 /* Number of page table entries in global offset table.  */
302 #define DT_MIPS_HIPAGENO        0x70000014
303
304 /* Address of run time loader map, used for debugging.  */
305 #define DT_MIPS_RLD_MAP         0x70000016
306 \f
307 /* Flags which may appear in a DT_MIPS_FLAGS entry.  */
308
309 /* No flags.  */
310 #define RHF_NONE                0x00000000
311
312 /* Uses shortcut pointers.  */
313 #define RHF_QUICKSTART          0x00000001
314
315 /* Hash size is not a power of two.  */
316 #define RHF_NOTPOT              0x00000002
317
318 /* Ignore LD_LIBRARY_PATH.  */
319 #define RHS_NO_LIBRARY_REPLACEMENT \
320                                 0x00000004
321 \f
322 /* Special values for the st_other field in the symbol table.  These
323    are used in an Irix 5 dynamic symbol table.  */
324
325 #define STO_DEFAULT             0x00
326 #define STO_INTERNAL            0x01
327 #define STO_HIDDEN              0x02
328 #define STO_PROTECTED           0x03
329
330 /* start-sanitize-sky */
331 /* These values are used for the dvp.  */
332 #define STO_DVP_DMA             0xe8
333 #define STO_DVP_PKE             0xe9
334 #define STO_DVP_GPUIF           0xea
335 #define STO_DVP_VU              0xeb
336 #define MIPS_STO_DVP_P(sto) ((sto) >= STO_DVP_DMA && (sto) <= STO_DVP_VU)
337
338 /* end-sanitize-sky */
339 /* This value is used for a mips16 .text symbol.  */
340 #define STO_MIPS16              0xf0
341 \f
342 /* The 64-bit MIPS ELF ABI uses an unusual reloc format.  Each
343    relocation entry specifies up to three actual relocations, all at
344    the same address.  The first relocation which required a symbol
345    uses the symbol in the r_sym field.  The second relocation which
346    requires a symbol uses the symbol in the r_ssym field.  If all
347    three relocations require a symbol, the third one uses a zero
348    value.  */
349
350 /* An entry in a 64 bit SHT_REL section.  */
351
352 typedef struct
353 {
354   /* Address of relocation.  */
355   unsigned char r_offset[8];
356   /* Symbol index.  */
357   unsigned char r_sym[4];
358   /* Special symbol.  */
359   unsigned char r_ssym[1];
360   /* Third relocation.  */
361   unsigned char r_type3[1];
362   /* Second relocation.  */
363   unsigned char r_type2[1];
364   /* First relocation.  */
365   unsigned char r_type[1];
366 } Elf64_Mips_External_Rel;
367
368 typedef struct
369 {
370   /* Address of relocation.  */
371   bfd_vma r_offset;
372   /* Symbol index.  */
373   unsigned long r_sym;
374   /* Special symbol.  */
375   unsigned char r_ssym;
376   /* Third relocation.  */
377   unsigned char r_type3;
378   /* Second relocation.  */
379   unsigned char r_type2;
380   /* First relocation.  */
381   unsigned char r_type;
382 } Elf64_Mips_Internal_Rel;
383
384 /* An entry in a 64 bit SHT_RELA section.  */
385
386 typedef struct
387 {
388   /* Address of relocation.  */
389   unsigned char r_offset[8];
390   /* Symbol index.  */
391   unsigned char r_sym[4];
392   /* Special symbol.  */
393   unsigned char r_ssym[1];
394   /* Third relocation.  */
395   unsigned char r_type3[1];
396   /* Second relocation.  */
397   unsigned char r_type2[1];
398   /* First relocation.  */
399   unsigned char r_type[1];
400   /* Addend.  */
401   unsigned char r_addend[8];
402 } Elf64_Mips_External_Rela;
403
404 typedef struct
405 {
406   /* Address of relocation.  */
407   bfd_vma r_offset;
408   /* Symbol index.  */
409   unsigned long r_sym;
410   /* Special symbol.  */
411   unsigned char r_ssym;
412   /* Third relocation.  */
413   unsigned char r_type3;
414   /* Second relocation.  */
415   unsigned char r_type2;
416   /* First relocation.  */
417   unsigned char r_type;
418   /* Addend.  */
419   bfd_signed_vma r_addend;
420 } Elf64_Mips_Internal_Rela;
421
422 /* Values found in the r_ssym field of a relocation entry.  */
423
424 /* No relocation.  */
425 #define RSS_UNDEF       0
426
427 /* Value of GP.  */
428 #define RSS_GP          1
429
430 /* Value of GP in object being relocated.  */
431 #define RSS_GP0         2
432
433 /* Address of location being relocated.  */
434 #define RSS_LOC         3
435 \f
436 /* A SHT_MIPS_OPTIONS section contains a series of options, each of
437    which starts with this header.  */
438
439 typedef struct
440 {
441   /* Type of option.  */
442   unsigned char kind[1];
443   /* Size of option descriptor, including header.  */
444   unsigned char size[1];
445   /* Section index of affected section, or 0 for global option.  */
446   unsigned char section[2];
447   /* Information specific to this kind of option.  */
448   unsigned char info[4];
449 } Elf_External_Options;
450
451 typedef struct
452 {
453   /* Type of option.  */
454   unsigned char kind;
455   /* Size of option descriptor, including header.  */
456   unsigned char size;
457   /* Section index of affected section, or 0 for global option.  */
458   unsigned short section;
459   /* Information specific to this kind of option.  */
460   unsigned long info;
461 } Elf_Internal_Options;
462
463 /* MIPS ELF option header swapping routines.  */
464 extern void bfd_mips_elf_swap_options_in
465   PARAMS ((bfd *, const Elf_External_Options *, Elf_Internal_Options *));
466 extern void bfd_mips_elf_swap_options_out
467   PARAMS ((bfd *, const Elf_Internal_Options *, Elf_External_Options *));
468
469 /* Values which may appear in the kind field of an Elf_Options
470    structure.  */
471
472 /* Undefined.  */
473 #define ODK_NULL        0
474
475 /* Register usage and GP value.  */
476 #define ODK_REGINFO     1
477
478 /* Exception processing information.  */
479 #define ODK_EXCEPTIONS  2
480
481 /* Section padding information.  */
482 #define ODK_PAD         3
483
484 /* In the 32 bit ABI, an ODK_REGINFO option is just a Elf32_Reginfo
485    structure.  In the 64 bit ABI, it is the following structure.  The
486    info field of the options header is not used.  */
487
488 typedef struct
489 {
490   /* Mask of general purpose registers used.  */
491   unsigned char ri_gprmask[4];
492   /* Padding.  */
493   unsigned char ri_pad[4];
494   /* Mask of co-processor registers used.  */
495   unsigned char ri_cprmask[4][4];
496   /* GP register value for this object file.  */
497   unsigned char ri_gp_value[8];
498 } Elf64_External_RegInfo;
499
500 typedef struct
501 {
502   /* Mask of general purpose registers used.  */
503   unsigned long ri_gprmask;
504   /* Padding.  */
505   unsigned long ri_pad;
506   /* Mask of co-processor registers used.  */
507   unsigned long ri_cprmask[4];
508   /* GP register value for this object file.  */
509   bfd_vma ri_gp_value;
510 } Elf64_Internal_RegInfo;
511
512 /* MIPS ELF reginfo swapping routines.  */
513 extern void bfd_mips_elf64_swap_reginfo_in
514   PARAMS ((bfd *, const Elf64_External_RegInfo *, Elf64_Internal_RegInfo *));
515 extern void bfd_mips_elf64_swap_reginfo_out
516   PARAMS ((bfd *, const Elf64_Internal_RegInfo *, Elf64_External_RegInfo *));
517
518 #endif /* _ELF_MIPS_H */