(linux_test_for_tracefork): Don't leave zombie
[deliverable/binutils-gdb.git] / bfd / elfn32-mips.c
1 /* MIPS-specific support for 32-bit ELF
2 Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
3 2003, 2004, 2005 Free Software Foundation, Inc.
4
5 Most of the information added by Ian Lance Taylor, Cygnus Support,
6 <ian@cygnus.com>.
7 N32/64 ABI support added by Mark Mitchell, CodeSourcery, LLC.
8 <mark@codesourcery.com>
9 Traditional MIPS targets support added by Koundinya.K, Dansk Data
10 Elektronik & Operations Research Group. <kk@ddeorg.soft.net>
11
12 This file is part of BFD, the Binary File Descriptor library.
13
14 This program is free software; you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by
16 the Free Software Foundation; either version 2 of the License, or
17 (at your option) any later version.
18
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, write to the Free Software
26 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
27
28 /* This file handles MIPS ELF targets. SGI Irix 5 uses a slightly
29 different MIPS ELF from other targets. This matters when linking.
30 This file supports both, switching at runtime. */
31
32 #include "bfd.h"
33 #include "sysdep.h"
34 #include "libbfd.h"
35 #include "bfdlink.h"
36 #include "genlink.h"
37 #include "elf-bfd.h"
38 #include "elfxx-mips.h"
39 #include "elf/mips.h"
40
41 /* Get the ECOFF swapping routines. */
42 #include "coff/sym.h"
43 #include "coff/symconst.h"
44 #include "coff/internal.h"
45 #include "coff/ecoff.h"
46 #include "coff/mips.h"
47 #define ECOFF_SIGNED_32
48 #include "ecoffswap.h"
49
50 static bfd_boolean mips_elf_assign_gp
51 (bfd *, bfd_vma *);
52 static bfd_reloc_status_type mips_elf_final_gp
53 (bfd *, asymbol *, bfd_boolean, char **, bfd_vma *);
54 static bfd_reloc_status_type mips_elf_gprel16_reloc
55 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
56 static bfd_reloc_status_type mips_elf_literal_reloc
57 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
58 static bfd_reloc_status_type mips_elf_gprel32_reloc
59 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
60 static bfd_reloc_status_type gprel32_with_gp
61 (bfd *, asymbol *, arelent *, asection *, bfd_boolean, void *, bfd_vma);
62 static bfd_reloc_status_type mips_elf_shift6_reloc
63 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
64 static bfd_reloc_status_type mips16_gprel_reloc
65 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
66 static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
67 (bfd *, bfd_reloc_code_real_type);
68 static reloc_howto_type *mips_elf_n32_rtype_to_howto
69 (unsigned int, bfd_boolean);
70 static void mips_info_to_howto_rel
71 (bfd *, arelent *, Elf_Internal_Rela *);
72 static void mips_info_to_howto_rela
73 (bfd *, arelent *, Elf_Internal_Rela *);
74 static bfd_boolean mips_elf_sym_is_global
75 (bfd *, asymbol *);
76 static bfd_boolean mips_elf_n32_object_p
77 (bfd *);
78 static bfd_boolean elf32_mips_grok_prstatus
79 (bfd *, Elf_Internal_Note *);
80 static bfd_boolean elf32_mips_grok_psinfo
81 (bfd *, Elf_Internal_Note *);
82 static irix_compat_t elf_n32_mips_irix_compat
83 (bfd *);
84
85 extern const bfd_target bfd_elf32_nbigmips_vec;
86 extern const bfd_target bfd_elf32_nlittlemips_vec;
87
88 /* Nonzero if ABFD is using the N32 ABI. */
89 #define ABI_N32_P(abfd) \
90 ((elf_elfheader (abfd)->e_flags & EF_MIPS_ABI2) != 0)
91
92 /* Whether we are trying to be compatible with IRIX at all. */
93 #define SGI_COMPAT(abfd) \
94 (elf_n32_mips_irix_compat (abfd) != ict_none)
95
96 /* The number of local .got entries we reserve. */
97 #define MIPS_RESERVED_GOTNO (2)
98
99 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
100 from smaller values. Start with zero, widen, *then* decrement. */
101 #define MINUS_ONE (((bfd_vma)0) - 1)
102
103 /* The relocation table used for SHT_REL sections. */
104
105 static reloc_howto_type elf_mips_howto_table_rel[] =
106 {
107 /* No relocation. */
108 HOWTO (R_MIPS_NONE, /* type */
109 0, /* rightshift */
110 0, /* size (0 = byte, 1 = short, 2 = long) */
111 0, /* bitsize */
112 FALSE, /* pc_relative */
113 0, /* bitpos */
114 complain_overflow_dont, /* complain_on_overflow */
115 _bfd_mips_elf_generic_reloc, /* special_function */
116 "R_MIPS_NONE", /* name */
117 FALSE, /* partial_inplace */
118 0, /* src_mask */
119 0, /* dst_mask */
120 FALSE), /* pcrel_offset */
121
122 /* 16 bit relocation. */
123 HOWTO (R_MIPS_16, /* type */
124 0, /* rightshift */
125 2, /* size (0 = byte, 1 = short, 2 = long) */
126 16, /* bitsize */
127 FALSE, /* pc_relative */
128 0, /* bitpos */
129 complain_overflow_signed, /* complain_on_overflow */
130 _bfd_mips_elf_generic_reloc, /* special_function */
131 "R_MIPS_16", /* name */
132 TRUE, /* partial_inplace */
133 0x0000ffff, /* src_mask */
134 0x0000ffff, /* dst_mask */
135 FALSE), /* pcrel_offset */
136
137 /* 32 bit relocation. */
138 HOWTO (R_MIPS_32, /* type */
139 0, /* rightshift */
140 2, /* size (0 = byte, 1 = short, 2 = long) */
141 32, /* bitsize */
142 FALSE, /* pc_relative */
143 0, /* bitpos */
144 complain_overflow_dont, /* complain_on_overflow */
145 _bfd_mips_elf_generic_reloc, /* special_function */
146 "R_MIPS_32", /* name */
147 TRUE, /* partial_inplace */
148 0xffffffff, /* src_mask */
149 0xffffffff, /* dst_mask */
150 FALSE), /* pcrel_offset */
151
152 /* 32 bit symbol relative relocation. */
153 HOWTO (R_MIPS_REL32, /* type */
154 0, /* rightshift */
155 2, /* size (0 = byte, 1 = short, 2 = long) */
156 32, /* bitsize */
157 FALSE, /* pc_relative */
158 0, /* bitpos */
159 complain_overflow_dont, /* complain_on_overflow */
160 _bfd_mips_elf_generic_reloc, /* special_function */
161 "R_MIPS_REL32", /* name */
162 TRUE, /* partial_inplace */
163 0xffffffff, /* src_mask */
164 0xffffffff, /* dst_mask */
165 FALSE), /* pcrel_offset */
166
167 /* 26 bit jump address. */
168 HOWTO (R_MIPS_26, /* type */
169 2, /* rightshift */
170 2, /* size (0 = byte, 1 = short, 2 = long) */
171 26, /* bitsize */
172 FALSE, /* pc_relative */
173 0, /* bitpos */
174 complain_overflow_dont, /* complain_on_overflow */
175 /* This needs complex overflow
176 detection, because the upper four
177 bits must match the PC + 4. */
178 _bfd_mips_elf_generic_reloc, /* special_function */
179 "R_MIPS_26", /* name */
180 TRUE, /* partial_inplace */
181 0x03ffffff, /* src_mask */
182 0x03ffffff, /* dst_mask */
183 FALSE), /* pcrel_offset */
184
185 /* R_MIPS_HI16 and R_MIPS_LO16 are unsupported for NewABI REL.
186 However, the native IRIX6 tools use them, so we try our best. */
187
188 /* High 16 bits of symbol value. */
189 HOWTO (R_MIPS_HI16, /* type */
190 16, /* rightshift */
191 2, /* size (0 = byte, 1 = short, 2 = long) */
192 16, /* bitsize */
193 FALSE, /* pc_relative */
194 0, /* bitpos */
195 complain_overflow_dont, /* complain_on_overflow */
196 _bfd_mips_elf_hi16_reloc, /* special_function */
197 "R_MIPS_HI16", /* name */
198 TRUE, /* partial_inplace */
199 0x0000ffff, /* src_mask */
200 0x0000ffff, /* dst_mask */
201 FALSE), /* pcrel_offset */
202
203 /* Low 16 bits of symbol value. */
204 HOWTO (R_MIPS_LO16, /* type */
205 0, /* rightshift */
206 2, /* size (0 = byte, 1 = short, 2 = long) */
207 16, /* bitsize */
208 FALSE, /* pc_relative */
209 0, /* bitpos */
210 complain_overflow_dont, /* complain_on_overflow */
211 _bfd_mips_elf_lo16_reloc, /* special_function */
212 "R_MIPS_LO16", /* name */
213 TRUE, /* partial_inplace */
214 0x0000ffff, /* src_mask */
215 0x0000ffff, /* dst_mask */
216 FALSE), /* pcrel_offset */
217
218 /* GP relative reference. */
219 HOWTO (R_MIPS_GPREL16, /* type */
220 0, /* rightshift */
221 2, /* size (0 = byte, 1 = short, 2 = long) */
222 16, /* bitsize */
223 FALSE, /* pc_relative */
224 0, /* bitpos */
225 complain_overflow_signed, /* complain_on_overflow */
226 mips_elf_gprel16_reloc, /* special_function */
227 "R_MIPS_GPREL16", /* name */
228 TRUE, /* partial_inplace */
229 0x0000ffff, /* src_mask */
230 0x0000ffff, /* dst_mask */
231 FALSE), /* pcrel_offset */
232
233 /* Reference to literal section. */
234 HOWTO (R_MIPS_LITERAL, /* type */
235 0, /* rightshift */
236 2, /* size (0 = byte, 1 = short, 2 = long) */
237 16, /* bitsize */
238 FALSE, /* pc_relative */
239 0, /* bitpos */
240 complain_overflow_signed, /* complain_on_overflow */
241 mips_elf_literal_reloc, /* special_function */
242 "R_MIPS_LITERAL", /* name */
243 TRUE, /* partial_inplace */
244 0x0000ffff, /* src_mask */
245 0x0000ffff, /* dst_mask */
246 FALSE), /* pcrel_offset */
247
248 /* Reference to global offset table. */
249 HOWTO (R_MIPS_GOT16, /* type */
250 0, /* rightshift */
251 2, /* size (0 = byte, 1 = short, 2 = long) */
252 16, /* bitsize */
253 FALSE, /* pc_relative */
254 0, /* bitpos */
255 complain_overflow_signed, /* complain_on_overflow */
256 _bfd_mips_elf_got16_reloc, /* special_function */
257 "R_MIPS_GOT16", /* name */
258 TRUE, /* partial_inplace */
259 0x0000ffff, /* src_mask */
260 0x0000ffff, /* dst_mask */
261 FALSE), /* pcrel_offset */
262
263 /* 16 bit PC relative reference. Note that the ABI document has a typo
264 and claims R_MIPS_PC16 to be not rightshifted, rendering it useless.
265 We do the right thing here. */
266 HOWTO (R_MIPS_PC16, /* type */
267 2, /* rightshift */
268 2, /* size (0 = byte, 1 = short, 2 = long) */
269 16, /* bitsize */
270 TRUE, /* pc_relative */
271 0, /* bitpos */
272 complain_overflow_signed, /* complain_on_overflow */
273 _bfd_mips_elf_generic_reloc, /* special_function */
274 "R_MIPS_PC16", /* name */
275 TRUE, /* partial_inplace */
276 0x0000ffff, /* src_mask */
277 0x0000ffff, /* dst_mask */
278 TRUE), /* pcrel_offset */
279
280 /* 16 bit call through global offset table. */
281 HOWTO (R_MIPS_CALL16, /* type */
282 0, /* rightshift */
283 2, /* size (0 = byte, 1 = short, 2 = long) */
284 16, /* bitsize */
285 FALSE, /* pc_relative */
286 0, /* bitpos */
287 complain_overflow_signed, /* complain_on_overflow */
288 _bfd_mips_elf_generic_reloc, /* special_function */
289 "R_MIPS_CALL16", /* name */
290 TRUE, /* partial_inplace */
291 0x0000ffff, /* src_mask */
292 0x0000ffff, /* dst_mask */
293 FALSE), /* pcrel_offset */
294
295 /* 32 bit GP relative reference. */
296 HOWTO (R_MIPS_GPREL32, /* type */
297 0, /* rightshift */
298 2, /* size (0 = byte, 1 = short, 2 = long) */
299 32, /* bitsize */
300 FALSE, /* pc_relative */
301 0, /* bitpos */
302 complain_overflow_dont, /* complain_on_overflow */
303 mips_elf_gprel32_reloc, /* special_function */
304 "R_MIPS_GPREL32", /* name */
305 TRUE, /* partial_inplace */
306 0xffffffff, /* src_mask */
307 0xffffffff, /* dst_mask */
308 FALSE), /* pcrel_offset */
309
310 /* The remaining relocs are defined on Irix 5, although they are
311 not defined by the ABI. */
312 EMPTY_HOWTO (13),
313 EMPTY_HOWTO (14),
314 EMPTY_HOWTO (15),
315
316 /* A 5 bit shift field. */
317 HOWTO (R_MIPS_SHIFT5, /* type */
318 0, /* rightshift */
319 2, /* size (0 = byte, 1 = short, 2 = long) */
320 5, /* bitsize */
321 FALSE, /* pc_relative */
322 6, /* bitpos */
323 complain_overflow_bitfield, /* complain_on_overflow */
324 _bfd_mips_elf_generic_reloc, /* special_function */
325 "R_MIPS_SHIFT5", /* name */
326 TRUE, /* partial_inplace */
327 0x000007c0, /* src_mask */
328 0x000007c0, /* dst_mask */
329 FALSE), /* pcrel_offset */
330
331 /* A 6 bit shift field. */
332 HOWTO (R_MIPS_SHIFT6, /* type */
333 0, /* rightshift */
334 2, /* size (0 = byte, 1 = short, 2 = long) */
335 6, /* bitsize */
336 FALSE, /* pc_relative */
337 6, /* bitpos */
338 complain_overflow_bitfield, /* complain_on_overflow */
339 mips_elf_shift6_reloc, /* special_function */
340 "R_MIPS_SHIFT6", /* name */
341 TRUE, /* partial_inplace */
342 0x000007c4, /* src_mask */
343 0x000007c4, /* dst_mask */
344 FALSE), /* pcrel_offset */
345
346 /* A 64 bit relocation. */
347 HOWTO (R_MIPS_64, /* type */
348 0, /* rightshift */
349 4, /* size (0 = byte, 1 = short, 2 = long) */
350 64, /* bitsize */
351 FALSE, /* pc_relative */
352 0, /* bitpos */
353 complain_overflow_dont, /* complain_on_overflow */
354 _bfd_mips_elf_generic_reloc, /* special_function */
355 "R_MIPS_64", /* name */
356 TRUE, /* partial_inplace */
357 MINUS_ONE, /* src_mask */
358 MINUS_ONE, /* dst_mask */
359 FALSE), /* pcrel_offset */
360
361 /* Displacement in the global offset table. */
362 HOWTO (R_MIPS_GOT_DISP, /* type */
363 0, /* rightshift */
364 2, /* size (0 = byte, 1 = short, 2 = long) */
365 16, /* bitsize */
366 FALSE, /* pc_relative */
367 0, /* bitpos */
368 complain_overflow_signed, /* complain_on_overflow */
369 _bfd_mips_elf_generic_reloc, /* special_function */
370 "R_MIPS_GOT_DISP", /* name */
371 TRUE, /* partial_inplace */
372 0x0000ffff, /* src_mask */
373 0x0000ffff, /* dst_mask */
374 FALSE), /* pcrel_offset */
375
376 /* Displacement to page pointer in the global offset table. */
377 HOWTO (R_MIPS_GOT_PAGE, /* type */
378 0, /* rightshift */
379 2, /* size (0 = byte, 1 = short, 2 = long) */
380 16, /* bitsize */
381 FALSE, /* pc_relative */
382 0, /* bitpos */
383 complain_overflow_signed, /* complain_on_overflow */
384 _bfd_mips_elf_generic_reloc, /* special_function */
385 "R_MIPS_GOT_PAGE", /* name */
386 TRUE, /* partial_inplace */
387 0x0000ffff, /* src_mask */
388 0x0000ffff, /* dst_mask */
389 FALSE), /* pcrel_offset */
390
391 /* Offset from page pointer in the global offset table. */
392 HOWTO (R_MIPS_GOT_OFST, /* type */
393 0, /* rightshift */
394 2, /* size (0 = byte, 1 = short, 2 = long) */
395 16, /* bitsize */
396 FALSE, /* pc_relative */
397 0, /* bitpos */
398 complain_overflow_signed, /* complain_on_overflow */
399 _bfd_mips_elf_generic_reloc, /* special_function */
400 "R_MIPS_GOT_OFST", /* name */
401 TRUE, /* partial_inplace */
402 0x0000ffff, /* src_mask */
403 0x0000ffff, /* dst_mask */
404 FALSE), /* pcrel_offset */
405
406 /* High 16 bits of displacement in global offset table. */
407 HOWTO (R_MIPS_GOT_HI16, /* type */
408 0, /* rightshift */
409 2, /* size (0 = byte, 1 = short, 2 = long) */
410 16, /* bitsize */
411 FALSE, /* pc_relative */
412 0, /* bitpos */
413 complain_overflow_dont, /* complain_on_overflow */
414 _bfd_mips_elf_generic_reloc, /* special_function */
415 "R_MIPS_GOT_HI16", /* name */
416 TRUE, /* partial_inplace */
417 0x0000ffff, /* src_mask */
418 0x0000ffff, /* dst_mask */
419 FALSE), /* pcrel_offset */
420
421 /* Low 16 bits of displacement in global offset table. */
422 HOWTO (R_MIPS_GOT_LO16, /* type */
423 0, /* rightshift */
424 2, /* size (0 = byte, 1 = short, 2 = long) */
425 16, /* bitsize */
426 FALSE, /* pc_relative */
427 0, /* bitpos */
428 complain_overflow_dont, /* complain_on_overflow */
429 _bfd_mips_elf_generic_reloc, /* special_function */
430 "R_MIPS_GOT_LO16", /* name */
431 TRUE, /* partial_inplace */
432 0x0000ffff, /* src_mask */
433 0x0000ffff, /* dst_mask */
434 FALSE), /* pcrel_offset */
435
436 /* 64 bit subtraction. */
437 HOWTO (R_MIPS_SUB, /* type */
438 0, /* rightshift */
439 4, /* size (0 = byte, 1 = short, 2 = long) */
440 64, /* bitsize */
441 FALSE, /* pc_relative */
442 0, /* bitpos */
443 complain_overflow_dont, /* complain_on_overflow */
444 _bfd_mips_elf_generic_reloc, /* special_function */
445 "R_MIPS_SUB", /* name */
446 TRUE, /* partial_inplace */
447 MINUS_ONE, /* src_mask */
448 MINUS_ONE, /* dst_mask */
449 FALSE), /* pcrel_offset */
450
451 /* Insert the addend as an instruction. */
452 /* FIXME: Not handled correctly. */
453 HOWTO (R_MIPS_INSERT_A, /* type */
454 0, /* rightshift */
455 2, /* size (0 = byte, 1 = short, 2 = long) */
456 32, /* bitsize */
457 FALSE, /* pc_relative */
458 0, /* bitpos */
459 complain_overflow_dont, /* complain_on_overflow */
460 _bfd_mips_elf_generic_reloc, /* special_function */
461 "R_MIPS_INSERT_A", /* name */
462 TRUE, /* partial_inplace */
463 0xffffffff, /* src_mask */
464 0xffffffff, /* dst_mask */
465 FALSE), /* pcrel_offset */
466
467 /* Insert the addend as an instruction, and change all relocations
468 to refer to the old instruction at the address. */
469 /* FIXME: Not handled correctly. */
470 HOWTO (R_MIPS_INSERT_B, /* type */
471 0, /* rightshift */
472 2, /* size (0 = byte, 1 = short, 2 = long) */
473 32, /* bitsize */
474 FALSE, /* pc_relative */
475 0, /* bitpos */
476 complain_overflow_dont, /* complain_on_overflow */
477 _bfd_mips_elf_generic_reloc, /* special_function */
478 "R_MIPS_INSERT_B", /* name */
479 TRUE, /* partial_inplace */
480 0xffffffff, /* src_mask */
481 0xffffffff, /* dst_mask */
482 FALSE), /* pcrel_offset */
483
484 /* Delete a 32 bit instruction. */
485 /* FIXME: Not handled correctly. */
486 HOWTO (R_MIPS_DELETE, /* type */
487 0, /* rightshift */
488 2, /* size (0 = byte, 1 = short, 2 = long) */
489 32, /* bitsize */
490 FALSE, /* pc_relative */
491 0, /* bitpos */
492 complain_overflow_dont, /* complain_on_overflow */
493 _bfd_mips_elf_generic_reloc, /* special_function */
494 "R_MIPS_DELETE", /* name */
495 TRUE, /* partial_inplace */
496 0xffffffff, /* src_mask */
497 0xffffffff, /* dst_mask */
498 FALSE), /* pcrel_offset */
499
500 /* The MIPS ELF64 ABI Draft wants us to support these for REL relocations.
501 We don't, because
502 a) It means building the addend from a R_MIPS_HIGHEST/R_MIPS_HIGHER/
503 R_MIPS_HI16/R_MIPS_LO16 sequence with varying ordering, using
504 fallable heuristics.
505 b) No other NewABI toolchain actually emits such relocations. */
506 EMPTY_HOWTO (R_MIPS_HIGHER),
507 EMPTY_HOWTO (R_MIPS_HIGHEST),
508
509 /* High 16 bits of displacement in global offset table. */
510 HOWTO (R_MIPS_CALL_HI16, /* type */
511 0, /* rightshift */
512 2, /* size (0 = byte, 1 = short, 2 = long) */
513 16, /* bitsize */
514 FALSE, /* pc_relative */
515 0, /* bitpos */
516 complain_overflow_dont, /* complain_on_overflow */
517 _bfd_mips_elf_generic_reloc, /* special_function */
518 "R_MIPS_CALL_HI16", /* name */
519 TRUE, /* partial_inplace */
520 0x0000ffff, /* src_mask */
521 0x0000ffff, /* dst_mask */
522 FALSE), /* pcrel_offset */
523
524 /* Low 16 bits of displacement in global offset table. */
525 HOWTO (R_MIPS_CALL_LO16, /* type */
526 0, /* rightshift */
527 2, /* size (0 = byte, 1 = short, 2 = long) */
528 16, /* bitsize */
529 FALSE, /* pc_relative */
530 0, /* bitpos */
531 complain_overflow_dont, /* complain_on_overflow */
532 _bfd_mips_elf_generic_reloc, /* special_function */
533 "R_MIPS_CALL_LO16", /* name */
534 TRUE, /* partial_inplace */
535 0x0000ffff, /* src_mask */
536 0x0000ffff, /* dst_mask */
537 FALSE), /* pcrel_offset */
538
539 /* Section displacement. */
540 HOWTO (R_MIPS_SCN_DISP, /* type */
541 0, /* rightshift */
542 2, /* size (0 = byte, 1 = short, 2 = long) */
543 32, /* bitsize */
544 FALSE, /* pc_relative */
545 0, /* bitpos */
546 complain_overflow_dont, /* complain_on_overflow */
547 _bfd_mips_elf_generic_reloc, /* special_function */
548 "R_MIPS_SCN_DISP", /* name */
549 TRUE, /* partial_inplace */
550 0xffffffff, /* src_mask */
551 0xffffffff, /* dst_mask */
552 FALSE), /* pcrel_offset */
553
554 HOWTO (R_MIPS_REL16, /* type */
555 0, /* rightshift */
556 1, /* size (0 = byte, 1 = short, 2 = long) */
557 16, /* bitsize */
558 FALSE, /* pc_relative */
559 0, /* bitpos */
560 complain_overflow_signed, /* complain_on_overflow */
561 _bfd_mips_elf_generic_reloc, /* special_function */
562 "R_MIPS_REL16", /* name */
563 TRUE, /* partial_inplace */
564 0xffff, /* src_mask */
565 0xffff, /* dst_mask */
566 FALSE), /* pcrel_offset */
567
568 /* These two are obsolete. */
569 EMPTY_HOWTO (R_MIPS_ADD_IMMEDIATE),
570 EMPTY_HOWTO (R_MIPS_PJUMP),
571
572 /* Similiar to R_MIPS_REL32, but used for relocations in a GOT section.
573 It must be used for multigot GOT's (and only there). */
574 HOWTO (R_MIPS_RELGOT, /* type */
575 0, /* rightshift */
576 2, /* size (0 = byte, 1 = short, 2 = long) */
577 32, /* bitsize */
578 FALSE, /* pc_relative */
579 0, /* bitpos */
580 complain_overflow_dont, /* complain_on_overflow */
581 _bfd_mips_elf_generic_reloc, /* special_function */
582 "R_MIPS_RELGOT", /* name */
583 TRUE, /* partial_inplace */
584 0xffffffff, /* src_mask */
585 0xffffffff, /* dst_mask */
586 FALSE), /* pcrel_offset */
587
588 /* Protected jump conversion. This is an optimization hint. No
589 relocation is required for correctness. */
590 HOWTO (R_MIPS_JALR, /* type */
591 0, /* rightshift */
592 2, /* size (0 = byte, 1 = short, 2 = long) */
593 32, /* bitsize */
594 FALSE, /* pc_relative */
595 0, /* bitpos */
596 complain_overflow_dont, /* complain_on_overflow */
597 _bfd_mips_elf_generic_reloc, /* special_function */
598 "R_MIPS_JALR", /* name */
599 FALSE, /* partial_inplace */
600 0x00000000, /* src_mask */
601 0x00000000, /* dst_mask */
602 FALSE), /* pcrel_offset */
603
604 /* TLS GD/LD dynamic relocations. */
605 HOWTO (R_MIPS_TLS_DTPMOD32, /* type */
606 0, /* rightshift */
607 2, /* size (0 = byte, 1 = short, 2 = long) */
608 32, /* bitsize */
609 FALSE, /* pc_relative */
610 0, /* bitpos */
611 complain_overflow_dont, /* complain_on_overflow */
612 _bfd_mips_elf_generic_reloc, /* special_function */
613 "R_MIPS_TLS_DTPMOD32", /* name */
614 TRUE, /* partial_inplace */
615 0xffffffff, /* src_mask */
616 0xffffffff, /* dst_mask */
617 FALSE), /* pcrel_offset */
618
619 HOWTO (R_MIPS_TLS_DTPREL32, /* type */
620 0, /* rightshift */
621 2, /* size (0 = byte, 1 = short, 2 = long) */
622 32, /* bitsize */
623 FALSE, /* pc_relative */
624 0, /* bitpos */
625 complain_overflow_dont, /* complain_on_overflow */
626 _bfd_mips_elf_generic_reloc, /* special_function */
627 "R_MIPS_TLS_DTPREL32", /* name */
628 TRUE, /* partial_inplace */
629 0xffffffff, /* src_mask */
630 0xffffffff, /* dst_mask */
631 FALSE), /* pcrel_offset */
632
633 EMPTY_HOWTO (R_MIPS_TLS_DTPMOD64),
634 EMPTY_HOWTO (R_MIPS_TLS_DTPREL64),
635
636 /* TLS general dynamic variable reference. */
637 HOWTO (R_MIPS_TLS_GD, /* type */
638 0, /* rightshift */
639 2, /* size (0 = byte, 1 = short, 2 = long) */
640 16, /* bitsize */
641 FALSE, /* pc_relative */
642 0, /* bitpos */
643 complain_overflow_signed, /* complain_on_overflow */
644 _bfd_mips_elf_generic_reloc, /* special_function */
645 "R_MIPS_TLS_GD", /* name */
646 TRUE, /* partial_inplace */
647 0x0000ffff, /* src_mask */
648 0x0000ffff, /* dst_mask */
649 FALSE), /* pcrel_offset */
650
651 /* TLS local dynamic variable reference. */
652 HOWTO (R_MIPS_TLS_LDM, /* type */
653 0, /* rightshift */
654 2, /* size (0 = byte, 1 = short, 2 = long) */
655 16, /* bitsize */
656 FALSE, /* pc_relative */
657 0, /* bitpos */
658 complain_overflow_signed, /* complain_on_overflow */
659 _bfd_mips_elf_generic_reloc, /* special_function */
660 "R_MIPS_TLS_LDM", /* name */
661 TRUE, /* partial_inplace */
662 0x0000ffff, /* src_mask */
663 0x0000ffff, /* dst_mask */
664 FALSE), /* pcrel_offset */
665
666 /* TLS local dynamic offset. */
667 HOWTO (R_MIPS_TLS_DTPREL_HI16, /* type */
668 0, /* rightshift */
669 2, /* size (0 = byte, 1 = short, 2 = long) */
670 16, /* bitsize */
671 FALSE, /* pc_relative */
672 0, /* bitpos */
673 complain_overflow_signed, /* complain_on_overflow */
674 _bfd_mips_elf_generic_reloc, /* special_function */
675 "R_MIPS_TLS_DTPREL_HI16", /* name */
676 TRUE, /* partial_inplace */
677 0x0000ffff, /* src_mask */
678 0x0000ffff, /* dst_mask */
679 FALSE), /* pcrel_offset */
680
681 /* TLS local dynamic offset. */
682 HOWTO (R_MIPS_TLS_DTPREL_LO16, /* type */
683 0, /* rightshift */
684 2, /* size (0 = byte, 1 = short, 2 = long) */
685 16, /* bitsize */
686 FALSE, /* pc_relative */
687 0, /* bitpos */
688 complain_overflow_signed, /* complain_on_overflow */
689 _bfd_mips_elf_generic_reloc, /* special_function */
690 "R_MIPS_TLS_DTPREL_LO16", /* name */
691 TRUE, /* partial_inplace */
692 0x0000ffff, /* src_mask */
693 0x0000ffff, /* dst_mask */
694 FALSE), /* pcrel_offset */
695
696 /* TLS thread pointer offset. */
697 HOWTO (R_MIPS_TLS_GOTTPREL, /* type */
698 0, /* rightshift */
699 2, /* size (0 = byte, 1 = short, 2 = long) */
700 16, /* bitsize */
701 FALSE, /* pc_relative */
702 0, /* bitpos */
703 complain_overflow_signed, /* complain_on_overflow */
704 _bfd_mips_elf_generic_reloc, /* special_function */
705 "R_MIPS_TLS_GOTTPREL", /* name */
706 TRUE, /* partial_inplace */
707 0x0000ffff, /* src_mask */
708 0x0000ffff, /* dst_mask */
709 FALSE), /* pcrel_offset */
710
711 /* TLS IE dynamic relocations. */
712 HOWTO (R_MIPS_TLS_TPREL32, /* type */
713 0, /* rightshift */
714 2, /* size (0 = byte, 1 = short, 2 = long) */
715 32, /* bitsize */
716 FALSE, /* pc_relative */
717 0, /* bitpos */
718 complain_overflow_dont, /* complain_on_overflow */
719 _bfd_mips_elf_generic_reloc, /* special_function */
720 "R_MIPS_TLS_TPREL32", /* name */
721 TRUE, /* partial_inplace */
722 0xffffffff, /* src_mask */
723 0xffffffff, /* dst_mask */
724 FALSE), /* pcrel_offset */
725
726 EMPTY_HOWTO (R_MIPS_TLS_TPREL64),
727
728 /* TLS thread pointer offset. */
729 HOWTO (R_MIPS_TLS_TPREL_HI16, /* type */
730 0, /* rightshift */
731 2, /* size (0 = byte, 1 = short, 2 = long) */
732 16, /* bitsize */
733 FALSE, /* pc_relative */
734 0, /* bitpos */
735 complain_overflow_signed, /* complain_on_overflow */
736 _bfd_mips_elf_generic_reloc, /* special_function */
737 "R_MIPS_TLS_TPREL_HI16", /* name */
738 TRUE, /* partial_inplace */
739 0x0000ffff, /* src_mask */
740 0x0000ffff, /* dst_mask */
741 FALSE), /* pcrel_offset */
742
743 /* TLS thread pointer offset. */
744 HOWTO (R_MIPS_TLS_TPREL_LO16, /* type */
745 0, /* rightshift */
746 2, /* size (0 = byte, 1 = short, 2 = long) */
747 16, /* bitsize */
748 FALSE, /* pc_relative */
749 0, /* bitpos */
750 complain_overflow_signed, /* complain_on_overflow */
751 _bfd_mips_elf_generic_reloc, /* special_function */
752 "R_MIPS_TLS_TPREL_LO16", /* name */
753 TRUE, /* partial_inplace */
754 0x0000ffff, /* src_mask */
755 0x0000ffff, /* dst_mask */
756 FALSE), /* pcrel_offset */
757 };
758
759 /* The relocation table used for SHT_RELA sections. */
760
761 static reloc_howto_type elf_mips_howto_table_rela[] =
762 {
763 /* No relocation. */
764 HOWTO (R_MIPS_NONE, /* type */
765 0, /* rightshift */
766 0, /* size (0 = byte, 1 = short, 2 = long) */
767 0, /* bitsize */
768 FALSE, /* pc_relative */
769 0, /* bitpos */
770 complain_overflow_dont, /* complain_on_overflow */
771 _bfd_mips_elf_generic_reloc, /* special_function */
772 "R_MIPS_NONE", /* name */
773 FALSE, /* partial_inplace */
774 0, /* src_mask */
775 0, /* dst_mask */
776 FALSE), /* pcrel_offset */
777
778 /* 16 bit relocation. */
779 HOWTO (R_MIPS_16, /* type */
780 0, /* rightshift */
781 2, /* size (0 = byte, 1 = short, 2 = long) */
782 16, /* bitsize */
783 FALSE, /* pc_relative */
784 0, /* bitpos */
785 complain_overflow_signed, /* complain_on_overflow */
786 _bfd_mips_elf_generic_reloc, /* special_function */
787 "R_MIPS_16", /* name */
788 FALSE, /* partial_inplace */
789 0, /* src_mask */
790 0x0000, /* dst_mask */
791 FALSE), /* pcrel_offset */
792
793 /* 32 bit relocation. */
794 HOWTO (R_MIPS_32, /* type */
795 0, /* rightshift */
796 2, /* size (0 = byte, 1 = short, 2 = long) */
797 32, /* bitsize */
798 FALSE, /* pc_relative */
799 0, /* bitpos */
800 complain_overflow_dont, /* complain_on_overflow */
801 _bfd_mips_elf_generic_reloc, /* special_function */
802 "R_MIPS_32", /* name */
803 FALSE, /* partial_inplace */
804 0, /* src_mask */
805 0xffffffff, /* dst_mask */
806 FALSE), /* pcrel_offset */
807
808 /* 32 bit symbol relative relocation. */
809 HOWTO (R_MIPS_REL32, /* type */
810 0, /* rightshift */
811 2, /* size (0 = byte, 1 = short, 2 = long) */
812 32, /* bitsize */
813 FALSE, /* pc_relative */
814 0, /* bitpos */
815 complain_overflow_dont, /* complain_on_overflow */
816 _bfd_mips_elf_generic_reloc, /* special_function */
817 "R_MIPS_REL32", /* name */
818 FALSE, /* partial_inplace */
819 0, /* src_mask */
820 0xffffffff, /* dst_mask */
821 FALSE), /* pcrel_offset */
822
823 /* 26 bit jump address. */
824 HOWTO (R_MIPS_26, /* type */
825 2, /* rightshift */
826 2, /* size (0 = byte, 1 = short, 2 = long) */
827 26, /* bitsize */
828 FALSE, /* pc_relative */
829 0, /* bitpos */
830 complain_overflow_dont, /* complain_on_overflow */
831 /* This needs complex overflow
832 detection, because the upper 36
833 bits must match the PC + 4. */
834 _bfd_mips_elf_generic_reloc, /* special_function */
835 "R_MIPS_26", /* name */
836 FALSE, /* partial_inplace */
837 0, /* src_mask */
838 0x03ffffff, /* dst_mask */
839 FALSE), /* pcrel_offset */
840
841 /* High 16 bits of symbol value. */
842 HOWTO (R_MIPS_HI16, /* type */
843 0, /* rightshift */
844 2, /* size (0 = byte, 1 = short, 2 = long) */
845 16, /* bitsize */
846 FALSE, /* pc_relative */
847 0, /* bitpos */
848 complain_overflow_dont, /* complain_on_overflow */
849 _bfd_mips_elf_generic_reloc, /* special_function */
850 "R_MIPS_HI16", /* name */
851 FALSE, /* partial_inplace */
852 0, /* src_mask */
853 0x0000ffff, /* dst_mask */
854 FALSE), /* pcrel_offset */
855
856 /* Low 16 bits of symbol value. */
857 HOWTO (R_MIPS_LO16, /* type */
858 0, /* rightshift */
859 2, /* size (0 = byte, 1 = short, 2 = long) */
860 16, /* bitsize */
861 FALSE, /* pc_relative */
862 0, /* bitpos */
863 complain_overflow_dont, /* complain_on_overflow */
864 _bfd_mips_elf_generic_reloc, /* special_function */
865 "R_MIPS_LO16", /* name */
866 FALSE, /* partial_inplace */
867 0, /* src_mask */
868 0x0000ffff, /* dst_mask */
869 FALSE), /* pcrel_offset */
870
871 /* GP relative reference. */
872 HOWTO (R_MIPS_GPREL16, /* type */
873 0, /* rightshift */
874 2, /* size (0 = byte, 1 = short, 2 = long) */
875 16, /* bitsize */
876 FALSE, /* pc_relative */
877 0, /* bitpos */
878 complain_overflow_signed, /* complain_on_overflow */
879 mips_elf_gprel16_reloc, /* special_function */
880 "R_MIPS_GPREL16", /* name */
881 FALSE, /* partial_inplace */
882 0, /* src_mask */
883 0x0000ffff, /* dst_mask */
884 FALSE), /* pcrel_offset */
885
886 /* Reference to literal section. */
887 HOWTO (R_MIPS_LITERAL, /* type */
888 0, /* rightshift */
889 2, /* size (0 = byte, 1 = short, 2 = long) */
890 16, /* bitsize */
891 FALSE, /* pc_relative */
892 0, /* bitpos */
893 complain_overflow_signed, /* complain_on_overflow */
894 mips_elf_literal_reloc, /* special_function */
895 "R_MIPS_LITERAL", /* name */
896 FALSE, /* partial_inplace */
897 0, /* src_mask */
898 0x0000ffff, /* dst_mask */
899 FALSE), /* pcrel_offset */
900
901 /* Reference to global offset table. */
902 HOWTO (R_MIPS_GOT16, /* type */
903 0, /* rightshift */
904 2, /* size (0 = byte, 1 = short, 2 = long) */
905 16, /* bitsize */
906 FALSE, /* pc_relative */
907 0, /* bitpos */
908 complain_overflow_signed, /* complain_on_overflow */
909 _bfd_mips_elf_generic_reloc, /* special_function */
910 "R_MIPS_GOT16", /* name */
911 FALSE, /* partial_inplace */
912 0, /* src_mask */
913 0x0000ffff, /* dst_mask */
914 FALSE), /* pcrel_offset */
915
916 /* 16 bit PC relative reference. Note that the ABI document has a typo
917 and claims R_MIPS_PC16 to be not rightshifted, rendering it useless.
918 We do the right thing here. */
919 HOWTO (R_MIPS_PC16, /* type */
920 2, /* rightshift */
921 2, /* size (0 = byte, 1 = short, 2 = long) */
922 16, /* bitsize */
923 TRUE, /* pc_relative */
924 0, /* bitpos */
925 complain_overflow_signed, /* complain_on_overflow */
926 _bfd_mips_elf_generic_reloc, /* special_function */
927 "R_MIPS_PC16", /* name */
928 FALSE, /* partial_inplace */
929 0, /* src_mask */
930 0x0000ffff, /* dst_mask */
931 TRUE), /* pcrel_offset */
932
933 /* 16 bit call through global offset table. */
934 HOWTO (R_MIPS_CALL16, /* type */
935 0, /* rightshift */
936 2, /* size (0 = byte, 1 = short, 2 = long) */
937 16, /* bitsize */
938 FALSE, /* pc_relative */
939 0, /* bitpos */
940 complain_overflow_signed, /* complain_on_overflow */
941 _bfd_mips_elf_generic_reloc, /* special_function */
942 "R_MIPS_CALL16", /* name */
943 FALSE, /* partial_inplace */
944 0, /* src_mask */
945 0x0000ffff, /* dst_mask */
946 FALSE), /* pcrel_offset */
947
948 /* 32 bit GP relative reference. */
949 HOWTO (R_MIPS_GPREL32, /* type */
950 0, /* rightshift */
951 2, /* size (0 = byte, 1 = short, 2 = long) */
952 32, /* bitsize */
953 FALSE, /* pc_relative */
954 0, /* bitpos */
955 complain_overflow_dont, /* complain_on_overflow */
956 mips_elf_gprel32_reloc, /* special_function */
957 "R_MIPS_GPREL32", /* name */
958 FALSE, /* partial_inplace */
959 0, /* src_mask */
960 0xffffffff, /* dst_mask */
961 FALSE), /* pcrel_offset */
962
963 EMPTY_HOWTO (13),
964 EMPTY_HOWTO (14),
965 EMPTY_HOWTO (15),
966
967 /* A 5 bit shift field. */
968 HOWTO (R_MIPS_SHIFT5, /* type */
969 0, /* rightshift */
970 2, /* size (0 = byte, 1 = short, 2 = long) */
971 5, /* bitsize */
972 FALSE, /* pc_relative */
973 6, /* bitpos */
974 complain_overflow_bitfield, /* complain_on_overflow */
975 _bfd_mips_elf_generic_reloc, /* special_function */
976 "R_MIPS_SHIFT5", /* name */
977 FALSE, /* partial_inplace */
978 0, /* src_mask */
979 0x000007c0, /* dst_mask */
980 FALSE), /* pcrel_offset */
981
982 /* A 6 bit shift field. */
983 HOWTO (R_MIPS_SHIFT6, /* type */
984 0, /* rightshift */
985 2, /* size (0 = byte, 1 = short, 2 = long) */
986 6, /* bitsize */
987 FALSE, /* pc_relative */
988 6, /* bitpos */
989 complain_overflow_bitfield, /* complain_on_overflow */
990 mips_elf_shift6_reloc, /* special_function */
991 "R_MIPS_SHIFT6", /* name */
992 FALSE, /* partial_inplace */
993 0, /* src_mask */
994 0x000007c4, /* dst_mask */
995 FALSE), /* pcrel_offset */
996
997 /* 64 bit relocation. */
998 HOWTO (R_MIPS_64, /* type */
999 0, /* rightshift */
1000 4, /* size (0 = byte, 1 = short, 2 = long) */
1001 64, /* bitsize */
1002 FALSE, /* pc_relative */
1003 0, /* bitpos */
1004 complain_overflow_dont, /* complain_on_overflow */
1005 _bfd_mips_elf_generic_reloc, /* special_function */
1006 "R_MIPS_64", /* name */
1007 FALSE, /* partial_inplace */
1008 0, /* src_mask */
1009 MINUS_ONE, /* dst_mask */
1010 FALSE), /* pcrel_offset */
1011
1012 /* Displacement in the global offset table. */
1013 HOWTO (R_MIPS_GOT_DISP, /* type */
1014 0, /* rightshift */
1015 2, /* size (0 = byte, 1 = short, 2 = long) */
1016 16, /* bitsize */
1017 FALSE, /* pc_relative */
1018 0, /* bitpos */
1019 complain_overflow_signed, /* complain_on_overflow */
1020 _bfd_mips_elf_generic_reloc, /* special_function */
1021 "R_MIPS_GOT_DISP", /* name */
1022 FALSE, /* partial_inplace */
1023 0, /* src_mask */
1024 0x0000ffff, /* dst_mask */
1025 FALSE), /* pcrel_offset */
1026
1027 /* Displacement to page pointer in the global offset table. */
1028 HOWTO (R_MIPS_GOT_PAGE, /* type */
1029 0, /* rightshift */
1030 2, /* size (0 = byte, 1 = short, 2 = long) */
1031 16, /* bitsize */
1032 FALSE, /* pc_relative */
1033 0, /* bitpos */
1034 complain_overflow_signed, /* complain_on_overflow */
1035 _bfd_mips_elf_generic_reloc, /* special_function */
1036 "R_MIPS_GOT_PAGE", /* name */
1037 FALSE, /* partial_inplace */
1038 0, /* src_mask */
1039 0x0000ffff, /* dst_mask */
1040 FALSE), /* pcrel_offset */
1041
1042 /* Offset from page pointer in the global offset table. */
1043 HOWTO (R_MIPS_GOT_OFST, /* type */
1044 0, /* rightshift */
1045 2, /* size (0 = byte, 1 = short, 2 = long) */
1046 16, /* bitsize */
1047 FALSE, /* pc_relative */
1048 0, /* bitpos */
1049 complain_overflow_signed, /* complain_on_overflow */
1050 _bfd_mips_elf_generic_reloc, /* special_function */
1051 "R_MIPS_GOT_OFST", /* name */
1052 FALSE, /* partial_inplace */
1053 0, /* src_mask */
1054 0x0000ffff, /* dst_mask */
1055 FALSE), /* pcrel_offset */
1056
1057 /* High 16 bits of displacement in global offset table. */
1058 HOWTO (R_MIPS_GOT_HI16, /* type */
1059 0, /* rightshift */
1060 2, /* size (0 = byte, 1 = short, 2 = long) */
1061 16, /* bitsize */
1062 FALSE, /* pc_relative */
1063 0, /* bitpos */
1064 complain_overflow_dont, /* complain_on_overflow */
1065 _bfd_mips_elf_generic_reloc, /* special_function */
1066 "R_MIPS_GOT_HI16", /* name */
1067 FALSE, /* partial_inplace */
1068 0, /* src_mask */
1069 0x0000ffff, /* dst_mask */
1070 FALSE), /* pcrel_offset */
1071
1072 /* Low 16 bits of displacement in global offset table. */
1073 HOWTO (R_MIPS_GOT_LO16, /* type */
1074 0, /* rightshift */
1075 2, /* size (0 = byte, 1 = short, 2 = long) */
1076 16, /* bitsize */
1077 FALSE, /* pc_relative */
1078 0, /* bitpos */
1079 complain_overflow_dont, /* complain_on_overflow */
1080 _bfd_mips_elf_generic_reloc, /* special_function */
1081 "R_MIPS_GOT_LO16", /* name */
1082 FALSE, /* partial_inplace */
1083 0, /* src_mask */
1084 0x0000ffff, /* dst_mask */
1085 FALSE), /* pcrel_offset */
1086
1087 /* 64 bit subtraction. */
1088 HOWTO (R_MIPS_SUB, /* type */
1089 0, /* rightshift */
1090 4, /* size (0 = byte, 1 = short, 2 = long) */
1091 64, /* bitsize */
1092 FALSE, /* pc_relative */
1093 0, /* bitpos */
1094 complain_overflow_dont, /* complain_on_overflow */
1095 _bfd_mips_elf_generic_reloc, /* special_function */
1096 "R_MIPS_SUB", /* name */
1097 FALSE, /* partial_inplace */
1098 0, /* src_mask */
1099 MINUS_ONE, /* dst_mask */
1100 FALSE), /* pcrel_offset */
1101
1102 /* Insert the addend as an instruction. */
1103 /* FIXME: Not handled correctly. */
1104 HOWTO (R_MIPS_INSERT_A, /* type */
1105 0, /* rightshift */
1106 2, /* size (0 = byte, 1 = short, 2 = long) */
1107 32, /* bitsize */
1108 FALSE, /* pc_relative */
1109 0, /* bitpos */
1110 complain_overflow_dont, /* complain_on_overflow */
1111 _bfd_mips_elf_generic_reloc, /* special_function */
1112 "R_MIPS_INSERT_A", /* name */
1113 FALSE, /* partial_inplace */
1114 0, /* src_mask */
1115 0xffffffff, /* dst_mask */
1116 FALSE), /* pcrel_offset */
1117
1118 /* Insert the addend as an instruction, and change all relocations
1119 to refer to the old instruction at the address. */
1120 /* FIXME: Not handled correctly. */
1121 HOWTO (R_MIPS_INSERT_B, /* type */
1122 0, /* rightshift */
1123 2, /* size (0 = byte, 1 = short, 2 = long) */
1124 32, /* bitsize */
1125 FALSE, /* pc_relative */
1126 0, /* bitpos */
1127 complain_overflow_dont, /* complain_on_overflow */
1128 _bfd_mips_elf_generic_reloc, /* special_function */
1129 "R_MIPS_INSERT_B", /* name */
1130 FALSE, /* partial_inplace */
1131 0, /* src_mask */
1132 0xffffffff, /* dst_mask */
1133 FALSE), /* pcrel_offset */
1134
1135 /* Delete a 32 bit instruction. */
1136 /* FIXME: Not handled correctly. */
1137 HOWTO (R_MIPS_DELETE, /* type */
1138 0, /* rightshift */
1139 2, /* size (0 = byte, 1 = short, 2 = long) */
1140 32, /* bitsize */
1141 FALSE, /* pc_relative */
1142 0, /* bitpos */
1143 complain_overflow_dont, /* complain_on_overflow */
1144 _bfd_mips_elf_generic_reloc, /* special_function */
1145 "R_MIPS_DELETE", /* name */
1146 FALSE, /* partial_inplace */
1147 0, /* src_mask */
1148 0xffffffff, /* dst_mask */
1149 FALSE), /* pcrel_offset */
1150
1151 /* Get the higher value of a 64 bit addend. */
1152 HOWTO (R_MIPS_HIGHER, /* type */
1153 0, /* rightshift */
1154 2, /* size (0 = byte, 1 = short, 2 = long) */
1155 16, /* bitsize */
1156 FALSE, /* pc_relative */
1157 0, /* bitpos */
1158 complain_overflow_dont, /* complain_on_overflow */
1159 _bfd_mips_elf_generic_reloc, /* special_function */
1160 "R_MIPS_HIGHER", /* name */
1161 FALSE, /* partial_inplace */
1162 0, /* src_mask */
1163 0x0000ffff, /* dst_mask */
1164 FALSE), /* pcrel_offset */
1165
1166 /* Get the highest value of a 64 bit addend. */
1167 HOWTO (R_MIPS_HIGHEST, /* type */
1168 0, /* rightshift */
1169 2, /* size (0 = byte, 1 = short, 2 = long) */
1170 16, /* bitsize */
1171 FALSE, /* pc_relative */
1172 0, /* bitpos */
1173 complain_overflow_dont, /* complain_on_overflow */
1174 _bfd_mips_elf_generic_reloc, /* special_function */
1175 "R_MIPS_HIGHEST", /* name */
1176 FALSE, /* partial_inplace */
1177 0, /* src_mask */
1178 0x0000ffff, /* dst_mask */
1179 FALSE), /* pcrel_offset */
1180
1181 /* High 16 bits of displacement in global offset table. */
1182 HOWTO (R_MIPS_CALL_HI16, /* type */
1183 0, /* rightshift */
1184 2, /* size (0 = byte, 1 = short, 2 = long) */
1185 16, /* bitsize */
1186 FALSE, /* pc_relative */
1187 0, /* bitpos */
1188 complain_overflow_dont, /* complain_on_overflow */
1189 _bfd_mips_elf_generic_reloc, /* special_function */
1190 "R_MIPS_CALL_HI16", /* name */
1191 FALSE, /* partial_inplace */
1192 0, /* src_mask */
1193 0x0000ffff, /* dst_mask */
1194 FALSE), /* pcrel_offset */
1195
1196 /* Low 16 bits of displacement in global offset table. */
1197 HOWTO (R_MIPS_CALL_LO16, /* type */
1198 0, /* rightshift */
1199 2, /* size (0 = byte, 1 = short, 2 = long) */
1200 16, /* bitsize */
1201 FALSE, /* pc_relative */
1202 0, /* bitpos */
1203 complain_overflow_dont, /* complain_on_overflow */
1204 _bfd_mips_elf_generic_reloc, /* special_function */
1205 "R_MIPS_CALL_LO16", /* name */
1206 FALSE, /* partial_inplace */
1207 0, /* src_mask */
1208 0x0000ffff, /* dst_mask */
1209 FALSE), /* pcrel_offset */
1210
1211 /* Section displacement, used by an associated event location section. */
1212 HOWTO (R_MIPS_SCN_DISP, /* type */
1213 0, /* rightshift */
1214 2, /* size (0 = byte, 1 = short, 2 = long) */
1215 32, /* bitsize */
1216 FALSE, /* pc_relative */
1217 0, /* bitpos */
1218 complain_overflow_dont, /* complain_on_overflow */
1219 _bfd_mips_elf_generic_reloc, /* special_function */
1220 "R_MIPS_SCN_DISP", /* name */
1221 FALSE, /* partial_inplace */
1222 0, /* src_mask */
1223 0xffffffff, /* dst_mask */
1224 FALSE), /* pcrel_offset */
1225
1226 /* 16 bit relocation. */
1227 HOWTO (R_MIPS_REL16, /* type */
1228 0, /* rightshift */
1229 1, /* size (0 = byte, 1 = short, 2 = long) */
1230 16, /* bitsize */
1231 FALSE, /* pc_relative */
1232 0, /* bitpos */
1233 complain_overflow_signed, /* complain_on_overflow */
1234 _bfd_mips_elf_generic_reloc, /* special_function */
1235 "R_MIPS_REL16", /* name */
1236 FALSE, /* partial_inplace */
1237 0, /* src_mask */
1238 0xffff, /* dst_mask */
1239 FALSE), /* pcrel_offset */
1240
1241 /* These two are obsolete. */
1242 EMPTY_HOWTO (R_MIPS_ADD_IMMEDIATE),
1243 EMPTY_HOWTO (R_MIPS_PJUMP),
1244
1245 /* Similiar to R_MIPS_REL32, but used for relocations in a GOT section.
1246 It must be used for multigot GOT's (and only there). */
1247 HOWTO (R_MIPS_RELGOT, /* type */
1248 0, /* rightshift */
1249 2, /* size (0 = byte, 1 = short, 2 = long) */
1250 32, /* bitsize */
1251 FALSE, /* pc_relative */
1252 0, /* bitpos */
1253 complain_overflow_dont, /* complain_on_overflow */
1254 _bfd_mips_elf_generic_reloc, /* special_function */
1255 "R_MIPS_RELGOT", /* name */
1256 FALSE, /* partial_inplace */
1257 0, /* src_mask */
1258 0xffffffff, /* dst_mask */
1259 FALSE), /* pcrel_offset */
1260
1261 /* Protected jump conversion. This is an optimization hint. No
1262 relocation is required for correctness. */
1263 HOWTO (R_MIPS_JALR, /* type */
1264 0, /* rightshift */
1265 2, /* size (0 = byte, 1 = short, 2 = long) */
1266 32, /* bitsize */
1267 FALSE, /* pc_relative */
1268 0, /* bitpos */
1269 complain_overflow_dont, /* complain_on_overflow */
1270 _bfd_mips_elf_generic_reloc, /* special_function */
1271 "R_MIPS_JALR", /* name */
1272 FALSE, /* partial_inplace */
1273 0, /* src_mask */
1274 0, /* dst_mask */
1275 FALSE), /* pcrel_offset */
1276
1277 /* TLS GD/LD dynamic relocations. */
1278 HOWTO (R_MIPS_TLS_DTPMOD32, /* type */
1279 0, /* rightshift */
1280 2, /* size (0 = byte, 1 = short, 2 = long) */
1281 32, /* bitsize */
1282 FALSE, /* pc_relative */
1283 0, /* bitpos */
1284 complain_overflow_dont, /* complain_on_overflow */
1285 _bfd_mips_elf_generic_reloc, /* special_function */
1286 "R_MIPS_TLS_DTPMOD32", /* name */
1287 TRUE, /* partial_inplace */
1288 0xffffffff, /* src_mask */
1289 0xffffffff, /* dst_mask */
1290 FALSE), /* pcrel_offset */
1291
1292 HOWTO (R_MIPS_TLS_DTPREL32, /* type */
1293 0, /* rightshift */
1294 2, /* size (0 = byte, 1 = short, 2 = long) */
1295 32, /* bitsize */
1296 FALSE, /* pc_relative */
1297 0, /* bitpos */
1298 complain_overflow_dont, /* complain_on_overflow */
1299 _bfd_mips_elf_generic_reloc, /* special_function */
1300 "R_MIPS_TLS_DTPREL32", /* name */
1301 TRUE, /* partial_inplace */
1302 0xffffffff, /* src_mask */
1303 0xffffffff, /* dst_mask */
1304 FALSE), /* pcrel_offset */
1305
1306 EMPTY_HOWTO (R_MIPS_TLS_DTPMOD64),
1307 EMPTY_HOWTO (R_MIPS_TLS_DTPREL64),
1308
1309 /* TLS general dynamic variable reference. */
1310 HOWTO (R_MIPS_TLS_GD, /* type */
1311 0, /* rightshift */
1312 2, /* size (0 = byte, 1 = short, 2 = long) */
1313 16, /* bitsize */
1314 FALSE, /* pc_relative */
1315 0, /* bitpos */
1316 complain_overflow_signed, /* complain_on_overflow */
1317 _bfd_mips_elf_generic_reloc, /* special_function */
1318 "R_MIPS_TLS_GD", /* name */
1319 TRUE, /* partial_inplace */
1320 0x0000ffff, /* src_mask */
1321 0x0000ffff, /* dst_mask */
1322 FALSE), /* pcrel_offset */
1323
1324 /* TLS local dynamic variable reference. */
1325 HOWTO (R_MIPS_TLS_LDM, /* type */
1326 0, /* rightshift */
1327 2, /* size (0 = byte, 1 = short, 2 = long) */
1328 16, /* bitsize */
1329 FALSE, /* pc_relative */
1330 0, /* bitpos */
1331 complain_overflow_signed, /* complain_on_overflow */
1332 _bfd_mips_elf_generic_reloc, /* special_function */
1333 "R_MIPS_TLS_LDM", /* name */
1334 TRUE, /* partial_inplace */
1335 0x0000ffff, /* src_mask */
1336 0x0000ffff, /* dst_mask */
1337 FALSE), /* pcrel_offset */
1338
1339 /* TLS local dynamic offset. */
1340 HOWTO (R_MIPS_TLS_DTPREL_HI16, /* type */
1341 0, /* rightshift */
1342 2, /* size (0 = byte, 1 = short, 2 = long) */
1343 16, /* bitsize */
1344 FALSE, /* pc_relative */
1345 0, /* bitpos */
1346 complain_overflow_signed, /* complain_on_overflow */
1347 _bfd_mips_elf_generic_reloc, /* special_function */
1348 "R_MIPS_TLS_DTPREL_HI16", /* name */
1349 TRUE, /* partial_inplace */
1350 0x0000ffff, /* src_mask */
1351 0x0000ffff, /* dst_mask */
1352 FALSE), /* pcrel_offset */
1353
1354 /* TLS local dynamic offset. */
1355 HOWTO (R_MIPS_TLS_DTPREL_LO16, /* type */
1356 0, /* rightshift */
1357 2, /* size (0 = byte, 1 = short, 2 = long) */
1358 16, /* bitsize */
1359 FALSE, /* pc_relative */
1360 0, /* bitpos */
1361 complain_overflow_signed, /* complain_on_overflow */
1362 _bfd_mips_elf_generic_reloc, /* special_function */
1363 "R_MIPS_TLS_DTPREL_LO16", /* name */
1364 TRUE, /* partial_inplace */
1365 0x0000ffff, /* src_mask */
1366 0x0000ffff, /* dst_mask */
1367 FALSE), /* pcrel_offset */
1368
1369 /* TLS thread pointer offset. */
1370 HOWTO (R_MIPS_TLS_GOTTPREL, /* type */
1371 0, /* rightshift */
1372 2, /* size (0 = byte, 1 = short, 2 = long) */
1373 16, /* bitsize */
1374 FALSE, /* pc_relative */
1375 0, /* bitpos */
1376 complain_overflow_signed, /* complain_on_overflow */
1377 _bfd_mips_elf_generic_reloc, /* special_function */
1378 "R_MIPS_TLS_GOTTPREL", /* name */
1379 TRUE, /* partial_inplace */
1380 0x0000ffff, /* src_mask */
1381 0x0000ffff, /* dst_mask */
1382 FALSE), /* pcrel_offset */
1383
1384 /* TLS IE dynamic relocations. */
1385 HOWTO (R_MIPS_TLS_TPREL32, /* type */
1386 0, /* rightshift */
1387 2, /* size (0 = byte, 1 = short, 2 = long) */
1388 32, /* bitsize */
1389 FALSE, /* pc_relative */
1390 0, /* bitpos */
1391 complain_overflow_dont, /* complain_on_overflow */
1392 _bfd_mips_elf_generic_reloc, /* special_function */
1393 "R_MIPS_TLS_TPREL32", /* name */
1394 TRUE, /* partial_inplace */
1395 0xffffffff, /* src_mask */
1396 0xffffffff, /* dst_mask */
1397 FALSE), /* pcrel_offset */
1398
1399 EMPTY_HOWTO (R_MIPS_TLS_TPREL64),
1400
1401 /* TLS thread pointer offset. */
1402 HOWTO (R_MIPS_TLS_TPREL_HI16, /* type */
1403 0, /* rightshift */
1404 2, /* size (0 = byte, 1 = short, 2 = long) */
1405 16, /* bitsize */
1406 FALSE, /* pc_relative */
1407 0, /* bitpos */
1408 complain_overflow_signed, /* complain_on_overflow */
1409 _bfd_mips_elf_generic_reloc, /* special_function */
1410 "R_MIPS_TLS_TPREL_HI16", /* name */
1411 TRUE, /* partial_inplace */
1412 0x0000ffff, /* src_mask */
1413 0x0000ffff, /* dst_mask */
1414 FALSE), /* pcrel_offset */
1415
1416 /* TLS thread pointer offset. */
1417 HOWTO (R_MIPS_TLS_TPREL_LO16, /* type */
1418 0, /* rightshift */
1419 2, /* size (0 = byte, 1 = short, 2 = long) */
1420 16, /* bitsize */
1421 FALSE, /* pc_relative */
1422 0, /* bitpos */
1423 complain_overflow_signed, /* complain_on_overflow */
1424 _bfd_mips_elf_generic_reloc, /* special_function */
1425 "R_MIPS_TLS_TPREL_LO16", /* name */
1426 TRUE, /* partial_inplace */
1427 0x0000ffff, /* src_mask */
1428 0x0000ffff, /* dst_mask */
1429 FALSE), /* pcrel_offset */
1430 };
1431
1432 static reloc_howto_type elf_mips16_howto_table_rel[] =
1433 {
1434 /* The reloc used for the mips16 jump instruction. */
1435 HOWTO (R_MIPS16_26, /* type */
1436 2, /* rightshift */
1437 2, /* size (0 = byte, 1 = short, 2 = long) */
1438 26, /* bitsize */
1439 FALSE, /* pc_relative */
1440 0, /* bitpos */
1441 complain_overflow_dont, /* complain_on_overflow */
1442 /* This needs complex overflow
1443 detection, because the upper four
1444 bits must match the PC. */
1445 _bfd_mips_elf_generic_reloc, /* special_function */
1446 "R_MIPS16_26", /* name */
1447 TRUE, /* partial_inplace */
1448 0x3ffffff, /* src_mask */
1449 0x3ffffff, /* dst_mask */
1450 FALSE), /* pcrel_offset */
1451
1452 /* The reloc used for the mips16 gprel instruction. */
1453 HOWTO (R_MIPS16_GPREL, /* type */
1454 0, /* rightshift */
1455 2, /* size (0 = byte, 1 = short, 2 = long) */
1456 16, /* bitsize */
1457 FALSE, /* pc_relative */
1458 0, /* bitpos */
1459 complain_overflow_signed, /* complain_on_overflow */
1460 mips16_gprel_reloc, /* special_function */
1461 "R_MIPS16_GPREL", /* name */
1462 TRUE, /* partial_inplace */
1463 0x0000ffff, /* src_mask */
1464 0x0000ffff, /* dst_mask */
1465 FALSE), /* pcrel_offset */
1466
1467 /* A placeholder for MIPS16 reference to global offset table. */
1468 EMPTY_HOWTO (R_MIPS16_GOT16),
1469
1470 /* A placeholder for MIPS16 16 bit call through global offset table. */
1471 EMPTY_HOWTO (R_MIPS16_CALL16),
1472
1473 /* MIPS16 high 16 bits of symbol value. */
1474 HOWTO (R_MIPS16_HI16, /* type */
1475 16, /* rightshift */
1476 2, /* size (0 = byte, 1 = short, 2 = long) */
1477 16, /* bitsize */
1478 FALSE, /* pc_relative */
1479 0, /* bitpos */
1480 complain_overflow_dont, /* complain_on_overflow */
1481 _bfd_mips_elf_hi16_reloc, /* special_function */
1482 "R_MIPS16_HI16", /* name */
1483 TRUE, /* partial_inplace */
1484 0x0000ffff, /* src_mask */
1485 0x0000ffff, /* dst_mask */
1486 FALSE), /* pcrel_offset */
1487
1488 /* MIPS16 low 16 bits of symbol value. */
1489 HOWTO (R_MIPS16_LO16, /* type */
1490 0, /* rightshift */
1491 2, /* size (0 = byte, 1 = short, 2 = long) */
1492 16, /* bitsize */
1493 FALSE, /* pc_relative */
1494 0, /* bitpos */
1495 complain_overflow_dont, /* complain_on_overflow */
1496 _bfd_mips_elf_lo16_reloc, /* special_function */
1497 "R_MIPS16_LO16", /* name */
1498 TRUE, /* partial_inplace */
1499 0x0000ffff, /* src_mask */
1500 0x0000ffff, /* dst_mask */
1501 FALSE), /* pcrel_offset */
1502 };
1503
1504 static reloc_howto_type elf_mips16_howto_table_rela[] =
1505 {
1506 /* The reloc used for the mips16 jump instruction. */
1507 HOWTO (R_MIPS16_26, /* type */
1508 2, /* rightshift */
1509 2, /* size (0 = byte, 1 = short, 2 = long) */
1510 26, /* bitsize */
1511 FALSE, /* pc_relative */
1512 0, /* bitpos */
1513 complain_overflow_dont, /* complain_on_overflow */
1514 /* This needs complex overflow
1515 detection, because the upper four
1516 bits must match the PC. */
1517 _bfd_mips_elf_generic_reloc, /* special_function */
1518 "R_MIPS16_26", /* name */
1519 FALSE, /* partial_inplace */
1520 0x3ffffff, /* src_mask */
1521 0x3ffffff, /* dst_mask */
1522 FALSE), /* pcrel_offset */
1523
1524 /* The reloc used for the mips16 gprel instruction. */
1525 HOWTO (R_MIPS16_GPREL, /* type */
1526 0, /* rightshift */
1527 2, /* size (0 = byte, 1 = short, 2 = long) */
1528 16, /* bitsize */
1529 FALSE, /* pc_relative */
1530 0, /* bitpos */
1531 complain_overflow_signed, /* complain_on_overflow */
1532 mips16_gprel_reloc, /* special_function */
1533 "R_MIPS16_GPREL", /* name */
1534 FALSE, /* partial_inplace */
1535 0x0000ffff, /* src_mask */
1536 0x0000ffff, /* dst_mask */
1537 FALSE), /* pcrel_offset */
1538
1539 /* A placeholder for MIPS16 reference to global offset table. */
1540 EMPTY_HOWTO (R_MIPS16_GOT16),
1541
1542 /* A placeholder for MIPS16 16 bit call through global offset table. */
1543 EMPTY_HOWTO (R_MIPS16_CALL16),
1544
1545 /* MIPS16 high 16 bits of symbol value. */
1546 HOWTO (R_MIPS16_HI16, /* type */
1547 16, /* rightshift */
1548 2, /* size (0 = byte, 1 = short, 2 = long) */
1549 16, /* bitsize */
1550 FALSE, /* pc_relative */
1551 0, /* bitpos */
1552 complain_overflow_dont, /* complain_on_overflow */
1553 _bfd_mips_elf_hi16_reloc, /* special_function */
1554 "R_MIPS16_HI16", /* name */
1555 FALSE, /* partial_inplace */
1556 0x0000ffff, /* src_mask */
1557 0x0000ffff, /* dst_mask */
1558 FALSE), /* pcrel_offset */
1559
1560 /* MIPS16 low 16 bits of symbol value. */
1561 HOWTO (R_MIPS16_LO16, /* type */
1562 0, /* rightshift */
1563 2, /* size (0 = byte, 1 = short, 2 = long) */
1564 16, /* bitsize */
1565 FALSE, /* pc_relative */
1566 0, /* bitpos */
1567 complain_overflow_dont, /* complain_on_overflow */
1568 _bfd_mips_elf_lo16_reloc, /* special_function */
1569 "R_MIPS16_LO16", /* name */
1570 FALSE, /* partial_inplace */
1571 0x0000ffff, /* src_mask */
1572 0x0000ffff, /* dst_mask */
1573 FALSE), /* pcrel_offset */
1574 };
1575
1576 /* GNU extension to record C++ vtable hierarchy */
1577 static reloc_howto_type elf_mips_gnu_vtinherit_howto =
1578 HOWTO (R_MIPS_GNU_VTINHERIT, /* type */
1579 0, /* rightshift */
1580 2, /* size (0 = byte, 1 = short, 2 = long) */
1581 0, /* bitsize */
1582 FALSE, /* pc_relative */
1583 0, /* bitpos */
1584 complain_overflow_dont, /* complain_on_overflow */
1585 NULL, /* special_function */
1586 "R_MIPS_GNU_VTINHERIT", /* name */
1587 FALSE, /* partial_inplace */
1588 0, /* src_mask */
1589 0, /* dst_mask */
1590 FALSE); /* pcrel_offset */
1591
1592 /* GNU extension to record C++ vtable member usage */
1593 static reloc_howto_type elf_mips_gnu_vtentry_howto =
1594 HOWTO (R_MIPS_GNU_VTENTRY, /* type */
1595 0, /* rightshift */
1596 2, /* size (0 = byte, 1 = short, 2 = long) */
1597 0, /* bitsize */
1598 FALSE, /* pc_relative */
1599 0, /* bitpos */
1600 complain_overflow_dont, /* complain_on_overflow */
1601 _bfd_elf_rel_vtable_reloc_fn, /* special_function */
1602 "R_MIPS_GNU_VTENTRY", /* name */
1603 FALSE, /* partial_inplace */
1604 0, /* src_mask */
1605 0, /* dst_mask */
1606 FALSE); /* pcrel_offset */
1607 \f
1608 /* 16 bit offset for pc-relative branches. */
1609 static reloc_howto_type elf_mips_gnu_rel16_s2 =
1610 HOWTO (R_MIPS_GNU_REL16_S2, /* type */
1611 2, /* rightshift */
1612 2, /* size (0 = byte, 1 = short, 2 = long) */
1613 16, /* bitsize */
1614 TRUE, /* pc_relative */
1615 0, /* bitpos */
1616 complain_overflow_signed, /* complain_on_overflow */
1617 _bfd_mips_elf_generic_reloc, /* special_function */
1618 "R_MIPS_GNU_REL16_S2", /* name */
1619 TRUE, /* partial_inplace */
1620 0x0000ffff, /* src_mask */
1621 0x0000ffff, /* dst_mask */
1622 TRUE); /* pcrel_offset */
1623
1624 /* 16 bit offset for pc-relative branches. */
1625 static reloc_howto_type elf_mips_gnu_rela16_s2 =
1626 HOWTO (R_MIPS_GNU_REL16_S2, /* type */
1627 2, /* rightshift */
1628 2, /* size (0 = byte, 1 = short, 2 = long) */
1629 16, /* bitsize */
1630 TRUE, /* pc_relative */
1631 0, /* bitpos */
1632 complain_overflow_signed, /* complain_on_overflow */
1633 _bfd_mips_elf_generic_reloc, /* special_function */
1634 "R_MIPS_GNU_REL16_S2", /* name */
1635 FALSE, /* partial_inplace */
1636 0, /* src_mask */
1637 0x0000ffff, /* dst_mask */
1638 TRUE); /* pcrel_offset */
1639 \f
1640 /* Set the GP value for OUTPUT_BFD. Returns FALSE if this is a
1641 dangerous relocation. */
1642
1643 static bfd_boolean
1644 mips_elf_assign_gp (bfd *output_bfd, bfd_vma *pgp)
1645 {
1646 unsigned int count;
1647 asymbol **sym;
1648 unsigned int i;
1649
1650 /* If we've already figured out what GP will be, just return it. */
1651 *pgp = _bfd_get_gp_value (output_bfd);
1652 if (*pgp)
1653 return TRUE;
1654
1655 count = bfd_get_symcount (output_bfd);
1656 sym = bfd_get_outsymbols (output_bfd);
1657
1658 /* The linker script will have created a symbol named `_gp' with the
1659 appropriate value. */
1660 if (sym == NULL)
1661 i = count;
1662 else
1663 {
1664 for (i = 0; i < count; i++, sym++)
1665 {
1666 register const char *name;
1667
1668 name = bfd_asymbol_name (*sym);
1669 if (*name == '_' && strcmp (name, "_gp") == 0)
1670 {
1671 *pgp = bfd_asymbol_value (*sym);
1672 _bfd_set_gp_value (output_bfd, *pgp);
1673 break;
1674 }
1675 }
1676 }
1677
1678 if (i >= count)
1679 {
1680 /* Only get the error once. */
1681 *pgp = 4;
1682 _bfd_set_gp_value (output_bfd, *pgp);
1683 return FALSE;
1684 }
1685
1686 return TRUE;
1687 }
1688
1689 /* We have to figure out the gp value, so that we can adjust the
1690 symbol value correctly. We look up the symbol _gp in the output
1691 BFD. If we can't find it, we're stuck. We cache it in the ELF
1692 target data. We don't need to adjust the symbol value for an
1693 external symbol if we are producing relocatable output. */
1694
1695 static bfd_reloc_status_type
1696 mips_elf_final_gp (bfd *output_bfd, asymbol *symbol, bfd_boolean relocatable,
1697 char **error_message, bfd_vma *pgp)
1698 {
1699 if (bfd_is_und_section (symbol->section)
1700 && ! relocatable)
1701 {
1702 *pgp = 0;
1703 return bfd_reloc_undefined;
1704 }
1705
1706 *pgp = _bfd_get_gp_value (output_bfd);
1707 if (*pgp == 0
1708 && (! relocatable
1709 || (symbol->flags & BSF_SECTION_SYM) != 0))
1710 {
1711 if (relocatable)
1712 {
1713 /* Make up a value. */
1714 *pgp = symbol->section->output_section->vma /*+ 0x4000*/;
1715 _bfd_set_gp_value (output_bfd, *pgp);
1716 }
1717 else if (!mips_elf_assign_gp (output_bfd, pgp))
1718 {
1719 *error_message =
1720 (char *) _("GP relative relocation when _gp not defined");
1721 return bfd_reloc_dangerous;
1722 }
1723 }
1724
1725 return bfd_reloc_ok;
1726 }
1727
1728 /* Do a R_MIPS_GPREL16 relocation. This is a 16 bit value which must
1729 become the offset from the gp register. */
1730
1731 static bfd_reloc_status_type
1732 mips_elf_gprel16_reloc (bfd *abfd ATTRIBUTE_UNUSED, arelent *reloc_entry,
1733 asymbol *symbol, void *data ATTRIBUTE_UNUSED,
1734 asection *input_section, bfd *output_bfd,
1735 char **error_message ATTRIBUTE_UNUSED)
1736 {
1737 bfd_boolean relocatable;
1738 bfd_reloc_status_type ret;
1739 bfd_vma gp;
1740
1741 if (output_bfd != NULL)
1742 relocatable = TRUE;
1743 else
1744 {
1745 relocatable = FALSE;
1746 output_bfd = symbol->section->output_section->owner;
1747 }
1748
1749 ret = mips_elf_final_gp (output_bfd, symbol, relocatable, error_message,
1750 &gp);
1751 if (ret != bfd_reloc_ok)
1752 return ret;
1753
1754 return _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
1755 input_section, relocatable,
1756 data, gp);
1757 }
1758
1759 /* Do a R_MIPS_LITERAL relocation. */
1760
1761 static bfd_reloc_status_type
1762 mips_elf_literal_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
1763 void *data, asection *input_section, bfd *output_bfd,
1764 char **error_message)
1765 {
1766 bfd_boolean relocatable;
1767 bfd_reloc_status_type ret;
1768 bfd_vma gp;
1769
1770 /* R_MIPS_LITERAL relocations are defined for local symbols only. */
1771 if (output_bfd != NULL
1772 && (symbol->flags & BSF_SECTION_SYM) == 0
1773 && (symbol->flags & BSF_LOCAL) != 0)
1774 {
1775 *error_message = (char *)
1776 _("literal relocation occurs for an external symbol");
1777 return bfd_reloc_outofrange;
1778 }
1779
1780 /* FIXME: The entries in the .lit8 and .lit4 sections should be merged. */
1781 if (output_bfd != NULL)
1782 relocatable = TRUE;
1783 else
1784 {
1785 relocatable = FALSE;
1786 output_bfd = symbol->section->output_section->owner;
1787 }
1788
1789 ret = mips_elf_final_gp (output_bfd, symbol, relocatable, error_message,
1790 &gp);
1791 if (ret != bfd_reloc_ok)
1792 return ret;
1793
1794 return _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
1795 input_section, relocatable,
1796 data, gp);
1797 }
1798
1799 /* Do a R_MIPS_GPREL32 relocation. This is a 32 bit value which must
1800 become the offset from the gp register. */
1801
1802 static bfd_reloc_status_type
1803 mips_elf_gprel32_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
1804 void *data, asection *input_section, bfd *output_bfd,
1805 char **error_message)
1806 {
1807 bfd_boolean relocatable;
1808 bfd_reloc_status_type ret;
1809 bfd_vma gp;
1810
1811 /* R_MIPS_GPREL32 relocations are defined for local symbols only. */
1812 if (output_bfd != NULL
1813 && (symbol->flags & BSF_SECTION_SYM) == 0
1814 && (symbol->flags & BSF_LOCAL) != 0)
1815 {
1816 *error_message = (char *)
1817 _("32bits gp relative relocation occurs for an external symbol");
1818 return bfd_reloc_outofrange;
1819 }
1820
1821 if (output_bfd != NULL)
1822 {
1823 relocatable = TRUE;
1824 gp = _bfd_get_gp_value (output_bfd);
1825 }
1826 else
1827 {
1828 relocatable = FALSE;
1829 output_bfd = symbol->section->output_section->owner;
1830
1831 ret = mips_elf_final_gp (output_bfd, symbol, relocatable,
1832 error_message, &gp);
1833 if (ret != bfd_reloc_ok)
1834 return ret;
1835 }
1836
1837 return gprel32_with_gp (abfd, symbol, reloc_entry, input_section,
1838 relocatable, data, gp);
1839 }
1840
1841 static bfd_reloc_status_type
1842 gprel32_with_gp (bfd *abfd, asymbol *symbol, arelent *reloc_entry,
1843 asection *input_section, bfd_boolean relocatable,
1844 void *data, bfd_vma gp)
1845 {
1846 bfd_vma relocation;
1847 unsigned long val;
1848
1849 if (bfd_is_com_section (symbol->section))
1850 relocation = 0;
1851 else
1852 relocation = symbol->value;
1853
1854 relocation += symbol->section->output_section->vma;
1855 relocation += symbol->section->output_offset;
1856
1857 if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
1858 return bfd_reloc_outofrange;
1859
1860 if (reloc_entry->howto->src_mask == 0)
1861 val = 0;
1862 else
1863 val = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
1864
1865 /* Set val to the offset into the section or symbol. */
1866 val += reloc_entry->addend;
1867
1868 /* Adjust val for the final section location and GP value. If we
1869 are producing relocatable output, we don't want to do this for
1870 an external symbol. */
1871 if (! relocatable
1872 || (symbol->flags & BSF_SECTION_SYM) != 0)
1873 val += relocation - gp;
1874
1875 bfd_put_32 (abfd, val, (bfd_byte *) data + reloc_entry->address);
1876
1877 if (relocatable)
1878 reloc_entry->address += input_section->output_offset;
1879
1880 return bfd_reloc_ok;
1881 }
1882
1883 /* Do a R_MIPS_SHIFT6 relocation. The MSB of the shift is stored at bit 2,
1884 the rest is at bits 6-10. The bitpos already got right by the howto. */
1885
1886 static bfd_reloc_status_type
1887 mips_elf_shift6_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
1888 void *data, asection *input_section, bfd *output_bfd,
1889 char **error_message)
1890 {
1891 if (reloc_entry->howto->partial_inplace)
1892 {
1893 reloc_entry->addend = ((reloc_entry->addend & 0x00007c0)
1894 | (reloc_entry->addend & 0x00000800) >> 9);
1895 }
1896
1897 return _bfd_mips_elf_generic_reloc (abfd, reloc_entry, symbol, data,
1898 input_section, output_bfd,
1899 error_message);
1900 }
1901 \f
1902 /* Handle a mips16 GP relative reloc. */
1903
1904 static bfd_reloc_status_type
1905 mips16_gprel_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
1906 void *data, asection *input_section, bfd *output_bfd,
1907 char **error_message)
1908 {
1909 bfd_boolean relocatable;
1910 bfd_reloc_status_type ret;
1911 bfd_byte *location;
1912 bfd_vma gp;
1913
1914 /* If we're relocating, and this is an external symbol, we don't want
1915 to change anything. */
1916 if (output_bfd != NULL
1917 && (symbol->flags & BSF_SECTION_SYM) == 0
1918 && (symbol->flags & BSF_LOCAL) != 0)
1919 {
1920 reloc_entry->address += input_section->output_offset;
1921 return bfd_reloc_ok;
1922 }
1923
1924 if (output_bfd != NULL)
1925 relocatable = TRUE;
1926 else
1927 {
1928 relocatable = FALSE;
1929 output_bfd = symbol->section->output_section->owner;
1930 }
1931
1932 ret = mips_elf_final_gp (output_bfd, symbol, relocatable, error_message,
1933 &gp);
1934 if (ret != bfd_reloc_ok)
1935 return ret;
1936
1937 location = (bfd_byte *) data + reloc_entry->address;
1938 _bfd_mips16_elf_reloc_unshuffle (abfd, reloc_entry->howto->type, FALSE,
1939 location);
1940 ret = _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
1941 input_section, relocatable,
1942 data, gp);
1943 _bfd_mips16_elf_reloc_shuffle (abfd, reloc_entry->howto->type, !relocatable,
1944 location);
1945
1946 return ret;
1947 }
1948 \f
1949 /* A mapping from BFD reloc types to MIPS ELF reloc types. */
1950
1951 struct elf_reloc_map {
1952 bfd_reloc_code_real_type bfd_val;
1953 enum elf_mips_reloc_type elf_val;
1954 };
1955
1956 static const struct elf_reloc_map mips_reloc_map[] =
1957 {
1958 { BFD_RELOC_NONE, R_MIPS_NONE },
1959 { BFD_RELOC_16, R_MIPS_16 },
1960 { BFD_RELOC_32, R_MIPS_32 },
1961 /* There is no BFD reloc for R_MIPS_REL32. */
1962 { BFD_RELOC_CTOR, R_MIPS_32 },
1963 { BFD_RELOC_64, R_MIPS_64 },
1964 { BFD_RELOC_16_PCREL_S2, R_MIPS_PC16 },
1965 { BFD_RELOC_HI16_S, R_MIPS_HI16 },
1966 { BFD_RELOC_LO16, R_MIPS_LO16 },
1967 { BFD_RELOC_GPREL16, R_MIPS_GPREL16 },
1968 { BFD_RELOC_GPREL32, R_MIPS_GPREL32 },
1969 { BFD_RELOC_MIPS_JMP, R_MIPS_26 },
1970 { BFD_RELOC_MIPS_LITERAL, R_MIPS_LITERAL },
1971 { BFD_RELOC_MIPS_GOT16, R_MIPS_GOT16 },
1972 { BFD_RELOC_MIPS_CALL16, R_MIPS_CALL16 },
1973 { BFD_RELOC_MIPS_SHIFT5, R_MIPS_SHIFT5 },
1974 { BFD_RELOC_MIPS_SHIFT6, R_MIPS_SHIFT6 },
1975 { BFD_RELOC_MIPS_GOT_DISP, R_MIPS_GOT_DISP },
1976 { BFD_RELOC_MIPS_GOT_PAGE, R_MIPS_GOT_PAGE },
1977 { BFD_RELOC_MIPS_GOT_OFST, R_MIPS_GOT_OFST },
1978 { BFD_RELOC_MIPS_GOT_HI16, R_MIPS_GOT_HI16 },
1979 { BFD_RELOC_MIPS_GOT_LO16, R_MIPS_GOT_LO16 },
1980 { BFD_RELOC_MIPS_SUB, R_MIPS_SUB },
1981 { BFD_RELOC_MIPS_INSERT_A, R_MIPS_INSERT_A },
1982 { BFD_RELOC_MIPS_INSERT_B, R_MIPS_INSERT_B },
1983 { BFD_RELOC_MIPS_DELETE, R_MIPS_DELETE },
1984 { BFD_RELOC_MIPS_HIGHEST, R_MIPS_HIGHEST },
1985 { BFD_RELOC_MIPS_HIGHER, R_MIPS_HIGHER },
1986 { BFD_RELOC_MIPS_CALL_HI16, R_MIPS_CALL_HI16 },
1987 { BFD_RELOC_MIPS_CALL_LO16, R_MIPS_CALL_LO16 },
1988 { BFD_RELOC_MIPS_SCN_DISP, R_MIPS_SCN_DISP },
1989 { BFD_RELOC_MIPS_REL16, R_MIPS_REL16 },
1990 /* Use of R_MIPS_ADD_IMMEDIATE and R_MIPS_PJUMP is deprecated. */
1991 { BFD_RELOC_MIPS_RELGOT, R_MIPS_RELGOT },
1992 { BFD_RELOC_MIPS_JALR, R_MIPS_JALR },
1993 { BFD_RELOC_MIPS_TLS_DTPMOD32, R_MIPS_TLS_DTPMOD32 },
1994 { BFD_RELOC_MIPS_TLS_DTPREL32, R_MIPS_TLS_DTPREL32 },
1995 { BFD_RELOC_MIPS_TLS_DTPMOD64, R_MIPS_TLS_DTPMOD64 },
1996 { BFD_RELOC_MIPS_TLS_DTPREL64, R_MIPS_TLS_DTPREL64 },
1997 { BFD_RELOC_MIPS_TLS_GD, R_MIPS_TLS_GD },
1998 { BFD_RELOC_MIPS_TLS_LDM, R_MIPS_TLS_LDM },
1999 { BFD_RELOC_MIPS_TLS_DTPREL_HI16, R_MIPS_TLS_DTPREL_HI16 },
2000 { BFD_RELOC_MIPS_TLS_DTPREL_LO16, R_MIPS_TLS_DTPREL_LO16 },
2001 { BFD_RELOC_MIPS_TLS_GOTTPREL, R_MIPS_TLS_GOTTPREL },
2002 { BFD_RELOC_MIPS_TLS_TPREL32, R_MIPS_TLS_TPREL32 },
2003 { BFD_RELOC_MIPS_TLS_TPREL64, R_MIPS_TLS_TPREL64 },
2004 { BFD_RELOC_MIPS_TLS_TPREL_HI16, R_MIPS_TLS_TPREL_HI16 },
2005 { BFD_RELOC_MIPS_TLS_TPREL_LO16, R_MIPS_TLS_TPREL_LO16 }
2006 };
2007
2008 static const struct elf_reloc_map mips16_reloc_map[] =
2009 {
2010 { BFD_RELOC_MIPS16_JMP, R_MIPS16_26 - R_MIPS16_min },
2011 { BFD_RELOC_MIPS16_GPREL, R_MIPS16_GPREL - R_MIPS16_min },
2012 { BFD_RELOC_MIPS16_HI16_S, R_MIPS16_HI16 - R_MIPS16_min },
2013 { BFD_RELOC_MIPS16_LO16, R_MIPS16_LO16 - R_MIPS16_min },
2014 };
2015
2016 /* Given a BFD reloc type, return a howto structure. */
2017
2018 static reloc_howto_type *
2019 bfd_elf32_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
2020 bfd_reloc_code_real_type code)
2021 {
2022 unsigned int i;
2023 /* FIXME: We default to RELA here instead of choosing the right
2024 relocation variant. */
2025 reloc_howto_type *howto_table = elf_mips_howto_table_rela;
2026 reloc_howto_type *howto16_table = elf_mips16_howto_table_rela;
2027
2028 for (i = 0; i < sizeof (mips_reloc_map) / sizeof (struct elf_reloc_map);
2029 i++)
2030 {
2031 if (mips_reloc_map[i].bfd_val == code)
2032 return &howto_table[(int) mips_reloc_map[i].elf_val];
2033 }
2034
2035 for (i = 0; i < sizeof (mips16_reloc_map) / sizeof (struct elf_reloc_map);
2036 i++)
2037 {
2038 if (mips16_reloc_map[i].bfd_val == code)
2039 return &howto16_table[(int) mips16_reloc_map[i].elf_val];
2040 }
2041
2042 switch (code)
2043 {
2044 case BFD_RELOC_VTABLE_INHERIT:
2045 return &elf_mips_gnu_vtinherit_howto;
2046 case BFD_RELOC_VTABLE_ENTRY:
2047 return &elf_mips_gnu_vtentry_howto;
2048 default:
2049 bfd_set_error (bfd_error_bad_value);
2050 return NULL;
2051 }
2052 }
2053
2054 /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure. */
2055
2056 static reloc_howto_type *
2057 mips_elf_n32_rtype_to_howto (unsigned int r_type, bfd_boolean rela_p)
2058 {
2059 switch (r_type)
2060 {
2061 case R_MIPS_GNU_VTINHERIT:
2062 return &elf_mips_gnu_vtinherit_howto;
2063 case R_MIPS_GNU_VTENTRY:
2064 return &elf_mips_gnu_vtentry_howto;
2065 case R_MIPS_GNU_REL16_S2:
2066 if (rela_p)
2067 return &elf_mips_gnu_rela16_s2;
2068 else
2069 return &elf_mips_gnu_rel16_s2;
2070 default:
2071 if (r_type >= R_MIPS16_min && r_type < R_MIPS16_max)
2072 {
2073 if (rela_p)
2074 return &elf_mips16_howto_table_rela[r_type - R_MIPS16_min];
2075 else
2076 return &elf_mips16_howto_table_rel[r_type - R_MIPS16_min];
2077 }
2078 BFD_ASSERT (r_type < (unsigned int) R_MIPS_max);
2079 if (rela_p)
2080 return &elf_mips_howto_table_rela[r_type];
2081 else
2082 return &elf_mips_howto_table_rel[r_type];
2083 break;
2084 }
2085 }
2086
2087 /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure. */
2088
2089 static void
2090 mips_info_to_howto_rel (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst)
2091 {
2092 unsigned int r_type;
2093
2094 r_type = ELF32_R_TYPE (dst->r_info);
2095 cache_ptr->howto = mips_elf_n32_rtype_to_howto (r_type, FALSE);
2096
2097 /* The addend for a GPREL16 or LITERAL relocation comes from the GP
2098 value for the object file. We get the addend now, rather than
2099 when we do the relocation, because the symbol manipulations done
2100 by the linker may cause us to lose track of the input BFD. */
2101 if (((*cache_ptr->sym_ptr_ptr)->flags & BSF_SECTION_SYM) != 0
2102 && (r_type == (unsigned int) R_MIPS_GPREL16
2103 || r_type == (unsigned int) R_MIPS_LITERAL))
2104 cache_ptr->addend = elf_gp (abfd);
2105 }
2106
2107 /* Given a MIPS Elf_Internal_Rela, fill in an arelent structure. */
2108
2109 static void
2110 mips_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED,
2111 arelent *cache_ptr, Elf_Internal_Rela *dst)
2112 {
2113 unsigned int r_type;
2114
2115 r_type = ELF32_R_TYPE (dst->r_info);
2116 cache_ptr->howto = mips_elf_n32_rtype_to_howto (r_type, TRUE);
2117 cache_ptr->addend = dst->r_addend;
2118 }
2119 \f
2120 /* Determine whether a symbol is global for the purposes of splitting
2121 the symbol table into global symbols and local symbols. At least
2122 on Irix 5, this split must be between section symbols and all other
2123 symbols. On most ELF targets the split is between static symbols
2124 and externally visible symbols. */
2125
2126 static bfd_boolean
2127 mips_elf_sym_is_global (bfd *abfd ATTRIBUTE_UNUSED, asymbol *sym)
2128 {
2129 if (SGI_COMPAT (abfd))
2130 return (sym->flags & BSF_SECTION_SYM) == 0;
2131 else
2132 return ((sym->flags & (BSF_GLOBAL | BSF_WEAK)) != 0
2133 || bfd_is_und_section (bfd_get_section (sym))
2134 || bfd_is_com_section (bfd_get_section (sym)));
2135 }
2136 \f
2137 /* Set the right machine number for a MIPS ELF file. */
2138
2139 static bfd_boolean
2140 mips_elf_n32_object_p (bfd *abfd)
2141 {
2142 unsigned long mach;
2143
2144 /* Irix 5 and 6 are broken. Object file symbol tables are not always
2145 sorted correctly such that local symbols precede global symbols,
2146 and the sh_info field in the symbol table is not always right. */
2147 if (SGI_COMPAT (abfd))
2148 elf_bad_symtab (abfd) = TRUE;
2149
2150 mach = _bfd_elf_mips_mach (elf_elfheader (abfd)->e_flags);
2151 bfd_default_set_arch_mach (abfd, bfd_arch_mips, mach);
2152
2153 if (! ABI_N32_P(abfd))
2154 return FALSE;
2155
2156 return TRUE;
2157 }
2158 \f
2159 /* Support for core dump NOTE sections. */
2160 static bfd_boolean
2161 elf32_mips_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
2162 {
2163 int offset;
2164 unsigned int size;
2165
2166 switch (note->descsz)
2167 {
2168 default:
2169 return FALSE;
2170
2171 case 440: /* Linux/MIPS N32 */
2172 /* pr_cursig */
2173 elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
2174
2175 /* pr_pid */
2176 elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24);
2177
2178 /* pr_reg */
2179 offset = 72;
2180 size = 360;
2181
2182 break;
2183 }
2184
2185 /* Make a ".reg/999" section. */
2186 return _bfd_elfcore_make_pseudosection (abfd, ".reg", size,
2187 note->descpos + offset);
2188 }
2189
2190 static bfd_boolean
2191 elf32_mips_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
2192 {
2193 switch (note->descsz)
2194 {
2195 default:
2196 return FALSE;
2197
2198 case 128: /* Linux/MIPS elf_prpsinfo */
2199 elf_tdata (abfd)->core_program
2200 = _bfd_elfcore_strndup (abfd, note->descdata + 32, 16);
2201 elf_tdata (abfd)->core_command
2202 = _bfd_elfcore_strndup (abfd, note->descdata + 48, 80);
2203 }
2204
2205 /* Note that for some reason, a spurious space is tacked
2206 onto the end of the args in some (at least one anyway)
2207 implementations, so strip it off if it exists. */
2208
2209 {
2210 char *command = elf_tdata (abfd)->core_command;
2211 int n = strlen (command);
2212
2213 if (0 < n && command[n - 1] == ' ')
2214 command[n - 1] = '\0';
2215 }
2216
2217 return TRUE;
2218 }
2219 \f
2220 /* Depending on the target vector we generate some version of Irix
2221 executables or "normal" MIPS ELF ABI executables. */
2222 static irix_compat_t
2223 elf_n32_mips_irix_compat (bfd *abfd)
2224 {
2225 if ((abfd->xvec == &bfd_elf32_nbigmips_vec)
2226 || (abfd->xvec == &bfd_elf32_nlittlemips_vec))
2227 return ict_irix6;
2228 else
2229 return ict_none;
2230 }
2231 \f
2232 /* ECOFF swapping routines. These are used when dealing with the
2233 .mdebug section, which is in the ECOFF debugging format. */
2234 static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = {
2235 /* Symbol table magic number. */
2236 magicSym,
2237 /* Alignment of debugging information. E.g., 4. */
2238 4,
2239 /* Sizes of external symbolic information. */
2240 sizeof (struct hdr_ext),
2241 sizeof (struct dnr_ext),
2242 sizeof (struct pdr_ext),
2243 sizeof (struct sym_ext),
2244 sizeof (struct opt_ext),
2245 sizeof (struct fdr_ext),
2246 sizeof (struct rfd_ext),
2247 sizeof (struct ext_ext),
2248 /* Functions to swap in external symbolic data. */
2249 ecoff_swap_hdr_in,
2250 ecoff_swap_dnr_in,
2251 ecoff_swap_pdr_in,
2252 ecoff_swap_sym_in,
2253 ecoff_swap_opt_in,
2254 ecoff_swap_fdr_in,
2255 ecoff_swap_rfd_in,
2256 ecoff_swap_ext_in,
2257 _bfd_ecoff_swap_tir_in,
2258 _bfd_ecoff_swap_rndx_in,
2259 /* Functions to swap out external symbolic data. */
2260 ecoff_swap_hdr_out,
2261 ecoff_swap_dnr_out,
2262 ecoff_swap_pdr_out,
2263 ecoff_swap_sym_out,
2264 ecoff_swap_opt_out,
2265 ecoff_swap_fdr_out,
2266 ecoff_swap_rfd_out,
2267 ecoff_swap_ext_out,
2268 _bfd_ecoff_swap_tir_out,
2269 _bfd_ecoff_swap_rndx_out,
2270 /* Function to read in symbolic data. */
2271 _bfd_mips_elf_read_ecoff_info
2272 };
2273 \f
2274 #define ELF_ARCH bfd_arch_mips
2275 #define ELF_MACHINE_CODE EM_MIPS
2276
2277 #define elf_backend_collect TRUE
2278 #define elf_backend_type_change_ok TRUE
2279 #define elf_backend_can_gc_sections TRUE
2280 #define elf_info_to_howto mips_info_to_howto_rela
2281 #define elf_info_to_howto_rel mips_info_to_howto_rel
2282 #define elf_backend_sym_is_global mips_elf_sym_is_global
2283 #define elf_backend_object_p mips_elf_n32_object_p
2284 #define elf_backend_symbol_processing _bfd_mips_elf_symbol_processing
2285 #define elf_backend_section_processing _bfd_mips_elf_section_processing
2286 #define elf_backend_section_from_shdr _bfd_mips_elf_section_from_shdr
2287 #define elf_backend_fake_sections _bfd_mips_elf_fake_sections
2288 #define elf_backend_section_from_bfd_section \
2289 _bfd_mips_elf_section_from_bfd_section
2290 #define elf_backend_add_symbol_hook _bfd_mips_elf_add_symbol_hook
2291 #define elf_backend_link_output_symbol_hook \
2292 _bfd_mips_elf_link_output_symbol_hook
2293 #define elf_backend_create_dynamic_sections \
2294 _bfd_mips_elf_create_dynamic_sections
2295 #define elf_backend_check_relocs _bfd_mips_elf_check_relocs
2296 #define elf_backend_merge_symbol_attribute \
2297 _bfd_mips_elf_merge_symbol_attribute
2298 #define elf_backend_adjust_dynamic_symbol \
2299 _bfd_mips_elf_adjust_dynamic_symbol
2300 #define elf_backend_always_size_sections \
2301 _bfd_mips_elf_always_size_sections
2302 #define elf_backend_size_dynamic_sections \
2303 _bfd_mips_elf_size_dynamic_sections
2304 #define elf_backend_relocate_section _bfd_mips_elf_relocate_section
2305 #define elf_backend_finish_dynamic_symbol \
2306 _bfd_mips_elf_finish_dynamic_symbol
2307 #define elf_backend_finish_dynamic_sections \
2308 _bfd_mips_elf_finish_dynamic_sections
2309 #define elf_backend_final_write_processing \
2310 _bfd_mips_elf_final_write_processing
2311 #define elf_backend_additional_program_headers \
2312 _bfd_mips_elf_additional_program_headers
2313 #define elf_backend_modify_segment_map _bfd_mips_elf_modify_segment_map
2314 #define elf_backend_gc_mark_hook _bfd_mips_elf_gc_mark_hook
2315 #define elf_backend_gc_sweep_hook _bfd_mips_elf_gc_sweep_hook
2316 #define elf_backend_copy_indirect_symbol \
2317 _bfd_mips_elf_copy_indirect_symbol
2318 #define elf_backend_hide_symbol _bfd_mips_elf_hide_symbol
2319 #define elf_backend_grok_prstatus elf32_mips_grok_prstatus
2320 #define elf_backend_grok_psinfo elf32_mips_grok_psinfo
2321 #define elf_backend_ecoff_debug_swap &mips_elf32_ecoff_debug_swap
2322
2323 #define elf_backend_got_header_size (4 * MIPS_RESERVED_GOTNO)
2324
2325 /* MIPS n32 ELF can use a mixture of REL and RELA, but some Relocations
2326 work better/work only in RELA, so we default to this. */
2327 #define elf_backend_may_use_rel_p 1
2328 #define elf_backend_may_use_rela_p 1
2329 #define elf_backend_default_use_rela_p 1
2330 #define elf_backend_sign_extend_vma TRUE
2331
2332 #define elf_backend_discard_info _bfd_mips_elf_discard_info
2333 #define elf_backend_ignore_discarded_relocs \
2334 _bfd_mips_elf_ignore_discarded_relocs
2335 #define elf_backend_write_section _bfd_mips_elf_write_section
2336 #define elf_backend_mips_irix_compat elf_n32_mips_irix_compat
2337 #define elf_backend_mips_rtype_to_howto mips_elf_n32_rtype_to_howto
2338 #define bfd_elf32_find_nearest_line _bfd_mips_elf_find_nearest_line
2339 #define bfd_elf32_find_inliner_info _bfd_mips_elf_find_inliner_info
2340 #define bfd_elf32_new_section_hook _bfd_mips_elf_new_section_hook
2341 #define bfd_elf32_set_section_contents _bfd_mips_elf_set_section_contents
2342 #define bfd_elf32_bfd_get_relocated_section_contents \
2343 _bfd_elf_mips_get_relocated_section_contents
2344 #define bfd_elf32_bfd_link_hash_table_create \
2345 _bfd_mips_elf_link_hash_table_create
2346 #define bfd_elf32_bfd_final_link _bfd_mips_elf_final_link
2347 #define bfd_elf32_bfd_merge_private_bfd_data \
2348 _bfd_mips_elf_merge_private_bfd_data
2349 #define bfd_elf32_bfd_set_private_flags _bfd_mips_elf_set_private_flags
2350 #define bfd_elf32_bfd_print_private_bfd_data \
2351 _bfd_mips_elf_print_private_bfd_data
2352 #define bfd_elf32_bfd_relax_section _bfd_mips_relax_section
2353
2354 /* Support for SGI-ish mips targets using n32 ABI. */
2355
2356 #define TARGET_LITTLE_SYM bfd_elf32_nlittlemips_vec
2357 #define TARGET_LITTLE_NAME "elf32-nlittlemips"
2358 #define TARGET_BIG_SYM bfd_elf32_nbigmips_vec
2359 #define TARGET_BIG_NAME "elf32-nbigmips"
2360
2361 #define ELF_MAXPAGESIZE 0x10000
2362 #define ELF_COMMONPAGESIZE 0x1000
2363
2364 #include "elf32-target.h"
2365
2366 /* Support for traditional mips targets using n32 ABI. */
2367 #undef TARGET_LITTLE_SYM
2368 #undef TARGET_LITTLE_NAME
2369 #undef TARGET_BIG_SYM
2370 #undef TARGET_BIG_NAME
2371
2372 #undef ELF_MAXPAGESIZE
2373 #undef ELF_COMMONPAGESIZE
2374
2375 #define TARGET_LITTLE_SYM bfd_elf32_ntradlittlemips_vec
2376 #define TARGET_LITTLE_NAME "elf32-ntradlittlemips"
2377 #define TARGET_BIG_SYM bfd_elf32_ntradbigmips_vec
2378 #define TARGET_BIG_NAME "elf32-ntradbigmips"
2379
2380 #define ELF_MAXPAGESIZE 0x10000
2381 #define ELF_COMMONPAGESIZE 0x1000
2382 #define elf32_bed elf32_tradbed
2383
2384 /* Include the target file again for this target. */
2385 #include "elf32-target.h"
This page took 0.086245 seconds and 4 git commands to generate.