1 /* MIPS-specific support for 64-bit ELF
2 Copyright (C) 1996-2023 Free Software Foundation, Inc.
3 Ian Lance Taylor, Cygnus Support
4 Linker support added by Mark Mitchell, CodeSourcery, LLC.
5 <mark@codesourcery.com>
7 This file is part of BFD, the Binary File Descriptor library.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
22 MA 02110-1301, USA. */
25 /* This file supports the 64-bit MIPS ELF ABI.
27 The MIPS 64-bit ELF ABI uses an unusual reloc format. This file
28 overrides the usual ELF reloc handling, and handles reading and
29 writing the relocations here. */
31 /* TODO: Many things are unsupported, even if there is some code for it
32 . (which was mostly stolen from elf32-mips.c and slightly adapted).
34 . - Relocation handling for REL relocs is wrong in many cases and
36 . - Relocation handling for RELA relocs related to GOT support are
37 . also likely to be wrong.
38 . - Support for MIPS16 is untested.
39 . - Combined relocs with RSS_* entries are unsupported.
40 . - The whole GOT handling for NewABI is missing, some parts of
41 . the OldABI version is still lying around and should be removed.
51 #include "elfxx-mips.h"
54 /* Get the ECOFF swapping routines. The 64-bit ABI is not supposed to
55 use ECOFF. However, we support it anyhow for an easier changeover. */
57 #include "coff/symconst.h"
58 #include "coff/internal.h"
59 #include "coff/ecoff.h"
60 /* The 64 bit versions of the mdebug data structures are in alpha.h. */
61 #include "coff/alpha.h"
62 #define ECOFF_SIGNED_64
63 #include "ecoffswap.h"
65 static void mips_elf64_swap_reloc_in
66 (bfd
*, const Elf64_Mips_External_Rel
*, Elf64_Mips_Internal_Rela
*);
67 static void mips_elf64_swap_reloca_in
68 (bfd
*, const Elf64_Mips_External_Rela
*, Elf64_Mips_Internal_Rela
*);
69 static void mips_elf64_swap_reloc_out
70 (bfd
*, const Elf64_Mips_Internal_Rela
*, Elf64_Mips_External_Rel
*);
71 static void mips_elf64_swap_reloca_out
72 (bfd
*, const Elf64_Mips_Internal_Rela
*, Elf64_Mips_External_Rela
*);
73 static void mips_elf64_be_swap_reloc_in
74 (bfd
*, const bfd_byte
*, Elf_Internal_Rela
*);
75 static void mips_elf64_be_swap_reloc_out
76 (bfd
*, const Elf_Internal_Rela
*, bfd_byte
*);
77 static void mips_elf64_be_swap_reloca_in
78 (bfd
*, const bfd_byte
*, Elf_Internal_Rela
*);
79 static void mips_elf64_be_swap_reloca_out
80 (bfd
*, const Elf_Internal_Rela
*, bfd_byte
*);
81 static reloc_howto_type
*bfd_elf64_bfd_reloc_type_lookup
82 (bfd
*, bfd_reloc_code_real_type
);
83 static bool mips_elf64_info_to_howto_rela
84 (bfd
*, arelent
*, Elf_Internal_Rela
*);
85 static long mips_elf64_get_dynamic_reloc_upper_bound
87 static bool mips_elf64_slurp_one_reloc_table
88 (bfd
*, asection
*, Elf_Internal_Shdr
*, bfd_size_type
, arelent
*,
90 static bool mips_elf64_slurp_reloc_table
91 (bfd
*, asection
*, asymbol
**, bool);
92 static void mips_elf64_write_relocs
93 (bfd
*, asection
*, void *);
94 static void mips_elf64_write_rel
95 (bfd
*, asection
*, Elf_Internal_Shdr
*, int *, void *);
96 static void mips_elf64_write_rela
97 (bfd
*, asection
*, Elf_Internal_Shdr
*, int *, void *);
98 static bfd_reloc_status_type mips_elf64_gprel16_reloc
99 (bfd
*, arelent
*, asymbol
*, void *, asection
*, bfd
*, char **);
100 static bfd_reloc_status_type mips_elf64_literal_reloc
101 (bfd
*, arelent
*, asymbol
*, void *, asection
*, bfd
*, char **);
102 static bfd_reloc_status_type mips_elf64_gprel32_reloc
103 (bfd
*, arelent
*, asymbol
*, void *, asection
*, bfd
*, char **);
104 static bfd_reloc_status_type mips_elf64_shift6_reloc
105 (bfd
*, arelent
*, asymbol
*, void *, asection
*, bfd
*, char **);
106 static bfd_reloc_status_type mips16_gprel_reloc
107 (bfd
*, arelent
*, asymbol
*, void *, asection
*, bfd
*, char **);
108 static bool mips_elf64_assign_gp
110 static bfd_reloc_status_type mips_elf64_final_gp
111 (bfd
*, asymbol
*, bool, char **, bfd_vma
*);
112 static bool mips_elf64_object_p
114 static irix_compat_t elf64_mips_irix_compat
116 static bool elf64_mips_grok_prstatus
117 (bfd
*, Elf_Internal_Note
*);
118 static bool elf64_mips_grok_psinfo
119 (bfd
*, Elf_Internal_Note
*);
121 extern const bfd_target mips_elf64_be_vec
;
122 extern const bfd_target mips_elf64_le_vec
;
124 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
125 from smaller values. Start with zero, widen, *then* decrement. */
126 #define MINUS_ONE (((bfd_vma)0) - 1)
128 /* The number of local .got entries we reserve. */
129 #define MIPS_RESERVED_GOTNO (2)
131 /* The relocation table used for SHT_REL sections. */
133 static reloc_howto_type mips_elf64_howto_table_rel
[] =
136 HOWTO (R_MIPS_NONE
, /* type */
140 false, /* pc_relative */
142 complain_overflow_dont
, /* complain_on_overflow */
143 _bfd_mips_elf_generic_reloc
, /* special_function */
144 "R_MIPS_NONE", /* name */
145 false, /* partial_inplace */
148 false), /* pcrel_offset */
150 /* 16 bit relocation. */
151 HOWTO (R_MIPS_16
, /* type */
155 false, /* pc_relative */
157 complain_overflow_signed
, /* complain_on_overflow */
158 _bfd_mips_elf_generic_reloc
, /* special_function */
159 "R_MIPS_16", /* name */
160 true, /* partial_inplace */
161 0x0000ffff, /* src_mask */
162 0x0000ffff, /* dst_mask */
163 false), /* pcrel_offset */
165 /* 32 bit relocation. */
166 HOWTO (R_MIPS_32
, /* type */
170 false, /* pc_relative */
172 complain_overflow_dont
, /* complain_on_overflow */
173 _bfd_mips_elf_generic_reloc
, /* special_function */
174 "R_MIPS_32", /* name */
175 true, /* partial_inplace */
176 0xffffffff, /* src_mask */
177 0xffffffff, /* dst_mask */
178 false), /* pcrel_offset */
180 /* 32 bit symbol relative relocation. */
181 HOWTO (R_MIPS_REL32
, /* type */
185 false, /* pc_relative */
187 complain_overflow_dont
, /* complain_on_overflow */
188 _bfd_mips_elf_generic_reloc
, /* special_function */
189 "R_MIPS_REL32", /* name */
190 true, /* partial_inplace */
191 0xffffffff, /* src_mask */
192 0xffffffff, /* dst_mask */
193 false), /* pcrel_offset */
195 /* 26 bit jump address. */
196 HOWTO (R_MIPS_26
, /* type */
200 false, /* pc_relative */
202 complain_overflow_dont
, /* complain_on_overflow */
203 /* This needs complex overflow
204 detection, because the upper 36
205 bits must match the PC + 4. */
206 _bfd_mips_elf_generic_reloc
, /* special_function */
207 "R_MIPS_26", /* name */
208 true, /* partial_inplace */
209 0x03ffffff, /* src_mask */
210 0x03ffffff, /* dst_mask */
211 false), /* pcrel_offset */
213 /* R_MIPS_HI16 and R_MIPS_LO16 are unsupported for NewABI REL.
214 However, the native IRIX6 tools use them, so we try our best. */
216 /* High 16 bits of symbol value. */
217 HOWTO (R_MIPS_HI16
, /* type */
221 false, /* pc_relative */
223 complain_overflow_dont
, /* complain_on_overflow */
224 _bfd_mips_elf_hi16_reloc
, /* special_function */
225 "R_MIPS_HI16", /* name */
226 true, /* partial_inplace */
227 0x0000ffff, /* src_mask */
228 0x0000ffff, /* dst_mask */
229 false), /* pcrel_offset */
231 /* Low 16 bits of symbol value. */
232 HOWTO (R_MIPS_LO16
, /* type */
236 false, /* pc_relative */
238 complain_overflow_dont
, /* complain_on_overflow */
239 _bfd_mips_elf_lo16_reloc
, /* special_function */
240 "R_MIPS_LO16", /* name */
241 true, /* partial_inplace */
242 0x0000ffff, /* src_mask */
243 0x0000ffff, /* dst_mask */
244 false), /* pcrel_offset */
246 /* GP relative reference. */
247 HOWTO (R_MIPS_GPREL16
, /* type */
251 false, /* pc_relative */
253 complain_overflow_signed
, /* complain_on_overflow */
254 mips_elf64_gprel16_reloc
, /* special_function */
255 "R_MIPS_GPREL16", /* name */
256 true, /* partial_inplace */
257 0x0000ffff, /* src_mask */
258 0x0000ffff, /* dst_mask */
259 false), /* pcrel_offset */
261 /* Reference to literal section. */
262 HOWTO (R_MIPS_LITERAL
, /* type */
266 false, /* pc_relative */
268 complain_overflow_signed
, /* complain_on_overflow */
269 mips_elf64_literal_reloc
, /* special_function */
270 "R_MIPS_LITERAL", /* name */
271 true, /* partial_inplace */
272 0x0000ffff, /* src_mask */
273 0x0000ffff, /* dst_mask */
274 false), /* pcrel_offset */
276 /* Reference to global offset table. */
277 HOWTO (R_MIPS_GOT16
, /* type */
281 false, /* pc_relative */
283 complain_overflow_signed
, /* complain_on_overflow */
284 _bfd_mips_elf_got16_reloc
, /* special_function */
285 "R_MIPS_GOT16", /* name */
286 true, /* partial_inplace */
287 0x0000ffff, /* src_mask */
288 0x0000ffff, /* dst_mask */
289 false), /* pcrel_offset */
291 /* 16 bit PC relative reference. Note that the ABI document has a typo
292 and claims R_MIPS_PC16 to be not rightshifted, rendering it useless.
293 We do the right thing here. */
294 HOWTO (R_MIPS_PC16
, /* type */
298 true, /* pc_relative */
300 complain_overflow_signed
, /* complain_on_overflow */
301 _bfd_mips_elf_generic_reloc
, /* special_function */
302 "R_MIPS_PC16", /* name */
303 true, /* partial_inplace */
304 0x0000ffff, /* src_mask */
305 0x0000ffff, /* dst_mask */
306 true), /* pcrel_offset */
308 /* 16 bit call through global offset table. */
309 HOWTO (R_MIPS_CALL16
, /* type */
313 false, /* pc_relative */
315 complain_overflow_signed
, /* complain_on_overflow */
316 _bfd_mips_elf_generic_reloc
, /* special_function */
317 "R_MIPS_CALL16", /* name */
318 true, /* partial_inplace */
319 0x0000ffff, /* src_mask */
320 0x0000ffff, /* dst_mask */
321 false), /* pcrel_offset */
323 /* 32 bit GP relative reference. */
324 HOWTO (R_MIPS_GPREL32
, /* type */
328 false, /* pc_relative */
330 complain_overflow_dont
, /* complain_on_overflow */
331 mips_elf64_gprel32_reloc
, /* special_function */
332 "R_MIPS_GPREL32", /* name */
333 true, /* partial_inplace */
334 0xffffffff, /* src_mask */
335 0xffffffff, /* dst_mask */
336 false), /* pcrel_offset */
342 /* A 5 bit shift field. */
343 HOWTO (R_MIPS_SHIFT5
, /* type */
347 false, /* pc_relative */
349 complain_overflow_bitfield
, /* complain_on_overflow */
350 _bfd_mips_elf_generic_reloc
, /* special_function */
351 "R_MIPS_SHIFT5", /* name */
352 true, /* partial_inplace */
353 0x000007c0, /* src_mask */
354 0x000007c0, /* dst_mask */
355 false), /* pcrel_offset */
357 /* A 6 bit shift field. */
358 HOWTO (R_MIPS_SHIFT6
, /* type */
362 false, /* pc_relative */
364 complain_overflow_bitfield
, /* complain_on_overflow */
365 mips_elf64_shift6_reloc
, /* special_function */
366 "R_MIPS_SHIFT6", /* name */
367 true, /* partial_inplace */
368 0x000007c4, /* src_mask */
369 0x000007c4, /* dst_mask */
370 false), /* pcrel_offset */
372 /* 64 bit relocation. */
373 HOWTO (R_MIPS_64
, /* type */
377 false, /* pc_relative */
379 complain_overflow_dont
, /* complain_on_overflow */
380 _bfd_mips_elf_generic_reloc
, /* special_function */
381 "R_MIPS_64", /* name */
382 true, /* partial_inplace */
383 MINUS_ONE
, /* src_mask */
384 MINUS_ONE
, /* dst_mask */
385 false), /* pcrel_offset */
387 /* Displacement in the global offset table. */
388 HOWTO (R_MIPS_GOT_DISP
, /* type */
392 false, /* pc_relative */
394 complain_overflow_signed
, /* complain_on_overflow */
395 _bfd_mips_elf_generic_reloc
, /* special_function */
396 "R_MIPS_GOT_DISP", /* name */
397 true, /* partial_inplace */
398 0x0000ffff, /* src_mask */
399 0x0000ffff, /* dst_mask */
400 false), /* pcrel_offset */
402 /* Displacement to page pointer in the global offset table. */
403 HOWTO (R_MIPS_GOT_PAGE
, /* type */
407 false, /* pc_relative */
409 complain_overflow_signed
, /* complain_on_overflow */
410 _bfd_mips_elf_generic_reloc
, /* special_function */
411 "R_MIPS_GOT_PAGE", /* name */
412 true, /* partial_inplace */
413 0x0000ffff, /* src_mask */
414 0x0000ffff, /* dst_mask */
415 false), /* pcrel_offset */
417 /* Offset from page pointer in the global offset table. */
418 HOWTO (R_MIPS_GOT_OFST
, /* type */
422 false, /* pc_relative */
424 complain_overflow_signed
, /* complain_on_overflow */
425 _bfd_mips_elf_generic_reloc
, /* special_function */
426 "R_MIPS_GOT_OFST", /* name */
427 true, /* partial_inplace */
428 0x0000ffff, /* src_mask */
429 0x0000ffff, /* dst_mask */
430 false), /* pcrel_offset */
432 /* High 16 bits of displacement in global offset table. */
433 HOWTO (R_MIPS_GOT_HI16
, /* type */
437 false, /* pc_relative */
439 complain_overflow_dont
, /* complain_on_overflow */
440 _bfd_mips_elf_generic_reloc
, /* special_function */
441 "R_MIPS_GOT_HI16", /* name */
442 true, /* partial_inplace */
443 0x0000ffff, /* src_mask */
444 0x0000ffff, /* dst_mask */
445 false), /* pcrel_offset */
447 /* Low 16 bits of displacement in global offset table. */
448 HOWTO (R_MIPS_GOT_LO16
, /* type */
452 false, /* pc_relative */
454 complain_overflow_dont
, /* complain_on_overflow */
455 _bfd_mips_elf_generic_reloc
, /* special_function */
456 "R_MIPS_GOT_LO16", /* name */
457 true, /* partial_inplace */
458 0x0000ffff, /* src_mask */
459 0x0000ffff, /* dst_mask */
460 false), /* pcrel_offset */
462 /* 64 bit subtraction. */
463 HOWTO (R_MIPS_SUB
, /* type */
467 false, /* pc_relative */
469 complain_overflow_dont
, /* complain_on_overflow */
470 _bfd_mips_elf_generic_reloc
, /* special_function */
471 "R_MIPS_SUB", /* name */
472 true, /* partial_inplace */
473 MINUS_ONE
, /* src_mask */
474 MINUS_ONE
, /* dst_mask */
475 false), /* pcrel_offset */
477 /* Insert the addend as an instruction. */
478 /* FIXME: Not handled correctly. */
479 HOWTO (R_MIPS_INSERT_A
, /* type */
483 false, /* pc_relative */
485 complain_overflow_dont
, /* complain_on_overflow */
486 _bfd_mips_elf_generic_reloc
, /* special_function */
487 "R_MIPS_INSERT_A", /* name */
488 true, /* partial_inplace */
489 0xffffffff, /* src_mask */
490 0xffffffff, /* dst_mask */
491 false), /* pcrel_offset */
493 /* Insert the addend as an instruction, and change all relocations
494 to refer to the old instruction at the address. */
495 /* FIXME: Not handled correctly. */
496 HOWTO (R_MIPS_INSERT_B
, /* type */
500 false, /* pc_relative */
502 complain_overflow_dont
, /* complain_on_overflow */
503 _bfd_mips_elf_generic_reloc
, /* special_function */
504 "R_MIPS_INSERT_B", /* name */
505 true, /* partial_inplace */
506 0xffffffff, /* src_mask */
507 0xffffffff, /* dst_mask */
508 false), /* pcrel_offset */
510 /* Delete a 32 bit instruction. */
511 /* FIXME: Not handled correctly. */
512 HOWTO (R_MIPS_DELETE
, /* type */
516 false, /* pc_relative */
518 complain_overflow_dont
, /* complain_on_overflow */
519 _bfd_mips_elf_generic_reloc
, /* special_function */
520 "R_MIPS_DELETE", /* name */
521 true, /* partial_inplace */
522 0xffffffff, /* src_mask */
523 0xffffffff, /* dst_mask */
524 false), /* pcrel_offset */
526 /* The MIPS ELF64 ABI Draft wants us to support these for REL relocations.
528 a) It means building the addend from a R_MIPS_HIGHEST/R_MIPS_HIGHER/
529 R_MIPS_HI16/R_MIPS_LO16 sequence with varying ordering, using
531 b) No other NewABI toolchain actually emits such relocations. */
532 EMPTY_HOWTO (R_MIPS_HIGHER
),
533 EMPTY_HOWTO (R_MIPS_HIGHEST
),
535 /* High 16 bits of displacement in global offset table. */
536 HOWTO (R_MIPS_CALL_HI16
, /* type */
540 false, /* pc_relative */
542 complain_overflow_dont
, /* complain_on_overflow */
543 _bfd_mips_elf_generic_reloc
, /* special_function */
544 "R_MIPS_CALL_HI16", /* name */
545 true, /* partial_inplace */
546 0x0000ffff, /* src_mask */
547 0x0000ffff, /* dst_mask */
548 false), /* pcrel_offset */
550 /* Low 16 bits of displacement in global offset table. */
551 HOWTO (R_MIPS_CALL_LO16
, /* type */
555 false, /* pc_relative */
557 complain_overflow_dont
, /* complain_on_overflow */
558 _bfd_mips_elf_generic_reloc
, /* special_function */
559 "R_MIPS_CALL_LO16", /* name */
560 true, /* partial_inplace */
561 0x0000ffff, /* src_mask */
562 0x0000ffff, /* dst_mask */
563 false), /* pcrel_offset */
565 /* Section displacement, used by an associated event location section. */
566 HOWTO (R_MIPS_SCN_DISP
, /* type */
570 false, /* pc_relative */
572 complain_overflow_dont
, /* complain_on_overflow */
573 _bfd_mips_elf_generic_reloc
, /* special_function */
574 "R_MIPS_SCN_DISP", /* name */
575 true, /* partial_inplace */
576 0xffffffff, /* src_mask */
577 0xffffffff, /* dst_mask */
578 false), /* pcrel_offset */
580 HOWTO (R_MIPS_REL16
, /* type */
584 false, /* pc_relative */
586 complain_overflow_signed
, /* complain_on_overflow */
587 _bfd_mips_elf_generic_reloc
, /* special_function */
588 "R_MIPS_REL16", /* name */
589 true, /* partial_inplace */
590 0xffff, /* src_mask */
591 0xffff, /* dst_mask */
592 false), /* pcrel_offset */
594 /* These two are obsolete. */
595 EMPTY_HOWTO (R_MIPS_ADD_IMMEDIATE
),
596 EMPTY_HOWTO (R_MIPS_PJUMP
),
598 /* Similiar to R_MIPS_REL32, but used for relocations in a GOT section.
599 It must be used for multigot GOT's (and only there). */
600 HOWTO (R_MIPS_RELGOT
, /* type */
604 false, /* pc_relative */
606 complain_overflow_dont
, /* complain_on_overflow */
607 _bfd_mips_elf_generic_reloc
, /* special_function */
608 "R_MIPS_RELGOT", /* name */
609 true, /* partial_inplace */
610 0xffffffff, /* src_mask */
611 0xffffffff, /* dst_mask */
612 false), /* pcrel_offset */
614 /* Protected jump conversion. This is an optimization hint. No
615 relocation is required for correctness. */
616 HOWTO (R_MIPS_JALR
, /* type */
620 false, /* pc_relative */
622 complain_overflow_dont
, /* complain_on_overflow */
623 _bfd_mips_elf_generic_reloc
, /* special_function */
624 "R_MIPS_JALR", /* name */
625 false, /* partial_inplace */
627 0x00000000, /* dst_mask */
628 false), /* pcrel_offset */
630 /* TLS relocations. */
631 EMPTY_HOWTO (R_MIPS_TLS_DTPMOD32
),
632 EMPTY_HOWTO (R_MIPS_TLS_DTPREL32
),
634 HOWTO (R_MIPS_TLS_DTPMOD64
, /* type */
638 false, /* pc_relative */
640 complain_overflow_dont
, /* complain_on_overflow */
641 _bfd_mips_elf_generic_reloc
, /* special_function */
642 "R_MIPS_TLS_DTPMOD64", /* name */
643 true, /* partial_inplace */
644 MINUS_ONE
, /* src_mask */
645 MINUS_ONE
, /* dst_mask */
646 false), /* pcrel_offset */
648 HOWTO (R_MIPS_TLS_DTPREL64
, /* type */
652 false, /* pc_relative */
654 complain_overflow_dont
, /* complain_on_overflow */
655 _bfd_mips_elf_generic_reloc
, /* special_function */
656 "R_MIPS_TLS_DTPREL64", /* name */
657 true, /* partial_inplace */
658 MINUS_ONE
, /* src_mask */
659 MINUS_ONE
, /* dst_mask */
660 false), /* pcrel_offset */
662 /* TLS general dynamic variable reference. */
663 HOWTO (R_MIPS_TLS_GD
, /* type */
667 false, /* pc_relative */
669 complain_overflow_signed
, /* complain_on_overflow */
670 _bfd_mips_elf_generic_reloc
, /* special_function */
671 "R_MIPS_TLS_GD", /* name */
672 true, /* partial_inplace */
673 0x0000ffff, /* src_mask */
674 0x0000ffff, /* dst_mask */
675 false), /* pcrel_offset */
677 /* TLS local dynamic variable reference. */
678 HOWTO (R_MIPS_TLS_LDM
, /* type */
682 false, /* pc_relative */
684 complain_overflow_signed
, /* complain_on_overflow */
685 _bfd_mips_elf_generic_reloc
, /* special_function */
686 "R_MIPS_TLS_LDM", /* name */
687 true, /* partial_inplace */
688 0x0000ffff, /* src_mask */
689 0x0000ffff, /* dst_mask */
690 false), /* pcrel_offset */
692 /* TLS local dynamic offset. */
693 HOWTO (R_MIPS_TLS_DTPREL_HI16
, /* type */
697 false, /* pc_relative */
699 complain_overflow_signed
, /* complain_on_overflow */
700 _bfd_mips_elf_generic_reloc
, /* special_function */
701 "R_MIPS_TLS_DTPREL_HI16", /* name */
702 true, /* partial_inplace */
703 0x0000ffff, /* src_mask */
704 0x0000ffff, /* dst_mask */
705 false), /* pcrel_offset */
707 /* TLS local dynamic offset. */
708 HOWTO (R_MIPS_TLS_DTPREL_LO16
, /* type */
712 false, /* pc_relative */
714 complain_overflow_signed
, /* complain_on_overflow */
715 _bfd_mips_elf_generic_reloc
, /* special_function */
716 "R_MIPS_TLS_DTPREL_LO16", /* name */
717 true, /* partial_inplace */
718 0x0000ffff, /* src_mask */
719 0x0000ffff, /* dst_mask */
720 false), /* pcrel_offset */
722 /* TLS thread pointer offset. */
723 HOWTO (R_MIPS_TLS_GOTTPREL
, /* type */
727 false, /* pc_relative */
729 complain_overflow_signed
, /* complain_on_overflow */
730 _bfd_mips_elf_generic_reloc
, /* special_function */
731 "R_MIPS_TLS_GOTTPREL", /* name */
732 true, /* partial_inplace */
733 0x0000ffff, /* src_mask */
734 0x0000ffff, /* dst_mask */
735 false), /* pcrel_offset */
737 /* TLS IE dynamic relocations. */
738 EMPTY_HOWTO (R_MIPS_TLS_TPREL32
),
740 HOWTO (R_MIPS_TLS_TPREL64
, /* type */
744 false, /* pc_relative */
746 complain_overflow_dont
, /* complain_on_overflow */
747 _bfd_mips_elf_generic_reloc
, /* special_function */
748 "R_MIPS_TLS_TPREL64", /* name */
749 true, /* partial_inplace */
750 MINUS_ONE
, /* src_mask */
751 MINUS_ONE
, /* dst_mask */
752 false), /* pcrel_offset */
754 /* TLS thread pointer offset. */
755 HOWTO (R_MIPS_TLS_TPREL_HI16
, /* type */
759 false, /* pc_relative */
761 complain_overflow_signed
, /* complain_on_overflow */
762 _bfd_mips_elf_generic_reloc
, /* special_function */
763 "R_MIPS_TLS_TPREL_HI16", /* name */
764 true, /* partial_inplace */
765 0x0000ffff, /* src_mask */
766 0x0000ffff, /* dst_mask */
767 false), /* pcrel_offset */
769 /* TLS thread pointer offset. */
770 HOWTO (R_MIPS_TLS_TPREL_LO16
, /* type */
774 false, /* pc_relative */
776 complain_overflow_signed
, /* complain_on_overflow */
777 _bfd_mips_elf_generic_reloc
, /* special_function */
778 "R_MIPS_TLS_TPREL_LO16", /* name */
779 true, /* partial_inplace */
780 0x0000ffff, /* src_mask */
781 0x0000ffff, /* dst_mask */
782 false), /* pcrel_offset */
784 /* 32 bit relocation with no addend. */
785 HOWTO (R_MIPS_GLOB_DAT
, /* type */
789 false, /* pc_relative */
791 complain_overflow_dont
, /* complain_on_overflow */
792 _bfd_mips_elf_generic_reloc
, /* special_function */
793 "R_MIPS_GLOB_DAT", /* name */
794 false, /* partial_inplace */
796 0xffffffff, /* dst_mask */
797 false), /* pcrel_offset */
808 HOWTO (R_MIPS_PC21_S2
, /* type */
812 true, /* pc_relative */
814 complain_overflow_signed
, /* complain_on_overflow */
815 _bfd_mips_elf_generic_reloc
, /* special_function */
816 "R_MIPS_PC21_S2", /* name */
817 true, /* partial_inplace */
818 0x001fffff, /* src_mask */
819 0x001fffff, /* dst_mask */
820 true), /* pcrel_offset */
822 HOWTO (R_MIPS_PC26_S2
, /* type */
826 true, /* pc_relative */
828 complain_overflow_signed
, /* complain_on_overflow */
829 _bfd_mips_elf_generic_reloc
, /* special_function */
830 "R_MIPS_PC26_S2", /* name */
831 true, /* partial_inplace */
832 0x03ffffff, /* src_mask */
833 0x03ffffff, /* dst_mask */
834 true), /* pcrel_offset */
836 HOWTO (R_MIPS_PC18_S3
, /* type */
840 true, /* pc_relative */
842 complain_overflow_signed
, /* complain_on_overflow */
843 _bfd_mips_elf_generic_reloc
, /* special_function */
844 "R_MIPS_PC18_S3", /* name */
845 true, /* partial_inplace */
846 0x0003ffff, /* src_mask */
847 0x0003ffff, /* dst_mask */
848 true), /* pcrel_offset */
850 HOWTO (R_MIPS_PC19_S2
, /* type */
854 true, /* pc_relative */
856 complain_overflow_signed
, /* complain_on_overflow */
857 _bfd_mips_elf_generic_reloc
, /* special_function */
858 "R_MIPS_PC19_S2", /* name */
859 true, /* partial_inplace */
860 0x0007ffff, /* src_mask */
861 0x0007ffff, /* dst_mask */
862 true), /* pcrel_offset */
864 HOWTO (R_MIPS_PCHI16
, /* type */
868 true, /* pc_relative */
870 complain_overflow_signed
, /* complain_on_overflow */
871 _bfd_mips_elf_generic_reloc
, /* special_function */
872 "R_MIPS_PCHI16", /* name */
873 true, /* partial_inplace */
874 0x0000ffff, /* src_mask */
875 0x0000ffff, /* dst_mask */
876 true), /* pcrel_offset */
878 HOWTO (R_MIPS_PCLO16
, /* type */
882 true, /* pc_relative */
884 complain_overflow_dont
, /* complain_on_overflow */
885 _bfd_mips_elf_generic_reloc
, /* special_function */
886 "R_MIPS_PCLO16", /* name */
887 true, /* partial_inplace */
888 0x0000ffff, /* src_mask */
889 0x0000ffff, /* dst_mask */
890 true), /* pcrel_offset */
894 /* The relocation table used for SHT_RELA sections. */
896 static reloc_howto_type mips_elf64_howto_table_rela
[] =
899 HOWTO (R_MIPS_NONE
, /* type */
903 false, /* pc_relative */
905 complain_overflow_dont
, /* complain_on_overflow */
906 _bfd_mips_elf_generic_reloc
, /* special_function */
907 "R_MIPS_NONE", /* name */
908 false, /* partial_inplace */
911 false), /* pcrel_offset */
913 /* 16 bit relocation. */
914 HOWTO (R_MIPS_16
, /* type */
918 false, /* pc_relative */
920 complain_overflow_signed
, /* complain_on_overflow */
921 _bfd_mips_elf_generic_reloc
, /* special_function */
922 "R_MIPS_16", /* name */
923 false, /* partial_inplace */
925 0x0000ffff, /* dst_mask */
926 false), /* pcrel_offset */
928 /* 32 bit relocation. */
929 HOWTO (R_MIPS_32
, /* type */
933 false, /* pc_relative */
935 complain_overflow_dont
, /* complain_on_overflow */
936 _bfd_mips_elf_generic_reloc
, /* special_function */
937 "R_MIPS_32", /* name */
938 false, /* partial_inplace */
940 0xffffffff, /* dst_mask */
941 false), /* pcrel_offset */
943 /* 32 bit symbol relative relocation. */
944 HOWTO (R_MIPS_REL32
, /* type */
948 false, /* pc_relative */
950 complain_overflow_dont
, /* complain_on_overflow */
951 _bfd_mips_elf_generic_reloc
, /* special_function */
952 "R_MIPS_REL32", /* name */
953 false, /* partial_inplace */
955 0xffffffff, /* dst_mask */
956 false), /* pcrel_offset */
958 /* 26 bit jump address. */
959 HOWTO (R_MIPS_26
, /* type */
963 false, /* pc_relative */
965 complain_overflow_dont
, /* complain_on_overflow */
966 /* This needs complex overflow
967 detection, because the upper 36
968 bits must match the PC + 4. */
969 _bfd_mips_elf_generic_reloc
, /* special_function */
970 "R_MIPS_26", /* name */
971 false, /* partial_inplace */
973 0x03ffffff, /* dst_mask */
974 false), /* pcrel_offset */
976 /* High 16 bits of symbol value. */
977 HOWTO (R_MIPS_HI16
, /* type */
981 false, /* pc_relative */
983 complain_overflow_dont
, /* complain_on_overflow */
984 _bfd_mips_elf_generic_reloc
, /* special_function */
985 "R_MIPS_HI16", /* name */
986 false, /* partial_inplace */
988 0x0000ffff, /* dst_mask */
989 false), /* pcrel_offset */
991 /* Low 16 bits of symbol value. */
992 HOWTO (R_MIPS_LO16
, /* type */
996 false, /* pc_relative */
998 complain_overflow_dont
, /* complain_on_overflow */
999 _bfd_mips_elf_generic_reloc
, /* special_function */
1000 "R_MIPS_LO16", /* name */
1001 false, /* partial_inplace */
1003 0x0000ffff, /* dst_mask */
1004 false), /* pcrel_offset */
1006 /* GP relative reference. */
1007 HOWTO (R_MIPS_GPREL16
, /* type */
1011 false, /* pc_relative */
1013 complain_overflow_signed
, /* complain_on_overflow */
1014 mips_elf64_gprel16_reloc
, /* special_function */
1015 "R_MIPS_GPREL16", /* name */
1016 false, /* partial_inplace */
1018 0x0000ffff, /* dst_mask */
1019 false), /* pcrel_offset */
1021 /* Reference to literal section. */
1022 HOWTO (R_MIPS_LITERAL
, /* type */
1026 false, /* pc_relative */
1028 complain_overflow_signed
, /* complain_on_overflow */
1029 mips_elf64_literal_reloc
, /* special_function */
1030 "R_MIPS_LITERAL", /* name */
1031 false, /* partial_inplace */
1033 0x0000ffff, /* dst_mask */
1034 false), /* pcrel_offset */
1036 /* Reference to global offset table. */
1037 HOWTO (R_MIPS_GOT16
, /* type */
1041 false, /* pc_relative */
1043 complain_overflow_signed
, /* complain_on_overflow */
1044 _bfd_mips_elf_generic_reloc
, /* special_function */
1045 "R_MIPS_GOT16", /* name */
1046 false, /* partial_inplace */
1048 0x0000ffff, /* dst_mask */
1049 false), /* pcrel_offset */
1051 /* 16 bit PC relative reference. Note that the ABI document has a typo
1052 and claims R_MIPS_PC16 to be not rightshifted, rendering it useless.
1053 We do the right thing here. */
1054 HOWTO (R_MIPS_PC16
, /* type */
1058 true, /* pc_relative */
1060 complain_overflow_signed
, /* complain_on_overflow */
1061 _bfd_mips_elf_generic_reloc
, /* special_function */
1062 "R_MIPS_PC16", /* name */
1063 false, /* partial_inplace */
1065 0x0000ffff, /* dst_mask */
1066 true), /* pcrel_offset */
1068 /* 16 bit call through global offset table. */
1069 HOWTO (R_MIPS_CALL16
, /* type */
1073 false, /* pc_relative */
1075 complain_overflow_signed
, /* complain_on_overflow */
1076 _bfd_mips_elf_generic_reloc
, /* special_function */
1077 "R_MIPS_CALL16", /* name */
1078 false, /* partial_inplace */
1080 0x0000ffff, /* dst_mask */
1081 false), /* pcrel_offset */
1083 /* 32 bit GP relative reference. */
1084 HOWTO (R_MIPS_GPREL32
, /* type */
1088 false, /* pc_relative */
1090 complain_overflow_dont
, /* complain_on_overflow */
1091 mips_elf64_gprel32_reloc
, /* special_function */
1092 "R_MIPS_GPREL32", /* name */
1093 false, /* partial_inplace */
1095 0xffffffff, /* dst_mask */
1096 false), /* pcrel_offset */
1102 /* A 5 bit shift field. */
1103 HOWTO (R_MIPS_SHIFT5
, /* type */
1107 false, /* pc_relative */
1109 complain_overflow_bitfield
, /* complain_on_overflow */
1110 _bfd_mips_elf_generic_reloc
, /* special_function */
1111 "R_MIPS_SHIFT5", /* name */
1112 false, /* partial_inplace */
1114 0x000007c0, /* dst_mask */
1115 false), /* pcrel_offset */
1117 /* A 6 bit shift field. */
1118 HOWTO (R_MIPS_SHIFT6
, /* type */
1122 false, /* pc_relative */
1124 complain_overflow_bitfield
, /* complain_on_overflow */
1125 mips_elf64_shift6_reloc
, /* special_function */
1126 "R_MIPS_SHIFT6", /* name */
1127 false, /* partial_inplace */
1129 0x000007c4, /* dst_mask */
1130 false), /* pcrel_offset */
1132 /* 64 bit relocation. */
1133 HOWTO (R_MIPS_64
, /* type */
1137 false, /* pc_relative */
1139 complain_overflow_dont
, /* complain_on_overflow */
1140 _bfd_mips_elf_generic_reloc
, /* special_function */
1141 "R_MIPS_64", /* name */
1142 false, /* partial_inplace */
1144 MINUS_ONE
, /* dst_mask */
1145 false), /* pcrel_offset */
1147 /* Displacement in the global offset table. */
1148 HOWTO (R_MIPS_GOT_DISP
, /* type */
1152 false, /* pc_relative */
1154 complain_overflow_signed
, /* complain_on_overflow */
1155 _bfd_mips_elf_generic_reloc
, /* special_function */
1156 "R_MIPS_GOT_DISP", /* name */
1157 false, /* partial_inplace */
1159 0x0000ffff, /* dst_mask */
1160 false), /* pcrel_offset */
1162 /* Displacement to page pointer in the global offset table. */
1163 HOWTO (R_MIPS_GOT_PAGE
, /* type */
1167 false, /* pc_relative */
1169 complain_overflow_signed
, /* complain_on_overflow */
1170 _bfd_mips_elf_generic_reloc
, /* special_function */
1171 "R_MIPS_GOT_PAGE", /* name */
1172 false, /* partial_inplace */
1174 0x0000ffff, /* dst_mask */
1175 false), /* pcrel_offset */
1177 /* Offset from page pointer in the global offset table. */
1178 HOWTO (R_MIPS_GOT_OFST
, /* type */
1182 false, /* pc_relative */
1184 complain_overflow_signed
, /* complain_on_overflow */
1185 _bfd_mips_elf_generic_reloc
, /* special_function */
1186 "R_MIPS_GOT_OFST", /* name */
1187 false, /* partial_inplace */
1189 0x0000ffff, /* dst_mask */
1190 false), /* pcrel_offset */
1192 /* High 16 bits of displacement in global offset table. */
1193 HOWTO (R_MIPS_GOT_HI16
, /* type */
1197 false, /* pc_relative */
1199 complain_overflow_dont
, /* complain_on_overflow */
1200 _bfd_mips_elf_generic_reloc
, /* special_function */
1201 "R_MIPS_GOT_HI16", /* name */
1202 false, /* partial_inplace */
1204 0x0000ffff, /* dst_mask */
1205 false), /* pcrel_offset */
1207 /* Low 16 bits of displacement in global offset table. */
1208 HOWTO (R_MIPS_GOT_LO16
, /* type */
1212 false, /* pc_relative */
1214 complain_overflow_dont
, /* complain_on_overflow */
1215 _bfd_mips_elf_generic_reloc
, /* special_function */
1216 "R_MIPS_GOT_LO16", /* name */
1217 false, /* partial_inplace */
1219 0x0000ffff, /* dst_mask */
1220 false), /* pcrel_offset */
1222 /* 64 bit subtraction. */
1223 HOWTO (R_MIPS_SUB
, /* type */
1227 false, /* pc_relative */
1229 complain_overflow_dont
, /* complain_on_overflow */
1230 _bfd_mips_elf_generic_reloc
, /* special_function */
1231 "R_MIPS_SUB", /* name */
1232 false, /* partial_inplace */
1234 MINUS_ONE
, /* dst_mask */
1235 false), /* pcrel_offset */
1237 /* Insert the addend as an instruction. */
1238 /* FIXME: Not handled correctly. */
1239 HOWTO (R_MIPS_INSERT_A
, /* type */
1243 false, /* pc_relative */
1245 complain_overflow_dont
, /* complain_on_overflow */
1246 _bfd_mips_elf_generic_reloc
, /* special_function */
1247 "R_MIPS_INSERT_A", /* name */
1248 false, /* partial_inplace */
1250 0xffffffff, /* dst_mask */
1251 false), /* pcrel_offset */
1253 /* Insert the addend as an instruction, and change all relocations
1254 to refer to the old instruction at the address. */
1255 /* FIXME: Not handled correctly. */
1256 HOWTO (R_MIPS_INSERT_B
, /* type */
1260 false, /* pc_relative */
1262 complain_overflow_dont
, /* complain_on_overflow */
1263 _bfd_mips_elf_generic_reloc
, /* special_function */
1264 "R_MIPS_INSERT_B", /* name */
1265 false, /* partial_inplace */
1267 0xffffffff, /* dst_mask */
1268 false), /* pcrel_offset */
1270 /* Delete a 32 bit instruction. */
1271 /* FIXME: Not handled correctly. */
1272 HOWTO (R_MIPS_DELETE
, /* type */
1276 false, /* pc_relative */
1278 complain_overflow_dont
, /* complain_on_overflow */
1279 _bfd_mips_elf_generic_reloc
, /* special_function */
1280 "R_MIPS_DELETE", /* name */
1281 false, /* partial_inplace */
1283 0xffffffff, /* dst_mask */
1284 false), /* pcrel_offset */
1286 /* Get the higher value of a 64 bit addend. */
1287 HOWTO (R_MIPS_HIGHER
, /* type */
1291 false, /* pc_relative */
1293 complain_overflow_dont
, /* complain_on_overflow */
1294 _bfd_mips_elf_generic_reloc
, /* special_function */
1295 "R_MIPS_HIGHER", /* name */
1296 false, /* partial_inplace */
1298 0x0000ffff, /* dst_mask */
1299 false), /* pcrel_offset */
1301 /* Get the highest value of a 64 bit addend. */
1302 HOWTO (R_MIPS_HIGHEST
, /* type */
1306 false, /* pc_relative */
1308 complain_overflow_dont
, /* complain_on_overflow */
1309 _bfd_mips_elf_generic_reloc
, /* special_function */
1310 "R_MIPS_HIGHEST", /* name */
1311 false, /* partial_inplace */
1313 0x0000ffff, /* dst_mask */
1314 false), /* pcrel_offset */
1316 /* High 16 bits of displacement in global offset table. */
1317 HOWTO (R_MIPS_CALL_HI16
, /* type */
1321 false, /* pc_relative */
1323 complain_overflow_dont
, /* complain_on_overflow */
1324 _bfd_mips_elf_generic_reloc
, /* special_function */
1325 "R_MIPS_CALL_HI16", /* name */
1326 false, /* partial_inplace */
1328 0x0000ffff, /* dst_mask */
1329 false), /* pcrel_offset */
1331 /* Low 16 bits of displacement in global offset table. */
1332 HOWTO (R_MIPS_CALL_LO16
, /* type */
1336 false, /* pc_relative */
1338 complain_overflow_dont
, /* complain_on_overflow */
1339 _bfd_mips_elf_generic_reloc
, /* special_function */
1340 "R_MIPS_CALL_LO16", /* name */
1341 false, /* partial_inplace */
1343 0x0000ffff, /* dst_mask */
1344 false), /* pcrel_offset */
1346 /* Section displacement, used by an associated event location section. */
1347 HOWTO (R_MIPS_SCN_DISP
, /* type */
1351 false, /* pc_relative */
1353 complain_overflow_dont
, /* complain_on_overflow */
1354 _bfd_mips_elf_generic_reloc
, /* special_function */
1355 "R_MIPS_SCN_DISP", /* name */
1356 false, /* partial_inplace */
1358 0xffffffff, /* dst_mask */
1359 false), /* pcrel_offset */
1361 HOWTO (R_MIPS_REL16
, /* type */
1365 false, /* pc_relative */
1367 complain_overflow_signed
, /* complain_on_overflow */
1368 _bfd_mips_elf_generic_reloc
, /* special_function */
1369 "R_MIPS_REL16", /* name */
1370 false, /* partial_inplace */
1372 0xffff, /* dst_mask */
1373 false), /* pcrel_offset */
1375 /* These two are obsolete. */
1376 EMPTY_HOWTO (R_MIPS_ADD_IMMEDIATE
),
1377 EMPTY_HOWTO (R_MIPS_PJUMP
),
1379 /* Similiar to R_MIPS_REL32, but used for relocations in a GOT section.
1380 It must be used for multigot GOT's (and only there). */
1381 HOWTO (R_MIPS_RELGOT
, /* type */
1385 false, /* pc_relative */
1387 complain_overflow_dont
, /* complain_on_overflow */
1388 _bfd_mips_elf_generic_reloc
, /* special_function */
1389 "R_MIPS_RELGOT", /* name */
1390 false, /* partial_inplace */
1392 0xffffffff, /* dst_mask */
1393 false), /* pcrel_offset */
1395 /* Protected jump conversion. This is an optimization hint. No
1396 relocation is required for correctness. */
1397 HOWTO (R_MIPS_JALR
, /* type */
1401 false, /* pc_relative */
1403 complain_overflow_dont
, /* complain_on_overflow */
1404 _bfd_mips_elf_generic_reloc
, /* special_function */
1405 "R_MIPS_JALR", /* name */
1406 false, /* partial_inplace */
1408 0x00000000, /* dst_mask */
1409 false), /* pcrel_offset */
1411 /* TLS relocations. */
1412 EMPTY_HOWTO (R_MIPS_TLS_DTPMOD32
),
1413 EMPTY_HOWTO (R_MIPS_TLS_DTPREL32
),
1415 HOWTO (R_MIPS_TLS_DTPMOD64
, /* type */
1419 false, /* pc_relative */
1421 complain_overflow_dont
, /* complain_on_overflow */
1422 _bfd_mips_elf_generic_reloc
, /* special_function */
1423 "R_MIPS_TLS_DTPMOD64", /* name */
1424 false, /* partial_inplace */
1426 MINUS_ONE
, /* dst_mask */
1427 false), /* pcrel_offset */
1429 HOWTO (R_MIPS_TLS_DTPREL64
, /* type */
1433 false, /* pc_relative */
1435 complain_overflow_dont
, /* complain_on_overflow */
1436 _bfd_mips_elf_generic_reloc
, /* special_function */
1437 "R_MIPS_TLS_DTPREL64", /* name */
1438 false, /* partial_inplace */
1440 MINUS_ONE
, /* dst_mask */
1441 false), /* pcrel_offset */
1443 /* TLS general dynamic variable reference. */
1444 HOWTO (R_MIPS_TLS_GD
, /* type */
1448 false, /* pc_relative */
1450 complain_overflow_signed
, /* complain_on_overflow */
1451 _bfd_mips_elf_generic_reloc
, /* special_function */
1452 "R_MIPS_TLS_GD", /* name */
1453 false, /* partial_inplace */
1455 0x0000ffff, /* dst_mask */
1456 false), /* pcrel_offset */
1458 /* TLS local dynamic variable reference. */
1459 HOWTO (R_MIPS_TLS_LDM
, /* type */
1463 false, /* pc_relative */
1465 complain_overflow_signed
, /* complain_on_overflow */
1466 _bfd_mips_elf_generic_reloc
, /* special_function */
1467 "R_MIPS_TLS_LDM", /* name */
1468 false, /* partial_inplace */
1470 0x0000ffff, /* dst_mask */
1471 false), /* pcrel_offset */
1473 /* TLS local dynamic offset. */
1474 HOWTO (R_MIPS_TLS_DTPREL_HI16
, /* type */
1478 false, /* pc_relative */
1480 complain_overflow_signed
, /* complain_on_overflow */
1481 _bfd_mips_elf_generic_reloc
, /* special_function */
1482 "R_MIPS_TLS_DTPREL_HI16", /* name */
1483 false, /* partial_inplace */
1485 0x0000ffff, /* dst_mask */
1486 false), /* pcrel_offset */
1488 /* TLS local dynamic offset. */
1489 HOWTO (R_MIPS_TLS_DTPREL_LO16
, /* type */
1493 false, /* pc_relative */
1495 complain_overflow_signed
, /* complain_on_overflow */
1496 _bfd_mips_elf_generic_reloc
, /* special_function */
1497 "R_MIPS_TLS_DTPREL_LO16", /* name */
1498 false, /* partial_inplace */
1500 0x0000ffff, /* dst_mask */
1501 false), /* pcrel_offset */
1503 /* TLS thread pointer offset. */
1504 HOWTO (R_MIPS_TLS_GOTTPREL
, /* type */
1508 false, /* pc_relative */
1510 complain_overflow_signed
, /* complain_on_overflow */
1511 _bfd_mips_elf_generic_reloc
, /* special_function */
1512 "R_MIPS_TLS_GOTTPREL", /* name */
1513 false, /* partial_inplace */
1515 0x0000ffff, /* dst_mask */
1516 false), /* pcrel_offset */
1518 /* TLS IE dynamic relocations. */
1519 EMPTY_HOWTO (R_MIPS_TLS_TPREL32
),
1521 HOWTO (R_MIPS_TLS_TPREL64
, /* type */
1525 false, /* pc_relative */
1527 complain_overflow_dont
, /* complain_on_overflow */
1528 _bfd_mips_elf_generic_reloc
, /* special_function */
1529 "R_MIPS_TLS_TPREL64", /* name */
1530 false, /* partial_inplace */
1532 MINUS_ONE
, /* dst_mask */
1533 false), /* pcrel_offset */
1535 /* TLS thread pointer offset. */
1536 HOWTO (R_MIPS_TLS_TPREL_HI16
, /* type */
1540 false, /* pc_relative */
1542 complain_overflow_signed
, /* complain_on_overflow */
1543 _bfd_mips_elf_generic_reloc
, /* special_function */
1544 "R_MIPS_TLS_TPREL_HI16", /* name */
1545 false, /* partial_inplace */
1547 0x0000ffff, /* dst_mask */
1548 false), /* pcrel_offset */
1550 /* TLS thread pointer offset. */
1551 HOWTO (R_MIPS_TLS_TPREL_LO16
, /* type */
1555 false, /* pc_relative */
1557 complain_overflow_signed
, /* complain_on_overflow */
1558 _bfd_mips_elf_generic_reloc
, /* special_function */
1559 "R_MIPS_TLS_TPREL_LO16", /* name */
1560 false, /* partial_inplace */
1562 0x0000ffff, /* dst_mask */
1563 false), /* pcrel_offset */
1565 /* 32 bit relocation with no addend. */
1566 HOWTO (R_MIPS_GLOB_DAT
, /* type */
1570 false, /* pc_relative */
1572 complain_overflow_dont
, /* complain_on_overflow */
1573 _bfd_mips_elf_generic_reloc
, /* special_function */
1574 "R_MIPS_GLOB_DAT", /* name */
1575 false, /* partial_inplace */
1577 0xffffffff, /* dst_mask */
1578 false), /* pcrel_offset */
1589 HOWTO (R_MIPS_PC21_S2
, /* type */
1593 true, /* pc_relative */
1595 complain_overflow_signed
, /* complain_on_overflow */
1596 _bfd_mips_elf_generic_reloc
, /* special_function */
1597 "R_MIPS_PC21_S2", /* name */
1598 false, /* partial_inplace */
1600 0x001fffff, /* dst_mask */
1601 true), /* pcrel_offset */
1603 HOWTO (R_MIPS_PC26_S2
, /* type */
1607 true, /* pc_relative */
1609 complain_overflow_signed
, /* complain_on_overflow */
1610 _bfd_mips_elf_generic_reloc
, /* special_function */
1611 "R_MIPS_PC26_S2", /* name */
1612 false, /* partial_inplace */
1614 0x03ffffff, /* dst_mask */
1615 true), /* pcrel_offset */
1617 HOWTO (R_MIPS_PC18_S3
, /* type */
1621 true, /* pc_relative */
1623 complain_overflow_signed
, /* complain_on_overflow */
1624 _bfd_mips_elf_generic_reloc
, /* special_function */
1625 "R_MIPS_PC18_S3", /* name */
1626 false, /* partial_inplace */
1628 0x0003ffff, /* dst_mask */
1629 true), /* pcrel_offset */
1631 HOWTO (R_MIPS_PC19_S2
, /* type */
1635 true, /* pc_relative */
1637 complain_overflow_signed
, /* complain_on_overflow */
1638 _bfd_mips_elf_generic_reloc
, /* special_function */
1639 "R_MIPS_PC19_S2", /* name */
1640 false, /* partial_inplace */
1642 0x0007ffff, /* dst_mask */
1643 true), /* pcrel_offset */
1645 HOWTO (R_MIPS_PCHI16
, /* type */
1646 16, /* rightshift */
1649 true, /* pc_relative */
1651 complain_overflow_signed
, /* complain_on_overflow */
1652 _bfd_mips_elf_generic_reloc
, /* special_function */
1653 "R_MIPS_PCHI16", /* name */
1654 false, /* partial_inplace */
1656 0x0000ffff, /* dst_mask */
1657 true), /* pcrel_offset */
1659 HOWTO (R_MIPS_PCLO16
, /* type */
1663 true, /* pc_relative */
1665 complain_overflow_dont
, /* complain_on_overflow */
1666 _bfd_mips_elf_generic_reloc
, /* special_function */
1667 "R_MIPS_PCLO16", /* name */
1668 false, /* partial_inplace */
1670 0x0000ffff, /* dst_mask */
1671 true), /* pcrel_offset */
1675 static reloc_howto_type mips16_elf64_howto_table_rel
[] =
1677 /* The reloc used for the mips16 jump instruction. */
1678 HOWTO (R_MIPS16_26
, /* type */
1682 false, /* pc_relative */
1684 complain_overflow_dont
, /* complain_on_overflow */
1685 /* This needs complex overflow
1686 detection, because the upper four
1687 bits must match the PC. */
1688 _bfd_mips_elf_generic_reloc
, /* special_function */
1689 "R_MIPS16_26", /* name */
1690 true, /* partial_inplace */
1691 0x3ffffff, /* src_mask */
1692 0x3ffffff, /* dst_mask */
1693 false), /* pcrel_offset */
1695 /* The reloc used for the mips16 gprel instruction. */
1696 HOWTO (R_MIPS16_GPREL
, /* type */
1700 false, /* pc_relative */
1702 complain_overflow_signed
, /* complain_on_overflow */
1703 mips16_gprel_reloc
, /* special_function */
1704 "R_MIPS16_GPREL", /* name */
1705 true, /* partial_inplace */
1706 0x0000ffff, /* src_mask */
1707 0x0000ffff, /* dst_mask */
1708 false), /* pcrel_offset */
1710 /* A MIPS16 reference to the global offset table. */
1711 HOWTO (R_MIPS16_GOT16
, /* type */
1715 false, /* pc_relative */
1717 complain_overflow_dont
, /* complain_on_overflow */
1718 _bfd_mips_elf_got16_reloc
, /* special_function */
1719 "R_MIPS16_GOT16", /* name */
1720 true, /* partial_inplace */
1721 0x0000ffff, /* src_mask */
1722 0x0000ffff, /* dst_mask */
1723 false), /* pcrel_offset */
1725 /* A MIPS16 call through the global offset table. */
1726 HOWTO (R_MIPS16_CALL16
, /* type */
1730 false, /* pc_relative */
1732 complain_overflow_dont
, /* complain_on_overflow */
1733 _bfd_mips_elf_generic_reloc
, /* special_function */
1734 "R_MIPS16_CALL16", /* name */
1735 true, /* partial_inplace */
1736 0x0000ffff, /* src_mask */
1737 0x0000ffff, /* dst_mask */
1738 false), /* pcrel_offset */
1740 /* MIPS16 high 16 bits of symbol value. */
1741 HOWTO (R_MIPS16_HI16
, /* type */
1742 16, /* rightshift */
1745 false, /* pc_relative */
1747 complain_overflow_dont
, /* complain_on_overflow */
1748 _bfd_mips_elf_hi16_reloc
, /* special_function */
1749 "R_MIPS16_HI16", /* name */
1750 true, /* partial_inplace */
1751 0x0000ffff, /* src_mask */
1752 0x0000ffff, /* dst_mask */
1753 false), /* pcrel_offset */
1755 /* MIPS16 low 16 bits of symbol value. */
1756 HOWTO (R_MIPS16_LO16
, /* type */
1760 false, /* pc_relative */
1762 complain_overflow_dont
, /* complain_on_overflow */
1763 _bfd_mips_elf_lo16_reloc
, /* special_function */
1764 "R_MIPS16_LO16", /* name */
1765 true, /* partial_inplace */
1766 0x0000ffff, /* src_mask */
1767 0x0000ffff, /* dst_mask */
1768 false), /* pcrel_offset */
1770 /* MIPS16 TLS general dynamic variable reference. */
1771 HOWTO (R_MIPS16_TLS_GD
, /* type */
1775 false, /* pc_relative */
1777 complain_overflow_signed
, /* complain_on_overflow */
1778 _bfd_mips_elf_generic_reloc
, /* special_function */
1779 "R_MIPS16_TLS_GD", /* name */
1780 true, /* partial_inplace */
1781 0x0000ffff, /* src_mask */
1782 0x0000ffff, /* dst_mask */
1783 false), /* pcrel_offset */
1785 /* MIPS16 TLS local dynamic variable reference. */
1786 HOWTO (R_MIPS16_TLS_LDM
, /* type */
1790 false, /* pc_relative */
1792 complain_overflow_signed
, /* complain_on_overflow */
1793 _bfd_mips_elf_generic_reloc
, /* special_function */
1794 "R_MIPS16_TLS_LDM", /* name */
1795 true, /* partial_inplace */
1796 0x0000ffff, /* src_mask */
1797 0x0000ffff, /* dst_mask */
1798 false), /* pcrel_offset */
1800 /* MIPS16 TLS local dynamic offset. */
1801 HOWTO (R_MIPS16_TLS_DTPREL_HI16
, /* type */
1805 false, /* pc_relative */
1807 complain_overflow_signed
, /* complain_on_overflow */
1808 _bfd_mips_elf_generic_reloc
, /* special_function */
1809 "R_MIPS16_TLS_DTPREL_HI16", /* name */
1810 true, /* partial_inplace */
1811 0x0000ffff, /* src_mask */
1812 0x0000ffff, /* dst_mask */
1813 false), /* pcrel_offset */
1815 /* MIPS16 TLS local dynamic offset. */
1816 HOWTO (R_MIPS16_TLS_DTPREL_LO16
, /* type */
1820 false, /* pc_relative */
1822 complain_overflow_signed
, /* complain_on_overflow */
1823 _bfd_mips_elf_generic_reloc
, /* special_function */
1824 "R_MIPS16_TLS_DTPREL_LO16", /* name */
1825 true, /* partial_inplace */
1826 0x0000ffff, /* src_mask */
1827 0x0000ffff, /* dst_mask */
1828 false), /* pcrel_offset */
1830 /* MIPS16 TLS thread pointer offset. */
1831 HOWTO (R_MIPS16_TLS_GOTTPREL
, /* type */
1835 false, /* pc_relative */
1837 complain_overflow_signed
, /* complain_on_overflow */
1838 _bfd_mips_elf_generic_reloc
, /* special_function */
1839 "R_MIPS16_TLS_GOTTPREL", /* name */
1840 true, /* partial_inplace */
1841 0x0000ffff, /* src_mask */
1842 0x0000ffff, /* dst_mask */
1843 false), /* pcrel_offset */
1845 /* MIPS16 TLS thread pointer offset. */
1846 HOWTO (R_MIPS16_TLS_TPREL_HI16
, /* type */
1850 false, /* pc_relative */
1852 complain_overflow_signed
, /* complain_on_overflow */
1853 _bfd_mips_elf_generic_reloc
, /* special_function */
1854 "R_MIPS16_TLS_TPREL_HI16", /* name */
1855 true, /* partial_inplace */
1856 0x0000ffff, /* src_mask */
1857 0x0000ffff, /* dst_mask */
1858 false), /* pcrel_offset */
1860 /* MIPS16 TLS thread pointer offset. */
1861 HOWTO (R_MIPS16_TLS_TPREL_LO16
, /* type */
1865 false, /* pc_relative */
1867 complain_overflow_signed
, /* complain_on_overflow */
1868 _bfd_mips_elf_generic_reloc
, /* special_function */
1869 "R_MIPS16_TLS_TPREL_LO16", /* name */
1870 true, /* partial_inplace */
1871 0x0000ffff, /* src_mask */
1872 0x0000ffff, /* dst_mask */
1873 false), /* pcrel_offset */
1875 /* MIPS16 16-bit PC-relative branch offset. */
1876 HOWTO (R_MIPS16_PC16_S1
, /* type */
1880 true, /* pc_relative */
1882 complain_overflow_signed
, /* complain_on_overflow */
1883 _bfd_mips_elf_generic_reloc
, /* special_function */
1884 "R_MIPS16_PC16_S1", /* name */
1885 true, /* partial_inplace */
1886 0x0000ffff, /* src_mask */
1887 0x0000ffff, /* dst_mask */
1888 true), /* pcrel_offset */
1891 static reloc_howto_type mips16_elf64_howto_table_rela
[] =
1893 /* The reloc used for the mips16 jump instruction. */
1894 HOWTO (R_MIPS16_26
, /* type */
1898 false, /* pc_relative */
1900 complain_overflow_dont
, /* complain_on_overflow */
1901 /* This needs complex overflow
1902 detection, because the upper four
1903 bits must match the PC. */
1904 _bfd_mips_elf_generic_reloc
, /* special_function */
1905 "R_MIPS16_26", /* name */
1906 false, /* partial_inplace */
1908 0x3ffffff, /* dst_mask */
1909 false), /* pcrel_offset */
1911 /* The reloc used for the mips16 gprel instruction. */
1912 HOWTO (R_MIPS16_GPREL
, /* type */
1916 false, /* pc_relative */
1918 complain_overflow_signed
, /* complain_on_overflow */
1919 mips16_gprel_reloc
, /* special_function */
1920 "R_MIPS16_GPREL", /* name */
1921 false, /* partial_inplace */
1923 0x0000ffff, /* dst_mask */
1924 false), /* pcrel_offset */
1926 /* A MIPS16 reference to the global offset table. */
1927 HOWTO (R_MIPS16_GOT16
, /* type */
1931 false, /* pc_relative */
1933 complain_overflow_dont
, /* complain_on_overflow */
1934 _bfd_mips_elf_got16_reloc
, /* special_function */
1935 "R_MIPS16_GOT16", /* name */
1936 false, /* partial_inplace */
1938 0x0000ffff, /* dst_mask */
1939 false), /* pcrel_offset */
1941 /* A MIPS16 call through the global offset table. */
1942 HOWTO (R_MIPS16_CALL16
, /* type */
1946 false, /* pc_relative */
1948 complain_overflow_dont
, /* complain_on_overflow */
1949 _bfd_mips_elf_generic_reloc
, /* special_function */
1950 "R_MIPS16_CALL16", /* name */
1951 false, /* partial_inplace */
1953 0x0000ffff, /* dst_mask */
1954 false), /* pcrel_offset */
1956 /* MIPS16 high 16 bits of symbol value. */
1957 HOWTO (R_MIPS16_HI16
, /* type */
1958 16, /* rightshift */
1961 false, /* pc_relative */
1963 complain_overflow_dont
, /* complain_on_overflow */
1964 _bfd_mips_elf_hi16_reloc
, /* special_function */
1965 "R_MIPS16_HI16", /* name */
1966 false, /* partial_inplace */
1968 0x0000ffff, /* dst_mask */
1969 false), /* pcrel_offset */
1971 /* MIPS16 low 16 bits of symbol value. */
1972 HOWTO (R_MIPS16_LO16
, /* type */
1976 false, /* pc_relative */
1978 complain_overflow_dont
, /* complain_on_overflow */
1979 _bfd_mips_elf_lo16_reloc
, /* special_function */
1980 "R_MIPS16_LO16", /* name */
1981 false, /* partial_inplace */
1983 0x0000ffff, /* dst_mask */
1984 false), /* pcrel_offset */
1986 /* MIPS16 TLS general dynamic variable reference. */
1987 HOWTO (R_MIPS16_TLS_GD
, /* type */
1991 false, /* pc_relative */
1993 complain_overflow_signed
, /* complain_on_overflow */
1994 _bfd_mips_elf_generic_reloc
, /* special_function */
1995 "R_MIPS16_TLS_GD", /* name */
1996 false, /* partial_inplace */
1998 0x0000ffff, /* dst_mask */
1999 false), /* pcrel_offset */
2001 /* MIPS16 TLS local dynamic variable reference. */
2002 HOWTO (R_MIPS16_TLS_LDM
, /* type */
2006 false, /* pc_relative */
2008 complain_overflow_signed
, /* complain_on_overflow */
2009 _bfd_mips_elf_generic_reloc
, /* special_function */
2010 "R_MIPS16_TLS_LDM", /* name */
2011 false, /* partial_inplace */
2013 0x0000ffff, /* dst_mask */
2014 false), /* pcrel_offset */
2016 /* MIPS16 TLS local dynamic offset. */
2017 HOWTO (R_MIPS16_TLS_DTPREL_HI16
, /* type */
2021 false, /* pc_relative */
2023 complain_overflow_signed
, /* complain_on_overflow */
2024 _bfd_mips_elf_generic_reloc
, /* special_function */
2025 "R_MIPS16_TLS_DTPREL_HI16", /* name */
2026 false, /* partial_inplace */
2028 0x0000ffff, /* dst_mask */
2029 false), /* pcrel_offset */
2031 /* MIPS16 TLS local dynamic offset. */
2032 HOWTO (R_MIPS16_TLS_DTPREL_LO16
, /* type */
2036 false, /* pc_relative */
2038 complain_overflow_signed
, /* complain_on_overflow */
2039 _bfd_mips_elf_generic_reloc
, /* special_function */
2040 "R_MIPS16_TLS_DTPREL_LO16", /* name */
2041 false, /* partial_inplace */
2043 0x0000ffff, /* dst_mask */
2044 false), /* pcrel_offset */
2046 /* MIPS16 TLS thread pointer offset. */
2047 HOWTO (R_MIPS16_TLS_GOTTPREL
, /* type */
2051 false, /* pc_relative */
2053 complain_overflow_signed
, /* complain_on_overflow */
2054 _bfd_mips_elf_generic_reloc
, /* special_function */
2055 "R_MIPS16_TLS_GOTTPREL", /* name */
2056 false, /* partial_inplace */
2058 0x0000ffff, /* dst_mask */
2059 false), /* pcrel_offset */
2061 /* MIPS16 TLS thread pointer offset. */
2062 HOWTO (R_MIPS16_TLS_TPREL_HI16
, /* type */
2066 false, /* pc_relative */
2068 complain_overflow_signed
, /* complain_on_overflow */
2069 _bfd_mips_elf_generic_reloc
, /* special_function */
2070 "R_MIPS16_TLS_TPREL_HI16", /* name */
2071 false, /* partial_inplace */
2073 0x0000ffff, /* dst_mask */
2074 false), /* pcrel_offset */
2076 /* MIPS16 TLS thread pointer offset. */
2077 HOWTO (R_MIPS16_TLS_TPREL_LO16
, /* type */
2081 false, /* pc_relative */
2083 complain_overflow_signed
, /* complain_on_overflow */
2084 _bfd_mips_elf_generic_reloc
, /* special_function */
2085 "R_MIPS16_TLS_TPREL_LO16", /* name */
2086 false, /* partial_inplace */
2088 0x0000ffff, /* dst_mask */
2089 false), /* pcrel_offset */
2091 /* MIPS16 16-bit PC-relative branch offset. */
2092 HOWTO (R_MIPS16_PC16_S1
, /* type */
2096 true, /* pc_relative */
2098 complain_overflow_signed
, /* complain_on_overflow */
2099 _bfd_mips_elf_generic_reloc
, /* special_function */
2100 "R_MIPS16_PC16_S1", /* name */
2101 false, /* partial_inplace */
2103 0x0000ffff, /* dst_mask */
2104 true), /* pcrel_offset */
2107 static reloc_howto_type micromips_elf64_howto_table_rel
[] =
2113 /* 26 bit jump address. */
2114 HOWTO (R_MICROMIPS_26_S1
, /* type */
2118 false, /* pc_relative */
2120 complain_overflow_dont
, /* complain_on_overflow */
2121 /* This needs complex overflow
2122 detection, because the upper four
2123 bits must match the PC. */
2124 _bfd_mips_elf_generic_reloc
, /* special_function */
2125 "R_MICROMIPS_26_S1", /* name */
2126 true, /* partial_inplace */
2127 0x3ffffff, /* src_mask */
2128 0x3ffffff, /* dst_mask */
2129 false), /* pcrel_offset */
2131 /* High 16 bits of symbol value. */
2132 HOWTO (R_MICROMIPS_HI16
, /* type */
2133 16, /* rightshift */
2136 false, /* pc_relative */
2138 complain_overflow_dont
, /* complain_on_overflow */
2139 _bfd_mips_elf_hi16_reloc
, /* special_function */
2140 "R_MICROMIPS_HI16", /* name */
2141 true, /* partial_inplace */
2142 0x0000ffff, /* src_mask */
2143 0x0000ffff, /* dst_mask */
2144 false), /* pcrel_offset */
2146 /* Low 16 bits of symbol value. */
2147 HOWTO (R_MICROMIPS_LO16
, /* type */
2151 false, /* pc_relative */
2153 complain_overflow_dont
, /* complain_on_overflow */
2154 _bfd_mips_elf_lo16_reloc
, /* special_function */
2155 "R_MICROMIPS_LO16", /* name */
2156 true, /* partial_inplace */
2157 0x0000ffff, /* src_mask */
2158 0x0000ffff, /* dst_mask */
2159 false), /* pcrel_offset */
2161 /* GP relative reference. */
2162 HOWTO (R_MICROMIPS_GPREL16
, /* type */
2166 false, /* pc_relative */
2168 complain_overflow_signed
, /* complain_on_overflow */
2169 _bfd_mips_elf32_gprel16_reloc
, /* special_function */
2170 "R_MICROMIPS_GPREL16", /* name */
2171 true, /* partial_inplace */
2172 0x0000ffff, /* src_mask */
2173 0x0000ffff, /* dst_mask */
2174 false), /* pcrel_offset */
2176 /* Reference to literal section. */
2177 HOWTO (R_MICROMIPS_LITERAL
, /* type */
2181 false, /* pc_relative */
2183 complain_overflow_signed
, /* complain_on_overflow */
2184 _bfd_mips_elf32_gprel16_reloc
, /* special_function */
2185 "R_MICROMIPS_LITERAL", /* name */
2186 true, /* partial_inplace */
2187 0x0000ffff, /* src_mask */
2188 0x0000ffff, /* dst_mask */
2189 false), /* pcrel_offset */
2191 /* Reference to global offset table. */
2192 HOWTO (R_MICROMIPS_GOT16
, /* type */
2196 false, /* pc_relative */
2198 complain_overflow_signed
, /* complain_on_overflow */
2199 _bfd_mips_elf_got16_reloc
, /* special_function */
2200 "R_MICROMIPS_GOT16", /* name */
2201 true, /* partial_inplace */
2202 0x0000ffff, /* src_mask */
2203 0x0000ffff, /* dst_mask */
2204 false), /* pcrel_offset */
2206 /* This is for microMIPS branches. */
2207 HOWTO (R_MICROMIPS_PC7_S1
, /* type */
2211 true, /* pc_relative */
2213 complain_overflow_signed
, /* complain_on_overflow */
2214 _bfd_mips_elf_generic_reloc
, /* special_function */
2215 "R_MICROMIPS_PC7_S1", /* name */
2216 true, /* partial_inplace */
2217 0x0000007f, /* src_mask */
2218 0x0000007f, /* dst_mask */
2219 true), /* pcrel_offset */
2221 HOWTO (R_MICROMIPS_PC10_S1
, /* type */
2225 true, /* pc_relative */
2227 complain_overflow_signed
, /* complain_on_overflow */
2228 _bfd_mips_elf_generic_reloc
, /* special_function */
2229 "R_MICROMIPS_PC10_S1", /* name */
2230 true, /* partial_inplace */
2231 0x000003ff, /* src_mask */
2232 0x000003ff, /* dst_mask */
2233 true), /* pcrel_offset */
2235 HOWTO (R_MICROMIPS_PC16_S1
, /* type */
2239 true, /* pc_relative */
2241 complain_overflow_signed
, /* complain_on_overflow */
2242 _bfd_mips_elf_generic_reloc
, /* special_function */
2243 "R_MICROMIPS_PC16_S1", /* name */
2244 true, /* partial_inplace */
2245 0x0000ffff, /* src_mask */
2246 0x0000ffff, /* dst_mask */
2247 true), /* pcrel_offset */
2249 /* 16 bit call through global offset table. */
2250 HOWTO (R_MICROMIPS_CALL16
, /* type */
2254 false, /* pc_relative */
2256 complain_overflow_signed
, /* complain_on_overflow */
2257 _bfd_mips_elf_generic_reloc
, /* special_function */
2258 "R_MICROMIPS_CALL16", /* name */
2259 true, /* partial_inplace */
2260 0x0000ffff, /* src_mask */
2261 0x0000ffff, /* dst_mask */
2262 false), /* pcrel_offset */
2267 /* Displacement in the global offset table. */
2268 HOWTO (R_MICROMIPS_GOT_DISP
, /* type */
2272 false, /* pc_relative */
2274 complain_overflow_signed
, /* complain_on_overflow */
2275 _bfd_mips_elf_generic_reloc
, /* special_function */
2276 "R_MICROMIPS_GOT_DISP",/* name */
2277 true, /* partial_inplace */
2278 0x0000ffff, /* src_mask */
2279 0x0000ffff, /* dst_mask */
2280 false), /* pcrel_offset */
2282 /* Displacement to page pointer in the global offset table. */
2283 HOWTO (R_MICROMIPS_GOT_PAGE
, /* type */
2287 false, /* pc_relative */
2289 complain_overflow_signed
, /* complain_on_overflow */
2290 _bfd_mips_elf_generic_reloc
, /* special_function */
2291 "R_MICROMIPS_GOT_PAGE",/* name */
2292 true, /* partial_inplace */
2293 0x0000ffff, /* src_mask */
2294 0x0000ffff, /* dst_mask */
2295 false), /* pcrel_offset */
2297 /* Offset from page pointer in the global offset table. */
2298 HOWTO (R_MICROMIPS_GOT_OFST
, /* type */
2302 false, /* pc_relative */
2304 complain_overflow_signed
, /* complain_on_overflow */
2305 _bfd_mips_elf_generic_reloc
, /* special_function */
2306 "R_MICROMIPS_GOT_OFST",/* name */
2307 true, /* partial_inplace */
2308 0x0000ffff, /* src_mask */
2309 0x0000ffff, /* dst_mask */
2310 false), /* pcrel_offset */
2312 /* High 16 bits of displacement in global offset table. */
2313 HOWTO (R_MICROMIPS_GOT_HI16
, /* type */
2317 false, /* pc_relative */
2319 complain_overflow_dont
, /* complain_on_overflow */
2320 _bfd_mips_elf_generic_reloc
, /* special_function */
2321 "R_MICROMIPS_GOT_HI16",/* name */
2322 true, /* partial_inplace */
2323 0x0000ffff, /* src_mask */
2324 0x0000ffff, /* dst_mask */
2325 false), /* pcrel_offset */
2327 /* Low 16 bits of displacement in global offset table. */
2328 HOWTO (R_MICROMIPS_GOT_LO16
, /* type */
2332 false, /* pc_relative */
2334 complain_overflow_dont
, /* complain_on_overflow */
2335 _bfd_mips_elf_generic_reloc
, /* special_function */
2336 "R_MICROMIPS_GOT_LO16",/* name */
2337 true, /* partial_inplace */
2338 0x0000ffff, /* src_mask */
2339 0x0000ffff, /* dst_mask */
2340 false), /* pcrel_offset */
2342 /* 64 bit subtraction. Used in the N32 ABI. */
2343 HOWTO (R_MICROMIPS_SUB
, /* type */
2347 false, /* pc_relative */
2349 complain_overflow_dont
, /* complain_on_overflow */
2350 _bfd_mips_elf_generic_reloc
, /* special_function */
2351 "R_MICROMIPS_SUB", /* name */
2352 true, /* partial_inplace */
2353 MINUS_ONE
, /* src_mask */
2354 MINUS_ONE
, /* dst_mask */
2355 false), /* pcrel_offset */
2357 /* We don't support these for REL relocations, because it means building
2358 the addend from a R_MICROMIPS_HIGHEST/R_MICROMIPS_HIGHER/
2359 R_MICROMIPS_HI16/R_MICROMIPS_LO16 sequence with varying ordering,
2360 using fallable heuristics. */
2361 EMPTY_HOWTO (R_MICROMIPS_HIGHER
),
2362 EMPTY_HOWTO (R_MICROMIPS_HIGHEST
),
2364 /* High 16 bits of displacement in global offset table. */
2365 HOWTO (R_MICROMIPS_CALL_HI16
, /* type */
2369 false, /* pc_relative */
2371 complain_overflow_dont
, /* complain_on_overflow */
2372 _bfd_mips_elf_generic_reloc
, /* special_function */
2373 "R_MICROMIPS_CALL_HI16",/* name */
2374 true, /* partial_inplace */
2375 0x0000ffff, /* src_mask */
2376 0x0000ffff, /* dst_mask */
2377 false), /* pcrel_offset */
2379 /* Low 16 bits of displacement in global offset table. */
2380 HOWTO (R_MICROMIPS_CALL_LO16
, /* type */
2384 false, /* pc_relative */
2386 complain_overflow_dont
, /* complain_on_overflow */
2387 _bfd_mips_elf_generic_reloc
, /* special_function */
2388 "R_MICROMIPS_CALL_LO16",/* name */
2389 true, /* partial_inplace */
2390 0x0000ffff, /* src_mask */
2391 0x0000ffff, /* dst_mask */
2392 false), /* pcrel_offset */
2394 /* Section displacement. */
2395 HOWTO (R_MICROMIPS_SCN_DISP
, /* type */
2399 false, /* pc_relative */
2401 complain_overflow_dont
, /* complain_on_overflow */
2402 _bfd_mips_elf_generic_reloc
, /* special_function */
2403 "R_MICROMIPS_SCN_DISP", /* name */
2404 true, /* partial_inplace */
2405 0xffffffff, /* src_mask */
2406 0xffffffff, /* dst_mask */
2407 false), /* pcrel_offset */
2409 /* Protected jump conversion. This is an optimization hint. No
2410 relocation is required for correctness. */
2411 HOWTO (R_MICROMIPS_JALR
, /* type */
2415 false, /* pc_relative */
2417 complain_overflow_dont
, /* complain_on_overflow */
2418 _bfd_mips_elf_generic_reloc
, /* special_function */
2419 "R_MICROMIPS_JALR", /* name */
2420 false, /* partial_inplace */
2422 0x00000000, /* dst_mask */
2423 false), /* pcrel_offset */
2425 /* Low 16 bits of symbol value. Note that the high 16 bits of symbol values
2426 must be zero. This is used for relaxation. */
2427 HOWTO (R_MICROMIPS_HI0_LO16
, /* type */
2431 false, /* pc_relative */
2433 complain_overflow_dont
, /* complain_on_overflow */
2434 _bfd_mips_elf_generic_reloc
, /* special_function */
2435 "R_MICROMIPS_HI0_LO16",/* name */
2436 true, /* partial_inplace */
2437 0x0000ffff, /* src_mask */
2438 0x0000ffff, /* dst_mask */
2439 false), /* pcrel_offset */
2446 /* TLS general dynamic variable reference. */
2447 HOWTO (R_MICROMIPS_TLS_GD
, /* type */
2451 false, /* pc_relative */
2453 complain_overflow_signed
, /* complain_on_overflow */
2454 _bfd_mips_elf_generic_reloc
, /* special_function */
2455 "R_MICROMIPS_TLS_GD", /* name */
2456 true, /* partial_inplace */
2457 0x0000ffff, /* src_mask */
2458 0x0000ffff, /* dst_mask */
2459 false), /* pcrel_offset */
2461 /* TLS local dynamic variable reference. */
2462 HOWTO (R_MICROMIPS_TLS_LDM
, /* type */
2466 false, /* pc_relative */
2468 complain_overflow_signed
, /* complain_on_overflow */
2469 _bfd_mips_elf_generic_reloc
, /* special_function */
2470 "R_MICROMIPS_TLS_LDM", /* name */
2471 true, /* partial_inplace */
2472 0x0000ffff, /* src_mask */
2473 0x0000ffff, /* dst_mask */
2474 false), /* pcrel_offset */
2476 /* TLS local dynamic offset. */
2477 HOWTO (R_MICROMIPS_TLS_DTPREL_HI16
, /* type */
2481 false, /* pc_relative */
2483 complain_overflow_signed
, /* complain_on_overflow */
2484 _bfd_mips_elf_generic_reloc
, /* special_function */
2485 "R_MICROMIPS_TLS_DTPREL_HI16", /* name */
2486 true, /* partial_inplace */
2487 0x0000ffff, /* src_mask */
2488 0x0000ffff, /* dst_mask */
2489 false), /* pcrel_offset */
2491 /* TLS local dynamic offset. */
2492 HOWTO (R_MICROMIPS_TLS_DTPREL_LO16
, /* type */
2496 false, /* pc_relative */
2498 complain_overflow_signed
, /* complain_on_overflow */
2499 _bfd_mips_elf_generic_reloc
, /* special_function */
2500 "R_MICROMIPS_TLS_DTPREL_LO16", /* name */
2501 true, /* partial_inplace */
2502 0x0000ffff, /* src_mask */
2503 0x0000ffff, /* dst_mask */
2504 false), /* pcrel_offset */
2506 /* TLS thread pointer offset. */
2507 HOWTO (R_MICROMIPS_TLS_GOTTPREL
, /* type */
2511 false, /* pc_relative */
2513 complain_overflow_signed
, /* complain_on_overflow */
2514 _bfd_mips_elf_generic_reloc
, /* special_function */
2515 "R_MICROMIPS_TLS_GOTTPREL", /* name */
2516 true, /* partial_inplace */
2517 0x0000ffff, /* src_mask */
2518 0x0000ffff, /* dst_mask */
2519 false), /* pcrel_offset */
2524 /* TLS thread pointer offset. */
2525 HOWTO (R_MICROMIPS_TLS_TPREL_HI16
, /* type */
2529 false, /* pc_relative */
2531 complain_overflow_signed
, /* complain_on_overflow */
2532 _bfd_mips_elf_generic_reloc
, /* special_function */
2533 "R_MICROMIPS_TLS_TPREL_HI16", /* name */
2534 true, /* partial_inplace */
2535 0x0000ffff, /* src_mask */
2536 0x0000ffff, /* dst_mask */
2537 false), /* pcrel_offset */
2539 /* TLS thread pointer offset. */
2540 HOWTO (R_MICROMIPS_TLS_TPREL_LO16
, /* type */
2544 false, /* pc_relative */
2546 complain_overflow_signed
, /* complain_on_overflow */
2547 _bfd_mips_elf_generic_reloc
, /* special_function */
2548 "R_MICROMIPS_TLS_TPREL_LO16", /* name */
2549 true, /* partial_inplace */
2550 0x0000ffff, /* src_mask */
2551 0x0000ffff, /* dst_mask */
2552 false), /* pcrel_offset */
2556 /* GP- and PC-relative relocations. */
2557 HOWTO (R_MICROMIPS_GPREL7_S2
, /* type */
2561 false, /* pc_relative */
2563 complain_overflow_signed
, /* complain_on_overflow */
2564 _bfd_mips_elf32_gprel16_reloc
, /* special_function */
2565 "R_MICROMIPS_GPREL7_S2", /* name */
2566 true, /* partial_inplace */
2567 0x0000007f, /* src_mask */
2568 0x0000007f, /* dst_mask */
2569 false), /* pcrel_offset */
2571 HOWTO (R_MICROMIPS_PC23_S2
, /* type */
2575 true, /* pc_relative */
2577 complain_overflow_signed
, /* complain_on_overflow */
2578 _bfd_mips_elf_generic_reloc
, /* special_function */
2579 "R_MICROMIPS_PC23_S2", /* name */
2580 true, /* partial_inplace */
2581 0x007fffff, /* src_mask */
2582 0x007fffff, /* dst_mask */
2583 true), /* pcrel_offset */
2586 static reloc_howto_type micromips_elf64_howto_table_rela
[] =
2592 /* 26 bit jump address. */
2593 HOWTO (R_MICROMIPS_26_S1
, /* type */
2597 false, /* pc_relative */
2599 complain_overflow_dont
, /* complain_on_overflow */
2600 /* This needs complex overflow
2601 detection, because the upper four
2602 bits must match the PC. */
2603 _bfd_mips_elf_generic_reloc
, /* special_function */
2604 "R_MICROMIPS_26_S1", /* name */
2605 false, /* partial_inplace */
2607 0x3ffffff, /* dst_mask */
2608 false), /* pcrel_offset */
2610 /* High 16 bits of symbol value. */
2611 HOWTO (R_MICROMIPS_HI16
, /* type */
2612 16, /* rightshift */
2615 false, /* pc_relative */
2617 complain_overflow_dont
, /* complain_on_overflow */
2618 _bfd_mips_elf_hi16_reloc
, /* special_function */
2619 "R_MICROMIPS_HI16", /* name */
2620 false, /* partial_inplace */
2622 0x0000ffff, /* dst_mask */
2623 false), /* pcrel_offset */
2625 /* Low 16 bits of symbol value. */
2626 HOWTO (R_MICROMIPS_LO16
, /* type */
2630 false, /* pc_relative */
2632 complain_overflow_dont
, /* complain_on_overflow */
2633 _bfd_mips_elf_lo16_reloc
, /* special_function */
2634 "R_MICROMIPS_LO16", /* name */
2635 false, /* partial_inplace */
2637 0x0000ffff, /* dst_mask */
2638 false), /* pcrel_offset */
2640 /* GP relative reference. */
2641 HOWTO (R_MICROMIPS_GPREL16
, /* type */
2645 false, /* pc_relative */
2647 complain_overflow_signed
, /* complain_on_overflow */
2648 _bfd_mips_elf32_gprel16_reloc
, /* special_function */
2649 "R_MICROMIPS_GPREL16", /* name */
2650 false, /* partial_inplace */
2652 0x0000ffff, /* dst_mask */
2653 false), /* pcrel_offset */
2655 /* Reference to literal section. */
2656 HOWTO (R_MICROMIPS_LITERAL
, /* type */
2660 false, /* pc_relative */
2662 complain_overflow_signed
, /* complain_on_overflow */
2663 _bfd_mips_elf32_gprel16_reloc
, /* special_function */
2664 "R_MICROMIPS_LITERAL", /* name */
2665 false, /* partial_inplace */
2667 0x0000ffff, /* dst_mask */
2668 false), /* pcrel_offset */
2670 /* Reference to global offset table. */
2671 HOWTO (R_MICROMIPS_GOT16
, /* type */
2675 false, /* pc_relative */
2677 complain_overflow_signed
, /* complain_on_overflow */
2678 _bfd_mips_elf_got16_reloc
, /* special_function */
2679 "R_MICROMIPS_GOT16", /* name */
2680 false, /* partial_inplace */
2682 0x0000ffff, /* dst_mask */
2683 false), /* pcrel_offset */
2685 /* This is for microMIPS branches. */
2686 HOWTO (R_MICROMIPS_PC7_S1
, /* type */
2690 true, /* pc_relative */
2692 complain_overflow_signed
, /* complain_on_overflow */
2693 _bfd_mips_elf_generic_reloc
, /* special_function */
2694 "R_MICROMIPS_PC7_S1", /* name */
2695 false, /* partial_inplace */
2697 0x0000007f, /* dst_mask */
2698 true), /* pcrel_offset */
2700 HOWTO (R_MICROMIPS_PC10_S1
, /* type */
2704 true, /* pc_relative */
2706 complain_overflow_signed
, /* complain_on_overflow */
2707 _bfd_mips_elf_generic_reloc
, /* special_function */
2708 "R_MICROMIPS_PC10_S1", /* name */
2709 false, /* partial_inplace */
2711 0x000003ff, /* dst_mask */
2712 true), /* pcrel_offset */
2714 HOWTO (R_MICROMIPS_PC16_S1
, /* type */
2718 true, /* pc_relative */
2720 complain_overflow_signed
, /* complain_on_overflow */
2721 _bfd_mips_elf_generic_reloc
, /* special_function */
2722 "R_MICROMIPS_PC16_S1", /* name */
2723 false, /* partial_inplace */
2725 0x0000ffff, /* dst_mask */
2726 true), /* pcrel_offset */
2728 /* 16 bit call through global offset table. */
2729 HOWTO (R_MICROMIPS_CALL16
, /* type */
2733 false, /* pc_relative */
2735 complain_overflow_signed
, /* complain_on_overflow */
2736 _bfd_mips_elf_generic_reloc
, /* special_function */
2737 "R_MICROMIPS_CALL16", /* name */
2738 false, /* partial_inplace */
2740 0x0000ffff, /* dst_mask */
2741 false), /* pcrel_offset */
2746 /* Displacement in the global offset table. */
2747 HOWTO (R_MICROMIPS_GOT_DISP
, /* type */
2751 false, /* pc_relative */
2753 complain_overflow_signed
, /* complain_on_overflow */
2754 _bfd_mips_elf_generic_reloc
, /* special_function */
2755 "R_MICROMIPS_GOT_DISP",/* name */
2756 false, /* partial_inplace */
2758 0x0000ffff, /* dst_mask */
2759 false), /* pcrel_offset */
2761 /* Displacement to page pointer in the global offset table. */
2762 HOWTO (R_MICROMIPS_GOT_PAGE
, /* type */
2766 false, /* pc_relative */
2768 complain_overflow_signed
, /* complain_on_overflow */
2769 _bfd_mips_elf_generic_reloc
, /* special_function */
2770 "R_MICROMIPS_GOT_PAGE",/* name */
2771 false, /* partial_inplace */
2773 0x0000ffff, /* dst_mask */
2774 false), /* pcrel_offset */
2776 /* Offset from page pointer in the global offset table. */
2777 HOWTO (R_MICROMIPS_GOT_OFST
, /* type */
2781 false, /* pc_relative */
2783 complain_overflow_signed
, /* complain_on_overflow */
2784 _bfd_mips_elf_generic_reloc
, /* special_function */
2785 "R_MICROMIPS_GOT_OFST",/* name */
2786 false, /* partial_inplace */
2788 0x0000ffff, /* dst_mask */
2789 false), /* pcrel_offset */
2791 /* High 16 bits of displacement in global offset table. */
2792 HOWTO (R_MICROMIPS_GOT_HI16
, /* type */
2796 false, /* pc_relative */
2798 complain_overflow_dont
, /* complain_on_overflow */
2799 _bfd_mips_elf_generic_reloc
, /* special_function */
2800 "R_MICROMIPS_GOT_HI16",/* name */
2801 false, /* partial_inplace */
2803 0x0000ffff, /* dst_mask */
2804 false), /* pcrel_offset */
2806 /* Low 16 bits of displacement in global offset table. */
2807 HOWTO (R_MICROMIPS_GOT_LO16
, /* type */
2811 false, /* pc_relative */
2813 complain_overflow_dont
, /* complain_on_overflow */
2814 _bfd_mips_elf_generic_reloc
, /* special_function */
2815 "R_MICROMIPS_GOT_LO16",/* name */
2816 false, /* partial_inplace */
2818 0x0000ffff, /* dst_mask */
2819 false), /* pcrel_offset */
2821 /* 64 bit subtraction. Used in the N32 ABI. */
2822 HOWTO (R_MICROMIPS_SUB
, /* type */
2826 false, /* pc_relative */
2828 complain_overflow_dont
, /* complain_on_overflow */
2829 _bfd_mips_elf_generic_reloc
, /* special_function */
2830 "R_MICROMIPS_SUB", /* name */
2831 false, /* partial_inplace */
2833 MINUS_ONE
, /* dst_mask */
2834 false), /* pcrel_offset */
2836 /* Get the higher value of a 64 bit addend. */
2837 HOWTO (R_MICROMIPS_HIGHER
, /* type */
2841 false, /* pc_relative */
2843 complain_overflow_dont
, /* complain_on_overflow */
2844 _bfd_mips_elf_generic_reloc
, /* special_function */
2845 "R_MICROMIPS_HIGHER", /* name */
2846 false, /* partial_inplace */
2848 0x0000ffff, /* dst_mask */
2849 false), /* pcrel_offset */
2851 /* Get the highest value of a 64 bit addend. */
2852 HOWTO (R_MICROMIPS_HIGHEST
, /* type */
2856 false, /* pc_relative */
2858 complain_overflow_dont
, /* complain_on_overflow */
2859 _bfd_mips_elf_generic_reloc
, /* special_function */
2860 "R_MICROMIPS_HIGHEST", /* name */
2861 false, /* partial_inplace */
2863 0x0000ffff, /* dst_mask */
2864 false), /* pcrel_offset */
2866 /* High 16 bits of displacement in global offset table. */
2867 HOWTO (R_MICROMIPS_CALL_HI16
, /* type */
2871 false, /* pc_relative */
2873 complain_overflow_dont
, /* complain_on_overflow */
2874 _bfd_mips_elf_generic_reloc
, /* special_function */
2875 "R_MICROMIPS_CALL_HI16",/* name */
2876 false, /* partial_inplace */
2878 0x0000ffff, /* dst_mask */
2879 false), /* pcrel_offset */
2881 /* Low 16 bits of displacement in global offset table. */
2882 HOWTO (R_MICROMIPS_CALL_LO16
, /* type */
2886 false, /* pc_relative */
2888 complain_overflow_dont
, /* complain_on_overflow */
2889 _bfd_mips_elf_generic_reloc
, /* special_function */
2890 "R_MICROMIPS_CALL_LO16",/* name */
2891 false, /* partial_inplace */
2893 0x0000ffff, /* dst_mask */
2894 false), /* pcrel_offset */
2896 /* Section displacement. */
2897 HOWTO (R_MICROMIPS_SCN_DISP
, /* type */
2901 false, /* pc_relative */
2903 complain_overflow_dont
, /* complain_on_overflow */
2904 _bfd_mips_elf_generic_reloc
, /* special_function */
2905 "R_MICROMIPS_SCN_DISP", /* name */
2906 false, /* partial_inplace */
2908 0xffffffff, /* dst_mask */
2909 false), /* pcrel_offset */
2911 /* Protected jump conversion. This is an optimization hint. No
2912 relocation is required for correctness. */
2913 HOWTO (R_MICROMIPS_JALR
, /* type */
2917 false, /* pc_relative */
2919 complain_overflow_dont
, /* complain_on_overflow */
2920 _bfd_mips_elf_generic_reloc
, /* special_function */
2921 "R_MICROMIPS_JALR", /* name */
2922 false, /* partial_inplace */
2924 0x00000000, /* dst_mask */
2925 false), /* pcrel_offset */
2927 /* Low 16 bits of symbol value. Note that the high 16 bits of symbol values
2928 must be zero. This is used for relaxation. */
2929 HOWTO (R_MICROMIPS_HI0_LO16
, /* type */
2933 false, /* pc_relative */
2935 complain_overflow_dont
, /* complain_on_overflow */
2936 _bfd_mips_elf_generic_reloc
, /* special_function */
2937 "R_MICROMIPS_HI0_LO16",/* name */
2938 false, /* partial_inplace */
2940 0x0000ffff, /* dst_mask */
2941 false), /* pcrel_offset */
2948 /* TLS general dynamic variable reference. */
2949 HOWTO (R_MICROMIPS_TLS_GD
, /* type */
2953 false, /* pc_relative */
2955 complain_overflow_signed
, /* complain_on_overflow */
2956 _bfd_mips_elf_generic_reloc
, /* special_function */
2957 "R_MICROMIPS_TLS_GD", /* name */
2958 false, /* partial_inplace */
2960 0x0000ffff, /* dst_mask */
2961 false), /* pcrel_offset */
2963 /* TLS local dynamic variable reference. */
2964 HOWTO (R_MICROMIPS_TLS_LDM
, /* type */
2968 false, /* pc_relative */
2970 complain_overflow_signed
, /* complain_on_overflow */
2971 _bfd_mips_elf_generic_reloc
, /* special_function */
2972 "R_MICROMIPS_TLS_LDM", /* name */
2973 false, /* partial_inplace */
2975 0x0000ffff, /* dst_mask */
2976 false), /* pcrel_offset */
2978 /* TLS local dynamic offset. */
2979 HOWTO (R_MICROMIPS_TLS_DTPREL_HI16
, /* type */
2983 false, /* pc_relative */
2985 complain_overflow_signed
, /* complain_on_overflow */
2986 _bfd_mips_elf_generic_reloc
, /* special_function */
2987 "R_MICROMIPS_TLS_DTPREL_HI16", /* name */
2988 false, /* partial_inplace */
2990 0x0000ffff, /* dst_mask */
2991 false), /* pcrel_offset */
2993 /* TLS local dynamic offset. */
2994 HOWTO (R_MICROMIPS_TLS_DTPREL_LO16
, /* type */
2998 false, /* pc_relative */
3000 complain_overflow_signed
, /* complain_on_overflow */
3001 _bfd_mips_elf_generic_reloc
, /* special_function */
3002 "R_MICROMIPS_TLS_DTPREL_LO16", /* name */
3003 false, /* partial_inplace */
3005 0x0000ffff, /* dst_mask */
3006 false), /* pcrel_offset */
3008 /* TLS thread pointer offset. */
3009 HOWTO (R_MICROMIPS_TLS_GOTTPREL
, /* type */
3013 false, /* pc_relative */
3015 complain_overflow_signed
, /* complain_on_overflow */
3016 _bfd_mips_elf_generic_reloc
, /* special_function */
3017 "R_MICROMIPS_TLS_GOTTPREL", /* name */
3018 false, /* partial_inplace */
3020 0x0000ffff, /* dst_mask */
3021 false), /* pcrel_offset */
3026 /* TLS thread pointer offset. */
3027 HOWTO (R_MICROMIPS_TLS_TPREL_HI16
, /* type */
3031 false, /* pc_relative */
3033 complain_overflow_signed
, /* complain_on_overflow */
3034 _bfd_mips_elf_generic_reloc
, /* special_function */
3035 "R_MICROMIPS_TLS_TPREL_HI16", /* name */
3036 false, /* partial_inplace */
3038 0x0000ffff, /* dst_mask */
3039 false), /* pcrel_offset */
3041 /* TLS thread pointer offset. */
3042 HOWTO (R_MICROMIPS_TLS_TPREL_LO16
, /* type */
3046 false, /* pc_relative */
3048 complain_overflow_signed
, /* complain_on_overflow */
3049 _bfd_mips_elf_generic_reloc
, /* special_function */
3050 "R_MICROMIPS_TLS_TPREL_LO16", /* name */
3051 false, /* partial_inplace */
3053 0x0000ffff, /* dst_mask */
3054 false), /* pcrel_offset */
3058 /* GP- and PC-relative relocations. */
3059 HOWTO (R_MICROMIPS_GPREL7_S2
, /* type */
3063 false, /* pc_relative */
3065 complain_overflow_signed
, /* complain_on_overflow */
3066 _bfd_mips_elf32_gprel16_reloc
, /* special_function */
3067 "R_MICROMIPS_GPREL7_S2", /* name */
3068 false, /* partial_inplace */
3070 0x0000007f, /* dst_mask */
3071 false), /* pcrel_offset */
3073 HOWTO (R_MICROMIPS_PC23_S2
, /* type */
3077 true, /* pc_relative */
3079 complain_overflow_signed
, /* complain_on_overflow */
3080 _bfd_mips_elf_generic_reloc
, /* special_function */
3081 "R_MICROMIPS_PC23_S2", /* name */
3082 false, /* partial_inplace */
3084 0x007fffff, /* dst_mask */
3085 true), /* pcrel_offset */
3088 /* GNU extension to record C++ vtable hierarchy */
3089 static reloc_howto_type elf_mips_gnu_vtinherit_howto
=
3090 HOWTO (R_MIPS_GNU_VTINHERIT
, /* type */
3094 false, /* pc_relative */
3096 complain_overflow_dont
, /* complain_on_overflow */
3097 NULL
, /* special_function */
3098 "R_MIPS_GNU_VTINHERIT", /* name */
3099 false, /* partial_inplace */
3102 false); /* pcrel_offset */
3104 /* GNU extension to record C++ vtable member usage */
3105 static reloc_howto_type elf_mips_gnu_vtentry_howto
=
3106 HOWTO (R_MIPS_GNU_VTENTRY
, /* type */
3110 false, /* pc_relative */
3112 complain_overflow_dont
, /* complain_on_overflow */
3113 _bfd_elf_rel_vtable_reloc_fn
, /* special_function */
3114 "R_MIPS_GNU_VTENTRY", /* name */
3115 false, /* partial_inplace */
3118 false); /* pcrel_offset */
3120 /* 16 bit offset for pc-relative branches. */
3121 static reloc_howto_type elf_mips_gnu_rel16_s2
=
3122 HOWTO (R_MIPS_GNU_REL16_S2
, /* type */
3126 true, /* pc_relative */
3128 complain_overflow_signed
, /* complain_on_overflow */
3129 _bfd_mips_elf_generic_reloc
, /* special_function */
3130 "R_MIPS_GNU_REL16_S2", /* name */
3131 true, /* partial_inplace */
3132 0x0000ffff, /* src_mask */
3133 0x0000ffff, /* dst_mask */
3134 true); /* pcrel_offset */
3136 /* 16 bit offset for pc-relative branches. */
3137 static reloc_howto_type elf_mips_gnu_rela16_s2
=
3138 HOWTO (R_MIPS_GNU_REL16_S2
, /* type */
3142 true, /* pc_relative */
3144 complain_overflow_signed
, /* complain_on_overflow */
3145 _bfd_mips_elf_generic_reloc
, /* special_function */
3146 "R_MIPS_GNU_REL16_S2", /* name */
3147 false, /* partial_inplace */
3149 0x0000ffff, /* dst_mask */
3150 true); /* pcrel_offset */
3152 /* 32 bit pc-relative. Used for compact EH tables. */
3153 static reloc_howto_type elf_mips_gnu_pcrel32
=
3154 HOWTO (R_MIPS_PC32
, /* type */
3158 true, /* pc_relative */
3160 complain_overflow_signed
, /* complain_on_overflow */
3161 _bfd_mips_elf_generic_reloc
, /* special_function */
3162 "R_MIPS_PC32", /* name */
3163 true, /* partial_inplace */
3164 0xffffffff, /* src_mask */
3165 0xffffffff, /* dst_mask */
3166 true); /* pcrel_offset */
3169 /* Originally a VxWorks extension, but now used for other systems too. */
3170 static reloc_howto_type elf_mips_copy_howto
=
3171 HOWTO (R_MIPS_COPY
, /* type */
3173 0, /* this one is variable size */
3175 false, /* pc_relative */
3177 complain_overflow_bitfield
, /* complain_on_overflow */
3178 _bfd_mips_elf_generic_reloc
, /* special_function */
3179 "R_MIPS_COPY", /* name */
3180 false, /* partial_inplace */
3183 false); /* pcrel_offset */
3185 /* Originally a VxWorks extension, but now used for other systems too. */
3186 static reloc_howto_type elf_mips_jump_slot_howto
=
3187 HOWTO (R_MIPS_JUMP_SLOT
, /* type */
3191 false, /* pc_relative */
3193 complain_overflow_bitfield
, /* complain_on_overflow */
3194 _bfd_mips_elf_generic_reloc
, /* special_function */
3195 "R_MIPS_JUMP_SLOT", /* name */
3196 false, /* partial_inplace */
3199 false); /* pcrel_offset */
3201 /* Used in EH tables. */
3202 static reloc_howto_type elf_mips_eh_howto
=
3203 HOWTO (R_MIPS_EH
, /* type */
3207 false, /* pc_relative */
3209 complain_overflow_signed
, /* complain_on_overflow */
3210 _bfd_mips_elf_generic_reloc
, /* special_function */
3211 "R_MIPS_EH", /* name */
3212 true, /* partial_inplace */
3213 0xffffffff, /* src_mask */
3214 0xffffffff, /* dst_mask */
3215 false); /* pcrel_offset */
3218 /* Swap in a MIPS 64-bit Rel reloc. */
3221 mips_elf64_swap_reloc_in (bfd
*abfd
, const Elf64_Mips_External_Rel
*src
,
3222 Elf64_Mips_Internal_Rela
*dst
)
3224 dst
->r_offset
= H_GET_64 (abfd
, src
->r_offset
);
3225 dst
->r_sym
= H_GET_32 (abfd
, src
->r_sym
);
3226 dst
->r_ssym
= H_GET_8 (abfd
, src
->r_ssym
);
3227 dst
->r_type3
= H_GET_8 (abfd
, src
->r_type3
);
3228 dst
->r_type2
= H_GET_8 (abfd
, src
->r_type2
);
3229 dst
->r_type
= H_GET_8 (abfd
, src
->r_type
);
3233 /* Swap in a MIPS 64-bit Rela reloc. */
3236 mips_elf64_swap_reloca_in (bfd
*abfd
, const Elf64_Mips_External_Rela
*src
,
3237 Elf64_Mips_Internal_Rela
*dst
)
3239 dst
->r_offset
= H_GET_64 (abfd
, src
->r_offset
);
3240 dst
->r_sym
= H_GET_32 (abfd
, src
->r_sym
);
3241 dst
->r_ssym
= H_GET_8 (abfd
, src
->r_ssym
);
3242 dst
->r_type3
= H_GET_8 (abfd
, src
->r_type3
);
3243 dst
->r_type2
= H_GET_8 (abfd
, src
->r_type2
);
3244 dst
->r_type
= H_GET_8 (abfd
, src
->r_type
);
3245 dst
->r_addend
= H_GET_S64 (abfd
, src
->r_addend
);
3248 /* Swap out a MIPS 64-bit Rel reloc. */
3251 mips_elf64_swap_reloc_out (bfd
*abfd
, const Elf64_Mips_Internal_Rela
*src
,
3252 Elf64_Mips_External_Rel
*dst
)
3254 H_PUT_64 (abfd
, src
->r_offset
, dst
->r_offset
);
3255 H_PUT_32 (abfd
, src
->r_sym
, dst
->r_sym
);
3256 H_PUT_8 (abfd
, src
->r_ssym
, dst
->r_ssym
);
3257 H_PUT_8 (abfd
, src
->r_type3
, dst
->r_type3
);
3258 H_PUT_8 (abfd
, src
->r_type2
, dst
->r_type2
);
3259 H_PUT_8 (abfd
, src
->r_type
, dst
->r_type
);
3262 /* Swap out a MIPS 64-bit Rela reloc. */
3265 mips_elf64_swap_reloca_out (bfd
*abfd
, const Elf64_Mips_Internal_Rela
*src
,
3266 Elf64_Mips_External_Rela
*dst
)
3268 H_PUT_64 (abfd
, src
->r_offset
, dst
->r_offset
);
3269 H_PUT_32 (abfd
, src
->r_sym
, dst
->r_sym
);
3270 H_PUT_8 (abfd
, src
->r_ssym
, dst
->r_ssym
);
3271 H_PUT_8 (abfd
, src
->r_type3
, dst
->r_type3
);
3272 H_PUT_8 (abfd
, src
->r_type2
, dst
->r_type2
);
3273 H_PUT_8 (abfd
, src
->r_type
, dst
->r_type
);
3274 H_PUT_S64 (abfd
, src
->r_addend
, dst
->r_addend
);
3277 /* Swap in a MIPS 64-bit Rel reloc. */
3280 mips_elf64_be_swap_reloc_in (bfd
*abfd
, const bfd_byte
*src
,
3281 Elf_Internal_Rela
*dst
)
3283 Elf64_Mips_Internal_Rela mirel
;
3285 mips_elf64_swap_reloc_in (abfd
,
3286 (const Elf64_Mips_External_Rel
*) src
,
3289 dst
[0].r_offset
= mirel
.r_offset
;
3290 dst
[0].r_info
= ELF64_R_INFO (mirel
.r_sym
, mirel
.r_type
);
3291 dst
[0].r_addend
= 0;
3292 dst
[1].r_offset
= mirel
.r_offset
;
3293 dst
[1].r_info
= ELF64_R_INFO (mirel
.r_ssym
, mirel
.r_type2
);
3294 dst
[1].r_addend
= 0;
3295 dst
[2].r_offset
= mirel
.r_offset
;
3296 dst
[2].r_info
= ELF64_R_INFO (STN_UNDEF
, mirel
.r_type3
);
3297 dst
[2].r_addend
= 0;
3300 /* Swap in a MIPS 64-bit Rela reloc. */
3303 mips_elf64_be_swap_reloca_in (bfd
*abfd
, const bfd_byte
*src
,
3304 Elf_Internal_Rela
*dst
)
3306 Elf64_Mips_Internal_Rela mirela
;
3308 mips_elf64_swap_reloca_in (abfd
,
3309 (const Elf64_Mips_External_Rela
*) src
,
3312 dst
[0].r_offset
= mirela
.r_offset
;
3313 dst
[0].r_info
= ELF64_R_INFO (mirela
.r_sym
, mirela
.r_type
);
3314 dst
[0].r_addend
= mirela
.r_addend
;
3315 dst
[1].r_offset
= mirela
.r_offset
;
3316 dst
[1].r_info
= ELF64_R_INFO (mirela
.r_ssym
, mirela
.r_type2
);
3317 dst
[1].r_addend
= 0;
3318 dst
[2].r_offset
= mirela
.r_offset
;
3319 dst
[2].r_info
= ELF64_R_INFO (STN_UNDEF
, mirela
.r_type3
);
3320 dst
[2].r_addend
= 0;
3323 /* Swap out a MIPS 64-bit Rel reloc. */
3326 mips_elf64_be_swap_reloc_out (bfd
*abfd
, const Elf_Internal_Rela
*src
,
3329 Elf64_Mips_Internal_Rela mirel
;
3331 mirel
.r_offset
= src
[0].r_offset
;
3332 BFD_ASSERT(src
[0].r_offset
== src
[1].r_offset
);
3333 BFD_ASSERT(src
[0].r_offset
== src
[2].r_offset
);
3335 mirel
.r_type
= ELF64_MIPS_R_TYPE (src
[0].r_info
);
3336 mirel
.r_sym
= ELF64_R_SYM (src
[0].r_info
);
3337 mirel
.r_type2
= ELF64_MIPS_R_TYPE (src
[1].r_info
);
3338 mirel
.r_ssym
= ELF64_MIPS_R_SSYM (src
[1].r_info
);
3339 mirel
.r_type3
= ELF64_MIPS_R_TYPE (src
[2].r_info
);
3341 mips_elf64_swap_reloc_out (abfd
, &mirel
,
3342 (Elf64_Mips_External_Rel
*) dst
);
3345 /* Swap out a MIPS 64-bit Rela reloc. */
3348 mips_elf64_be_swap_reloca_out (bfd
*abfd
, const Elf_Internal_Rela
*src
,
3351 Elf64_Mips_Internal_Rela mirela
;
3353 mirela
.r_offset
= src
[0].r_offset
;
3354 BFD_ASSERT(src
[0].r_offset
== src
[1].r_offset
);
3355 BFD_ASSERT(src
[0].r_offset
== src
[2].r_offset
);
3357 mirela
.r_type
= ELF64_MIPS_R_TYPE (src
[0].r_info
);
3358 mirela
.r_sym
= ELF64_R_SYM (src
[0].r_info
);
3359 mirela
.r_addend
= src
[0].r_addend
;
3360 BFD_ASSERT(src
[1].r_addend
== 0);
3361 BFD_ASSERT(src
[2].r_addend
== 0);
3363 mirela
.r_type2
= ELF64_MIPS_R_TYPE (src
[1].r_info
);
3364 mirela
.r_ssym
= ELF64_MIPS_R_SSYM (src
[1].r_info
);
3365 mirela
.r_type3
= ELF64_MIPS_R_TYPE (src
[2].r_info
);
3367 mips_elf64_swap_reloca_out (abfd
, &mirela
,
3368 (Elf64_Mips_External_Rela
*) dst
);
3371 /* Set the GP value for OUTPUT_BFD. Returns FALSE if this is a
3372 dangerous relocation. */
3375 mips_elf64_assign_gp (bfd
*output_bfd
, bfd_vma
*pgp
)
3381 /* If we've already figured out what GP will be, just return it. */
3382 *pgp
= _bfd_get_gp_value (output_bfd
);
3386 count
= bfd_get_symcount (output_bfd
);
3387 sym
= bfd_get_outsymbols (output_bfd
);
3389 /* The linker script will have created a symbol named `_gp' with the
3390 appropriate value. */
3395 for (i
= 0; i
< count
; i
++, sym
++)
3397 register const char *name
;
3399 name
= bfd_asymbol_name (*sym
);
3400 if (*name
== '_' && strcmp (name
, "_gp") == 0)
3402 *pgp
= bfd_asymbol_value (*sym
);
3403 _bfd_set_gp_value (output_bfd
, *pgp
);
3411 /* Only get the error once. */
3413 _bfd_set_gp_value (output_bfd
, *pgp
);
3420 /* We have to figure out the gp value, so that we can adjust the
3421 symbol value correctly. We look up the symbol _gp in the output
3422 BFD. If we can't find it, we're stuck. We cache it in the ELF
3423 target data. We don't need to adjust the symbol value for an
3424 external symbol if we are producing relocatable output. */
3426 static bfd_reloc_status_type
3427 mips_elf64_final_gp (bfd
*output_bfd
, asymbol
*symbol
, bool relocatable
,
3428 char **error_message
, bfd_vma
*pgp
)
3430 if (output_bfd
== NULL
)
3433 return bfd_reloc_undefined
;
3436 *pgp
= _bfd_get_gp_value (output_bfd
);
3439 || (symbol
->flags
& BSF_SECTION_SYM
) != 0))
3443 /* Make up a value. */
3444 *pgp
= symbol
->section
->output_section
->vma
/*+ 0x4000*/;
3445 _bfd_set_gp_value (output_bfd
, *pgp
);
3447 else if (!mips_elf64_assign_gp (output_bfd
, pgp
))
3450 (char *) _("GP relative relocation when _gp not defined");
3451 return bfd_reloc_dangerous
;
3455 return bfd_reloc_ok
;
3458 /* Do a R_MIPS_GPREL16 relocation. This is a 16 bit value which must
3459 become the offset from the gp register. */
3461 static bfd_reloc_status_type
3462 mips_elf64_gprel16_reloc (bfd
*abfd
, arelent
*reloc_entry
, asymbol
*symbol
,
3463 void *data
, asection
*input_section
, bfd
*output_bfd
,
3464 char **error_message
)
3467 bfd_reloc_status_type ret
;
3470 /* If we're relocating, and this is an external symbol, we don't want
3471 to change anything. */
3472 if (output_bfd
!= NULL
3473 && (symbol
->flags
& BSF_SECTION_SYM
) == 0
3474 && (symbol
->flags
& BSF_LOCAL
) != 0)
3476 reloc_entry
->address
+= input_section
->output_offset
;
3477 return bfd_reloc_ok
;
3480 if (output_bfd
!= NULL
)
3484 relocatable
= false;
3485 output_bfd
= input_section
->output_section
->owner
;
3488 ret
= mips_elf64_final_gp (output_bfd
, symbol
, relocatable
, error_message
,
3490 if (ret
!= bfd_reloc_ok
)
3493 return _bfd_mips_elf_gprel16_with_gp (abfd
, symbol
, reloc_entry
,
3494 input_section
, relocatable
,
3498 /* Do a R_MIPS_LITERAL relocation. */
3500 static bfd_reloc_status_type
3501 mips_elf64_literal_reloc (bfd
*abfd
, arelent
*reloc_entry
, asymbol
*symbol
,
3502 void *data
, asection
*input_section
, bfd
*output_bfd
,
3503 char **error_message
)
3506 bfd_reloc_status_type ret
;
3509 /* R_MIPS_LITERAL relocations are defined for local symbols only. */
3510 if (output_bfd
!= NULL
3511 && (symbol
->flags
& BSF_SECTION_SYM
) == 0
3512 && (symbol
->flags
& BSF_LOCAL
) != 0)
3514 *error_message
= (char *)
3515 _("literal relocation occurs for an external symbol");
3516 return bfd_reloc_outofrange
;
3519 /* FIXME: The entries in the .lit8 and .lit4 sections should be merged. */
3520 if (output_bfd
!= NULL
)
3524 relocatable
= false;
3525 output_bfd
= input_section
->output_section
->owner
;
3528 ret
= mips_elf64_final_gp (output_bfd
, symbol
, relocatable
, error_message
,
3530 if (ret
!= bfd_reloc_ok
)
3533 return _bfd_mips_elf_gprel16_with_gp (abfd
, symbol
, reloc_entry
,
3534 input_section
, relocatable
,
3538 /* Do a R_MIPS_GPREL32 relocation. This is a 32 bit value which must
3539 become the offset from the gp register. */
3541 static bfd_reloc_status_type
3542 mips_elf64_gprel32_reloc (bfd
*abfd
, arelent
*reloc_entry
, asymbol
*symbol
,
3543 void *data
, asection
*input_section
, bfd
*output_bfd
,
3544 char **error_message
)
3547 bfd_reloc_status_type ret
;
3552 /* R_MIPS_GPREL32 relocations are defined for local symbols only. */
3553 if (output_bfd
!= NULL
3554 && (symbol
->flags
& BSF_SECTION_SYM
) == 0
3555 && (symbol
->flags
& BSF_LOCAL
) != 0)
3557 *error_message
= (char *)
3558 _("32bits gp relative relocation occurs for an external symbol");
3559 return bfd_reloc_outofrange
;
3562 if (output_bfd
!= NULL
)
3566 relocatable
= false;
3567 output_bfd
= input_section
->output_section
->owner
;
3570 ret
= mips_elf64_final_gp (output_bfd
, symbol
, relocatable
,
3571 error_message
, &gp
);
3572 if (ret
!= bfd_reloc_ok
)
3575 if (bfd_is_com_section (symbol
->section
))
3578 relocation
= symbol
->value
;
3580 if (symbol
->section
->output_section
!= NULL
)
3582 relocation
+= symbol
->section
->output_section
->vma
;
3583 relocation
+= symbol
->section
->output_offset
;
3586 if (!_bfd_mips_reloc_offset_in_range (abfd
, input_section
, reloc_entry
,
3588 return bfd_reloc_outofrange
;
3590 /* Set val to the offset into the section or symbol. */
3591 val
= reloc_entry
->addend
;
3593 if (reloc_entry
->howto
->partial_inplace
)
3594 val
+= bfd_get_32 (abfd
, (bfd_byte
*) data
+ reloc_entry
->address
);
3596 /* Adjust val for the final section location and GP value. If we
3597 are producing relocatable output, we don't want to do this for
3598 an external symbol. */
3600 || (symbol
->flags
& BSF_SECTION_SYM
) != 0)
3601 val
+= relocation
- gp
;
3603 if (reloc_entry
->howto
->partial_inplace
)
3604 bfd_put_32 (abfd
, val
, (bfd_byte
*) data
+ reloc_entry
->address
);
3606 reloc_entry
->addend
= val
;
3609 reloc_entry
->address
+= input_section
->output_offset
;
3611 return bfd_reloc_ok
;
3614 /* Do a R_MIPS_SHIFT6 relocation. The MSB of the shift is stored at bit 2,
3615 the rest is at bits 6-10. The bitpos already got right by the howto. */
3617 static bfd_reloc_status_type
3618 mips_elf64_shift6_reloc (bfd
*abfd
, arelent
*reloc_entry
, asymbol
*symbol
,
3619 void *data
, asection
*input_section
, bfd
*output_bfd
,
3620 char **error_message
)
3622 if (reloc_entry
->howto
->partial_inplace
)
3624 reloc_entry
->addend
= ((reloc_entry
->addend
& 0x00007c0)
3625 | (reloc_entry
->addend
& 0x00000800) >> 9);
3628 return _bfd_mips_elf_generic_reloc (abfd
, reloc_entry
, symbol
, data
,
3629 input_section
, output_bfd
,
3633 /* Handle a mips16 GP relative reloc. */
3635 static bfd_reloc_status_type
3636 mips16_gprel_reloc (bfd
*abfd
, arelent
*reloc_entry
, asymbol
*symbol
,
3637 void *data
, asection
*input_section
, bfd
*output_bfd
,
3638 char **error_message
)
3641 bfd_reloc_status_type ret
;
3645 /* If we're relocating, and this is an external symbol, we don't want
3646 to change anything. */
3647 if (output_bfd
!= NULL
3648 && (symbol
->flags
& BSF_SECTION_SYM
) == 0
3649 && (symbol
->flags
& BSF_LOCAL
) != 0)
3651 reloc_entry
->address
+= input_section
->output_offset
;
3652 return bfd_reloc_ok
;
3655 if (output_bfd
!= NULL
)
3659 relocatable
= false;
3660 output_bfd
= input_section
->output_section
->owner
;
3663 ret
= mips_elf64_final_gp (output_bfd
, symbol
, relocatable
, error_message
,
3665 if (ret
!= bfd_reloc_ok
)
3668 if (!_bfd_mips_reloc_offset_in_range (abfd
, input_section
, reloc_entry
,
3670 return bfd_reloc_outofrange
;
3672 location
= (bfd_byte
*) data
+ reloc_entry
->address
;
3673 _bfd_mips_elf_reloc_unshuffle (abfd
, reloc_entry
->howto
->type
, false,
3675 ret
= _bfd_mips_elf_gprel16_with_gp (abfd
, symbol
, reloc_entry
,
3676 input_section
, relocatable
,
3678 _bfd_mips_elf_reloc_shuffle (abfd
, reloc_entry
->howto
->type
, !relocatable
,
3684 /* A mapping from BFD reloc types to MIPS ELF reloc types. */
3686 struct elf_reloc_map
{
3687 bfd_reloc_code_real_type bfd_val
;
3688 enum elf_mips_reloc_type elf_val
;
3691 static const struct elf_reloc_map mips_reloc_map
[] =
3693 { BFD_RELOC_NONE
, R_MIPS_NONE
},
3694 { BFD_RELOC_MIPS_16
, R_MIPS_16
},
3695 { BFD_RELOC_16
, R_MIPS_REL16
},
3696 { BFD_RELOC_32
, R_MIPS_32
},
3697 /* There is no BFD reloc for R_MIPS_REL32. */
3698 { BFD_RELOC_64
, R_MIPS_64
},
3699 { BFD_RELOC_CTOR
, R_MIPS_64
},
3700 { BFD_RELOC_16_PCREL_S2
, R_MIPS_PC16
},
3701 { BFD_RELOC_HI16_S
, R_MIPS_HI16
},
3702 { BFD_RELOC_LO16
, R_MIPS_LO16
},
3703 { BFD_RELOC_GPREL16
, R_MIPS_GPREL16
},
3704 { BFD_RELOC_GPREL32
, R_MIPS_GPREL32
},
3705 { BFD_RELOC_MIPS_JMP
, R_MIPS_26
},
3706 { BFD_RELOC_MIPS_LITERAL
, R_MIPS_LITERAL
},
3707 { BFD_RELOC_MIPS_GOT16
, R_MIPS_GOT16
},
3708 { BFD_RELOC_MIPS_CALL16
, R_MIPS_CALL16
},
3709 { BFD_RELOC_MIPS_SHIFT5
, R_MIPS_SHIFT5
},
3710 { BFD_RELOC_MIPS_SHIFT6
, R_MIPS_SHIFT6
},
3711 { BFD_RELOC_MIPS_GOT_DISP
, R_MIPS_GOT_DISP
},
3712 { BFD_RELOC_MIPS_GOT_PAGE
, R_MIPS_GOT_PAGE
},
3713 { BFD_RELOC_MIPS_GOT_OFST
, R_MIPS_GOT_OFST
},
3714 { BFD_RELOC_MIPS_GOT_HI16
, R_MIPS_GOT_HI16
},
3715 { BFD_RELOC_MIPS_GOT_LO16
, R_MIPS_GOT_LO16
},
3716 { BFD_RELOC_MIPS_SUB
, R_MIPS_SUB
},
3717 { BFD_RELOC_MIPS_INSERT_A
, R_MIPS_INSERT_A
},
3718 { BFD_RELOC_MIPS_INSERT_B
, R_MIPS_INSERT_B
},
3719 { BFD_RELOC_MIPS_DELETE
, R_MIPS_DELETE
},
3720 { BFD_RELOC_MIPS_HIGHEST
, R_MIPS_HIGHEST
},
3721 { BFD_RELOC_MIPS_HIGHER
, R_MIPS_HIGHER
},
3722 { BFD_RELOC_MIPS_CALL_HI16
, R_MIPS_CALL_HI16
},
3723 { BFD_RELOC_MIPS_CALL_LO16
, R_MIPS_CALL_LO16
},
3724 { BFD_RELOC_MIPS_SCN_DISP
, R_MIPS_SCN_DISP
},
3725 /* Use of R_MIPS_ADD_IMMEDIATE and R_MIPS_PJUMP is deprecated. */
3726 { BFD_RELOC_MIPS_RELGOT
, R_MIPS_RELGOT
},
3727 { BFD_RELOC_MIPS_JALR
, R_MIPS_JALR
},
3728 { BFD_RELOC_MIPS_TLS_DTPMOD32
, R_MIPS_TLS_DTPMOD32
},
3729 { BFD_RELOC_MIPS_TLS_DTPREL32
, R_MIPS_TLS_DTPREL32
},
3730 { BFD_RELOC_MIPS_TLS_DTPMOD64
, R_MIPS_TLS_DTPMOD64
},
3731 { BFD_RELOC_MIPS_TLS_DTPREL64
, R_MIPS_TLS_DTPREL64
},
3732 { BFD_RELOC_MIPS_TLS_GD
, R_MIPS_TLS_GD
},
3733 { BFD_RELOC_MIPS_TLS_LDM
, R_MIPS_TLS_LDM
},
3734 { BFD_RELOC_MIPS_TLS_DTPREL_HI16
, R_MIPS_TLS_DTPREL_HI16
},
3735 { BFD_RELOC_MIPS_TLS_DTPREL_LO16
, R_MIPS_TLS_DTPREL_LO16
},
3736 { BFD_RELOC_MIPS_TLS_GOTTPREL
, R_MIPS_TLS_GOTTPREL
},
3737 { BFD_RELOC_MIPS_TLS_TPREL32
, R_MIPS_TLS_TPREL32
},
3738 { BFD_RELOC_MIPS_TLS_TPREL64
, R_MIPS_TLS_TPREL64
},
3739 { BFD_RELOC_MIPS_TLS_TPREL_HI16
, R_MIPS_TLS_TPREL_HI16
},
3740 { BFD_RELOC_MIPS_TLS_TPREL_LO16
, R_MIPS_TLS_TPREL_LO16
},
3741 { BFD_RELOC_MIPS_21_PCREL_S2
, R_MIPS_PC21_S2
},
3742 { BFD_RELOC_MIPS_26_PCREL_S2
, R_MIPS_PC26_S2
},
3743 { BFD_RELOC_MIPS_18_PCREL_S3
, R_MIPS_PC18_S3
},
3744 { BFD_RELOC_MIPS_19_PCREL_S2
, R_MIPS_PC19_S2
},
3745 { BFD_RELOC_HI16_S_PCREL
, R_MIPS_PCHI16
},
3746 { BFD_RELOC_LO16_PCREL
, R_MIPS_PCLO16
}
3749 static const struct elf_reloc_map mips16_reloc_map
[] =
3751 { BFD_RELOC_MIPS16_JMP
, R_MIPS16_26
- R_MIPS16_min
},
3752 { BFD_RELOC_MIPS16_GPREL
, R_MIPS16_GPREL
- R_MIPS16_min
},
3753 { BFD_RELOC_MIPS16_GOT16
, R_MIPS16_GOT16
- R_MIPS16_min
},
3754 { BFD_RELOC_MIPS16_CALL16
, R_MIPS16_CALL16
- R_MIPS16_min
},
3755 { BFD_RELOC_MIPS16_HI16_S
, R_MIPS16_HI16
- R_MIPS16_min
},
3756 { BFD_RELOC_MIPS16_LO16
, R_MIPS16_LO16
- R_MIPS16_min
},
3757 { BFD_RELOC_MIPS16_TLS_GD
, R_MIPS16_TLS_GD
- R_MIPS16_min
},
3758 { BFD_RELOC_MIPS16_TLS_LDM
, R_MIPS16_TLS_LDM
- R_MIPS16_min
},
3759 { BFD_RELOC_MIPS16_TLS_DTPREL_HI16
,
3760 R_MIPS16_TLS_DTPREL_HI16
- R_MIPS16_min
},
3761 { BFD_RELOC_MIPS16_TLS_DTPREL_LO16
,
3762 R_MIPS16_TLS_DTPREL_LO16
- R_MIPS16_min
},
3763 { BFD_RELOC_MIPS16_TLS_GOTTPREL
, R_MIPS16_TLS_GOTTPREL
- R_MIPS16_min
},
3764 { BFD_RELOC_MIPS16_TLS_TPREL_HI16
, R_MIPS16_TLS_TPREL_HI16
- R_MIPS16_min
},
3765 { BFD_RELOC_MIPS16_TLS_TPREL_LO16
, R_MIPS16_TLS_TPREL_LO16
- R_MIPS16_min
},
3766 { BFD_RELOC_MIPS16_16_PCREL_S1
, R_MIPS16_PC16_S1
- R_MIPS16_min
}
3769 static const struct elf_reloc_map micromips_reloc_map
[] =
3771 { BFD_RELOC_MICROMIPS_JMP
, R_MICROMIPS_26_S1
- R_MICROMIPS_min
},
3772 { BFD_RELOC_MICROMIPS_HI16_S
, R_MICROMIPS_HI16
- R_MICROMIPS_min
},
3773 { BFD_RELOC_MICROMIPS_LO16
, R_MICROMIPS_LO16
- R_MICROMIPS_min
},
3774 { BFD_RELOC_MICROMIPS_GPREL16
, R_MICROMIPS_GPREL16
- R_MICROMIPS_min
},
3775 { BFD_RELOC_MICROMIPS_LITERAL
, R_MICROMIPS_LITERAL
- R_MICROMIPS_min
},
3776 { BFD_RELOC_MICROMIPS_GOT16
, R_MICROMIPS_GOT16
- R_MICROMIPS_min
},
3777 { BFD_RELOC_MICROMIPS_7_PCREL_S1
, R_MICROMIPS_PC7_S1
- R_MICROMIPS_min
},
3778 { BFD_RELOC_MICROMIPS_10_PCREL_S1
, R_MICROMIPS_PC10_S1
- R_MICROMIPS_min
},
3779 { BFD_RELOC_MICROMIPS_16_PCREL_S1
, R_MICROMIPS_PC16_S1
- R_MICROMIPS_min
},
3780 { BFD_RELOC_MICROMIPS_CALL16
, R_MICROMIPS_CALL16
- R_MICROMIPS_min
},
3781 { BFD_RELOC_MICROMIPS_GOT_DISP
, R_MICROMIPS_GOT_DISP
- R_MICROMIPS_min
},
3782 { BFD_RELOC_MICROMIPS_GOT_PAGE
, R_MICROMIPS_GOT_PAGE
- R_MICROMIPS_min
},
3783 { BFD_RELOC_MICROMIPS_GOT_OFST
, R_MICROMIPS_GOT_OFST
- R_MICROMIPS_min
},
3784 { BFD_RELOC_MICROMIPS_GOT_HI16
, R_MICROMIPS_GOT_HI16
- R_MICROMIPS_min
},
3785 { BFD_RELOC_MICROMIPS_GOT_LO16
, R_MICROMIPS_GOT_LO16
- R_MICROMIPS_min
},
3786 { BFD_RELOC_MICROMIPS_SUB
, R_MICROMIPS_SUB
- R_MICROMIPS_min
},
3787 { BFD_RELOC_MICROMIPS_HIGHER
, R_MICROMIPS_HIGHER
- R_MICROMIPS_min
},
3788 { BFD_RELOC_MICROMIPS_HIGHEST
, R_MICROMIPS_HIGHEST
- R_MICROMIPS_min
},
3789 { BFD_RELOC_MICROMIPS_CALL_HI16
, R_MICROMIPS_CALL_HI16
- R_MICROMIPS_min
},
3790 { BFD_RELOC_MICROMIPS_CALL_LO16
, R_MICROMIPS_CALL_LO16
- R_MICROMIPS_min
},
3791 { BFD_RELOC_MICROMIPS_SCN_DISP
, R_MICROMIPS_SCN_DISP
- R_MICROMIPS_min
},
3792 { BFD_RELOC_MICROMIPS_JALR
, R_MICROMIPS_JALR
- R_MICROMIPS_min
},
3793 /* There is no BFD reloc for R_MICROMIPS_HI0_LO16. */
3794 { BFD_RELOC_MICROMIPS_TLS_GD
, R_MICROMIPS_TLS_GD
- R_MICROMIPS_min
},
3795 { BFD_RELOC_MICROMIPS_TLS_LDM
, R_MICROMIPS_TLS_LDM
- R_MICROMIPS_min
},
3796 { BFD_RELOC_MICROMIPS_TLS_DTPREL_HI16
,
3797 R_MICROMIPS_TLS_DTPREL_HI16
- R_MICROMIPS_min
},
3798 { BFD_RELOC_MICROMIPS_TLS_DTPREL_LO16
,
3799 R_MICROMIPS_TLS_DTPREL_LO16
- R_MICROMIPS_min
},
3800 { BFD_RELOC_MICROMIPS_TLS_GOTTPREL
,
3801 R_MICROMIPS_TLS_GOTTPREL
- R_MICROMIPS_min
},
3802 { BFD_RELOC_MICROMIPS_TLS_TPREL_HI16
,
3803 R_MICROMIPS_TLS_TPREL_HI16
- R_MICROMIPS_min
},
3804 { BFD_RELOC_MICROMIPS_TLS_TPREL_LO16
,
3805 R_MICROMIPS_TLS_TPREL_LO16
- R_MICROMIPS_min
},
3806 /* There is no BFD reloc for R_MICROMIPS_GPREL7_S2. */
3807 /* There is no BFD reloc for R_MICROMIPS_PC23_S2. */
3809 /* Given a BFD reloc type, return a howto structure. */
3811 static reloc_howto_type
*
3812 bfd_elf64_bfd_reloc_type_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
3813 bfd_reloc_code_real_type code
)
3816 /* FIXME: We default to RELA here instead of choosing the right
3817 relocation variant. */
3818 reloc_howto_type
*howto_table
= mips_elf64_howto_table_rela
;
3819 reloc_howto_type
*howto16_table
= mips16_elf64_howto_table_rela
;
3820 reloc_howto_type
*howto_micromips_table
= micromips_elf64_howto_table_rela
;
3822 for (i
= 0; i
< sizeof (mips_reloc_map
) / sizeof (struct elf_reloc_map
);
3825 if (mips_reloc_map
[i
].bfd_val
== code
)
3826 return &howto_table
[(int) mips_reloc_map
[i
].elf_val
];
3829 for (i
= 0; i
< sizeof (mips16_reloc_map
) / sizeof (struct elf_reloc_map
);
3832 if (mips16_reloc_map
[i
].bfd_val
== code
)
3833 return &howto16_table
[(int) mips16_reloc_map
[i
].elf_val
];
3836 for (i
= 0; i
< sizeof (micromips_reloc_map
) / sizeof (struct elf_reloc_map
);
3839 if (micromips_reloc_map
[i
].bfd_val
== code
)
3840 return &howto_micromips_table
[(int) micromips_reloc_map
[i
].elf_val
];
3845 case BFD_RELOC_VTABLE_INHERIT
:
3846 return &elf_mips_gnu_vtinherit_howto
;
3847 case BFD_RELOC_VTABLE_ENTRY
:
3848 return &elf_mips_gnu_vtentry_howto
;
3849 case BFD_RELOC_32_PCREL
:
3850 return &elf_mips_gnu_pcrel32
;
3851 case BFD_RELOC_MIPS_EH
:
3852 return &elf_mips_eh_howto
;
3853 case BFD_RELOC_MIPS_COPY
:
3854 return &elf_mips_copy_howto
;
3855 case BFD_RELOC_MIPS_JUMP_SLOT
:
3856 return &elf_mips_jump_slot_howto
;
3858 bfd_set_error (bfd_error_bad_value
);
3863 static reloc_howto_type
*
3864 bfd_elf64_bfd_reloc_name_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
3870 i
< (sizeof (mips_elf64_howto_table_rela
)
3871 / sizeof (mips_elf64_howto_table_rela
[0])); i
++)
3872 if (mips_elf64_howto_table_rela
[i
].name
!= NULL
3873 && strcasecmp (mips_elf64_howto_table_rela
[i
].name
, r_name
) == 0)
3874 return &mips_elf64_howto_table_rela
[i
];
3877 i
< (sizeof (mips16_elf64_howto_table_rela
)
3878 / sizeof (mips16_elf64_howto_table_rela
[0]));
3880 if (mips16_elf64_howto_table_rela
[i
].name
!= NULL
3881 && strcasecmp (mips16_elf64_howto_table_rela
[i
].name
, r_name
) == 0)
3882 return &mips16_elf64_howto_table_rela
[i
];
3885 i
< (sizeof (micromips_elf64_howto_table_rela
)
3886 / sizeof (micromips_elf64_howto_table_rela
[0]));
3888 if (micromips_elf64_howto_table_rela
[i
].name
!= NULL
3889 && strcasecmp (micromips_elf64_howto_table_rela
[i
].name
, r_name
) == 0)
3890 return µmips_elf64_howto_table_rela
[i
];
3892 if (strcasecmp (elf_mips_gnu_vtinherit_howto
.name
, r_name
) == 0)
3893 return &elf_mips_gnu_vtinherit_howto
;
3894 if (strcasecmp (elf_mips_gnu_vtentry_howto
.name
, r_name
) == 0)
3895 return &elf_mips_gnu_vtentry_howto
;
3896 if (strcasecmp (elf_mips_gnu_rel16_s2
.name
, r_name
) == 0)
3897 return &elf_mips_gnu_rel16_s2
;
3898 if (strcasecmp (elf_mips_gnu_rela16_s2
.name
, r_name
) == 0)
3899 return &elf_mips_gnu_rela16_s2
;
3900 if (strcasecmp (elf_mips_gnu_pcrel32
.name
, r_name
) == 0)
3901 return &elf_mips_gnu_pcrel32
;
3902 if (strcasecmp (elf_mips_eh_howto
.name
, r_name
) == 0)
3903 return &elf_mips_eh_howto
;
3904 if (strcasecmp (elf_mips_copy_howto
.name
, r_name
) == 0)
3905 return &elf_mips_copy_howto
;
3906 if (strcasecmp (elf_mips_jump_slot_howto
.name
, r_name
) == 0)
3907 return &elf_mips_jump_slot_howto
;
3912 /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure. */
3914 static reloc_howto_type
*
3915 mips_elf64_rtype_to_howto (bfd
*abfd
, unsigned int r_type
, bool rela_p
)
3917 reloc_howto_type
*howto
= NULL
;
3921 case R_MIPS_GNU_VTINHERIT
:
3922 return &elf_mips_gnu_vtinherit_howto
;
3923 case R_MIPS_GNU_VTENTRY
:
3924 return &elf_mips_gnu_vtentry_howto
;
3925 case R_MIPS_GNU_REL16_S2
:
3927 return &elf_mips_gnu_rela16_s2
;
3929 return &elf_mips_gnu_rel16_s2
;
3931 return &elf_mips_gnu_pcrel32
;
3933 return &elf_mips_eh_howto
;
3935 return &elf_mips_copy_howto
;
3936 case R_MIPS_JUMP_SLOT
:
3937 return &elf_mips_jump_slot_howto
;
3939 if (r_type
>= R_MICROMIPS_min
&& r_type
< R_MICROMIPS_max
)
3943 = µmips_elf64_howto_table_rela
[r_type
- R_MICROMIPS_min
];
3946 = µmips_elf64_howto_table_rel
[r_type
- R_MICROMIPS_min
];
3948 if (r_type
>= R_MIPS16_min
&& r_type
< R_MIPS16_max
)
3951 howto
= &mips16_elf64_howto_table_rela
[r_type
- R_MIPS16_min
];
3953 howto
= &mips16_elf64_howto_table_rel
[r_type
- R_MIPS16_min
];
3955 if (r_type
< R_MIPS_max
)
3958 howto
= &mips_elf64_howto_table_rela
[r_type
];
3960 howto
= &mips_elf64_howto_table_rel
[r_type
];
3962 if (howto
!= NULL
&& howto
->name
!= NULL
)
3965 _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
3967 bfd_set_error (bfd_error_bad_value
);
3972 /* Prevent relocation handling by bfd for MIPS ELF64. */
3975 mips_elf64_info_to_howto_rela (bfd
*abfd
,
3976 arelent
*cache_ptr ATTRIBUTE_UNUSED
,
3977 Elf_Internal_Rela
*dst
)
3979 unsigned int r_type
= ELF32_R_TYPE (dst
->r_info
);
3980 /* xgettext:c-format */
3981 _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
3983 bfd_set_error (bfd_error_bad_value
);
3987 /* Since each entry in an SHT_REL or SHT_RELA section can represent up
3988 to three relocs, we must tell the user to allocate more space. */
3991 mips_elf64_get_dynamic_reloc_upper_bound (bfd
*abfd
)
3993 return _bfd_elf_get_dynamic_reloc_upper_bound (abfd
) * 3;
3996 /* Read the relocations from one reloc section. This is mostly copied
3997 from elfcode.h, except for the changes to expand one external
3998 relocation to 3 internal ones. To reduce processing effort we
3999 could discard those R_MIPS_NONE relocations that occupy the second
4000 and the third entry of a triplet, as `mips_elf64_write_rel' and
4001 `mips_elf64_write_rela' recreate them in output automagically,
4002 however that would also remove them from `objdump -r' output,
4003 breaking a long-established tradition and likely confusing people. */
4006 mips_elf64_slurp_one_reloc_table (bfd
*abfd
, asection
*asect
,
4007 Elf_Internal_Shdr
*rel_hdr
,
4008 bfd_size_type reloc_count
,
4009 arelent
*relents
, asymbol
**symbols
,
4013 bfd_byte
*native_relocs
;
4014 unsigned int symcount
;
4020 if (bfd_seek (abfd
, rel_hdr
->sh_offset
, SEEK_SET
) != 0)
4022 allocated
= _bfd_malloc_and_read (abfd
, rel_hdr
->sh_size
, rel_hdr
->sh_size
);
4023 if (allocated
== NULL
)
4026 native_relocs
= allocated
;
4028 entsize
= rel_hdr
->sh_entsize
;
4029 BFD_ASSERT (entsize
== sizeof (Elf64_Mips_External_Rel
)
4030 || entsize
== sizeof (Elf64_Mips_External_Rela
));
4032 if (entsize
== sizeof (Elf64_Mips_External_Rel
))
4038 symcount
= bfd_get_dynamic_symcount (abfd
);
4040 symcount
= bfd_get_symcount (abfd
);
4042 for (i
= 0, relent
= relents
;
4044 i
++, native_relocs
+= entsize
)
4046 Elf64_Mips_Internal_Rela rela
;
4047 bool used_sym
, used_ssym
;
4050 if (entsize
== sizeof (Elf64_Mips_External_Rela
))
4051 mips_elf64_swap_reloca_in (abfd
,
4052 (Elf64_Mips_External_Rela
*) native_relocs
,
4055 mips_elf64_swap_reloc_in (abfd
,
4056 (Elf64_Mips_External_Rel
*) native_relocs
,
4059 /* Each entry represents exactly three actual relocations. */
4063 for (ir
= 0; ir
< 3; ir
++)
4065 enum elf_mips_reloc_type type
;
4072 type
= (enum elf_mips_reloc_type
) rela
.r_type
;
4075 type
= (enum elf_mips_reloc_type
) rela
.r_type2
;
4078 type
= (enum elf_mips_reloc_type
) rela
.r_type3
;
4082 /* Some types require symbols, whereas some do not. */
4083 relent
->sym_ptr_ptr
= bfd_abs_section_ptr
->symbol_ptr_ptr
;
4087 case R_MIPS_LITERAL
:
4088 case R_MIPS_INSERT_A
:
4089 case R_MIPS_INSERT_B
:
4096 if (rela
.r_sym
== STN_UNDEF
)
4098 else if (rela
.r_sym
> symcount
)
4101 /* xgettext:c-format */
4102 (_("%pB(%pA): relocation %" PRIu64
4103 " has invalid symbol index %ld"),
4104 abfd
, asect
, (uint64_t) i
, rela
.r_sym
);
4105 bfd_set_error (bfd_error_bad_value
);
4111 ps
= symbols
+ rela
.r_sym
- 1;
4113 if ((s
->flags
& BSF_SECTION_SYM
) == 0)
4114 relent
->sym_ptr_ptr
= ps
;
4116 relent
->sym_ptr_ptr
= s
->section
->symbol_ptr_ptr
;
4121 else if (! used_ssym
)
4123 switch (rela
.r_ssym
)
4131 /* FIXME: I think these need to be handled using
4132 special howto structures. */
4146 /* The address of an ELF reloc is section relative for an
4147 object file, and absolute for an executable file or
4148 shared library. The address of a BFD reloc is always
4149 section relative. */
4150 if ((abfd
->flags
& (EXEC_P
| DYNAMIC
)) == 0 || dynamic
)
4151 relent
->address
= rela
.r_offset
;
4153 relent
->address
= rela
.r_offset
- asect
->vma
;
4155 relent
->addend
= rela
.r_addend
;
4157 relent
->howto
= mips_elf64_rtype_to_howto (abfd
, type
, rela_p
);
4158 if (relent
->howto
== NULL
)
4173 /* Read the relocations. On Irix 6, there can be two reloc sections
4174 associated with a single data section. This is copied from
4175 elfcode.h as well, with changes as small as accounting for 3
4176 internal relocs per external reloc. */
4179 mips_elf64_slurp_reloc_table (bfd
*abfd
, asection
*asect
,
4180 asymbol
**symbols
, bool dynamic
)
4182 struct bfd_elf_section_data
* const d
= elf_section_data (asect
);
4183 Elf_Internal_Shdr
*rel_hdr
;
4184 Elf_Internal_Shdr
*rel_hdr2
;
4185 bfd_size_type reloc_count
;
4186 bfd_size_type reloc_count2
;
4190 if (asect
->relocation
!= NULL
)
4195 if ((asect
->flags
& SEC_RELOC
) == 0
4196 || asect
->reloc_count
== 0)
4199 rel_hdr
= d
->rel
.hdr
;
4200 reloc_count
= rel_hdr
? NUM_SHDR_ENTRIES (rel_hdr
) : 0;
4201 rel_hdr2
= d
->rela
.hdr
;
4202 reloc_count2
= (rel_hdr2
? NUM_SHDR_ENTRIES (rel_hdr2
) : 0);
4204 BFD_ASSERT (asect
->reloc_count
== 3 * (reloc_count
+ reloc_count2
));
4205 BFD_ASSERT ((rel_hdr
&& asect
->rel_filepos
== rel_hdr
->sh_offset
)
4206 || (rel_hdr2
&& asect
->rel_filepos
== rel_hdr2
->sh_offset
));
4211 /* Note that ASECT->RELOC_COUNT tends not to be accurate in this
4212 case because relocations against this section may use the
4213 dynamic symbol table, and in that case bfd_section_from_shdr
4214 in elf.c does not update the RELOC_COUNT. */
4215 if (asect
->size
== 0)
4218 rel_hdr
= &d
->this_hdr
;
4219 reloc_count
= NUM_SHDR_ENTRIES (rel_hdr
);
4224 /* Allocate space for 3 arelent structures for each Rel structure. */
4225 amt
= (reloc_count
+ reloc_count2
) * 3 * sizeof (arelent
);
4226 relents
= bfd_alloc (abfd
, amt
);
4227 if (relents
== NULL
)
4231 && ! mips_elf64_slurp_one_reloc_table (abfd
, asect
,
4232 rel_hdr
, reloc_count
,
4236 if (rel_hdr2
!= NULL
4237 && ! mips_elf64_slurp_one_reloc_table (abfd
, asect
,
4238 rel_hdr2
, reloc_count2
,
4239 relents
+ reloc_count
* 3,
4243 asect
->relocation
= relents
;
4247 /* Write out the relocations. */
4250 mips_elf64_write_relocs (bfd
*abfd
, asection
*sec
, void *data
)
4252 bool *failedp
= data
;
4254 Elf_Internal_Shdr
*rel_hdr
;
4257 /* If we have already failed, don't do anything. */
4261 if ((sec
->flags
& SEC_RELOC
) == 0)
4264 /* The linker backend writes the relocs out itself, and sets the
4265 reloc_count field to zero to inhibit writing them here. Also,
4266 sometimes the SEC_RELOC flag gets set even when there aren't any
4268 if (sec
->reloc_count
== 0)
4271 /* We can combine up to three relocs that refer to the same address
4272 if the latter relocs have no associated symbol. */
4274 for (idx
= 0; idx
< sec
->reloc_count
; idx
++)
4281 addr
= sec
->orelocation
[idx
]->address
;
4282 for (i
= 0; i
< 2; i
++)
4286 if (idx
+ 1 >= sec
->reloc_count
)
4288 r
= sec
->orelocation
[idx
+ 1];
4289 if (r
->address
!= addr
4290 || ! bfd_is_abs_section ((*r
->sym_ptr_ptr
)->section
)
4291 || (*r
->sym_ptr_ptr
)->value
!= 0)
4294 /* We can merge the reloc at IDX + 1 with the reloc at IDX. */
4300 rel_hdr
= _bfd_elf_single_rel_hdr (sec
);
4302 /* Do the actual relocation. */
4304 if (rel_hdr
->sh_entsize
== sizeof(Elf64_Mips_External_Rel
))
4305 mips_elf64_write_rel (abfd
, sec
, rel_hdr
, &count
, data
);
4306 else if (rel_hdr
->sh_entsize
== sizeof(Elf64_Mips_External_Rela
))
4307 mips_elf64_write_rela (abfd
, sec
, rel_hdr
, &count
, data
);
4313 mips_elf64_write_rel (bfd
*abfd
, asection
*sec
,
4314 Elf_Internal_Shdr
*rel_hdr
,
4315 int *count
, void *data
)
4317 bool *failedp
= data
;
4318 Elf64_Mips_External_Rel
*ext_rel
;
4320 asymbol
*last_sym
= 0;
4321 int last_sym_idx
= 0;
4323 rel_hdr
->sh_size
= rel_hdr
->sh_entsize
* *count
;
4324 rel_hdr
->contents
= bfd_alloc (abfd
, rel_hdr
->sh_size
);
4325 if (rel_hdr
->contents
== NULL
)
4331 ext_rel
= (Elf64_Mips_External_Rel
*) rel_hdr
->contents
;
4332 for (idx
= 0; idx
< sec
->reloc_count
; idx
++, ext_rel
++)
4335 Elf64_Mips_Internal_Rela int_rel
;
4340 ptr
= sec
->orelocation
[idx
];
4342 /* The address of an ELF reloc is section relative for an object
4343 file, and absolute for an executable file or shared library.
4344 The address of a BFD reloc is always section relative. */
4345 if ((abfd
->flags
& (EXEC_P
| DYNAMIC
)) == 0)
4346 int_rel
.r_offset
= ptr
->address
;
4348 int_rel
.r_offset
= ptr
->address
+ sec
->vma
;
4350 sym
= *ptr
->sym_ptr_ptr
;
4351 if (sym
== last_sym
)
4353 else if (bfd_is_abs_section (sym
->section
) && sym
->value
== 0)
4358 n
= _bfd_elf_symbol_from_bfd_symbol (abfd
, &sym
);
4368 int_rel
.r_ssym
= RSS_UNDEF
;
4370 if ((*ptr
->sym_ptr_ptr
)->the_bfd
!= NULL
4371 && (*ptr
->sym_ptr_ptr
)->the_bfd
->xvec
!= abfd
->xvec
4372 && ! _bfd_elf_validate_reloc (abfd
, ptr
))
4378 int_rel
.r_type
= ptr
->howto
->type
;
4379 int_rel
.r_type2
= (int) R_MIPS_NONE
;
4380 int_rel
.r_type3
= (int) R_MIPS_NONE
;
4382 for (i
= 0; i
< 2; i
++)
4386 if (idx
+ 1 >= sec
->reloc_count
)
4388 r
= sec
->orelocation
[idx
+ 1];
4389 if (r
->address
!= ptr
->address
4390 || ! bfd_is_abs_section ((*r
->sym_ptr_ptr
)->section
)
4391 || (*r
->sym_ptr_ptr
)->value
!= 0)
4394 /* We can merge the reloc at IDX + 1 with the reloc at IDX. */
4397 int_rel
.r_type2
= r
->howto
->type
;
4399 int_rel
.r_type3
= r
->howto
->type
;
4404 mips_elf64_swap_reloc_out (abfd
, &int_rel
, ext_rel
);
4407 BFD_ASSERT (ext_rel
- (Elf64_Mips_External_Rel
*) rel_hdr
->contents
4412 mips_elf64_write_rela (bfd
*abfd
, asection
*sec
,
4413 Elf_Internal_Shdr
*rela_hdr
,
4414 int *count
, void *data
)
4416 bool *failedp
= data
;
4417 Elf64_Mips_External_Rela
*ext_rela
;
4419 asymbol
*last_sym
= 0;
4420 int last_sym_idx
= 0;
4422 rela_hdr
->sh_size
= rela_hdr
->sh_entsize
* *count
;
4423 rela_hdr
->contents
= bfd_alloc (abfd
, rela_hdr
->sh_size
);
4424 if (rela_hdr
->contents
== NULL
)
4430 ext_rela
= (Elf64_Mips_External_Rela
*) rela_hdr
->contents
;
4431 for (idx
= 0; idx
< sec
->reloc_count
; idx
++, ext_rela
++)
4434 Elf64_Mips_Internal_Rela int_rela
;
4439 ptr
= sec
->orelocation
[idx
];
4441 /* The address of an ELF reloc is section relative for an object
4442 file, and absolute for an executable file or shared library.
4443 The address of a BFD reloc is always section relative. */
4444 if ((abfd
->flags
& (EXEC_P
| DYNAMIC
)) == 0)
4445 int_rela
.r_offset
= ptr
->address
;
4447 int_rela
.r_offset
= ptr
->address
+ sec
->vma
;
4449 sym
= *ptr
->sym_ptr_ptr
;
4450 if (sym
== last_sym
)
4452 else if (bfd_is_abs_section (sym
->section
) && sym
->value
== 0)
4457 n
= _bfd_elf_symbol_from_bfd_symbol (abfd
, &sym
);
4467 int_rela
.r_addend
= ptr
->addend
;
4468 int_rela
.r_ssym
= RSS_UNDEF
;
4470 if ((*ptr
->sym_ptr_ptr
)->the_bfd
!= NULL
4471 && (*ptr
->sym_ptr_ptr
)->the_bfd
->xvec
!= abfd
->xvec
4472 && ! _bfd_elf_validate_reloc (abfd
, ptr
))
4478 int_rela
.r_type
= ptr
->howto
->type
;
4479 int_rela
.r_type2
= (int) R_MIPS_NONE
;
4480 int_rela
.r_type3
= (int) R_MIPS_NONE
;
4482 for (i
= 0; i
< 2; i
++)
4486 if (idx
+ 1 >= sec
->reloc_count
)
4488 r
= sec
->orelocation
[idx
+ 1];
4489 if (r
->address
!= ptr
->address
4490 || ! bfd_is_abs_section ((*r
->sym_ptr_ptr
)->section
)
4491 || (*r
->sym_ptr_ptr
)->value
!= 0)
4494 /* We can merge the reloc at IDX + 1 with the reloc at IDX. */
4497 int_rela
.r_type2
= r
->howto
->type
;
4499 int_rela
.r_type3
= r
->howto
->type
;
4504 mips_elf64_swap_reloca_out (abfd
, &int_rela
, ext_rela
);
4507 BFD_ASSERT (ext_rela
- (Elf64_Mips_External_Rela
*) rela_hdr
->contents
4511 /* Set the right machine number for a MIPS ELF file. */
4514 mips_elf64_object_p (bfd
*abfd
)
4518 /* Irix 6 is broken. Object file symbol tables are not always
4519 sorted correctly such that local symbols precede global symbols,
4520 and the sh_info field in the symbol table is not always right. */
4521 if (elf64_mips_irix_compat (abfd
) != ict_none
)
4522 elf_bad_symtab (abfd
) = true;
4524 mach
= _bfd_elf_mips_mach (elf_elfheader (abfd
)->e_flags
);
4525 bfd_default_set_arch_mach (abfd
, bfd_arch_mips
, mach
);
4529 /* Depending on the target vector we generate some version of Irix
4530 executables or "normal" MIPS ELF ABI executables. */
4531 static irix_compat_t
4532 elf64_mips_irix_compat (bfd
*abfd
)
4534 if ((abfd
->xvec
== &mips_elf64_be_vec
)
4535 || (abfd
->xvec
== &mips_elf64_le_vec
))
4541 /* Support for core dump NOTE sections. */
4543 elf64_mips_grok_prstatus (bfd
*abfd
, Elf_Internal_Note
*note
)
4548 switch (note
->descsz
)
4553 case 480: /* Linux/MIPS - N64 kernel */
4555 elf_tdata (abfd
)->core
->signal
= bfd_get_16 (abfd
, note
->descdata
+ 12);
4558 elf_tdata (abfd
)->core
->lwpid
= bfd_get_32 (abfd
, note
->descdata
+ 32);
4567 /* Make a ".reg/999" section. */
4568 return _bfd_elfcore_make_pseudosection (abfd
, ".reg",
4569 size
, note
->descpos
+ offset
);
4573 elf64_mips_grok_psinfo (bfd
*abfd
, Elf_Internal_Note
*note
)
4575 switch (note
->descsz
)
4580 case 136: /* Linux/MIPS - N64 kernel elf_prpsinfo */
4581 elf_tdata (abfd
)->core
->pid
4582 = bfd_get_32 (abfd
, note
->descdata
+ 24);
4583 elf_tdata (abfd
)->core
->program
4584 = _bfd_elfcore_strndup (abfd
, note
->descdata
+ 40, 16);
4585 elf_tdata (abfd
)->core
->command
4586 = _bfd_elfcore_strndup (abfd
, note
->descdata
+ 56, 80);
4589 /* Note that for some reason, a spurious space is tacked
4590 onto the end of the args in some (at least one anyway)
4591 implementations, so strip it off if it exists. */
4594 char *command
= elf_tdata (abfd
)->core
->command
;
4595 int n
= strlen (command
);
4597 if (0 < n
&& command
[n
- 1] == ' ')
4598 command
[n
- 1] = '\0';
4604 /* Write Linux core PRSTATUS note into core file. */
4607 elf64_mips_write_core_note (bfd
*abfd
, char *buf
, int *bufsiz
, int note_type
,
4627 va_start (ap
, note_type
);
4628 memset (data
, 0, 112);
4629 pid
= va_arg (ap
, long);
4630 bfd_put_32 (abfd
, pid
, data
+ 32);
4631 cursig
= va_arg (ap
, int);
4632 bfd_put_16 (abfd
, cursig
, data
+ 12);
4633 greg
= va_arg (ap
, const void *);
4634 memcpy (data
+ 112, greg
, 360);
4635 memset (data
+ 472, 0, 8);
4637 return elfcore_write_note (abfd
, buf
, bufsiz
,
4638 "CORE", note_type
, data
, sizeof (data
));
4643 /* ECOFF swapping routines. These are used when dealing with the
4644 .mdebug section, which is in the ECOFF debugging format. */
4645 static const struct ecoff_debug_swap mips_elf64_ecoff_debug_swap
=
4647 /* Symbol table magic number. */
4649 /* Alignment of debugging information. E.g., 4. */
4651 /* Sizes of external symbolic information. */
4652 sizeof (struct hdr_ext
),
4653 sizeof (struct dnr_ext
),
4654 sizeof (struct pdr_ext
),
4655 sizeof (struct sym_ext
),
4656 sizeof (struct opt_ext
),
4657 sizeof (struct fdr_ext
),
4658 sizeof (struct rfd_ext
),
4659 sizeof (struct ext_ext
),
4660 /* Functions to swap in external symbolic data. */
4669 _bfd_ecoff_swap_tir_in
,
4670 _bfd_ecoff_swap_rndx_in
,
4671 /* Functions to swap out external symbolic data. */
4680 _bfd_ecoff_swap_tir_out
,
4681 _bfd_ecoff_swap_rndx_out
,
4682 /* Function to read in symbolic data. */
4683 _bfd_mips_elf_read_ecoff_info
4686 /* Relocations in the 64 bit MIPS ELF ABI are more complex than in
4687 standard ELF. This structure is used to redirect the relocation
4688 handling routines. */
4690 const struct elf_size_info mips_elf64_size_info
=
4692 sizeof (Elf64_External_Ehdr
),
4693 sizeof (Elf64_External_Phdr
),
4694 sizeof (Elf64_External_Shdr
),
4695 sizeof (Elf64_Mips_External_Rel
),
4696 sizeof (Elf64_Mips_External_Rela
),
4697 sizeof (Elf64_External_Sym
),
4698 sizeof (Elf64_External_Dyn
),
4699 sizeof (Elf_External_Note
),
4700 4, /* hash-table entry size */
4701 3, /* internal relocations per external relocations */
4703 3, /* log_file_align */
4706 bfd_elf64_write_out_phdrs
,
4707 bfd_elf64_write_shdrs_and_ehdr
,
4708 bfd_elf64_checksum_contents
,
4709 mips_elf64_write_relocs
,
4710 bfd_elf64_swap_symbol_in
,
4711 bfd_elf64_swap_symbol_out
,
4712 mips_elf64_slurp_reloc_table
,
4713 bfd_elf64_slurp_symbol_table
,
4714 bfd_elf64_swap_dyn_in
,
4715 bfd_elf64_swap_dyn_out
,
4716 mips_elf64_be_swap_reloc_in
,
4717 mips_elf64_be_swap_reloc_out
,
4718 mips_elf64_be_swap_reloca_in
,
4719 mips_elf64_be_swap_reloca_out
4722 #define ELF_ARCH bfd_arch_mips
4723 #define ELF_TARGET_ID MIPS_ELF_DATA
4724 #define ELF_MACHINE_CODE EM_MIPS
4726 #define elf_backend_collect true
4727 #define elf_backend_type_change_ok true
4728 #define elf_backend_can_gc_sections true
4729 #define elf_backend_gc_mark_extra_sections \
4730 _bfd_mips_elf_gc_mark_extra_sections
4731 #define elf_info_to_howto mips_elf64_info_to_howto_rela
4732 #define elf_info_to_howto_rel mips_elf64_info_to_howto_rela
4733 #define elf_backend_object_p mips_elf64_object_p
4734 #define elf_backend_symbol_processing _bfd_mips_elf_symbol_processing
4735 #define elf_backend_section_processing _bfd_mips_elf_section_processing
4736 #define elf_backend_section_from_shdr _bfd_mips_elf_section_from_shdr
4737 #define elf_backend_fake_sections _bfd_mips_elf_fake_sections
4738 #define elf_backend_section_from_bfd_section \
4739 _bfd_mips_elf_section_from_bfd_section
4740 #define elf_backend_add_symbol_hook _bfd_mips_elf_add_symbol_hook
4741 #define elf_backend_link_output_symbol_hook \
4742 _bfd_mips_elf_link_output_symbol_hook
4743 #define elf_backend_create_dynamic_sections \
4744 _bfd_mips_elf_create_dynamic_sections
4745 #define elf_backend_check_relocs _bfd_mips_elf_check_relocs
4746 #define elf_backend_merge_symbol_attribute \
4747 _bfd_mips_elf_merge_symbol_attribute
4748 #define elf_backend_get_target_dtag _bfd_mips_elf_get_target_dtag
4749 #define elf_backend_adjust_dynamic_symbol \
4750 _bfd_mips_elf_adjust_dynamic_symbol
4751 #define elf_backend_always_size_sections \
4752 _bfd_mips_elf_always_size_sections
4753 #define elf_backend_size_dynamic_sections \
4754 _bfd_mips_elf_size_dynamic_sections
4755 #define elf_backend_init_index_section _bfd_elf_init_1_index_section
4756 #define elf_backend_relocate_section _bfd_mips_elf_relocate_section
4757 #define elf_backend_finish_dynamic_symbol \
4758 _bfd_mips_elf_finish_dynamic_symbol
4759 #define elf_backend_finish_dynamic_sections \
4760 _bfd_mips_elf_finish_dynamic_sections
4761 #define elf_backend_final_write_processing \
4762 _bfd_mips_elf_final_write_processing
4763 #define elf_backend_additional_program_headers \
4764 _bfd_mips_elf_additional_program_headers
4765 #define elf_backend_modify_segment_map _bfd_mips_elf_modify_segment_map
4766 #define elf_backend_gc_mark_hook _bfd_mips_elf_gc_mark_hook
4767 #define elf_backend_copy_indirect_symbol \
4768 _bfd_mips_elf_copy_indirect_symbol
4769 #define elf_backend_hide_symbol _bfd_mips_elf_hide_symbol
4770 #define elf_backend_ignore_discarded_relocs \
4771 _bfd_mips_elf_ignore_discarded_relocs
4772 #define elf_backend_mips_irix_compat elf64_mips_irix_compat
4773 #define elf_backend_mips_rtype_to_howto mips_elf64_rtype_to_howto
4774 #define elf_backend_ecoff_debug_swap &mips_elf64_ecoff_debug_swap
4775 #define elf_backend_size_info mips_elf64_size_info
4777 #define elf_backend_grok_prstatus elf64_mips_grok_prstatus
4778 #define elf_backend_grok_psinfo elf64_mips_grok_psinfo
4780 #define elf_backend_got_header_size (8 * MIPS_RESERVED_GOTNO)
4781 #define elf_backend_want_dynrelro 1
4783 /* MIPS ELF64 can use a mixture of REL and RELA, but some Relocations
4784 work better/work only in RELA, so we default to this. */
4785 #define elf_backend_may_use_rel_p 1
4786 #define elf_backend_may_use_rela_p 1
4787 #define elf_backend_default_use_rela_p 1
4788 #define elf_backend_rela_plts_and_copies_p 0
4789 #define elf_backend_plt_readonly 1
4790 #define elf_backend_plt_sym_val _bfd_mips_elf_plt_sym_val
4792 #define elf_backend_sign_extend_vma true
4794 #define elf_backend_write_section _bfd_mips_elf_write_section
4795 #define elf_backend_sort_relocs_p _bfd_mips_elf_sort_relocs_p
4797 /* We don't set bfd_elf64_bfd_is_local_label_name because the 32-bit
4798 MIPS-specific function only applies to IRIX5, which had no 64-bit
4800 #define bfd_elf64_bfd_is_target_special_symbol \
4801 _bfd_mips_elf_is_target_special_symbol
4802 #define bfd_elf64_find_nearest_line _bfd_mips_elf_find_nearest_line
4803 #define bfd_elf64_find_nearest_line_with_alt \
4804 _bfd_mips_elf_find_nearest_line_with_alt
4805 #define bfd_elf64_find_inliner_info _bfd_mips_elf_find_inliner_info
4806 #define bfd_elf64_new_section_hook _bfd_mips_elf_new_section_hook
4807 #define bfd_elf64_set_section_contents _bfd_mips_elf_set_section_contents
4808 #define bfd_elf64_bfd_get_relocated_section_contents \
4809 _bfd_elf_mips_get_relocated_section_contents
4810 #define bfd_elf64_bfd_link_hash_table_create \
4811 _bfd_mips_elf_link_hash_table_create
4812 #define bfd_elf64_bfd_final_link _bfd_mips_elf_final_link
4813 #define bfd_elf64_bfd_merge_private_bfd_data \
4814 _bfd_mips_elf_merge_private_bfd_data
4815 #define bfd_elf64_bfd_set_private_flags _bfd_mips_elf_set_private_flags
4816 #define bfd_elf64_bfd_print_private_bfd_data \
4817 _bfd_mips_elf_print_private_bfd_data
4819 #define bfd_elf64_get_dynamic_reloc_upper_bound mips_elf64_get_dynamic_reloc_upper_bound
4820 #define bfd_elf64_mkobject _bfd_mips_elf_mkobject
4821 #define bfd_elf64_bfd_free_cached_info _bfd_mips_elf_free_cached_info
4823 /* The SGI style (n)64 NewABI. */
4824 #define TARGET_LITTLE_SYM mips_elf64_le_vec
4825 #define TARGET_LITTLE_NAME "elf64-littlemips"
4826 #define TARGET_BIG_SYM mips_elf64_be_vec
4827 #define TARGET_BIG_NAME "elf64-bigmips"
4829 #define ELF_MAXPAGESIZE 0x10000
4830 #define ELF_COMMONPAGESIZE 0x1000
4832 #include "elf64-target.h"
4834 /* The SYSV-style 'traditional' (n)64 NewABI. */
4835 #undef TARGET_LITTLE_SYM
4836 #undef TARGET_LITTLE_NAME
4837 #undef TARGET_BIG_SYM
4838 #undef TARGET_BIG_NAME
4840 #undef ELF_MAXPAGESIZE
4841 #undef ELF_COMMONPAGESIZE
4843 #define TARGET_LITTLE_SYM mips_elf64_trad_le_vec
4844 #define TARGET_LITTLE_NAME "elf64-tradlittlemips"
4845 #define TARGET_BIG_SYM mips_elf64_trad_be_vec
4846 #define TARGET_BIG_NAME "elf64-tradbigmips"
4848 #define ELF_MAXPAGESIZE 0x10000
4849 #define ELF_COMMONPAGESIZE 0x1000
4850 #define elf64_bed elf64_tradbed
4852 #undef elf_backend_write_core_note
4853 #define elf_backend_write_core_note elf64_mips_write_core_note
4855 /* Include the target file again for this target. */
4856 #include "elf64-target.h"
4859 /* FreeBSD support. */
4861 #undef TARGET_LITTLE_SYM
4862 #undef TARGET_LITTLE_NAME
4863 #undef TARGET_BIG_SYM
4864 #undef TARGET_BIG_NAME
4866 #define TARGET_LITTLE_SYM mips_elf64_tradfbsd_le_vec
4867 #define TARGET_LITTLE_NAME "elf64-tradlittlemips-freebsd"
4868 #define TARGET_BIG_SYM mips_elf64_tradfbsd_be_vec
4869 #define TARGET_BIG_NAME "elf64-tradbigmips-freebsd"
4872 #define ELF_OSABI ELFOSABI_FREEBSD
4875 #define elf64_bed elf64_fbsd_tradbed
4877 #undef elf64_mips_write_core_note
4879 #include "elf64-target.h"