]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/binutils/include/elf/mips.h
This commit was generated by cvs2svn to compensate for changes in r56385,
[FreeBSD/FreeBSD.git] / contrib / binutils / 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 /* This value is used for a mips16 .text symbol.  */
331 #define STO_MIPS16              0xf0
332 \f
333 /* The 64-bit MIPS ELF ABI uses an unusual reloc format.  Each
334    relocation entry specifies up to three actual relocations, all at
335    the same address.  The first relocation which required a symbol
336    uses the symbol in the r_sym field.  The second relocation which
337    requires a symbol uses the symbol in the r_ssym field.  If all
338    three relocations require a symbol, the third one uses a zero
339    value.  */
340
341 /* An entry in a 64 bit SHT_REL section.  */
342
343 typedef struct
344 {
345   /* Address of relocation.  */
346   unsigned char r_offset[8];
347   /* Symbol index.  */
348   unsigned char r_sym[4];
349   /* Special symbol.  */
350   unsigned char r_ssym[1];
351   /* Third relocation.  */
352   unsigned char r_type3[1];
353   /* Second relocation.  */
354   unsigned char r_type2[1];
355   /* First relocation.  */
356   unsigned char r_type[1];
357 } Elf64_Mips_External_Rel;
358
359 typedef struct
360 {
361   /* Address of relocation.  */
362   bfd_vma r_offset;
363   /* Symbol index.  */
364   unsigned long r_sym;
365   /* Special symbol.  */
366   unsigned char r_ssym;
367   /* Third relocation.  */
368   unsigned char r_type3;
369   /* Second relocation.  */
370   unsigned char r_type2;
371   /* First relocation.  */
372   unsigned char r_type;
373 } Elf64_Mips_Internal_Rel;
374
375 /* An entry in a 64 bit SHT_RELA section.  */
376
377 typedef struct
378 {
379   /* Address of relocation.  */
380   unsigned char r_offset[8];
381   /* Symbol index.  */
382   unsigned char r_sym[4];
383   /* Special symbol.  */
384   unsigned char r_ssym[1];
385   /* Third relocation.  */
386   unsigned char r_type3[1];
387   /* Second relocation.  */
388   unsigned char r_type2[1];
389   /* First relocation.  */
390   unsigned char r_type[1];
391   /* Addend.  */
392   unsigned char r_addend[8];
393 } Elf64_Mips_External_Rela;
394
395 typedef struct
396 {
397   /* Address of relocation.  */
398   bfd_vma r_offset;
399   /* Symbol index.  */
400   unsigned long r_sym;
401   /* Special symbol.  */
402   unsigned char r_ssym;
403   /* Third relocation.  */
404   unsigned char r_type3;
405   /* Second relocation.  */
406   unsigned char r_type2;
407   /* First relocation.  */
408   unsigned char r_type;
409   /* Addend.  */
410   bfd_signed_vma r_addend;
411 } Elf64_Mips_Internal_Rela;
412
413 /* Values found in the r_ssym field of a relocation entry.  */
414
415 /* No relocation.  */
416 #define RSS_UNDEF       0
417
418 /* Value of GP.  */
419 #define RSS_GP          1
420
421 /* Value of GP in object being relocated.  */
422 #define RSS_GP0         2
423
424 /* Address of location being relocated.  */
425 #define RSS_LOC         3
426 \f
427 /* A SHT_MIPS_OPTIONS section contains a series of options, each of
428    which starts with this header.  */
429
430 typedef struct
431 {
432   /* Type of option.  */
433   unsigned char kind[1];
434   /* Size of option descriptor, including header.  */
435   unsigned char size[1];
436   /* Section index of affected section, or 0 for global option.  */
437   unsigned char section[2];
438   /* Information specific to this kind of option.  */
439   unsigned char info[4];
440 } Elf_External_Options;
441
442 typedef struct
443 {
444   /* Type of option.  */
445   unsigned char kind;
446   /* Size of option descriptor, including header.  */
447   unsigned char size;
448   /* Section index of affected section, or 0 for global option.  */
449   unsigned short section;
450   /* Information specific to this kind of option.  */
451   unsigned long info;
452 } Elf_Internal_Options;
453
454 /* MIPS ELF option header swapping routines.  */
455 extern void bfd_mips_elf_swap_options_in
456   PARAMS ((bfd *, const Elf_External_Options *, Elf_Internal_Options *));
457 extern void bfd_mips_elf_swap_options_out
458   PARAMS ((bfd *, const Elf_Internal_Options *, Elf_External_Options *));
459
460 /* Values which may appear in the kind field of an Elf_Options
461    structure.  */
462
463 /* Undefined.  */
464 #define ODK_NULL        0
465
466 /* Register usage and GP value.  */
467 #define ODK_REGINFO     1
468
469 /* Exception processing information.  */
470 #define ODK_EXCEPTIONS  2
471
472 /* Section padding information.  */
473 #define ODK_PAD         3
474
475 /* In the 32 bit ABI, an ODK_REGINFO option is just a Elf32_Reginfo
476    structure.  In the 64 bit ABI, it is the following structure.  The
477    info field of the options header is not used.  */
478
479 typedef struct
480 {
481   /* Mask of general purpose registers used.  */
482   unsigned char ri_gprmask[4];
483   /* Padding.  */
484   unsigned char ri_pad[4];
485   /* Mask of co-processor registers used.  */
486   unsigned char ri_cprmask[4][4];
487   /* GP register value for this object file.  */
488   unsigned char ri_gp_value[8];
489 } Elf64_External_RegInfo;
490
491 typedef struct
492 {
493   /* Mask of general purpose registers used.  */
494   unsigned long ri_gprmask;
495   /* Padding.  */
496   unsigned long ri_pad;
497   /* Mask of co-processor registers used.  */
498   unsigned long ri_cprmask[4];
499   /* GP register value for this object file.  */
500   bfd_vma ri_gp_value;
501 } Elf64_Internal_RegInfo;
502
503 /* MIPS ELF reginfo swapping routines.  */
504 extern void bfd_mips_elf64_swap_reginfo_in
505   PARAMS ((bfd *, const Elf64_External_RegInfo *, Elf64_Internal_RegInfo *));
506 extern void bfd_mips_elf64_swap_reginfo_out
507   PARAMS ((bfd *, const Elf64_Internal_RegInfo *, Elf64_External_RegInfo *));
508
509 #endif /* _ELF_MIPS_H */