1 /* MIPS ELF support for BFD.
2 Copyright (C) 1993, 1994, 1995, 1996 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 /* 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. */
64 /* Defined and allocated common symbol. Value is virtual address. If
65 relocated, alignment must be preserved. */
66 #define SHN_MIPS_ACOMMON 0xff00
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
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
76 /* Small common symbol. */
77 #define SHN_MIPS_SCOMMON 0xff03
79 /* Small undefined symbol. */
80 #define SHN_MIPS_SUNDEFINED 0xff04
82 /* Processor specific section types. */
84 /* Section contains the set of dynamic shared objects used when
85 statically linking. */
86 #define SHT_MIPS_LIBLIST 0x70000000
88 /* I'm not sure what this is, but it's used on Irix 5. */
89 #define SHT_MIPS_MSYM 0x70000001
91 /* Section contains list of symbols whose definitions conflict with
92 symbols defined in shared objects. */
93 #define SHT_MIPS_CONFLICT 0x70000002
95 /* Section contains the global pointer table. */
96 #define SHT_MIPS_GPTAB 0x70000003
98 /* Section contains microcode information. The exact format is
100 #define SHT_MIPS_UCODE 0x70000004
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
106 /* Section contains register usage information. */
107 #define SHT_MIPS_REGINFO 0x70000006
109 /* Section contains interface information. */
110 #define SHT_MIPS_IFACE 0x7000000b
112 /* Section contains description of contents of another section. */
113 #define SHT_MIPS_CONTENT 0x7000000c
115 /* Section contains miscellaneous options. */
116 #define SHT_MIPS_OPTIONS 0x7000000d
118 /* DWARF debugging section. */
119 #define SHT_MIPS_DWARF 0x7000001e
121 /* I'm not sure what this is, but it appears on Irix 6. */
122 #define SHT_MIPS_SYMBOL_LIB 0x70000020
124 /* Events section. */
125 #define SHT_MIPS_EVENTS 0x70000021
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
133 /* String table index for name of shared object. */
134 unsigned long l_name
;
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
;
142 unsigned long l_flags
;
145 /* The l_flags field of an Elf32_Lib structure may contain the
148 /* Require an exact match at runtime. */
149 #define LL_EXACT_MATCH 0x00000001
151 /* Ignore version incompatibilities at runtime. */
152 #define LL_IGNORE_INT_VER 0x00000002
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
;
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. */
170 /* -G value actually used for this object file. */
171 unsigned long gt_current_g_value
;
173 unsigned long gt_unused
;
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
;
184 /* The external version of Elf32_gptab. */
190 unsigned char gt_current_g_value
[4];
191 unsigned char gt_unused
[4];
195 unsigned char gt_g_value
[4];
196 unsigned char gt_bytes
[4];
198 } Elf32_External_gptab
;
200 /* A section of type SHT_MIPS_REGINFO contains the following
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. */
212 /* The external version of the Elf_RegInfo structure. */
215 unsigned char ri_gprmask
[4];
216 unsigned char ri_cprmask
[4][4];
217 unsigned char ri_gp_value
[4];
218 } Elf32_External_RegInfo
;
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
*));
226 /* Processor specific section flags. */
228 /* This section must be in the global data area. */
229 #define SHF_MIPS_GPREL 0x10000000
231 /* This section should be merged. */
232 #define SHF_MIPS_MERGE 0x20000000
234 /* This section contains 32 bit addresses. */
235 #define SHF_MIPS_ADDR32 0x40000000
237 /* This section contains 64 bit addresses. */
238 #define SHF_MIPS_ADDR64 0x80000000
240 /* This section may not be stripped. */
241 #define SHF_MIPS_NOSTRIP 0x08000000
243 /* This section is local to threads. */
244 #define SHF_MIPS_LOCAL 0x04000000
246 /* Linker should generate implicit weak names for this section. */
247 #define SHF_MIPS_NAMES 0x02000000
249 /* Processor specific program header types. */
251 /* Register usage information. Identifies one .reginfo section. */
252 #define PT_MIPS_REGINFO 0x70000000
254 /* Runtime procedure table. */
255 #define PT_MIPS_RTPROC 0x70000001
257 /* Processor specific dynamic array tags. */
259 /* 32 bit version number for runtime linker interface. */
260 #define DT_MIPS_RLD_VERSION 0x70000001
263 #define DT_MIPS_TIME_STAMP 0x70000002
265 /* Checksum of external strings and common sizes. */
266 #define DT_MIPS_ICHECKSUM 0x70000003
268 /* Index of version string in string table. */
269 #define DT_MIPS_IVERSION 0x70000004
271 /* 32 bits of flags. */
272 #define DT_MIPS_FLAGS 0x70000005
274 /* Base address of the segment. */
275 #define DT_MIPS_BASE_ADDRESS 0x70000006
277 /* Address of .conflict section. */
278 #define DT_MIPS_CONFLICT 0x70000008
280 /* Address of .liblist section. */
281 #define DT_MIPS_LIBLIST 0x70000009
283 /* Number of local global offset table entries. */
284 #define DT_MIPS_LOCAL_GOTNO 0x7000000a
286 /* Number of entries in the .conflict section. */
287 #define DT_MIPS_CONFLICTNO 0x7000000b
289 /* Number of entries in the .liblist section. */
290 #define DT_MIPS_LIBLISTNO 0x70000010
292 /* Number of entries in the .dynsym section. */
293 #define DT_MIPS_SYMTABNO 0x70000011
295 /* Index of first external dynamic symbol not referenced locally. */
296 #define DT_MIPS_UNREFEXTNO 0x70000012
298 /* Index of first dynamic symbol in global offset table. */
299 #define DT_MIPS_GOTSYM 0x70000013
301 /* Number of page table entries in global offset table. */
302 #define DT_MIPS_HIPAGENO 0x70000014
304 /* Address of run time loader map, used for debugging. */
305 #define DT_MIPS_RLD_MAP 0x70000016
307 /* Flags which may appear in a DT_MIPS_FLAGS entry. */
310 #define RHF_NONE 0x00000000
312 /* Uses shortcut pointers. */
313 #define RHF_QUICKSTART 0x00000001
315 /* Hash size is not a power of two. */
316 #define RHF_NOTPOT 0x00000002
318 /* Ignore LD_LIBRARY_PATH. */
319 #define RHS_NO_LIBRARY_REPLACEMENT \
322 /* Special values for the st_other field in the symbol table. These
323 are used in an Irix 5 dynamic symbol table. */
325 #define STO_DEFAULT 0x00
326 #define STO_INTERNAL 0x01
327 #define STO_HIDDEN 0x02
328 #define STO_PROTECTED 0x03
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)
338 /* end-sanitize-sky */
339 /* This value is used for a mips16 .text symbol. */
340 #define STO_MIPS16 0xf0
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
350 /* An entry in a 64 bit SHT_REL section. */
354 /* Address of relocation. */
355 unsigned char r_offset
[8];
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
;
370 /* Address of relocation. */
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
;
384 /* An entry in a 64 bit SHT_RELA section. */
388 /* Address of relocation. */
389 unsigned char r_offset
[8];
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];
401 unsigned char r_addend
[8];
402 } Elf64_Mips_External_Rela
;
406 /* Address of relocation. */
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
;
419 bfd_signed_vma r_addend
;
420 } Elf64_Mips_Internal_Rela
;
422 /* Values found in the r_ssym field of a relocation entry. */
430 /* Value of GP in object being relocated. */
433 /* Address of location being relocated. */
436 /* A SHT_MIPS_OPTIONS section contains a series of options, each of
437 which starts with this header. */
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
;
453 /* Type of option. */
455 /* Size of option descriptor, including header. */
457 /* Section index of affected section, or 0 for global option. */
458 unsigned short section
;
459 /* Information specific to this kind of option. */
461 } Elf_Internal_Options
;
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
*));
469 /* Values which may appear in the kind field of an Elf_Options
475 /* Register usage and GP value. */
476 #define ODK_REGINFO 1
478 /* Exception processing information. */
479 #define ODK_EXCEPTIONS 2
481 /* Section padding information. */
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. */
490 /* Mask of general purpose registers used. */
491 unsigned char ri_gprmask
[4];
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
;
502 /* Mask of general purpose registers used. */
503 unsigned long ri_gprmask
;
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. */
510 } Elf64_Internal_RegInfo
;
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
*));
518 #endif /* _ELF_MIPS_H */