1 /* MIPS ELF support for BFD.
2 Copyright (C) 1993, 1994 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 /* Four bit MIPS architecture field. */
43 #define EF_MIPS_ARCH 0xf0000000
46 #define E_MIPS_ARCH_1 0x00000000
49 #define E_MIPS_ARCH_2 0x10000000
52 #define E_MIPS_ARCH_3 0x20000000
54 /* Processor specific section indices. These sections do not actually
55 exist. Symbols with a st_shndx field corresponding to one of these
56 values have a special meaning. */
58 /* Defined and allocated common symbol. Value is virtual address. If
59 relocated, alignment must be preserved. */
60 #define SHN_MIPS_ACOMMON 0xff00
62 /* Defined and allocated text symbol. Value is virtual address.
63 Occur in the dynamic symbol table of Alpha OSF/1 and Irix 5 executables. */
64 #define SHN_MIPS_TEXT 0xff01
66 /* Defined and allocated data symbol. Value is virtual address.
67 Occur in the dynamic symbol table of Alpha OSF/1 and Irix 5 executables. */
68 #define SHN_MIPS_DATA 0xff02
70 /* Small common symbol. */
71 #define SHN_MIPS_SCOMMON 0xff03
73 /* Small undefined symbol. */
74 #define SHN_MIPS_SUNDEFINED 0xff04
76 /* Processor specific section types. */
78 /* Section contains the set of dynamic shared objects used when
79 statically linking. */
80 #define SHT_MIPS_LIBLIST 0x70000000
82 /* I'm not sure what this is, but it's used on Irix 5. */
83 #define SHT_MIPS_MSYM 0x70000001
85 /* Section contains list of symbols whose definitions conflict with
86 symbols defined in shared objects. */
87 #define SHT_MIPS_CONFLICT 0x70000002
89 /* Section contains the global pointer table. */
90 #define SHT_MIPS_GPTAB 0x70000003
92 /* Section contains microcode information. The exact format is
94 #define SHT_MIPS_UCODE 0x70000004
96 /* Section contains some sort of debugging information. The exact
97 format is unspecified. It's probably ECOFF symbols. */
98 #define SHT_MIPS_DEBUG 0x70000005
100 /* Section contains register usage information. */
101 #define SHT_MIPS_REGINFO 0x70000006
103 /* Section contains miscellaneous options (used on Irix). */
104 #define SHT_MIPS_OPTIONS 0x7000000d
106 /* DWARF debugging section (used on Irix 6). */
107 #define SHT_MIPS_DWARF 0x7000001e
109 /* Events section. This appears on Irix 6. I don't know what it
111 #define SHT_MIPS_EVENTS 0x70000021
113 /* A section of type SHT_MIPS_LIBLIST contains an array of the
114 following structure. The sh_link field is the section index of the
115 string table. The sh_info field is the number of entries in the
119 /* String table index for name of shared object. */
120 unsigned long l_name;
122 unsigned long l_time_stamp;
123 /* Checksum of symbol names and common sizes. */
124 unsigned long l_checksum;
125 /* String table index for version. */
126 unsigned long l_version;
128 unsigned long l_flags;
131 /* The l_flags field of an Elf32_Lib structure may contain the
134 /* Require an exact match at runtime. */
135 #define LL_EXACT_MATCH 0x00000001
137 /* Ignore version incompatibilities at runtime. */
138 #define LL_IGNORE_INT_VER 0x00000002
140 /* A section of type SHT_MIPS_CONFLICT is an array of indices into the
141 .dynsym section. Each element has the following type. */
142 typedef unsigned long Elf32_Conflict;
144 /* A section of type SHT_MIPS_GPTAB contains information about how
145 much GP space would be required for different -G arguments. This
146 information is only used so that the linker can provide informative
147 suggestions as to the best -G value to use. The sh_info field is
148 the index of the section for which this information applies. The
149 contents of the section are an array of the following union. The
150 first element uses the gt_header field. The remaining elements use
151 the gt_entry field. */
156 /* -G value actually used for this object file. */
157 unsigned long gt_current_g_value;
159 unsigned long gt_unused;
163 /* If this -G argument has been used... */
164 unsigned long gt_g_value;
165 /* ...this many GP section bytes would be required. */
166 unsigned long gt_bytes;
170 /* The external version of Elf32_gptab. */
176 unsigned char gt_current_g_value[4];
177 unsigned char gt_unused[4];
181 unsigned char gt_g_value[4];
182 unsigned char gt_bytes[4];
184 } Elf32_External_gptab;
186 /* A section of type SHT_MIPS_REGINFO contains the following
190 /* Mask of general purpose registers used. */
191 unsigned long ri_gprmask;
192 /* Mask of co-processor registers used. */
193 unsigned long ri_cprmask[4];
194 /* GP register value for this object file. */
198 /* The external version of the Elf_RegInfo structure. */
201 unsigned char ri_gprmask[4];
202 unsigned char ri_cprmask[4][4];
203 unsigned char ri_gp_value[4];
204 } Elf32_External_RegInfo;
206 /* MIPS ELF .reginfo swapping routines. */
207 extern void bfd_mips_elf32_swap_reginfo_in
208 PARAMS ((bfd *, const Elf32_External_RegInfo *, Elf32_RegInfo *));
209 extern void bfd_mips_elf32_swap_reginfo_out
210 PARAMS ((bfd *, const Elf32_RegInfo *, Elf32_External_RegInfo *));
212 /* Processor specific section flags. */
214 /* This section must be in the global data area. */
215 #define SHF_MIPS_GPREL 0x10000000
217 /* Processor specific program header types. */
219 /* Register usage information. Identifies one .reginfo section. */
220 #define PT_MIPS_REGINFO 0x70000000
222 /* Runtime procedure table. */
223 #define PT_MIPS_RTPROC 0x70000001
225 /* Processor specific dynamic array tags. */
227 /* 32 bit version number for runtime linker interface. */
228 #define DT_MIPS_RLD_VERSION 0x70000001
231 #define DT_MIPS_TIME_STAMP 0x70000002
233 /* Checksum of external strings and common sizes. */
234 #define DT_MIPS_ICHECKSUM 0x70000003
236 /* Index of version string in string table. */
237 #define DT_MIPS_IVERSION 0x70000004
239 /* 32 bits of flags. */
240 #define DT_MIPS_FLAGS 0x70000005
242 /* Base address of the segment. */
243 #define DT_MIPS_BASE_ADDRESS 0x70000006
245 /* Address of .conflict section. */
246 #define DT_MIPS_CONFLICT 0x70000008
248 /* Address of .liblist section. */
249 #define DT_MIPS_LIBLIST 0x70000009
251 /* Number of local global offset table entries. */
252 #define DT_MIPS_LOCAL_GOTNO 0x7000000a
254 /* Number of entries in the .conflict section. */
255 #define DT_MIPS_CONFLICTNO 0x7000000b
257 /* Number of entries in the .liblist section. */
258 #define DT_MIPS_LIBLISTNO 0x70000010
260 /* Number of entries in the .dynsym section. */
261 #define DT_MIPS_SYMTABNO 0x70000011
263 /* Index of first external dynamic symbol not referenced locally. */
264 #define DT_MIPS_UNREFEXTNO 0x70000012
266 /* Index of first dynamic symbol in global offset table. */
267 #define DT_MIPS_GOTSYM 0x70000013
269 /* Number of page table entries in global offset table. */
270 #define DT_MIPS_HIPAGENO 0x70000014
272 /* Address of run time loader map, used for debugging. */
273 #define DT_MIPS_RLD_MAP 0x70000016
275 /* Flags which may appear in a DT_MIPS_FLAGS entry. */
278 #define RHF_NONE 0x00000000
280 /* Uses shortcut pointers. */
281 #define RHF_QUICKSTART 0x00000001
283 /* Hash size is not a power of two. */
284 #define RHF_NOTPOT 0x00000002
286 /* Ignore LD_LIBRARY_PATH. */
287 #define RHS_NO_LIBRARY_REPLACEMENT \
290 /* Special values for the st_other field in the symbol table. These
291 are used in an Irix 5 dynamic symbol table. */
293 #define STO_DEFAULT 0x00
294 #define STO_INTERNAL 0x01
295 #define STO_HIDDEN 0x02
296 #define STO_PROTECTED 0x03
298 /* The 64-bit MIPS ELF ABI uses an usual reloc format. Each
299 relocation entry specifies up to three actual relocations, all at
300 the same address. The first relocation which required a symbol
301 uses the symbol in the r_sym field. The second relocation which
302 requires a symbol uses the symbol in the r_ssym field. If all
303 three relocations require a symbol, the third one uses a zero
306 /* An entry in a 64 bit SHT_REL section. */
310 /* Address of relocation. */
311 unsigned char r_offset[8];
313 unsigned char r_sym[4];
314 /* Special symbol. */
315 unsigned char r_ssym[1];
316 /* Third relocation. */
317 unsigned char r_type3[1];
318 /* Second relocation. */
319 unsigned char r_type2[1];
320 /* First relocation. */
321 unsigned char r_type[1];
322 } Elf64_Mips_External_Rel;
326 /* Address of relocation. */
330 /* Special symbol. */
331 unsigned char r_ssym;
332 /* Third relocation. */
333 unsigned char r_type3;
334 /* Second relocation. */
335 unsigned char r_type2;
336 /* First relocation. */
337 unsigned char r_type;
338 } Elf64_Mips_Internal_Rel;
340 /* An entry in a 64 bit SHT_RELA section. */
344 /* Address of relocation. */
345 unsigned char r_offset[8];
347 unsigned char r_sym[4];
348 /* Special symbol. */
349 unsigned char r_ssym[1];
350 /* Third relocation. */
351 unsigned char r_type3[1];
352 /* Second relocation. */
353 unsigned char r_type2[1];
354 /* First relocation. */
355 unsigned char r_type[1];
357 unsigned char r_addend[8];
358 } Elf64_Mips_External_Rela;
362 /* Address of relocation. */
366 /* Special symbol. */
367 unsigned char r_ssym;
368 /* Third relocation. */
369 unsigned char r_type3;
370 /* Second relocation. */
371 unsigned char r_type2;
372 /* First relocation. */
373 unsigned char r_type;
375 bfd_signed_vma r_addend;
376 } Elf64_Mips_Internal_Rela;
378 /* Values found in the r_ssym field of a relocation entry. */
386 /* Value of GP in object being relocated. */
389 /* Address of location being relocated. */
392 #endif /* _ELF_MIPS_H */