Commit | Line | Data |
---|---|---|
55d5703f | 1 | /* MIPS ELF support for BFD. |
4c040a64 | 2 | Copyright (C) 1993, 1994 Free Software Foundation, Inc. |
55d5703f ILT |
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 | |
80483b24 | 22 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
55d5703f ILT |
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 | ||
80483b24 ILT |
27 | #ifndef _ELF_MIPS_H |
28 | #define _ELF_MIPS_H | |
29 | ||
55d5703f ILT |
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 | /* Four bit MIPS architecture field. */ | |
43 | #define EF_MIPS_ARCH 0xf0000000 | |
4c040a64 PS |
44 | |
45 | /* -mips1 code. */ | |
46 | #define E_MIPS_ARCH_1 0x00000000 | |
47 | ||
48 | /* -mips2 code. */ | |
49 | #define E_MIPS_ARCH_2 0x10000000 | |
50 | ||
51 | /* -mips3 code. */ | |
52 | #define E_MIPS_ARCH_3 0x20000000 | |
68745520 ILT |
53 | |
54 | /* -mips4 code. */ | |
55 | #define E_MIPS_ARCH_4 0x30000000 | |
55d5703f ILT |
56 | \f |
57 | /* Processor specific section indices. These sections do not actually | |
58 | exist. Symbols with a st_shndx field corresponding to one of these | |
59 | values have a special meaning. */ | |
60 | ||
61 | /* Defined and allocated common symbol. Value is virtual address. If | |
62 | relocated, alignment must be preserved. */ | |
63 | #define SHN_MIPS_ACOMMON 0xff00 | |
64 | ||
80483b24 ILT |
65 | /* Defined and allocated text symbol. Value is virtual address. |
66 | Occur in the dynamic symbol table of Alpha OSF/1 and Irix 5 executables. */ | |
67 | #define SHN_MIPS_TEXT 0xff01 | |
68 | ||
69 | /* Defined and allocated data symbol. Value is virtual address. | |
70 | Occur in the dynamic symbol table of Alpha OSF/1 and Irix 5 executables. */ | |
71 | #define SHN_MIPS_DATA 0xff02 | |
72 | ||
55d5703f ILT |
73 | /* Small common symbol. */ |
74 | #define SHN_MIPS_SCOMMON 0xff03 | |
75 | ||
76 | /* Small undefined symbol. */ | |
77 | #define SHN_MIPS_SUNDEFINED 0xff04 | |
78 | \f | |
79 | /* Processor specific section types. */ | |
80 | ||
81 | /* Section contains the set of dynamic shared objects used when | |
82 | statically linking. */ | |
83 | #define SHT_MIPS_LIBLIST 0x70000000 | |
84 | ||
80483b24 ILT |
85 | /* I'm not sure what this is, but it's used on Irix 5. */ |
86 | #define SHT_MIPS_MSYM 0x70000001 | |
87 | ||
55d5703f ILT |
88 | /* Section contains list of symbols whose definitions conflict with |
89 | symbols defined in shared objects. */ | |
90 | #define SHT_MIPS_CONFLICT 0x70000002 | |
91 | ||
92 | /* Section contains the global pointer table. */ | |
93 | #define SHT_MIPS_GPTAB 0x70000003 | |
94 | ||
95 | /* Section contains microcode information. The exact format is | |
96 | unspecified. */ | |
97 | #define SHT_MIPS_UCODE 0x70000004 | |
98 | ||
99 | /* Section contains some sort of debugging information. The exact | |
100 | format is unspecified. It's probably ECOFF symbols. */ | |
101 | #define SHT_MIPS_DEBUG 0x70000005 | |
102 | ||
103 | /* Section contains register usage information. */ | |
104 | #define SHT_MIPS_REGINFO 0x70000006 | |
105 | ||
4c040a64 PS |
106 | /* Section contains miscellaneous options (used on Irix). */ |
107 | #define SHT_MIPS_OPTIONS 0x7000000d | |
108 | ||
80483b24 ILT |
109 | /* DWARF debugging section (used on Irix 6). */ |
110 | #define SHT_MIPS_DWARF 0x7000001e | |
111 | ||
112 | /* Events section. This appears on Irix 6. I don't know what it | |
113 | means. */ | |
114 | #define SHT_MIPS_EVENTS 0x70000021 | |
115 | ||
55d5703f ILT |
116 | /* A section of type SHT_MIPS_LIBLIST contains an array of the |
117 | following structure. The sh_link field is the section index of the | |
118 | string table. The sh_info field is the number of entries in the | |
119 | section. */ | |
120 | typedef struct | |
121 | { | |
122 | /* String table index for name of shared object. */ | |
4c040a64 | 123 | unsigned long l_name; |
55d5703f | 124 | /* Time stamp. */ |
4c040a64 | 125 | unsigned long l_time_stamp; |
55d5703f | 126 | /* Checksum of symbol names and common sizes. */ |
4c040a64 | 127 | unsigned long l_checksum; |
55d5703f | 128 | /* String table index for version. */ |
4c040a64 | 129 | unsigned long l_version; |
55d5703f | 130 | /* Flags. */ |
4c040a64 | 131 | unsigned long l_flags; |
55d5703f ILT |
132 | } Elf32_Lib; |
133 | ||
134 | /* The l_flags field of an Elf32_Lib structure may contain the | |
135 | following flags. */ | |
136 | ||
137 | /* Require an exact match at runtime. */ | |
138 | #define LL_EXACT_MATCH 0x00000001 | |
139 | ||
140 | /* Ignore version incompatibilities at runtime. */ | |
141 | #define LL_IGNORE_INT_VER 0x00000002 | |
142 | ||
143 | /* A section of type SHT_MIPS_CONFLICT is an array of indices into the | |
144 | .dynsym section. Each element has the following type. */ | |
4c040a64 | 145 | typedef unsigned long Elf32_Conflict; |
55d5703f ILT |
146 | |
147 | /* A section of type SHT_MIPS_GPTAB contains information about how | |
148 | much GP space would be required for different -G arguments. This | |
149 | information is only used so that the linker can provide informative | |
150 | suggestions as to the best -G value to use. The sh_info field is | |
151 | the index of the section for which this information applies. The | |
152 | contents of the section are an array of the following union. The | |
153 | first element uses the gt_header field. The remaining elements use | |
154 | the gt_entry field. */ | |
155 | typedef union | |
156 | { | |
157 | struct | |
158 | { | |
159 | /* -G value actually used for this object file. */ | |
4c040a64 | 160 | unsigned long gt_current_g_value; |
55d5703f | 161 | /* Unused. */ |
4c040a64 | 162 | unsigned long gt_unused; |
55d5703f ILT |
163 | } gt_header; |
164 | struct | |
165 | { | |
166 | /* If this -G argument has been used... */ | |
4c040a64 | 167 | unsigned long gt_g_value; |
55d5703f | 168 | /* ...this many GP section bytes would be required. */ |
4c040a64 | 169 | unsigned long gt_bytes; |
55d5703f ILT |
170 | } gt_entry; |
171 | } Elf32_gptab; | |
172 | ||
80483b24 ILT |
173 | /* The external version of Elf32_gptab. */ |
174 | ||
175 | typedef union | |
176 | { | |
177 | struct | |
178 | { | |
179 | unsigned char gt_current_g_value[4]; | |
180 | unsigned char gt_unused[4]; | |
181 | } gt_header; | |
182 | struct | |
183 | { | |
184 | unsigned char gt_g_value[4]; | |
185 | unsigned char gt_bytes[4]; | |
186 | } gt_entry; | |
187 | } Elf32_External_gptab; | |
188 | ||
55d5703f ILT |
189 | /* A section of type SHT_MIPS_REGINFO contains the following |
190 | structure. */ | |
191 | typedef struct | |
192 | { | |
193 | /* Mask of general purpose registers used. */ | |
4c040a64 | 194 | unsigned long ri_gprmask; |
55d5703f | 195 | /* Mask of co-processor registers used. */ |
4c040a64 | 196 | unsigned long ri_cprmask[4]; |
55d5703f | 197 | /* GP register value for this object file. */ |
4c040a64 PS |
198 | long ri_gp_value; |
199 | } Elf32_RegInfo; | |
200 | ||
201 | /* The external version of the Elf_RegInfo structure. */ | |
202 | typedef struct | |
203 | { | |
204 | unsigned char ri_gprmask[4]; | |
205 | unsigned char ri_cprmask[4][4]; | |
206 | unsigned char ri_gp_value[4]; | |
207 | } Elf32_External_RegInfo; | |
208 | ||
209 | /* MIPS ELF .reginfo swapping routines. */ | |
210 | extern void bfd_mips_elf32_swap_reginfo_in | |
211 | PARAMS ((bfd *, const Elf32_External_RegInfo *, Elf32_RegInfo *)); | |
212 | extern void bfd_mips_elf32_swap_reginfo_out | |
213 | PARAMS ((bfd *, const Elf32_RegInfo *, Elf32_External_RegInfo *)); | |
55d5703f ILT |
214 | \f |
215 | /* Processor specific section flags. */ | |
216 | ||
217 | /* This section must be in the global data area. */ | |
4c040a64 PS |
218 | #define SHF_MIPS_GPREL 0x10000000 |
219 | \f | |
220 | /* Processor specific program header types. */ | |
221 | ||
222 | /* Register usage information. Identifies one .reginfo section. */ | |
223 | #define PT_MIPS_REGINFO 0x70000000 | |
80483b24 ILT |
224 | |
225 | /* Runtime procedure table. */ | |
226 | #define PT_MIPS_RTPROC 0x70000001 | |
4c040a64 PS |
227 | \f |
228 | /* Processor specific dynamic array tags. */ | |
229 | ||
230 | /* 32 bit version number for runtime linker interface. */ | |
231 | #define DT_MIPS_RLD_VERSION 0x70000001 | |
232 | ||
233 | /* Time stamp. */ | |
234 | #define DT_MIPS_TIME_STAMP 0x70000002 | |
235 | ||
236 | /* Checksum of external strings and common sizes. */ | |
237 | #define DT_MIPS_ICHECKSUM 0x70000003 | |
238 | ||
239 | /* Index of version string in string table. */ | |
240 | #define DT_MIPS_IVERSION 0x70000004 | |
241 | ||
242 | /* 32 bits of flags. */ | |
243 | #define DT_MIPS_FLAGS 0x70000005 | |
244 | ||
245 | /* Base address of the segment. */ | |
246 | #define DT_MIPS_BASE_ADDRESS 0x70000006 | |
247 | ||
248 | /* Address of .conflict section. */ | |
249 | #define DT_MIPS_CONFLICT 0x70000008 | |
250 | ||
251 | /* Address of .liblist section. */ | |
252 | #define DT_MIPS_LIBLIST 0x70000009 | |
253 | ||
254 | /* Number of local global offset table entries. */ | |
255 | #define DT_MIPS_LOCAL_GOTNO 0x7000000a | |
256 | ||
257 | /* Number of entries in the .conflict section. */ | |
258 | #define DT_MIPS_CONFLICTNO 0x7000000b | |
259 | ||
260 | /* Number of entries in the .liblist section. */ | |
261 | #define DT_MIPS_LIBLISTNO 0x70000010 | |
262 | ||
263 | /* Number of entries in the .dynsym section. */ | |
264 | #define DT_MIPS_SYMTABNO 0x70000011 | |
265 | ||
266 | /* Index of first external dynamic symbol not referenced locally. */ | |
267 | #define DT_MIPS_UNREFEXTNO 0x70000012 | |
268 | ||
269 | /* Index of first dynamic symbol in global offset table. */ | |
270 | #define DT_MIPS_GOTSYM 0x70000013 | |
271 | ||
272 | /* Number of page table entries in global offset table. */ | |
273 | #define DT_MIPS_HIPAGENO 0x70000014 | |
274 | ||
275 | /* Address of run time loader map, used for debugging. */ | |
276 | #define DT_MIPS_RLD_MAP 0x70000016 | |
80483b24 ILT |
277 | \f |
278 | /* Flags which may appear in a DT_MIPS_FLAGS entry. */ | |
279 | ||
280 | /* No flags. */ | |
281 | #define RHF_NONE 0x00000000 | |
282 | ||
283 | /* Uses shortcut pointers. */ | |
284 | #define RHF_QUICKSTART 0x00000001 | |
285 | ||
286 | /* Hash size is not a power of two. */ | |
287 | #define RHF_NOTPOT 0x00000002 | |
288 | ||
289 | /* Ignore LD_LIBRARY_PATH. */ | |
290 | #define RHS_NO_LIBRARY_REPLACEMENT \ | |
291 | 0x00000004 | |
292 | \f | |
293 | /* Special values for the st_other field in the symbol table. These | |
294 | are used in an Irix 5 dynamic symbol table. */ | |
295 | ||
296 | #define STO_DEFAULT 0x00 | |
297 | #define STO_INTERNAL 0x01 | |
298 | #define STO_HIDDEN 0x02 | |
299 | #define STO_PROTECTED 0x03 | |
300 | \f | |
301 | /* The 64-bit MIPS ELF ABI uses an usual reloc format. Each | |
302 | relocation entry specifies up to three actual relocations, all at | |
303 | the same address. The first relocation which required a symbol | |
304 | uses the symbol in the r_sym field. The second relocation which | |
305 | requires a symbol uses the symbol in the r_ssym field. If all | |
306 | three relocations require a symbol, the third one uses a zero | |
307 | value. */ | |
308 | ||
309 | /* An entry in a 64 bit SHT_REL section. */ | |
310 | ||
311 | typedef struct | |
312 | { | |
313 | /* Address of relocation. */ | |
314 | unsigned char r_offset[8]; | |
315 | /* Symbol index. */ | |
316 | unsigned char r_sym[4]; | |
317 | /* Special symbol. */ | |
318 | unsigned char r_ssym[1]; | |
319 | /* Third relocation. */ | |
320 | unsigned char r_type3[1]; | |
321 | /* Second relocation. */ | |
322 | unsigned char r_type2[1]; | |
323 | /* First relocation. */ | |
324 | unsigned char r_type[1]; | |
325 | } Elf64_Mips_External_Rel; | |
326 | ||
327 | typedef struct | |
328 | { | |
329 | /* Address of relocation. */ | |
330 | bfd_vma r_offset; | |
331 | /* Symbol index. */ | |
332 | unsigned long r_sym; | |
333 | /* Special symbol. */ | |
334 | unsigned char r_ssym; | |
335 | /* Third relocation. */ | |
336 | unsigned char r_type3; | |
337 | /* Second relocation. */ | |
338 | unsigned char r_type2; | |
339 | /* First relocation. */ | |
340 | unsigned char r_type; | |
341 | } Elf64_Mips_Internal_Rel; | |
342 | ||
343 | /* An entry in a 64 bit SHT_RELA section. */ | |
344 | ||
345 | typedef struct | |
346 | { | |
347 | /* Address of relocation. */ | |
348 | unsigned char r_offset[8]; | |
349 | /* Symbol index. */ | |
350 | unsigned char r_sym[4]; | |
351 | /* Special symbol. */ | |
352 | unsigned char r_ssym[1]; | |
353 | /* Third relocation. */ | |
354 | unsigned char r_type3[1]; | |
355 | /* Second relocation. */ | |
356 | unsigned char r_type2[1]; | |
357 | /* First relocation. */ | |
358 | unsigned char r_type[1]; | |
359 | /* Addend. */ | |
360 | unsigned char r_addend[8]; | |
361 | } Elf64_Mips_External_Rela; | |
362 | ||
363 | typedef struct | |
364 | { | |
365 | /* Address of relocation. */ | |
366 | bfd_vma r_offset; | |
367 | /* Symbol index. */ | |
368 | unsigned long r_sym; | |
369 | /* Special symbol. */ | |
370 | unsigned char r_ssym; | |
371 | /* Third relocation. */ | |
372 | unsigned char r_type3; | |
373 | /* Second relocation. */ | |
374 | unsigned char r_type2; | |
375 | /* First relocation. */ | |
376 | unsigned char r_type; | |
377 | /* Addend. */ | |
378 | bfd_signed_vma r_addend; | |
379 | } Elf64_Mips_Internal_Rela; | |
380 | ||
381 | /* Values found in the r_ssym field of a relocation entry. */ | |
382 | ||
383 | /* No relocation. */ | |
384 | #define RSS_UNDEF 0 | |
385 | ||
386 | /* Value of GP. */ | |
387 | #define RSS_GP 1 | |
388 | ||
389 | /* Value of GP in object being relocated. */ | |
390 | #define RSS_GP0 2 | |
391 | ||
392 | /* Address of location being relocated. */ | |
393 | #define RSS_LOC 3 | |
394 | ||
395 | #endif /* _ELF_MIPS_H */ |