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.
5 Most of the information added by Ian Lance Taylor, Cygnus Support,
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>
12 This file is part of BFD, the Binary File Descriptor library.
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.
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.
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. */
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. */
38 #include "elfxx-mips.h"
41 /* Get the ECOFF swapping routines. */
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"
50 static bfd_boolean mips_elf_assign_gp
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
76 static bfd_boolean mips_elf_n32_object_p
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
85 extern const bfd_target bfd_elf32_nbigmips_vec
;
86 extern const bfd_target bfd_elf32_nlittlemips_vec
;
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)
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)
96 /* The number of local .got entries we reserve. */
97 #define MIPS_RESERVED_GOTNO (2)
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)
103 /* The relocation table used for SHT_REL sections. */
105 static reloc_howto_type elf_mips_howto_table_rel
[] =
108 HOWTO (R_MIPS_NONE
, /* type */
110 0, /* size (0 = byte, 1 = short, 2 = long) */
112 FALSE
, /* pc_relative */
114 complain_overflow_dont
, /* complain_on_overflow */
115 _bfd_mips_elf_generic_reloc
, /* special_function */
116 "R_MIPS_NONE", /* name */
117 FALSE
, /* partial_inplace */
120 FALSE
), /* pcrel_offset */
122 /* 16 bit relocation. */
123 HOWTO (R_MIPS_16
, /* type */
125 2, /* size (0 = byte, 1 = short, 2 = long) */
127 FALSE
, /* pc_relative */
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 */
137 /* 32 bit relocation. */
138 HOWTO (R_MIPS_32
, /* type */
140 2, /* size (0 = byte, 1 = short, 2 = long) */
142 FALSE
, /* pc_relative */
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 */
152 /* 32 bit symbol relative relocation. */
153 HOWTO (R_MIPS_REL32
, /* type */
155 2, /* size (0 = byte, 1 = short, 2 = long) */
157 FALSE
, /* pc_relative */
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 */
167 /* 26 bit jump address. */
168 HOWTO (R_MIPS_26
, /* type */
170 2, /* size (0 = byte, 1 = short, 2 = long) */
172 FALSE
, /* pc_relative */
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 */
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. */
188 /* High 16 bits of symbol value. */
189 HOWTO (R_MIPS_HI16
, /* type */
191 2, /* size (0 = byte, 1 = short, 2 = long) */
193 FALSE
, /* pc_relative */
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 */
203 /* Low 16 bits of symbol value. */
204 HOWTO (R_MIPS_LO16
, /* type */
206 2, /* size (0 = byte, 1 = short, 2 = long) */
208 FALSE
, /* pc_relative */
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 */
218 /* GP relative reference. */
219 HOWTO (R_MIPS_GPREL16
, /* type */
221 2, /* size (0 = byte, 1 = short, 2 = long) */
223 FALSE
, /* pc_relative */
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 */
233 /* Reference to literal section. */
234 HOWTO (R_MIPS_LITERAL
, /* type */
236 2, /* size (0 = byte, 1 = short, 2 = long) */
238 FALSE
, /* pc_relative */
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 */
248 /* Reference to global offset table. */
249 HOWTO (R_MIPS_GOT16
, /* type */
251 2, /* size (0 = byte, 1 = short, 2 = long) */
253 FALSE
, /* pc_relative */
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 */
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 */
268 2, /* size (0 = byte, 1 = short, 2 = long) */
270 TRUE
, /* pc_relative */
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 */
280 /* 16 bit call through global offset table. */
281 HOWTO (R_MIPS_CALL16
, /* type */
283 2, /* size (0 = byte, 1 = short, 2 = long) */
285 FALSE
, /* pc_relative */
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 */
295 /* 32 bit GP relative reference. */
296 HOWTO (R_MIPS_GPREL32
, /* type */
298 2, /* size (0 = byte, 1 = short, 2 = long) */
300 FALSE
, /* pc_relative */
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 */
310 /* The remaining relocs are defined on Irix 5, although they are
311 not defined by the ABI. */
316 /* A 5 bit shift field. */
317 HOWTO (R_MIPS_SHIFT5
, /* type */
319 2, /* size (0 = byte, 1 = short, 2 = long) */
321 FALSE
, /* pc_relative */
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 */
331 /* A 6 bit shift field. */
332 HOWTO (R_MIPS_SHIFT6
, /* type */
334 2, /* size (0 = byte, 1 = short, 2 = long) */
336 FALSE
, /* pc_relative */
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 */
346 /* A 64 bit relocation. */
347 HOWTO (R_MIPS_64
, /* type */
349 4, /* size (0 = byte, 1 = short, 2 = long) */
351 FALSE
, /* pc_relative */
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 */
361 /* Displacement in the global offset table. */
362 HOWTO (R_MIPS_GOT_DISP
, /* type */
364 2, /* size (0 = byte, 1 = short, 2 = long) */
366 FALSE
, /* pc_relative */
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 */
376 /* Displacement to page pointer in the global offset table. */
377 HOWTO (R_MIPS_GOT_PAGE
, /* type */
379 2, /* size (0 = byte, 1 = short, 2 = long) */
381 FALSE
, /* pc_relative */
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 */
391 /* Offset from page pointer in the global offset table. */
392 HOWTO (R_MIPS_GOT_OFST
, /* type */
394 2, /* size (0 = byte, 1 = short, 2 = long) */
396 FALSE
, /* pc_relative */
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 */
406 /* High 16 bits of displacement in global offset table. */
407 HOWTO (R_MIPS_GOT_HI16
, /* type */
409 2, /* size (0 = byte, 1 = short, 2 = long) */
411 FALSE
, /* pc_relative */
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 */
421 /* Low 16 bits of displacement in global offset table. */
422 HOWTO (R_MIPS_GOT_LO16
, /* type */
424 2, /* size (0 = byte, 1 = short, 2 = long) */
426 FALSE
, /* pc_relative */
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 */
436 /* 64 bit subtraction. */
437 HOWTO (R_MIPS_SUB
, /* type */
439 4, /* size (0 = byte, 1 = short, 2 = long) */
441 FALSE
, /* pc_relative */
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 */
451 /* Insert the addend as an instruction. */
452 /* FIXME: Not handled correctly. */
453 HOWTO (R_MIPS_INSERT_A
, /* type */
455 2, /* size (0 = byte, 1 = short, 2 = long) */
457 FALSE
, /* pc_relative */
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 */
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 */
472 2, /* size (0 = byte, 1 = short, 2 = long) */
474 FALSE
, /* pc_relative */
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 */
484 /* Delete a 32 bit instruction. */
485 /* FIXME: Not handled correctly. */
486 HOWTO (R_MIPS_DELETE
, /* type */
488 2, /* size (0 = byte, 1 = short, 2 = long) */
490 FALSE
, /* pc_relative */
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 */
500 /* The MIPS ELF64 ABI Draft wants us to support these for REL relocations.
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
505 b) No other NewABI toolchain actually emits such relocations. */
506 EMPTY_HOWTO (R_MIPS_HIGHER
),
507 EMPTY_HOWTO (R_MIPS_HIGHEST
),
509 /* High 16 bits of displacement in global offset table. */
510 HOWTO (R_MIPS_CALL_HI16
, /* type */
512 2, /* size (0 = byte, 1 = short, 2 = long) */
514 FALSE
, /* pc_relative */
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 */
524 /* Low 16 bits of displacement in global offset table. */
525 HOWTO (R_MIPS_CALL_LO16
, /* type */
527 2, /* size (0 = byte, 1 = short, 2 = long) */
529 FALSE
, /* pc_relative */
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 */
539 /* Section displacement. */
540 HOWTO (R_MIPS_SCN_DISP
, /* type */
542 2, /* size (0 = byte, 1 = short, 2 = long) */
544 FALSE
, /* pc_relative */
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 */
554 HOWTO (R_MIPS_REL16
, /* type */
556 1, /* size (0 = byte, 1 = short, 2 = long) */
558 FALSE
, /* pc_relative */
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 */
568 /* These two are obsolete. */
569 EMPTY_HOWTO (R_MIPS_ADD_IMMEDIATE
),
570 EMPTY_HOWTO (R_MIPS_PJUMP
),
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 */
576 2, /* size (0 = byte, 1 = short, 2 = long) */
578 FALSE
, /* pc_relative */
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 */
588 /* Protected jump conversion. This is an optimization hint. No
589 relocation is required for correctness. */
590 HOWTO (R_MIPS_JALR
, /* type */
592 2, /* size (0 = byte, 1 = short, 2 = long) */
594 FALSE
, /* pc_relative */
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 */
604 /* TLS GD/LD dynamic relocations. */
605 HOWTO (R_MIPS_TLS_DTPMOD32
, /* type */
607 2, /* size (0 = byte, 1 = short, 2 = long) */
609 FALSE
, /* pc_relative */
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 */
619 HOWTO (R_MIPS_TLS_DTPREL32
, /* type */
621 2, /* size (0 = byte, 1 = short, 2 = long) */
623 FALSE
, /* pc_relative */
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 */
633 EMPTY_HOWTO (R_MIPS_TLS_DTPMOD64
),
634 EMPTY_HOWTO (R_MIPS_TLS_DTPREL64
),
636 /* TLS general dynamic variable reference. */
637 HOWTO (R_MIPS_TLS_GD
, /* type */
639 2, /* size (0 = byte, 1 = short, 2 = long) */
641 FALSE
, /* pc_relative */
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 */
651 /* TLS local dynamic variable reference. */
652 HOWTO (R_MIPS_TLS_LDM
, /* type */
654 2, /* size (0 = byte, 1 = short, 2 = long) */
656 FALSE
, /* pc_relative */
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 */
666 /* TLS local dynamic offset. */
667 HOWTO (R_MIPS_TLS_DTPREL_HI16
, /* type */
669 2, /* size (0 = byte, 1 = short, 2 = long) */
671 FALSE
, /* pc_relative */
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 */
681 /* TLS local dynamic offset. */
682 HOWTO (R_MIPS_TLS_DTPREL_LO16
, /* type */
684 2, /* size (0 = byte, 1 = short, 2 = long) */
686 FALSE
, /* pc_relative */
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 */
696 /* TLS thread pointer offset. */
697 HOWTO (R_MIPS_TLS_GOTTPREL
, /* type */
699 2, /* size (0 = byte, 1 = short, 2 = long) */
701 FALSE
, /* pc_relative */
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 */
711 /* TLS IE dynamic relocations. */
712 HOWTO (R_MIPS_TLS_TPREL32
, /* type */
714 2, /* size (0 = byte, 1 = short, 2 = long) */
716 FALSE
, /* pc_relative */
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 */
726 EMPTY_HOWTO (R_MIPS_TLS_TPREL64
),
728 /* TLS thread pointer offset. */
729 HOWTO (R_MIPS_TLS_TPREL_HI16
, /* type */
731 2, /* size (0 = byte, 1 = short, 2 = long) */
733 FALSE
, /* pc_relative */
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 */
743 /* TLS thread pointer offset. */
744 HOWTO (R_MIPS_TLS_TPREL_LO16
, /* type */
746 2, /* size (0 = byte, 1 = short, 2 = long) */
748 FALSE
, /* pc_relative */
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 */
759 /* The relocation table used for SHT_RELA sections. */
761 static reloc_howto_type elf_mips_howto_table_rela
[] =
764 HOWTO (R_MIPS_NONE
, /* type */
766 0, /* size (0 = byte, 1 = short, 2 = long) */
768 FALSE
, /* pc_relative */
770 complain_overflow_dont
, /* complain_on_overflow */
771 _bfd_mips_elf_generic_reloc
, /* special_function */
772 "R_MIPS_NONE", /* name */
773 FALSE
, /* partial_inplace */
776 FALSE
), /* pcrel_offset */
778 /* 16 bit relocation. */
779 HOWTO (R_MIPS_16
, /* type */
781 2, /* size (0 = byte, 1 = short, 2 = long) */
783 FALSE
, /* pc_relative */
785 complain_overflow_signed
, /* complain_on_overflow */
786 _bfd_mips_elf_generic_reloc
, /* special_function */
787 "R_MIPS_16", /* name */
788 FALSE
, /* partial_inplace */
790 0x0000, /* dst_mask */
791 FALSE
), /* pcrel_offset */
793 /* 32 bit relocation. */
794 HOWTO (R_MIPS_32
, /* type */
796 2, /* size (0 = byte, 1 = short, 2 = long) */
798 FALSE
, /* pc_relative */
800 complain_overflow_dont
, /* complain_on_overflow */
801 _bfd_mips_elf_generic_reloc
, /* special_function */
802 "R_MIPS_32", /* name */
803 FALSE
, /* partial_inplace */
805 0xffffffff, /* dst_mask */
806 FALSE
), /* pcrel_offset */
808 /* 32 bit symbol relative relocation. */
809 HOWTO (R_MIPS_REL32
, /* type */
811 2, /* size (0 = byte, 1 = short, 2 = long) */
813 FALSE
, /* pc_relative */
815 complain_overflow_dont
, /* complain_on_overflow */
816 _bfd_mips_elf_generic_reloc
, /* special_function */
817 "R_MIPS_REL32", /* name */
818 FALSE
, /* partial_inplace */
820 0xffffffff, /* dst_mask */
821 FALSE
), /* pcrel_offset */
823 /* 26 bit jump address. */
824 HOWTO (R_MIPS_26
, /* type */
826 2, /* size (0 = byte, 1 = short, 2 = long) */
828 FALSE
, /* pc_relative */
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 */
838 0x03ffffff, /* dst_mask */
839 FALSE
), /* pcrel_offset */
841 /* High 16 bits of symbol value. */
842 HOWTO (R_MIPS_HI16
, /* type */
844 2, /* size (0 = byte, 1 = short, 2 = long) */
846 FALSE
, /* pc_relative */
848 complain_overflow_dont
, /* complain_on_overflow */
849 _bfd_mips_elf_generic_reloc
, /* special_function */
850 "R_MIPS_HI16", /* name */
851 FALSE
, /* partial_inplace */
853 0x0000ffff, /* dst_mask */
854 FALSE
), /* pcrel_offset */
856 /* Low 16 bits of symbol value. */
857 HOWTO (R_MIPS_LO16
, /* type */
859 2, /* size (0 = byte, 1 = short, 2 = long) */
861 FALSE
, /* pc_relative */
863 complain_overflow_dont
, /* complain_on_overflow */
864 _bfd_mips_elf_generic_reloc
, /* special_function */
865 "R_MIPS_LO16", /* name */
866 FALSE
, /* partial_inplace */
868 0x0000ffff, /* dst_mask */
869 FALSE
), /* pcrel_offset */
871 /* GP relative reference. */
872 HOWTO (R_MIPS_GPREL16
, /* type */
874 2, /* size (0 = byte, 1 = short, 2 = long) */
876 FALSE
, /* pc_relative */
878 complain_overflow_signed
, /* complain_on_overflow */
879 mips_elf_gprel16_reloc
, /* special_function */
880 "R_MIPS_GPREL16", /* name */
881 FALSE
, /* partial_inplace */
883 0x0000ffff, /* dst_mask */
884 FALSE
), /* pcrel_offset */
886 /* Reference to literal section. */
887 HOWTO (R_MIPS_LITERAL
, /* type */
889 2, /* size (0 = byte, 1 = short, 2 = long) */
891 FALSE
, /* pc_relative */
893 complain_overflow_signed
, /* complain_on_overflow */
894 mips_elf_literal_reloc
, /* special_function */
895 "R_MIPS_LITERAL", /* name */
896 FALSE
, /* partial_inplace */
898 0x0000ffff, /* dst_mask */
899 FALSE
), /* pcrel_offset */
901 /* Reference to global offset table. */
902 HOWTO (R_MIPS_GOT16
, /* type */
904 2, /* size (0 = byte, 1 = short, 2 = long) */
906 FALSE
, /* pc_relative */
908 complain_overflow_signed
, /* complain_on_overflow */
909 _bfd_mips_elf_generic_reloc
, /* special_function */
910 "R_MIPS_GOT16", /* name */
911 FALSE
, /* partial_inplace */
913 0x0000ffff, /* dst_mask */
914 FALSE
), /* pcrel_offset */
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 */
921 2, /* size (0 = byte, 1 = short, 2 = long) */
923 TRUE
, /* pc_relative */
925 complain_overflow_signed
, /* complain_on_overflow */
926 _bfd_mips_elf_generic_reloc
, /* special_function */
927 "R_MIPS_PC16", /* name */
928 FALSE
, /* partial_inplace */
930 0x0000ffff, /* dst_mask */
931 TRUE
), /* pcrel_offset */
933 /* 16 bit call through global offset table. */
934 HOWTO (R_MIPS_CALL16
, /* type */
936 2, /* size (0 = byte, 1 = short, 2 = long) */
938 FALSE
, /* pc_relative */
940 complain_overflow_signed
, /* complain_on_overflow */
941 _bfd_mips_elf_generic_reloc
, /* special_function */
942 "R_MIPS_CALL16", /* name */
943 FALSE
, /* partial_inplace */
945 0x0000ffff, /* dst_mask */
946 FALSE
), /* pcrel_offset */
948 /* 32 bit GP relative reference. */
949 HOWTO (R_MIPS_GPREL32
, /* type */
951 2, /* size (0 = byte, 1 = short, 2 = long) */
953 FALSE
, /* pc_relative */
955 complain_overflow_dont
, /* complain_on_overflow */
956 mips_elf_gprel32_reloc
, /* special_function */
957 "R_MIPS_GPREL32", /* name */
958 FALSE
, /* partial_inplace */
960 0xffffffff, /* dst_mask */
961 FALSE
), /* pcrel_offset */
967 /* A 5 bit shift field. */
968 HOWTO (R_MIPS_SHIFT5
, /* type */
970 2, /* size (0 = byte, 1 = short, 2 = long) */
972 FALSE
, /* pc_relative */
974 complain_overflow_bitfield
, /* complain_on_overflow */
975 _bfd_mips_elf_generic_reloc
, /* special_function */
976 "R_MIPS_SHIFT5", /* name */
977 FALSE
, /* partial_inplace */
979 0x000007c0, /* dst_mask */
980 FALSE
), /* pcrel_offset */
982 /* A 6 bit shift field. */
983 HOWTO (R_MIPS_SHIFT6
, /* type */
985 2, /* size (0 = byte, 1 = short, 2 = long) */
987 FALSE
, /* pc_relative */
989 complain_overflow_bitfield
, /* complain_on_overflow */
990 mips_elf_shift6_reloc
, /* special_function */
991 "R_MIPS_SHIFT6", /* name */
992 FALSE
, /* partial_inplace */
994 0x000007c4, /* dst_mask */
995 FALSE
), /* pcrel_offset */
997 /* 64 bit relocation. */
998 HOWTO (R_MIPS_64
, /* type */
1000 4, /* size (0 = byte, 1 = short, 2 = long) */
1002 FALSE
, /* pc_relative */
1004 complain_overflow_dont
, /* complain_on_overflow */
1005 _bfd_mips_elf_generic_reloc
, /* special_function */
1006 "R_MIPS_64", /* name */
1007 FALSE
, /* partial_inplace */
1009 MINUS_ONE
, /* dst_mask */
1010 FALSE
), /* pcrel_offset */
1012 /* Displacement in the global offset table. */
1013 HOWTO (R_MIPS_GOT_DISP
, /* type */
1015 2, /* size (0 = byte, 1 = short, 2 = long) */
1017 FALSE
, /* pc_relative */
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 */
1024 0x0000ffff, /* dst_mask */
1025 FALSE
), /* pcrel_offset */
1027 /* Displacement to page pointer in the global offset table. */
1028 HOWTO (R_MIPS_GOT_PAGE
, /* type */
1030 2, /* size (0 = byte, 1 = short, 2 = long) */
1032 FALSE
, /* pc_relative */
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 */
1039 0x0000ffff, /* dst_mask */
1040 FALSE
), /* pcrel_offset */
1042 /* Offset from page pointer in the global offset table. */
1043 HOWTO (R_MIPS_GOT_OFST
, /* type */
1045 2, /* size (0 = byte, 1 = short, 2 = long) */
1047 FALSE
, /* pc_relative */
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 */
1054 0x0000ffff, /* dst_mask */
1055 FALSE
), /* pcrel_offset */
1057 /* High 16 bits of displacement in global offset table. */
1058 HOWTO (R_MIPS_GOT_HI16
, /* type */
1060 2, /* size (0 = byte, 1 = short, 2 = long) */
1062 FALSE
, /* pc_relative */
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 */
1069 0x0000ffff, /* dst_mask */
1070 FALSE
), /* pcrel_offset */
1072 /* Low 16 bits of displacement in global offset table. */
1073 HOWTO (R_MIPS_GOT_LO16
, /* type */
1075 2, /* size (0 = byte, 1 = short, 2 = long) */
1077 FALSE
, /* pc_relative */
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 */
1084 0x0000ffff, /* dst_mask */
1085 FALSE
), /* pcrel_offset */
1087 /* 64 bit subtraction. */
1088 HOWTO (R_MIPS_SUB
, /* type */
1090 4, /* size (0 = byte, 1 = short, 2 = long) */
1092 FALSE
, /* pc_relative */
1094 complain_overflow_dont
, /* complain_on_overflow */
1095 _bfd_mips_elf_generic_reloc
, /* special_function */
1096 "R_MIPS_SUB", /* name */
1097 FALSE
, /* partial_inplace */
1099 MINUS_ONE
, /* dst_mask */
1100 FALSE
), /* pcrel_offset */
1102 /* Insert the addend as an instruction. */
1103 /* FIXME: Not handled correctly. */
1104 HOWTO (R_MIPS_INSERT_A
, /* type */
1106 2, /* size (0 = byte, 1 = short, 2 = long) */
1108 FALSE
, /* pc_relative */
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 */
1115 0xffffffff, /* dst_mask */
1116 FALSE
), /* pcrel_offset */
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 */
1123 2, /* size (0 = byte, 1 = short, 2 = long) */
1125 FALSE
, /* pc_relative */
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 */
1132 0xffffffff, /* dst_mask */
1133 FALSE
), /* pcrel_offset */
1135 /* Delete a 32 bit instruction. */
1136 /* FIXME: Not handled correctly. */
1137 HOWTO (R_MIPS_DELETE
, /* type */
1139 2, /* size (0 = byte, 1 = short, 2 = long) */
1141 FALSE
, /* pc_relative */
1143 complain_overflow_dont
, /* complain_on_overflow */
1144 _bfd_mips_elf_generic_reloc
, /* special_function */
1145 "R_MIPS_DELETE", /* name */
1146 FALSE
, /* partial_inplace */
1148 0xffffffff, /* dst_mask */
1149 FALSE
), /* pcrel_offset */
1151 /* Get the higher value of a 64 bit addend. */
1152 HOWTO (R_MIPS_HIGHER
, /* type */
1154 2, /* size (0 = byte, 1 = short, 2 = long) */
1156 FALSE
, /* pc_relative */
1158 complain_overflow_dont
, /* complain_on_overflow */
1159 _bfd_mips_elf_generic_reloc
, /* special_function */
1160 "R_MIPS_HIGHER", /* name */
1161 FALSE
, /* partial_inplace */
1163 0x0000ffff, /* dst_mask */
1164 FALSE
), /* pcrel_offset */
1166 /* Get the highest value of a 64 bit addend. */
1167 HOWTO (R_MIPS_HIGHEST
, /* type */
1169 2, /* size (0 = byte, 1 = short, 2 = long) */
1171 FALSE
, /* pc_relative */
1173 complain_overflow_dont
, /* complain_on_overflow */
1174 _bfd_mips_elf_generic_reloc
, /* special_function */
1175 "R_MIPS_HIGHEST", /* name */
1176 FALSE
, /* partial_inplace */
1178 0x0000ffff, /* dst_mask */
1179 FALSE
), /* pcrel_offset */
1181 /* High 16 bits of displacement in global offset table. */
1182 HOWTO (R_MIPS_CALL_HI16
, /* type */
1184 2, /* size (0 = byte, 1 = short, 2 = long) */
1186 FALSE
, /* pc_relative */
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 */
1193 0x0000ffff, /* dst_mask */
1194 FALSE
), /* pcrel_offset */
1196 /* Low 16 bits of displacement in global offset table. */
1197 HOWTO (R_MIPS_CALL_LO16
, /* type */
1199 2, /* size (0 = byte, 1 = short, 2 = long) */
1201 FALSE
, /* pc_relative */
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 */
1208 0x0000ffff, /* dst_mask */
1209 FALSE
), /* pcrel_offset */
1211 /* Section displacement, used by an associated event location section. */
1212 HOWTO (R_MIPS_SCN_DISP
, /* type */
1214 2, /* size (0 = byte, 1 = short, 2 = long) */
1216 FALSE
, /* pc_relative */
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 */
1223 0xffffffff, /* dst_mask */
1224 FALSE
), /* pcrel_offset */
1226 /* 16 bit relocation. */
1227 HOWTO (R_MIPS_REL16
, /* type */
1229 1, /* size (0 = byte, 1 = short, 2 = long) */
1231 FALSE
, /* pc_relative */
1233 complain_overflow_signed
, /* complain_on_overflow */
1234 _bfd_mips_elf_generic_reloc
, /* special_function */
1235 "R_MIPS_REL16", /* name */
1236 FALSE
, /* partial_inplace */
1238 0xffff, /* dst_mask */
1239 FALSE
), /* pcrel_offset */
1241 /* These two are obsolete. */
1242 EMPTY_HOWTO (R_MIPS_ADD_IMMEDIATE
),
1243 EMPTY_HOWTO (R_MIPS_PJUMP
),
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 */
1249 2, /* size (0 = byte, 1 = short, 2 = long) */
1251 FALSE
, /* pc_relative */
1253 complain_overflow_dont
, /* complain_on_overflow */
1254 _bfd_mips_elf_generic_reloc
, /* special_function */
1255 "R_MIPS_RELGOT", /* name */
1256 FALSE
, /* partial_inplace */
1258 0xffffffff, /* dst_mask */
1259 FALSE
), /* pcrel_offset */
1261 /* Protected jump conversion. This is an optimization hint. No
1262 relocation is required for correctness. */
1263 HOWTO (R_MIPS_JALR
, /* type */
1265 2, /* size (0 = byte, 1 = short, 2 = long) */
1267 FALSE
, /* pc_relative */
1269 complain_overflow_dont
, /* complain_on_overflow */
1270 _bfd_mips_elf_generic_reloc
, /* special_function */
1271 "R_MIPS_JALR", /* name */
1272 FALSE
, /* partial_inplace */
1275 FALSE
), /* pcrel_offset */
1277 /* TLS GD/LD dynamic relocations. */
1278 HOWTO (R_MIPS_TLS_DTPMOD32
, /* type */
1280 2, /* size (0 = byte, 1 = short, 2 = long) */
1282 FALSE
, /* pc_relative */
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 */
1292 HOWTO (R_MIPS_TLS_DTPREL32
, /* type */
1294 2, /* size (0 = byte, 1 = short, 2 = long) */
1296 FALSE
, /* pc_relative */
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 */
1306 EMPTY_HOWTO (R_MIPS_TLS_DTPMOD64
),
1307 EMPTY_HOWTO (R_MIPS_TLS_DTPREL64
),
1309 /* TLS general dynamic variable reference. */
1310 HOWTO (R_MIPS_TLS_GD
, /* type */
1312 2, /* size (0 = byte, 1 = short, 2 = long) */
1314 FALSE
, /* pc_relative */
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 */
1324 /* TLS local dynamic variable reference. */
1325 HOWTO (R_MIPS_TLS_LDM
, /* type */
1327 2, /* size (0 = byte, 1 = short, 2 = long) */
1329 FALSE
, /* pc_relative */
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 */
1339 /* TLS local dynamic offset. */
1340 HOWTO (R_MIPS_TLS_DTPREL_HI16
, /* type */
1342 2, /* size (0 = byte, 1 = short, 2 = long) */
1344 FALSE
, /* pc_relative */
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 */
1354 /* TLS local dynamic offset. */
1355 HOWTO (R_MIPS_TLS_DTPREL_LO16
, /* type */
1357 2, /* size (0 = byte, 1 = short, 2 = long) */
1359 FALSE
, /* pc_relative */
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 */
1369 /* TLS thread pointer offset. */
1370 HOWTO (R_MIPS_TLS_GOTTPREL
, /* type */
1372 2, /* size (0 = byte, 1 = short, 2 = long) */
1374 FALSE
, /* pc_relative */
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 */
1384 /* TLS IE dynamic relocations. */
1385 HOWTO (R_MIPS_TLS_TPREL32
, /* type */
1387 2, /* size (0 = byte, 1 = short, 2 = long) */
1389 FALSE
, /* pc_relative */
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 */
1399 EMPTY_HOWTO (R_MIPS_TLS_TPREL64
),
1401 /* TLS thread pointer offset. */
1402 HOWTO (R_MIPS_TLS_TPREL_HI16
, /* type */
1404 2, /* size (0 = byte, 1 = short, 2 = long) */
1406 FALSE
, /* pc_relative */
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 */
1416 /* TLS thread pointer offset. */
1417 HOWTO (R_MIPS_TLS_TPREL_LO16
, /* type */
1419 2, /* size (0 = byte, 1 = short, 2 = long) */
1421 FALSE
, /* pc_relative */
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 */
1432 static reloc_howto_type elf_mips16_howto_table_rel
[] =
1434 /* The reloc used for the mips16 jump instruction. */
1435 HOWTO (R_MIPS16_26
, /* type */
1437 2, /* size (0 = byte, 1 = short, 2 = long) */
1439 FALSE
, /* pc_relative */
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 */
1452 /* The reloc used for the mips16 gprel instruction. */
1453 HOWTO (R_MIPS16_GPREL
, /* type */
1455 2, /* size (0 = byte, 1 = short, 2 = long) */
1457 FALSE
, /* pc_relative */
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 */
1467 /* A placeholder for MIPS16 reference to global offset table. */
1468 EMPTY_HOWTO (R_MIPS16_GOT16
),
1470 /* A placeholder for MIPS16 16 bit call through global offset table. */
1471 EMPTY_HOWTO (R_MIPS16_CALL16
),
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) */
1478 FALSE
, /* pc_relative */
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 */
1488 /* MIPS16 low 16 bits of symbol value. */
1489 HOWTO (R_MIPS16_LO16
, /* type */
1491 2, /* size (0 = byte, 1 = short, 2 = long) */
1493 FALSE
, /* pc_relative */
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 */
1504 static reloc_howto_type elf_mips16_howto_table_rela
[] =
1506 /* The reloc used for the mips16 jump instruction. */
1507 HOWTO (R_MIPS16_26
, /* type */
1509 2, /* size (0 = byte, 1 = short, 2 = long) */
1511 FALSE
, /* pc_relative */
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 */
1524 /* The reloc used for the mips16 gprel instruction. */
1525 HOWTO (R_MIPS16_GPREL
, /* type */
1527 2, /* size (0 = byte, 1 = short, 2 = long) */
1529 FALSE
, /* pc_relative */
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 */
1539 /* A placeholder for MIPS16 reference to global offset table. */
1540 EMPTY_HOWTO (R_MIPS16_GOT16
),
1542 /* A placeholder for MIPS16 16 bit call through global offset table. */
1543 EMPTY_HOWTO (R_MIPS16_CALL16
),
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) */
1550 FALSE
, /* pc_relative */
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 */
1560 /* MIPS16 low 16 bits of symbol value. */
1561 HOWTO (R_MIPS16_LO16
, /* type */
1563 2, /* size (0 = byte, 1 = short, 2 = long) */
1565 FALSE
, /* pc_relative */
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 */
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 */
1580 2, /* size (0 = byte, 1 = short, 2 = long) */
1582 FALSE
, /* pc_relative */
1584 complain_overflow_dont
, /* complain_on_overflow */
1585 NULL
, /* special_function */
1586 "R_MIPS_GNU_VTINHERIT", /* name */
1587 FALSE
, /* partial_inplace */
1590 FALSE
); /* pcrel_offset */
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 */
1596 2, /* size (0 = byte, 1 = short, 2 = long) */
1598 FALSE
, /* pc_relative */
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 */
1606 FALSE
); /* pcrel_offset */
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 */
1612 2, /* size (0 = byte, 1 = short, 2 = long) */
1614 TRUE
, /* pc_relative */
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 */
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 */
1628 2, /* size (0 = byte, 1 = short, 2 = long) */
1630 TRUE
, /* pc_relative */
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 */
1637 0x0000ffff, /* dst_mask */
1638 TRUE
); /* pcrel_offset */
1640 /* Set the GP value for OUTPUT_BFD. Returns FALSE if this is a
1641 dangerous relocation. */
1644 mips_elf_assign_gp (bfd
*output_bfd
, bfd_vma
*pgp
)
1650 /* If we've already figured out what GP will be, just return it. */
1651 *pgp
= _bfd_get_gp_value (output_bfd
);
1655 count
= bfd_get_symcount (output_bfd
);
1656 sym
= bfd_get_outsymbols (output_bfd
);
1658 /* The linker script will have created a symbol named `_gp' with the
1659 appropriate value. */
1664 for (i
= 0; i
< count
; i
++, sym
++)
1666 register const char *name
;
1668 name
= bfd_asymbol_name (*sym
);
1669 if (*name
== '_' && strcmp (name
, "_gp") == 0)
1671 *pgp
= bfd_asymbol_value (*sym
);
1672 _bfd_set_gp_value (output_bfd
, *pgp
);
1680 /* Only get the error once. */
1682 _bfd_set_gp_value (output_bfd
, *pgp
);
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. */
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
)
1699 if (bfd_is_und_section (symbol
->section
)
1703 return bfd_reloc_undefined
;
1706 *pgp
= _bfd_get_gp_value (output_bfd
);
1709 || (symbol
->flags
& BSF_SECTION_SYM
) != 0))
1713 /* Make up a value. */
1714 *pgp
= symbol
->section
->output_section
->vma
/*+ 0x4000*/;
1715 _bfd_set_gp_value (output_bfd
, *pgp
);
1717 else if (!mips_elf_assign_gp (output_bfd
, pgp
))
1720 (char *) _("GP relative relocation when _gp not defined");
1721 return bfd_reloc_dangerous
;
1725 return bfd_reloc_ok
;
1728 /* Do a R_MIPS_GPREL16 relocation. This is a 16 bit value which must
1729 become the offset from the gp register. */
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
)
1737 bfd_boolean relocatable
;
1738 bfd_reloc_status_type ret
;
1741 if (output_bfd
!= NULL
)
1745 relocatable
= FALSE
;
1746 output_bfd
= symbol
->section
->output_section
->owner
;
1749 ret
= mips_elf_final_gp (output_bfd
, symbol
, relocatable
, error_message
,
1751 if (ret
!= bfd_reloc_ok
)
1754 return _bfd_mips_elf_gprel16_with_gp (abfd
, symbol
, reloc_entry
,
1755 input_section
, relocatable
,
1759 /* Do a R_MIPS_LITERAL relocation. */
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
)
1766 bfd_boolean relocatable
;
1767 bfd_reloc_status_type ret
;
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)
1775 *error_message
= (char *)
1776 _("literal relocation occurs for an external symbol");
1777 return bfd_reloc_outofrange
;
1780 /* FIXME: The entries in the .lit8 and .lit4 sections should be merged. */
1781 if (output_bfd
!= NULL
)
1785 relocatable
= FALSE
;
1786 output_bfd
= symbol
->section
->output_section
->owner
;
1789 ret
= mips_elf_final_gp (output_bfd
, symbol
, relocatable
, error_message
,
1791 if (ret
!= bfd_reloc_ok
)
1794 return _bfd_mips_elf_gprel16_with_gp (abfd
, symbol
, reloc_entry
,
1795 input_section
, relocatable
,
1799 /* Do a R_MIPS_GPREL32 relocation. This is a 32 bit value which must
1800 become the offset from the gp register. */
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
)
1807 bfd_boolean relocatable
;
1808 bfd_reloc_status_type ret
;
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)
1816 *error_message
= (char *)
1817 _("32bits gp relative relocation occurs for an external symbol");
1818 return bfd_reloc_outofrange
;
1821 if (output_bfd
!= NULL
)
1824 gp
= _bfd_get_gp_value (output_bfd
);
1828 relocatable
= FALSE
;
1829 output_bfd
= symbol
->section
->output_section
->owner
;
1831 ret
= mips_elf_final_gp (output_bfd
, symbol
, relocatable
,
1832 error_message
, &gp
);
1833 if (ret
!= bfd_reloc_ok
)
1837 return gprel32_with_gp (abfd
, symbol
, reloc_entry
, input_section
,
1838 relocatable
, data
, gp
);
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
)
1849 if (bfd_is_com_section (symbol
->section
))
1852 relocation
= symbol
->value
;
1854 relocation
+= symbol
->section
->output_section
->vma
;
1855 relocation
+= symbol
->section
->output_offset
;
1857 if (reloc_entry
->address
> bfd_get_section_limit (abfd
, input_section
))
1858 return bfd_reloc_outofrange
;
1860 if (reloc_entry
->howto
->src_mask
== 0)
1863 val
= bfd_get_32 (abfd
, (bfd_byte
*) data
+ reloc_entry
->address
);
1865 /* Set val to the offset into the section or symbol. */
1866 val
+= reloc_entry
->addend
;
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. */
1872 || (symbol
->flags
& BSF_SECTION_SYM
) != 0)
1873 val
+= relocation
- gp
;
1875 bfd_put_32 (abfd
, val
, (bfd_byte
*) data
+ reloc_entry
->address
);
1878 reloc_entry
->address
+= input_section
->output_offset
;
1880 return bfd_reloc_ok
;
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. */
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
)
1891 if (reloc_entry
->howto
->partial_inplace
)
1893 reloc_entry
->addend
= ((reloc_entry
->addend
& 0x00007c0)
1894 | (reloc_entry
->addend
& 0x00000800) >> 9);
1897 return _bfd_mips_elf_generic_reloc (abfd
, reloc_entry
, symbol
, data
,
1898 input_section
, output_bfd
,
1902 /* Handle a mips16 GP relative reloc. */
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
)
1909 bfd_boolean relocatable
;
1910 bfd_reloc_status_type ret
;
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)
1920 reloc_entry
->address
+= input_section
->output_offset
;
1921 return bfd_reloc_ok
;
1924 if (output_bfd
!= NULL
)
1928 relocatable
= FALSE
;
1929 output_bfd
= symbol
->section
->output_section
->owner
;
1932 ret
= mips_elf_final_gp (output_bfd
, symbol
, relocatable
, error_message
,
1934 if (ret
!= bfd_reloc_ok
)
1937 location
= (bfd_byte
*) data
+ reloc_entry
->address
;
1938 _bfd_mips16_elf_reloc_unshuffle (abfd
, reloc_entry
->howto
->type
, FALSE
,
1940 ret
= _bfd_mips_elf_gprel16_with_gp (abfd
, symbol
, reloc_entry
,
1941 input_section
, relocatable
,
1943 _bfd_mips16_elf_reloc_shuffle (abfd
, reloc_entry
->howto
->type
, !relocatable
,
1949 /* A mapping from BFD reloc types to MIPS ELF reloc types. */
1951 struct elf_reloc_map
{
1952 bfd_reloc_code_real_type bfd_val
;
1953 enum elf_mips_reloc_type elf_val
;
1956 static const struct elf_reloc_map mips_reloc_map
[] =
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
}
2008 static const struct elf_reloc_map mips16_reloc_map
[] =
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
},
2016 /* Given a BFD reloc type, return a howto structure. */
2018 static reloc_howto_type
*
2019 bfd_elf32_bfd_reloc_type_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
2020 bfd_reloc_code_real_type code
)
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
;
2028 for (i
= 0; i
< sizeof (mips_reloc_map
) / sizeof (struct elf_reloc_map
);
2031 if (mips_reloc_map
[i
].bfd_val
== code
)
2032 return &howto_table
[(int) mips_reloc_map
[i
].elf_val
];
2035 for (i
= 0; i
< sizeof (mips16_reloc_map
) / sizeof (struct elf_reloc_map
);
2038 if (mips16_reloc_map
[i
].bfd_val
== code
)
2039 return &howto16_table
[(int) mips16_reloc_map
[i
].elf_val
];
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
;
2049 bfd_set_error (bfd_error_bad_value
);
2054 /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure. */
2056 static reloc_howto_type
*
2057 mips_elf_n32_rtype_to_howto (unsigned int r_type
, bfd_boolean rela_p
)
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
:
2067 return &elf_mips_gnu_rela16_s2
;
2069 return &elf_mips_gnu_rel16_s2
;
2071 if (r_type
>= R_MIPS16_min
&& r_type
< R_MIPS16_max
)
2074 return &elf_mips16_howto_table_rela
[r_type
- R_MIPS16_min
];
2076 return &elf_mips16_howto_table_rel
[r_type
- R_MIPS16_min
];
2078 BFD_ASSERT (r_type
< (unsigned int) R_MIPS_max
);
2080 return &elf_mips_howto_table_rela
[r_type
];
2082 return &elf_mips_howto_table_rel
[r_type
];
2087 /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure. */
2090 mips_info_to_howto_rel (bfd
*abfd
, arelent
*cache_ptr
, Elf_Internal_Rela
*dst
)
2092 unsigned int r_type
;
2094 r_type
= ELF32_R_TYPE (dst
->r_info
);
2095 cache_ptr
->howto
= mips_elf_n32_rtype_to_howto (r_type
, FALSE
);
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
);
2107 /* Given a MIPS Elf_Internal_Rela, fill in an arelent structure. */
2110 mips_info_to_howto_rela (bfd
*abfd ATTRIBUTE_UNUSED
,
2111 arelent
*cache_ptr
, Elf_Internal_Rela
*dst
)
2113 unsigned int r_type
;
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
;
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. */
2127 mips_elf_sym_is_global (bfd
*abfd ATTRIBUTE_UNUSED
, asymbol
*sym
)
2129 if (SGI_COMPAT (abfd
))
2130 return (sym
->flags
& BSF_SECTION_SYM
) == 0;
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
)));
2137 /* Set the right machine number for a MIPS ELF file. */
2140 mips_elf_n32_object_p (bfd
*abfd
)
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
;
2150 mach
= _bfd_elf_mips_mach (elf_elfheader (abfd
)->e_flags
);
2151 bfd_default_set_arch_mach (abfd
, bfd_arch_mips
, mach
);
2153 if (! ABI_N32_P(abfd
))
2159 /* Support for core dump NOTE sections. */
2161 elf32_mips_grok_prstatus (bfd
*abfd
, Elf_Internal_Note
*note
)
2166 switch (note
->descsz
)
2171 case 440: /* Linux/MIPS N32 */
2173 elf_tdata (abfd
)->core_signal
= bfd_get_16 (abfd
, note
->descdata
+ 12);
2176 elf_tdata (abfd
)->core_pid
= bfd_get_32 (abfd
, note
->descdata
+ 24);
2185 /* Make a ".reg/999" section. */
2186 return _bfd_elfcore_make_pseudosection (abfd
, ".reg", size
,
2187 note
->descpos
+ offset
);
2191 elf32_mips_grok_psinfo (bfd
*abfd
, Elf_Internal_Note
*note
)
2193 switch (note
->descsz
)
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);
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. */
2210 char *command
= elf_tdata (abfd
)->core_command
;
2211 int n
= strlen (command
);
2213 if (0 < n
&& command
[n
- 1] == ' ')
2214 command
[n
- 1] = '\0';
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
)
2225 if ((abfd
->xvec
== &bfd_elf32_nbigmips_vec
)
2226 || (abfd
->xvec
== &bfd_elf32_nlittlemips_vec
))
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. */
2237 /* Alignment of debugging information. E.g., 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. */
2257 _bfd_ecoff_swap_tir_in
,
2258 _bfd_ecoff_swap_rndx_in
,
2259 /* Functions to swap out external symbolic data. */
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
2274 #define ELF_ARCH bfd_arch_mips
2275 #define ELF_MACHINE_CODE EM_MIPS
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
2323 #define elf_backend_got_header_size (4 * MIPS_RESERVED_GOTNO)
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
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
2354 /* Support for SGI-ish mips targets using n32 ABI. */
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"
2361 #define ELF_MAXPAGESIZE 0x10000
2362 #define ELF_COMMONPAGESIZE 0x1000
2364 #include "elf32-target.h"
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
2372 #undef ELF_MAXPAGESIZE
2373 #undef ELF_COMMONPAGESIZE
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"
2380 #define ELF_MAXPAGESIZE 0x10000
2381 #define ELF_COMMONPAGESIZE 0x1000
2382 #define elf32_bed elf32_tradbed
2384 /* Include the target file again for this target. */
2385 #include "elf32-target.h"