1 /* MIPS ELF support for BFD.
2 Copyright (C) 1993, 1994, 1995, 1996, 1998 Free Software Foundation, Inc.
4 By Ian Lance Taylor, Cygnus Support, <ian@cygnus.com>, from
5 information in the System V Application Binary Interface, MIPS
8 This file is part of BFD, the Binary File Descriptor library.
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.
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.
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. */
24 /* This file holds definitions specific to the MIPS ELF ABI. Note
25 that most of this is not actually implemented by BFD. */
30 /* Processor specific flags for the ELF header e_flags field. */
32 /* At least one .noreorder directive appears in the source. */
33 #define EF_MIPS_NOREORDER 0x00000001
35 /* File contains position independent code. */
36 #define EF_MIPS_PIC 0x00000002
38 /* Code in file uses the standard calling sequence for calling
39 position independent code. */
40 #define EF_MIPS_CPIC 0x00000004
42 /* Code in file uses new ABI (-n32 on Irix 6). */
43 #define EF_MIPS_ABI2 0x00000020
45 /* Four bit MIPS architecture field. */
46 #define EF_MIPS_ARCH 0xf0000000
49 #define E_MIPS_ARCH_1 0x00000000
52 #define E_MIPS_ARCH_2 0x10000000
55 #define E_MIPS_ARCH_3 0x20000000
58 #define E_MIPS_ARCH_4 0x30000000
60 /* Machine variant if we know it. This field was invented at Cygnus,
61 but it is hoped that other vendors will adopt it. If some standard
62 is developed, this code should be changed to follow it. */
64 #define EF_MIPS_MACH 0x00FF0000
66 /* Cygnus is choosing values between 80 and 9F;
67 00 - 7F should be left for a future standard;
70 #define E_MIPS_MACH_3900 0x00810000
72 #define E_MIPS_MACH_4010 0x00820000
73 #define E_MIPS_MACH_4100 0x00830000
74 /* start-sanitize-vr4320 */
75 #define E_MIPS_MACH_4320 0x00840000
76 /* end-sanitize-vr4320 */
77 #define E_MIPS_MACH_4650 0x00850000
78 /* start-sanitize-tx49 */
79 #define E_MIPS_MACH_4900 0x00860000
80 /* end-sanitize-tx49 */
82 /* start-sanitize-vr5400 */
83 #define E_MIPS_MACH_5400 0x00910000
84 /* end-sanitize-vr5400 */
85 /* start-sanitize-r5900 */
86 #define E_MIPS_MACH_5900 0x00920000
87 /* end-sanitize-r5900 */
89 /* Processor specific section indices. These sections do not actually
90 exist. Symbols with a st_shndx field corresponding to one of these
91 values have a special meaning. */
93 /* Defined and allocated common symbol. Value is virtual address. If
94 relocated, alignment must be preserved. */
95 #define SHN_MIPS_ACOMMON 0xff00
97 /* Defined and allocated text symbol. Value is virtual address.
98 Occur in the dynamic symbol table of Alpha OSF/1 and Irix 5 executables. */
99 #define SHN_MIPS_TEXT 0xff01
101 /* Defined and allocated data symbol. Value is virtual address.
102 Occur in the dynamic symbol table of Alpha OSF/1 and Irix 5 executables. */
103 #define SHN_MIPS_DATA 0xff02
105 /* Small common symbol. */
106 #define SHN_MIPS_SCOMMON 0xff03
108 /* Small undefined symbol. */
109 #define SHN_MIPS_SUNDEFINED 0xff04
111 /* Processor specific section types. */
113 /* Section contains the set of dynamic shared objects used when
114 statically linking. */
115 #define SHT_MIPS_LIBLIST 0x70000000
117 /* I'm not sure what this is, but it's used on Irix 5. */
118 #define SHT_MIPS_MSYM 0x70000001
120 /* Section contains list of symbols whose definitions conflict with
121 symbols defined in shared objects. */
122 #define SHT_MIPS_CONFLICT 0x70000002
124 /* Section contains the global pointer table. */
125 #define SHT_MIPS_GPTAB 0x70000003
127 /* Section contains microcode information. The exact format is
129 #define SHT_MIPS_UCODE 0x70000004
131 /* Section contains some sort of debugging information. The exact
132 format is unspecified. It's probably ECOFF symbols. */
133 #define SHT_MIPS_DEBUG 0x70000005
135 /* Section contains register usage information. */
136 #define SHT_MIPS_REGINFO 0x70000006
138 /* Section contains interface information. */
139 #define SHT_MIPS_IFACE 0x7000000b
141 /* Section contains description of contents of another section. */
142 #define SHT_MIPS_CONTENT 0x7000000c
144 /* Section contains miscellaneous options. */
145 #define SHT_MIPS_OPTIONS 0x7000000d
147 /* DWARF debugging section. */
148 #define SHT_MIPS_DWARF 0x7000001e
150 /* I'm not sure what this is, but it appears on Irix 6. */
151 #define SHT_MIPS_SYMBOL_LIB 0x70000020
153 /* Events section. */
154 #define SHT_MIPS_EVENTS 0x70000021
156 /* start-sanitize-sky */
157 /* The VU overlay table. */
158 #define SHT_DVP_OVERLAY_TABLE 0x7ffff420
159 #define SHNAME_DVP_OVERLAY_TABLE ".DVP.ovlytab"
160 #define SHNAME_DVP_OVERLAY_STRTAB ".DVP.ovlystrtab"
162 #define SHT_DVP_OVERLAY 0x7ffff421
163 /* Prefix of VU overlay sections. */
164 #define SHNAME_DVP_OVERLAY_PREFIX ".DVP.overlay."
165 /* end-sanitize-sky */
167 /* A section of type SHT_MIPS_LIBLIST contains an array of the
168 following structure. The sh_link field is the section index of the
169 string table. The sh_info field is the number of entries in the
173 /* String table index for name of shared object. */
174 unsigned long l_name;
176 unsigned long l_time_stamp;
177 /* Checksum of symbol names and common sizes. */
178 unsigned long l_checksum;
179 /* String table index for version. */
180 unsigned long l_version;
182 unsigned long l_flags;
185 /* The l_flags field of an Elf32_Lib structure may contain the
188 /* Require an exact match at runtime. */
189 #define LL_EXACT_MATCH 0x00000001
191 /* Ignore version incompatibilities at runtime. */
192 #define LL_IGNORE_INT_VER 0x00000002
194 /* A section of type SHT_MIPS_CONFLICT is an array of indices into the
195 .dynsym section. Each element has the following type. */
196 typedef unsigned long Elf32_Conflict;
198 /* A section of type SHT_MIPS_GPTAB contains information about how
199 much GP space would be required for different -G arguments. This
200 information is only used so that the linker can provide informative
201 suggestions as to the best -G value to use. The sh_info field is
202 the index of the section for which this information applies. The
203 contents of the section are an array of the following union. The
204 first element uses the gt_header field. The remaining elements use
205 the gt_entry field. */
210 /* -G value actually used for this object file. */
211 unsigned long gt_current_g_value;
213 unsigned long gt_unused;
217 /* If this -G argument has been used... */
218 unsigned long gt_g_value;
219 /* ...this many GP section bytes would be required. */
220 unsigned long gt_bytes;
224 /* The external version of Elf32_gptab. */
230 unsigned char gt_current_g_value[4];
231 unsigned char gt_unused[4];
235 unsigned char gt_g_value[4];
236 unsigned char gt_bytes[4];
238 } Elf32_External_gptab;
240 /* A section of type SHT_MIPS_REGINFO contains the following
244 /* Mask of general purpose registers used. */
245 unsigned long ri_gprmask;
246 /* Mask of co-processor registers used. */
247 unsigned long ri_cprmask[4];
248 /* GP register value for this object file. */
252 /* The external version of the Elf_RegInfo structure. */
255 unsigned char ri_gprmask[4];
256 unsigned char ri_cprmask[4][4];
257 unsigned char ri_gp_value[4];
258 } Elf32_External_RegInfo;
260 /* MIPS ELF .reginfo swapping routines. */
261 extern void bfd_mips_elf32_swap_reginfo_in
262 PARAMS ((bfd *, const Elf32_External_RegInfo *, Elf32_RegInfo *));
263 extern void bfd_mips_elf32_swap_reginfo_out
264 PARAMS ((bfd *, const Elf32_RegInfo *, Elf32_External_RegInfo *));
266 /* Processor specific section flags. */
268 /* This section must be in the global data area. */
269 #define SHF_MIPS_GPREL 0x10000000
271 /* This section should be merged. */
272 #define SHF_MIPS_MERGE 0x20000000
274 /* This section contains 32 bit addresses. */
275 #define SHF_MIPS_ADDR32 0x40000000
277 /* This section contains 64 bit addresses. */
278 #define SHF_MIPS_ADDR64 0x80000000
280 /* This section may not be stripped. */
281 #define SHF_MIPS_NOSTRIP 0x08000000
283 /* This section is local to threads. */
284 #define SHF_MIPS_LOCAL 0x04000000
286 /* Linker should generate implicit weak names for this section. */
287 #define SHF_MIPS_NAMES 0x02000000
289 /* Processor specific program header types. */
291 /* Register usage information. Identifies one .reginfo section. */
292 #define PT_MIPS_REGINFO 0x70000000
294 /* Runtime procedure table. */
295 #define PT_MIPS_RTPROC 0x70000001
297 /* Options (for what ???). */
298 #define PT_MIPS_OPTIONS 0x70000002
300 /* Processor specific dynamic array tags. */
302 /* 32 bit version number for runtime linker interface. */
303 #define DT_MIPS_RLD_VERSION 0x70000001
306 #define DT_MIPS_TIME_STAMP 0x70000002
308 /* Checksum of external strings and common sizes. */
309 #define DT_MIPS_ICHECKSUM 0x70000003
311 /* Index of version string in string table. */
312 #define DT_MIPS_IVERSION 0x70000004
314 /* 32 bits of flags. */
315 #define DT_MIPS_FLAGS 0x70000005
317 /* Base address of the segment. */
318 #define DT_MIPS_BASE_ADDRESS 0x70000006
321 #define DT_MIPS_MSYM 0x70000007
323 /* Address of .conflict section. */
324 #define DT_MIPS_CONFLICT 0x70000008
326 /* Address of .liblist section. */
327 #define DT_MIPS_LIBLIST 0x70000009
329 /* Number of local global offset table entries. */
330 #define DT_MIPS_LOCAL_GOTNO 0x7000000a
332 /* Number of entries in the .conflict section. */
333 #define DT_MIPS_CONFLICTNO 0x7000000b
335 /* Number of entries in the .liblist section. */
336 #define DT_MIPS_LIBLISTNO 0x70000010
338 /* Number of entries in the .dynsym section. */
339 #define DT_MIPS_SYMTABNO 0x70000011
341 /* Index of first external dynamic symbol not referenced locally. */
342 #define DT_MIPS_UNREFEXTNO 0x70000012
344 /* Index of first dynamic symbol in global offset table. */
345 #define DT_MIPS_GOTSYM 0x70000013
347 /* Number of page table entries in global offset table. */
348 #define DT_MIPS_HIPAGENO 0x70000014
350 /* Address of run time loader map, used for debugging. */
351 #define DT_MIPS_RLD_MAP 0x70000016
353 /* Delta C++ class definition. */
354 #define DT_MIPS_DELTA_CLASS 0x70000017
356 /* Number of entries in DT_MIPS_DELTA_CLASS. */
357 #define DT_MIPS_DELTA_CLASS_NO 0x70000018
359 /* Delta C++ class instances. */
360 #define DT_MIPS_DELTA_INSTANCE 0x70000019
362 /* Number of entries in DT_MIPS_DELTA_INSTANCE. */
363 #define DT_MIPS_DELTA_INSTANCE_NO 0x7000001a
365 /* Delta relocations. */
366 #define DT_MIPS_DELTA_RELOC 0x7000001b
368 /* Number of entries in DT_MIPS_DELTA_RELOC. */
369 #define DT_MIPS_DELTA_RELOC_NO 0x7000001c
371 /* Delta symbols that Delta relocations refer to. */
372 #define DT_MIPS_DELTA_SYM 0x7000001d
374 /* Number of entries in DT_MIPS_DELTA_SYM. */
375 #define DT_MIPS_DELTA_SYM_NO 0x7000001e
377 /* Delta symbols that hold class declarations. */
378 #define DT_MIPS_DELTA_CLASSSYM 0x70000020
380 /* Number of entries in DT_MIPS_DELTA_CLASSSYM. */
381 #define DT_MIPS_DELTA_CLASSSYM_NO 0x70000021
383 /* Flags indicating information about C++ flavor. */
384 #define DT_MIPS_CXX_FLAGS 0x70000022
386 /* Pixie information (???). */
387 #define DT_MIPS_PIXIE_INIT 0x70000023
390 #define DT_MIPS_SYMBOL_LIB 0x70000024
393 #define DT_MIPS_LOCALPAGE_GOTIDX 0x70000025
396 #define DT_MIPS_LOCAL_GOTIDX 0x70000026
399 #define DT_MIPS_HIDDEN_GOTIDX 0x70000027
402 #define DT_MIPS_PROTECTED_GOTIDX 0x70000028
404 /* Address of `.MIPS.options'. */
405 #define DT_MIPS_OPTIONS 0x70000029
407 /* Address of `.interface'. */
408 #define DT_MIPS_INTERFACE 0x7000002a
411 #define DT_MIPS_DYNSTR_ALIGN 0x7000002b
413 /* Size of the .interface section. */
414 #define DT_MIPS_INTERFACE_SIZE 0x7000002c
416 /* Size of rld_text_resolve function stored in the GOT. */
417 #define DT_MIPS_RLD_TEXT_RESOLVE_ADDR 0x7000002d
419 /* Default suffix of DSO to be added by rld on dlopen() calls. */
420 #define DT_MIPS_PERF_SUFFIX 0x7000002e
422 /* Size of compact relocation section (O32). */
423 #define DT_MIPS_COMPACT_SIZE 0x7000002f
425 /* GP value for auxiliary GOTs. */
426 #define DT_MIPS_GP_VALUE 0x70000030
428 /* Address of auxiliary .dynamic. */
429 #define DT_MIPS_AUX_DYNAMIC 0x70000031
431 /* Flags which may appear in a DT_MIPS_FLAGS entry. */
434 #define RHF_NONE 0x00000000
436 /* Uses shortcut pointers. */
437 #define RHF_QUICKSTART 0x00000001
439 /* Hash size is not a power of two. */
440 #define RHF_NOTPOT 0x00000002
442 /* Ignore LD_LIBRARY_PATH. */
443 #define RHS_NO_LIBRARY_REPLACEMENT \
446 /* Special values for the st_other field in the symbol table. These
447 are used in an Irix 5 dynamic symbol table. */
449 #define STO_DEFAULT 0x00
450 #define STO_INTERNAL 0x01
451 #define STO_HIDDEN 0x02
452 #define STO_PROTECTED 0x03
454 /* start-sanitize-sky */
455 /* These values are used for the dvp. */
456 #define STO_DVP_DMA 0xe8
457 #define STO_DVP_VIF 0xe9
458 #define STO_DVP_GIF 0xea
459 #define STO_DVP_VU 0xeb
460 /* Reserve a couple in case we need them. */
461 #define STO_DVP_RES1 0xec
462 #define STO_DVP_RES2 0xed
463 #define STO_DVP_P(sto) ((sto) >= STO_DVP_DMA && (sto) <= STO_DVP_RES2)
465 /* end-sanitize-sky */
466 /* This value is used for a mips16 .text symbol. */
467 #define STO_MIPS16 0xf0
469 /* The 64-bit MIPS ELF ABI uses an unusual reloc format. Each
470 relocation entry specifies up to three actual relocations, all at
471 the same address. The first relocation which required a symbol
472 uses the symbol in the r_sym field. The second relocation which
473 requires a symbol uses the symbol in the r_ssym field. If all
474 three relocations require a symbol, the third one uses a zero
477 /* An entry in a 64 bit SHT_REL section. */
481 /* Address of relocation. */
482 unsigned char r_offset[8];
484 unsigned char r_sym[4];
485 /* Special symbol. */
486 unsigned char r_ssym[1];
487 /* Third relocation. */
488 unsigned char r_type3[1];
489 /* Second relocation. */
490 unsigned char r_type2[1];
491 /* First relocation. */
492 unsigned char r_type[1];
493 } Elf64_Mips_External_Rel;
497 /* Address of relocation. */
501 /* Special symbol. */
502 unsigned char r_ssym;
503 /* Third relocation. */
504 unsigned char r_type3;
505 /* Second relocation. */
506 unsigned char r_type2;
507 /* First relocation. */
508 unsigned char r_type;
509 } Elf64_Mips_Internal_Rel;
511 /* An entry in a 64 bit SHT_RELA section. */
515 /* Address of relocation. */
516 unsigned char r_offset[8];
518 unsigned char r_sym[4];
519 /* Special symbol. */
520 unsigned char r_ssym[1];
521 /* Third relocation. */
522 unsigned char r_type3[1];
523 /* Second relocation. */
524 unsigned char r_type2[1];
525 /* First relocation. */
526 unsigned char r_type[1];
528 unsigned char r_addend[8];
529 } Elf64_Mips_External_Rela;
533 /* Address of relocation. */
537 /* Special symbol. */
538 unsigned char r_ssym;
539 /* Third relocation. */
540 unsigned char r_type3;
541 /* Second relocation. */
542 unsigned char r_type2;
543 /* First relocation. */
544 unsigned char r_type;
546 bfd_signed_vma r_addend;
547 } Elf64_Mips_Internal_Rela;
549 /* Values found in the r_ssym field of a relocation entry. */
557 /* Value of GP in object being relocated. */
560 /* Address of location being relocated. */
563 /* A SHT_MIPS_OPTIONS section contains a series of options, each of
564 which starts with this header. */
568 /* Type of option. */
569 unsigned char kind[1];
570 /* Size of option descriptor, including header. */
571 unsigned char size[1];
572 /* Section index of affected section, or 0 for global option. */
573 unsigned char section[2];
574 /* Information specific to this kind of option. */
575 unsigned char info[4];
576 } Elf_External_Options;
580 /* Type of option. */
582 /* Size of option descriptor, including header. */
584 /* Section index of affected section, or 0 for global option. */
585 unsigned short section;
586 /* Information specific to this kind of option. */
588 } Elf_Internal_Options;
590 /* MIPS ELF option header swapping routines. */
591 extern void bfd_mips_elf_swap_options_in
592 PARAMS ((bfd *, const Elf_External_Options *, Elf_Internal_Options *));
593 extern void bfd_mips_elf_swap_options_out
594 PARAMS ((bfd *, const Elf_Internal_Options *, Elf_External_Options *));
596 /* Values which may appear in the kind field of an Elf_Options
602 /* Register usage and GP value. */
603 #define ODK_REGINFO 1
605 /* Exception processing information. */
606 #define ODK_EXCEPTIONS 2
608 /* Section padding information. */
611 /* In the 32 bit ABI, an ODK_REGINFO option is just a Elf32_Reginfo
612 structure. In the 64 bit ABI, it is the following structure. The
613 info field of the options header is not used. */
617 /* Mask of general purpose registers used. */
618 unsigned char ri_gprmask[4];
620 unsigned char ri_pad[4];
621 /* Mask of co-processor registers used. */
622 unsigned char ri_cprmask[4][4];
623 /* GP register value for this object file. */
624 unsigned char ri_gp_value[8];
625 } Elf64_External_RegInfo;
629 /* Mask of general purpose registers used. */
630 unsigned long ri_gprmask;
632 unsigned long ri_pad;
633 /* Mask of co-processor registers used. */
634 unsigned long ri_cprmask[4];
635 /* GP register value for this object file. */
637 } Elf64_Internal_RegInfo;
639 /* MIPS ELF reginfo swapping routines. */
640 extern void bfd_mips_elf64_swap_reginfo_in
641 PARAMS ((bfd *, const Elf64_External_RegInfo *, Elf64_Internal_RegInfo *));
642 extern void bfd_mips_elf64_swap_reginfo_out
643 PARAMS ((bfd *, const Elf64_Internal_RegInfo *, Elf64_External_RegInfo *));
645 /* start-sanitize-sky */
646 /* The vu overlay table is an array of this. */
650 /* `name' is offset into overlay string table section. */
654 } Elf32_Dvp_External_Overlay;
661 } Elf32_Dvp_Internal_Overlay;
663 /* overlay swapping routines. */
664 extern void bfd_dvp_elf32_swap_overlay_in
665 PARAMS ((bfd *, const Elf32_Dvp_External_Overlay *,
666 Elf32_Dvp_Internal_Overlay *));
667 extern void bfd_dvp_elf32_swap_overlay_out
668 PARAMS ((bfd *, const Elf32_Dvp_Internal_Overlay *,
669 Elf32_Dvp_External_Overlay *));
671 /* end-sanitize-sky */
673 #endif /* _ELF_MIPS_H */