1 /* MIPS-specific support for 32-bit ELF
2 Copyright (C) 1993-2022 Free Software Foundation, Inc.
4 Most of the information added by Ian Lance Taylor, Cygnus Support,
6 N32/64 ABI support added by Mark Mitchell, CodeSourcery, LLC.
7 <mark@codesourcery.com>
8 Traditional MIPS targets support added by Koundinya.K, Dansk Data
9 Elektronik & Operations Research Group. <kk@ddeorg.soft.net>
11 This file is part of BFD, the Binary File Descriptor library.
13 This program is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 3 of the License, or
16 (at your option) any later version.
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
26 MA 02110-1301, USA. */
29 /* This file handles MIPS ELF targets. SGI Irix 5 uses a slightly
30 different MIPS ELF from other targets. This matters when linking.
31 This file supports both, switching at runtime. */
39 #include "elfxx-mips.h"
41 #include "elf-vxworks.h"
43 /* Get the ECOFF swapping routines. */
45 #include "coff/symconst.h"
46 #include "coff/internal.h"
47 #include "coff/ecoff.h"
48 #include "coff/mips.h"
49 #define ECOFF_SIGNED_32
50 #include "ecoffswap.h"
52 static bfd_reloc_status_type gprel32_with_gp
53 (bfd
*, asymbol
*, arelent
*, asection
*, bool, void *, bfd_vma
);
54 static bfd_reloc_status_type mips_elf_gprel32_reloc
55 (bfd
*, arelent
*, asymbol
*, void *, asection
*, bfd
*, char **);
56 static bfd_reloc_status_type mips32_64bit_reloc
57 (bfd
*, arelent
*, asymbol
*, void *, asection
*, bfd
*, char **);
58 static reloc_howto_type
*bfd_elf32_bfd_reloc_type_lookup
59 (bfd
*, bfd_reloc_code_real_type
);
60 static bool mips_info_to_howto_rel
61 (bfd
*, arelent
*, Elf_Internal_Rela
*);
62 static bool mips_info_to_howto_rela
63 (bfd
*, arelent
*, Elf_Internal_Rela
*);
64 static bool mips_elf_sym_is_global
66 static bool mips_elf32_elfsym_local_is_section
68 static bool mips_elf32_object_p
70 static bool mips_elf_is_local_label_name
71 (bfd
*, const char *);
72 static bfd_reloc_status_type mips16_gprel_reloc
73 (bfd
*, arelent
*, asymbol
*, void *, asection
*, bfd
*, char **);
74 static bfd_reloc_status_type mips_elf_final_gp
75 (bfd
*, asymbol
*, bool, char **, bfd_vma
*);
76 static bool mips_elf_assign_gp
78 static bool elf32_mips_grok_prstatus
79 (bfd
*, Elf_Internal_Note
*);
80 static bool elf32_mips_grok_psinfo
81 (bfd
*, Elf_Internal_Note
*);
82 static irix_compat_t elf32_mips_irix_compat
85 extern const bfd_target mips_elf32_be_vec
;
86 extern const bfd_target mips_elf32_le_vec
;
88 /* Nonzero if ABFD is using the N32 ABI. */
89 #define ABI_N32_P(abfd) \
90 ((elf_elfheader (abfd)->e_flags & EF_MIPS_ABI2) != 0)
92 /* Whether we are trying to be compatible with IRIX at all. */
93 #define SGI_COMPAT(abfd) \
94 (elf32_mips_irix_compat (abfd) != ict_none)
96 /* The number of local .got entries we reserve. */
97 #define MIPS_RESERVED_GOTNO (2)
99 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
100 from smaller values. Start with zero, widen, *then* decrement. */
101 #define MINUS_ONE (((bfd_vma)0) - 1)
103 /* The relocation table used for SHT_REL sections. */
105 static reloc_howto_type elf_mips_howto_table_rel
[] =
108 HOWTO (R_MIPS_NONE
, /* type */
112 false, /* pc_relative */
114 complain_overflow_dont
, /* complain_on_overflow */
115 _bfd_mips_elf_generic_reloc
, /* special_function */
116 "R_MIPS_NONE", /* name */
117 false, /* partial_inplace */
120 false), /* pcrel_offset */
122 /* 16 bit relocation. */
123 HOWTO (R_MIPS_16
, /* type */
127 false, /* pc_relative */
129 complain_overflow_signed
, /* complain_on_overflow */
130 _bfd_mips_elf_generic_reloc
, /* special_function */
131 "R_MIPS_16", /* name */
132 true, /* partial_inplace */
133 0x0000ffff, /* src_mask */
134 0x0000ffff, /* dst_mask */
135 false), /* pcrel_offset */
137 /* 32 bit relocation. */
138 HOWTO (R_MIPS_32
, /* type */
142 false, /* pc_relative */
144 complain_overflow_dont
, /* complain_on_overflow */
145 _bfd_mips_elf_generic_reloc
, /* special_function */
146 "R_MIPS_32", /* name */
147 true, /* partial_inplace */
148 0xffffffff, /* src_mask */
149 0xffffffff, /* dst_mask */
150 false), /* pcrel_offset */
152 /* 32 bit symbol relative relocation. */
153 HOWTO (R_MIPS_REL32
, /* type */
157 false, /* pc_relative */
159 complain_overflow_dont
, /* complain_on_overflow */
160 _bfd_mips_elf_generic_reloc
, /* special_function */
161 "R_MIPS_REL32", /* name */
162 true, /* partial_inplace */
163 0xffffffff, /* src_mask */
164 0xffffffff, /* dst_mask */
165 false), /* pcrel_offset */
167 /* 26 bit jump address. */
168 HOWTO (R_MIPS_26
, /* type */
172 false, /* pc_relative */
174 complain_overflow_dont
, /* complain_on_overflow */
175 /* This needs complex overflow
176 detection, because the upper four
177 bits must match the PC + 4. */
178 _bfd_mips_elf_generic_reloc
, /* special_function */
179 "R_MIPS_26", /* name */
180 true, /* partial_inplace */
181 0x03ffffff, /* src_mask */
182 0x03ffffff, /* dst_mask */
183 false), /* pcrel_offset */
185 /* High 16 bits of symbol value. */
186 HOWTO (R_MIPS_HI16
, /* type */
190 false, /* pc_relative */
192 complain_overflow_dont
, /* complain_on_overflow */
193 _bfd_mips_elf_hi16_reloc
, /* special_function */
194 "R_MIPS_HI16", /* name */
195 true, /* partial_inplace */
196 0x0000ffff, /* src_mask */
197 0x0000ffff, /* dst_mask */
198 false), /* pcrel_offset */
200 /* Low 16 bits of symbol value. */
201 HOWTO (R_MIPS_LO16
, /* type */
205 false, /* pc_relative */
207 complain_overflow_dont
, /* complain_on_overflow */
208 _bfd_mips_elf_lo16_reloc
, /* special_function */
209 "R_MIPS_LO16", /* name */
210 true, /* partial_inplace */
211 0x0000ffff, /* src_mask */
212 0x0000ffff, /* dst_mask */
213 false), /* pcrel_offset */
215 /* GP relative reference. */
216 HOWTO (R_MIPS_GPREL16
, /* type */
220 false, /* pc_relative */
222 complain_overflow_signed
, /* complain_on_overflow */
223 _bfd_mips_elf32_gprel16_reloc
, /* special_function */
224 "R_MIPS_GPREL16", /* name */
225 true, /* partial_inplace */
226 0x0000ffff, /* src_mask */
227 0x0000ffff, /* dst_mask */
228 false), /* pcrel_offset */
230 /* Reference to literal section. */
231 HOWTO (R_MIPS_LITERAL
, /* type */
235 false, /* pc_relative */
237 complain_overflow_signed
, /* complain_on_overflow */
238 _bfd_mips_elf32_gprel16_reloc
, /* special_function */
239 "R_MIPS_LITERAL", /* name */
240 true, /* partial_inplace */
241 0x0000ffff, /* src_mask */
242 0x0000ffff, /* dst_mask */
243 false), /* pcrel_offset */
245 /* Reference to global offset table. */
246 HOWTO (R_MIPS_GOT16
, /* type */
250 false, /* pc_relative */
252 complain_overflow_signed
, /* complain_on_overflow */
253 _bfd_mips_elf_got16_reloc
, /* special_function */
254 "R_MIPS_GOT16", /* name */
255 true, /* partial_inplace */
256 0x0000ffff, /* src_mask */
257 0x0000ffff, /* dst_mask */
258 false), /* pcrel_offset */
260 /* 16 bit PC relative reference. Note that the ABI document has a typo
261 and claims R_MIPS_PC16 to be not rightshifted, rendering it useless.
262 We do the right thing here. */
263 HOWTO (R_MIPS_PC16
, /* type */
267 true, /* pc_relative */
269 complain_overflow_signed
, /* complain_on_overflow */
270 _bfd_mips_elf_generic_reloc
, /* special_function */
271 "R_MIPS_PC16", /* name */
272 true, /* partial_inplace */
273 0x0000ffff, /* src_mask */
274 0x0000ffff, /* dst_mask */
275 true), /* pcrel_offset */
277 /* 16 bit call through global offset table. */
278 HOWTO (R_MIPS_CALL16
, /* type */
282 false, /* pc_relative */
284 complain_overflow_signed
, /* complain_on_overflow */
285 _bfd_mips_elf_generic_reloc
, /* special_function */
286 "R_MIPS_CALL16", /* name */
287 true, /* partial_inplace */
288 0x0000ffff, /* src_mask */
289 0x0000ffff, /* dst_mask */
290 false), /* pcrel_offset */
292 /* 32 bit GP relative reference. */
293 HOWTO (R_MIPS_GPREL32
, /* type */
297 false, /* pc_relative */
299 complain_overflow_dont
, /* complain_on_overflow */
300 mips_elf_gprel32_reloc
, /* special_function */
301 "R_MIPS_GPREL32", /* name */
302 true, /* partial_inplace */
303 0xffffffff, /* src_mask */
304 0xffffffff, /* dst_mask */
305 false), /* pcrel_offset */
307 /* The remaining relocs are defined on Irix 5, although they are
308 not defined by the ABI. */
313 /* A 5 bit shift field. */
314 HOWTO (R_MIPS_SHIFT5
, /* type */
318 false, /* pc_relative */
320 complain_overflow_bitfield
, /* complain_on_overflow */
321 _bfd_mips_elf_generic_reloc
, /* special_function */
322 "R_MIPS_SHIFT5", /* name */
323 true, /* partial_inplace */
324 0x000007c0, /* src_mask */
325 0x000007c0, /* dst_mask */
326 false), /* pcrel_offset */
328 /* A 6 bit shift field. */
329 /* FIXME: This is not handled correctly; a special function is
330 needed to put the most significant bit in the right place. */
331 HOWTO (R_MIPS_SHIFT6
, /* type */
335 false, /* pc_relative */
337 complain_overflow_bitfield
, /* complain_on_overflow */
338 _bfd_mips_elf_generic_reloc
, /* special_function */
339 "R_MIPS_SHIFT6", /* name */
340 true, /* partial_inplace */
341 0x000007c4, /* src_mask */
342 0x000007c4, /* dst_mask */
343 false), /* pcrel_offset */
345 /* A 64 bit relocation. */
346 HOWTO (R_MIPS_64
, /* type */
350 false, /* pc_relative */
352 complain_overflow_dont
, /* complain_on_overflow */
353 mips32_64bit_reloc
, /* special_function */
354 "R_MIPS_64", /* name */
355 true, /* partial_inplace */
356 MINUS_ONE
, /* src_mask */
357 MINUS_ONE
, /* dst_mask */
358 false), /* pcrel_offset */
360 /* Displacement in the global offset table. */
361 HOWTO (R_MIPS_GOT_DISP
, /* type */
365 false, /* pc_relative */
367 complain_overflow_signed
, /* complain_on_overflow */
368 _bfd_mips_elf_generic_reloc
, /* special_function */
369 "R_MIPS_GOT_DISP", /* name */
370 true, /* partial_inplace */
371 0x0000ffff, /* src_mask */
372 0x0000ffff, /* dst_mask */
373 false), /* pcrel_offset */
375 /* Displacement to page pointer in the global offset table. */
376 HOWTO (R_MIPS_GOT_PAGE
, /* type */
380 false, /* pc_relative */
382 complain_overflow_signed
, /* complain_on_overflow */
383 _bfd_mips_elf_generic_reloc
, /* special_function */
384 "R_MIPS_GOT_PAGE", /* name */
385 true, /* partial_inplace */
386 0x0000ffff, /* src_mask */
387 0x0000ffff, /* dst_mask */
388 false), /* pcrel_offset */
390 /* Offset from page pointer in the global offset table. */
391 HOWTO (R_MIPS_GOT_OFST
, /* type */
395 false, /* pc_relative */
397 complain_overflow_signed
, /* complain_on_overflow */
398 _bfd_mips_elf_generic_reloc
, /* special_function */
399 "R_MIPS_GOT_OFST", /* name */
400 true, /* partial_inplace */
401 0x0000ffff, /* src_mask */
402 0x0000ffff, /* dst_mask */
403 false), /* pcrel_offset */
405 /* High 16 bits of displacement in global offset table. */
406 HOWTO (R_MIPS_GOT_HI16
, /* type */
410 false, /* pc_relative */
412 complain_overflow_dont
, /* complain_on_overflow */
413 _bfd_mips_elf_generic_reloc
, /* special_function */
414 "R_MIPS_GOT_HI16", /* name */
415 true, /* partial_inplace */
416 0x0000ffff, /* src_mask */
417 0x0000ffff, /* dst_mask */
418 false), /* pcrel_offset */
420 /* Low 16 bits of displacement in global offset table. */
421 HOWTO (R_MIPS_GOT_LO16
, /* type */
425 false, /* pc_relative */
427 complain_overflow_dont
, /* complain_on_overflow */
428 _bfd_mips_elf_generic_reloc
, /* special_function */
429 "R_MIPS_GOT_LO16", /* name */
430 true, /* partial_inplace */
431 0x0000ffff, /* src_mask */
432 0x0000ffff, /* dst_mask */
433 false), /* pcrel_offset */
435 /* 64 bit subtraction. Used in the N32 ABI. */
436 HOWTO (R_MIPS_SUB
, /* type */
440 false, /* pc_relative */
442 complain_overflow_dont
, /* complain_on_overflow */
443 _bfd_mips_elf_generic_reloc
, /* special_function */
444 "R_MIPS_SUB", /* name */
445 true, /* partial_inplace */
446 MINUS_ONE
, /* src_mask */
447 MINUS_ONE
, /* dst_mask */
448 false), /* pcrel_offset */
450 /* Used to cause the linker to insert and delete instructions? */
451 EMPTY_HOWTO (R_MIPS_INSERT_A
),
452 EMPTY_HOWTO (R_MIPS_INSERT_B
),
453 EMPTY_HOWTO (R_MIPS_DELETE
),
455 /* Get the higher value of a 64 bit addend. */
456 HOWTO (R_MIPS_HIGHER
, /* type */
460 false, /* pc_relative */
462 complain_overflow_dont
, /* complain_on_overflow */
463 _bfd_mips_elf_generic_reloc
, /* special_function */
464 "R_MIPS_HIGHER", /* name */
465 true, /* partial_inplace */
466 0x0000ffff, /* src_mask */
467 0x0000ffff, /* dst_mask */
468 false), /* pcrel_offset */
470 /* Get the highest value of a 64 bit addend. */
471 HOWTO (R_MIPS_HIGHEST
, /* type */
475 false, /* pc_relative */
477 complain_overflow_dont
, /* complain_on_overflow */
478 _bfd_mips_elf_generic_reloc
, /* special_function */
479 "R_MIPS_HIGHEST", /* name */
480 true, /* partial_inplace */
481 0x0000ffff, /* src_mask */
482 0x0000ffff, /* dst_mask */
483 false), /* pcrel_offset */
485 /* High 16 bits of displacement in global offset table. */
486 HOWTO (R_MIPS_CALL_HI16
, /* type */
490 false, /* pc_relative */
492 complain_overflow_dont
, /* complain_on_overflow */
493 _bfd_mips_elf_generic_reloc
, /* special_function */
494 "R_MIPS_CALL_HI16", /* name */
495 true, /* partial_inplace */
496 0x0000ffff, /* src_mask */
497 0x0000ffff, /* dst_mask */
498 false), /* pcrel_offset */
500 /* Low 16 bits of displacement in global offset table. */
501 HOWTO (R_MIPS_CALL_LO16
, /* type */
505 false, /* pc_relative */
507 complain_overflow_dont
, /* complain_on_overflow */
508 _bfd_mips_elf_generic_reloc
, /* special_function */
509 "R_MIPS_CALL_LO16", /* name */
510 true, /* partial_inplace */
511 0x0000ffff, /* src_mask */
512 0x0000ffff, /* dst_mask */
513 false), /* pcrel_offset */
515 /* Section displacement. */
516 HOWTO (R_MIPS_SCN_DISP
, /* type */
520 false, /* pc_relative */
522 complain_overflow_dont
, /* complain_on_overflow */
523 _bfd_mips_elf_generic_reloc
, /* special_function */
524 "R_MIPS_SCN_DISP", /* name */
525 true, /* partial_inplace */
526 0xffffffff, /* src_mask */
527 0xffffffff, /* dst_mask */
528 false), /* pcrel_offset */
530 EMPTY_HOWTO (R_MIPS_REL16
),
531 EMPTY_HOWTO (R_MIPS_ADD_IMMEDIATE
),
532 EMPTY_HOWTO (R_MIPS_PJUMP
),
533 EMPTY_HOWTO (R_MIPS_RELGOT
),
535 /* Protected jump conversion. This is an optimization hint. No
536 relocation is required for correctness. */
537 HOWTO (R_MIPS_JALR
, /* type */
541 false, /* pc_relative */
543 complain_overflow_dont
, /* complain_on_overflow */
544 _bfd_mips_elf_generic_reloc
, /* special_function */
545 "R_MIPS_JALR", /* name */
546 false, /* partial_inplace */
547 0x00000000, /* src_mask */
548 0x00000000, /* dst_mask */
549 false), /* pcrel_offset */
551 /* TLS GD/LD dynamic relocations. */
552 HOWTO (R_MIPS_TLS_DTPMOD32
, /* type */
556 false, /* pc_relative */
558 complain_overflow_dont
, /* complain_on_overflow */
559 _bfd_mips_elf_generic_reloc
, /* special_function */
560 "R_MIPS_TLS_DTPMOD32", /* name */
561 true, /* partial_inplace */
562 0xffffffff, /* src_mask */
563 0xffffffff, /* dst_mask */
564 false), /* pcrel_offset */
566 HOWTO (R_MIPS_TLS_DTPREL32
, /* type */
570 false, /* pc_relative */
572 complain_overflow_dont
, /* complain_on_overflow */
573 _bfd_mips_elf_generic_reloc
, /* special_function */
574 "R_MIPS_TLS_DTPREL32", /* name */
575 true, /* partial_inplace */
576 0xffffffff, /* src_mask */
577 0xffffffff, /* dst_mask */
578 false), /* pcrel_offset */
580 EMPTY_HOWTO (R_MIPS_TLS_DTPMOD64
),
581 EMPTY_HOWTO (R_MIPS_TLS_DTPREL64
),
583 /* TLS general dynamic variable reference. */
584 HOWTO (R_MIPS_TLS_GD
, /* type */
588 false, /* pc_relative */
590 complain_overflow_signed
, /* complain_on_overflow */
591 _bfd_mips_elf_generic_reloc
, /* special_function */
592 "R_MIPS_TLS_GD", /* name */
593 true, /* partial_inplace */
594 0x0000ffff, /* src_mask */
595 0x0000ffff, /* dst_mask */
596 false), /* pcrel_offset */
598 /* TLS local dynamic variable reference. */
599 HOWTO (R_MIPS_TLS_LDM
, /* type */
603 false, /* pc_relative */
605 complain_overflow_signed
, /* complain_on_overflow */
606 _bfd_mips_elf_generic_reloc
, /* special_function */
607 "R_MIPS_TLS_LDM", /* name */
608 true, /* partial_inplace */
609 0x0000ffff, /* src_mask */
610 0x0000ffff, /* dst_mask */
611 false), /* pcrel_offset */
613 /* TLS local dynamic offset. */
614 HOWTO (R_MIPS_TLS_DTPREL_HI16
, /* type */
618 false, /* pc_relative */
620 complain_overflow_signed
, /* complain_on_overflow */
621 _bfd_mips_elf_generic_reloc
, /* special_function */
622 "R_MIPS_TLS_DTPREL_HI16", /* name */
623 true, /* partial_inplace */
624 0x0000ffff, /* src_mask */
625 0x0000ffff, /* dst_mask */
626 false), /* pcrel_offset */
628 /* TLS local dynamic offset. */
629 HOWTO (R_MIPS_TLS_DTPREL_LO16
, /* type */
633 false, /* pc_relative */
635 complain_overflow_signed
, /* complain_on_overflow */
636 _bfd_mips_elf_generic_reloc
, /* special_function */
637 "R_MIPS_TLS_DTPREL_LO16", /* name */
638 true, /* partial_inplace */
639 0x0000ffff, /* src_mask */
640 0x0000ffff, /* dst_mask */
641 false), /* pcrel_offset */
643 /* TLS thread pointer offset. */
644 HOWTO (R_MIPS_TLS_GOTTPREL
, /* type */
648 false, /* pc_relative */
650 complain_overflow_signed
, /* complain_on_overflow */
651 _bfd_mips_elf_generic_reloc
, /* special_function */
652 "R_MIPS_TLS_GOTTPREL", /* name */
653 true, /* partial_inplace */
654 0x0000ffff, /* src_mask */
655 0x0000ffff, /* dst_mask */
656 false), /* pcrel_offset */
658 /* TLS IE dynamic relocations. */
659 HOWTO (R_MIPS_TLS_TPREL32
, /* type */
663 false, /* pc_relative */
665 complain_overflow_dont
, /* complain_on_overflow */
666 _bfd_mips_elf_generic_reloc
, /* special_function */
667 "R_MIPS_TLS_TPREL32", /* name */
668 true, /* partial_inplace */
669 0xffffffff, /* src_mask */
670 0xffffffff, /* dst_mask */
671 false), /* pcrel_offset */
673 EMPTY_HOWTO (R_MIPS_TLS_TPREL64
),
675 /* TLS thread pointer offset. */
676 HOWTO (R_MIPS_TLS_TPREL_HI16
, /* type */
680 false, /* pc_relative */
682 complain_overflow_signed
, /* complain_on_overflow */
683 _bfd_mips_elf_generic_reloc
, /* special_function */
684 "R_MIPS_TLS_TPREL_HI16", /* name */
685 true, /* partial_inplace */
686 0x0000ffff, /* src_mask */
687 0x0000ffff, /* dst_mask */
688 false), /* pcrel_offset */
690 /* TLS thread pointer offset. */
691 HOWTO (R_MIPS_TLS_TPREL_LO16
, /* type */
695 false, /* pc_relative */
697 complain_overflow_signed
, /* complain_on_overflow */
698 _bfd_mips_elf_generic_reloc
, /* special_function */
699 "R_MIPS_TLS_TPREL_LO16", /* name */
700 true, /* partial_inplace */
701 0x0000ffff, /* src_mask */
702 0x0000ffff, /* dst_mask */
703 false), /* pcrel_offset */
705 /* 32 bit relocation with no addend. */
706 HOWTO (R_MIPS_GLOB_DAT
, /* type */
710 false, /* pc_relative */
712 complain_overflow_dont
, /* complain_on_overflow */
713 _bfd_mips_elf_generic_reloc
, /* special_function */
714 "R_MIPS_GLOB_DAT", /* name */
715 false, /* partial_inplace */
717 0xffffffff, /* dst_mask */
718 false), /* pcrel_offset */
729 HOWTO (R_MIPS_PC21_S2
, /* type */
733 true, /* pc_relative */
735 complain_overflow_signed
, /* complain_on_overflow */
736 _bfd_mips_elf_generic_reloc
, /* special_function */
737 "R_MIPS_PC21_S2", /* name */
738 true, /* partial_inplace */
739 0x001fffff, /* src_mask */
740 0x001fffff, /* dst_mask */
741 true), /* pcrel_offset */
743 HOWTO (R_MIPS_PC26_S2
, /* type */
747 true, /* pc_relative */
749 complain_overflow_signed
, /* complain_on_overflow */
750 _bfd_mips_elf_generic_reloc
, /* special_function */
751 "R_MIPS_PC26_S2", /* name */
752 true, /* partial_inplace */
753 0x03ffffff, /* src_mask */
754 0x03ffffff, /* dst_mask */
755 true), /* pcrel_offset */
757 HOWTO (R_MIPS_PC18_S3
, /* type */
761 true, /* pc_relative */
763 complain_overflow_signed
, /* complain_on_overflow */
764 _bfd_mips_elf_generic_reloc
, /* special_function */
765 "R_MIPS_PC18_S3", /* name */
766 true, /* partial_inplace */
767 0x0003ffff, /* src_mask */
768 0x0003ffff, /* dst_mask */
769 true), /* pcrel_offset */
771 HOWTO (R_MIPS_PC19_S2
, /* type */
775 true, /* pc_relative */
777 complain_overflow_signed
, /* complain_on_overflow */
778 _bfd_mips_elf_generic_reloc
, /* special_function */
779 "R_MIPS_PC19_S2", /* name */
780 true, /* partial_inplace */
781 0x0007ffff, /* src_mask */
782 0x0007ffff, /* dst_mask */
783 true), /* pcrel_offset */
785 HOWTO (R_MIPS_PCHI16
, /* type */
789 true, /* pc_relative */
791 complain_overflow_signed
, /* complain_on_overflow */
792 _bfd_mips_elf_generic_reloc
, /* special_function */
793 "R_MIPS_PCHI16", /* name */
794 true, /* partial_inplace */
795 0x0000ffff, /* src_mask */
796 0x0000ffff, /* dst_mask */
797 true), /* pcrel_offset */
799 HOWTO (R_MIPS_PCLO16
, /* type */
803 true, /* pc_relative */
805 complain_overflow_dont
, /* complain_on_overflow */
806 _bfd_mips_elf_generic_reloc
, /* special_function */
807 "R_MIPS_PCLO16", /* name */
808 true, /* partial_inplace */
809 0x0000ffff, /* src_mask */
810 0x0000ffff, /* dst_mask */
811 true), /* pcrel_offset */
814 /* The reloc used for BFD_RELOC_CTOR when doing a 64 bit link. This
815 is a hack to make the linker think that we need 64 bit values. */
816 static reloc_howto_type elf_mips_ctor64_howto
=
817 HOWTO (R_MIPS_64
, /* type */
821 false, /* pc_relative */
823 complain_overflow_signed
, /* complain_on_overflow */
824 mips32_64bit_reloc
, /* special_function */
825 "R_MIPS_64", /* name */
826 true, /* partial_inplace */
827 0xffffffff, /* src_mask */
828 0xffffffff, /* dst_mask */
829 false); /* pcrel_offset */
831 static reloc_howto_type elf_mips16_howto_table_rel
[] =
833 /* The reloc used for the mips16 jump instruction. */
834 HOWTO (R_MIPS16_26
, /* type */
838 false, /* pc_relative */
840 complain_overflow_dont
, /* complain_on_overflow */
841 /* This needs complex overflow
842 detection, because the upper four
843 bits must match the PC. */
844 _bfd_mips_elf_generic_reloc
, /* special_function */
845 "R_MIPS16_26", /* name */
846 true, /* partial_inplace */
847 0x3ffffff, /* src_mask */
848 0x3ffffff, /* dst_mask */
849 false), /* pcrel_offset */
851 /* The reloc used for the mips16 gprel instruction. */
852 HOWTO (R_MIPS16_GPREL
, /* type */
856 false, /* pc_relative */
858 complain_overflow_signed
, /* complain_on_overflow */
859 mips16_gprel_reloc
, /* special_function */
860 "R_MIPS16_GPREL", /* name */
861 true, /* partial_inplace */
862 0x0000ffff, /* src_mask */
863 0x0000ffff, /* dst_mask */
864 false), /* pcrel_offset */
866 /* A MIPS16 reference to the global offset table. */
867 HOWTO (R_MIPS16_GOT16
, /* type */
871 false, /* pc_relative */
873 complain_overflow_dont
, /* complain_on_overflow */
874 _bfd_mips_elf_got16_reloc
, /* special_function */
875 "R_MIPS16_GOT16", /* name */
876 true, /* partial_inplace */
877 0x0000ffff, /* src_mask */
878 0x0000ffff, /* dst_mask */
879 false), /* pcrel_offset */
881 /* A MIPS16 call through the global offset table. */
882 HOWTO (R_MIPS16_CALL16
, /* type */
886 false, /* pc_relative */
888 complain_overflow_dont
, /* complain_on_overflow */
889 _bfd_mips_elf_generic_reloc
, /* special_function */
890 "R_MIPS16_CALL16", /* name */
891 true, /* partial_inplace */
892 0x0000ffff, /* src_mask */
893 0x0000ffff, /* dst_mask */
894 false), /* pcrel_offset */
896 /* MIPS16 high 16 bits of symbol value. */
897 HOWTO (R_MIPS16_HI16
, /* type */
901 false, /* pc_relative */
903 complain_overflow_dont
, /* complain_on_overflow */
904 _bfd_mips_elf_hi16_reloc
, /* special_function */
905 "R_MIPS16_HI16", /* name */
906 true, /* partial_inplace */
907 0x0000ffff, /* src_mask */
908 0x0000ffff, /* dst_mask */
909 false), /* pcrel_offset */
911 /* MIPS16 low 16 bits of symbol value. */
912 HOWTO (R_MIPS16_LO16
, /* type */
916 false, /* pc_relative */
918 complain_overflow_dont
, /* complain_on_overflow */
919 _bfd_mips_elf_lo16_reloc
, /* special_function */
920 "R_MIPS16_LO16", /* name */
921 true, /* partial_inplace */
922 0x0000ffff, /* src_mask */
923 0x0000ffff, /* dst_mask */
924 false), /* pcrel_offset */
926 /* MIPS16 TLS general dynamic variable reference. */
927 HOWTO (R_MIPS16_TLS_GD
, /* type */
931 false, /* pc_relative */
933 complain_overflow_signed
, /* complain_on_overflow */
934 _bfd_mips_elf_generic_reloc
, /* special_function */
935 "R_MIPS16_TLS_GD", /* name */
936 true, /* partial_inplace */
937 0x0000ffff, /* src_mask */
938 0x0000ffff, /* dst_mask */
939 false), /* pcrel_offset */
941 /* MIPS16 TLS local dynamic variable reference. */
942 HOWTO (R_MIPS16_TLS_LDM
, /* type */
946 false, /* pc_relative */
948 complain_overflow_signed
, /* complain_on_overflow */
949 _bfd_mips_elf_generic_reloc
, /* special_function */
950 "R_MIPS16_TLS_LDM", /* name */
951 true, /* partial_inplace */
952 0x0000ffff, /* src_mask */
953 0x0000ffff, /* dst_mask */
954 false), /* pcrel_offset */
956 /* MIPS16 TLS local dynamic offset. */
957 HOWTO (R_MIPS16_TLS_DTPREL_HI16
, /* type */
961 false, /* pc_relative */
963 complain_overflow_signed
, /* complain_on_overflow */
964 _bfd_mips_elf_generic_reloc
, /* special_function */
965 "R_MIPS16_TLS_DTPREL_HI16", /* name */
966 true, /* partial_inplace */
967 0x0000ffff, /* src_mask */
968 0x0000ffff, /* dst_mask */
969 false), /* pcrel_offset */
971 /* MIPS16 TLS local dynamic offset. */
972 HOWTO (R_MIPS16_TLS_DTPREL_LO16
, /* type */
976 false, /* pc_relative */
978 complain_overflow_signed
, /* complain_on_overflow */
979 _bfd_mips_elf_generic_reloc
, /* special_function */
980 "R_MIPS16_TLS_DTPREL_LO16", /* name */
981 true, /* partial_inplace */
982 0x0000ffff, /* src_mask */
983 0x0000ffff, /* dst_mask */
984 false), /* pcrel_offset */
986 /* MIPS16 TLS thread pointer offset. */
987 HOWTO (R_MIPS16_TLS_GOTTPREL
, /* type */
991 false, /* pc_relative */
993 complain_overflow_signed
, /* complain_on_overflow */
994 _bfd_mips_elf_generic_reloc
, /* special_function */
995 "R_MIPS16_TLS_GOTTPREL", /* name */
996 true, /* partial_inplace */
997 0x0000ffff, /* src_mask */
998 0x0000ffff, /* dst_mask */
999 false), /* pcrel_offset */
1001 /* MIPS16 TLS thread pointer offset. */
1002 HOWTO (R_MIPS16_TLS_TPREL_HI16
, /* type */
1006 false, /* pc_relative */
1008 complain_overflow_signed
, /* complain_on_overflow */
1009 _bfd_mips_elf_generic_reloc
, /* special_function */
1010 "R_MIPS16_TLS_TPREL_HI16", /* name */
1011 true, /* partial_inplace */
1012 0x0000ffff, /* src_mask */
1013 0x0000ffff, /* dst_mask */
1014 false), /* pcrel_offset */
1016 /* MIPS16 TLS thread pointer offset. */
1017 HOWTO (R_MIPS16_TLS_TPREL_LO16
, /* type */
1021 false, /* pc_relative */
1023 complain_overflow_signed
, /* complain_on_overflow */
1024 _bfd_mips_elf_generic_reloc
, /* special_function */
1025 "R_MIPS16_TLS_TPREL_LO16", /* name */
1026 true, /* partial_inplace */
1027 0x0000ffff, /* src_mask */
1028 0x0000ffff, /* dst_mask */
1029 false), /* pcrel_offset */
1031 /* MIPS16 16-bit PC-relative branch offset. */
1032 HOWTO (R_MIPS16_PC16_S1
, /* type */
1036 true, /* pc_relative */
1038 complain_overflow_signed
, /* complain_on_overflow */
1039 _bfd_mips_elf_generic_reloc
, /* special_function */
1040 "R_MIPS16_PC16_S1", /* name */
1041 true, /* partial_inplace */
1042 0x0000ffff, /* src_mask */
1043 0x0000ffff, /* dst_mask */
1044 true), /* pcrel_offset */
1047 static reloc_howto_type elf_micromips_howto_table_rel
[] =
1053 /* 26 bit jump address. */
1054 HOWTO (R_MICROMIPS_26_S1
, /* type */
1058 false, /* pc_relative */
1060 complain_overflow_dont
, /* complain_on_overflow */
1061 /* This needs complex overflow
1062 detection, because the upper four
1063 bits must match the PC. */
1064 _bfd_mips_elf_generic_reloc
, /* special_function */
1065 "R_MICROMIPS_26_S1", /* name */
1066 true, /* partial_inplace */
1067 0x3ffffff, /* src_mask */
1068 0x3ffffff, /* dst_mask */
1069 false), /* pcrel_offset */
1071 /* High 16 bits of symbol value. */
1072 HOWTO (R_MICROMIPS_HI16
, /* type */
1073 16, /* rightshift */
1076 false, /* pc_relative */
1078 complain_overflow_dont
, /* complain_on_overflow */
1079 _bfd_mips_elf_hi16_reloc
, /* special_function */
1080 "R_MICROMIPS_HI16", /* name */
1081 true, /* partial_inplace */
1082 0x0000ffff, /* src_mask */
1083 0x0000ffff, /* dst_mask */
1084 false), /* pcrel_offset */
1086 /* Low 16 bits of symbol value. */
1087 HOWTO (R_MICROMIPS_LO16
, /* type */
1091 false, /* pc_relative */
1093 complain_overflow_dont
, /* complain_on_overflow */
1094 _bfd_mips_elf_lo16_reloc
, /* special_function */
1095 "R_MICROMIPS_LO16", /* name */
1096 true, /* partial_inplace */
1097 0x0000ffff, /* src_mask */
1098 0x0000ffff, /* dst_mask */
1099 false), /* pcrel_offset */
1101 /* GP relative reference. */
1102 HOWTO (R_MICROMIPS_GPREL16
, /* type */
1106 false, /* pc_relative */
1108 complain_overflow_signed
, /* complain_on_overflow */
1109 _bfd_mips_elf32_gprel16_reloc
, /* special_function */
1110 "R_MICROMIPS_GPREL16", /* name */
1111 true, /* partial_inplace */
1112 0x0000ffff, /* src_mask */
1113 0x0000ffff, /* dst_mask */
1114 false), /* pcrel_offset */
1116 /* Reference to literal section. */
1117 HOWTO (R_MICROMIPS_LITERAL
, /* type */
1121 false, /* pc_relative */
1123 complain_overflow_signed
, /* complain_on_overflow */
1124 _bfd_mips_elf32_gprel16_reloc
, /* special_function */
1125 "R_MICROMIPS_LITERAL", /* name */
1126 true, /* partial_inplace */
1127 0x0000ffff, /* src_mask */
1128 0x0000ffff, /* dst_mask */
1129 false), /* pcrel_offset */
1131 /* Reference to global offset table. */
1132 HOWTO (R_MICROMIPS_GOT16
, /* type */
1136 false, /* pc_relative */
1138 complain_overflow_signed
, /* complain_on_overflow */
1139 _bfd_mips_elf_got16_reloc
, /* special_function */
1140 "R_MICROMIPS_GOT16", /* name */
1141 true, /* partial_inplace */
1142 0x0000ffff, /* src_mask */
1143 0x0000ffff, /* dst_mask */
1144 false), /* pcrel_offset */
1146 /* This is for microMIPS branches. */
1147 HOWTO (R_MICROMIPS_PC7_S1
, /* type */
1151 true, /* pc_relative */
1153 complain_overflow_signed
, /* complain_on_overflow */
1154 _bfd_mips_elf_generic_reloc
, /* special_function */
1155 "R_MICROMIPS_PC7_S1", /* name */
1156 true, /* partial_inplace */
1157 0x0000007f, /* src_mask */
1158 0x0000007f, /* dst_mask */
1159 true), /* pcrel_offset */
1161 HOWTO (R_MICROMIPS_PC10_S1
, /* type */
1165 true, /* pc_relative */
1167 complain_overflow_signed
, /* complain_on_overflow */
1168 _bfd_mips_elf_generic_reloc
, /* special_function */
1169 "R_MICROMIPS_PC10_S1", /* name */
1170 true, /* partial_inplace */
1171 0x000003ff, /* src_mask */
1172 0x000003ff, /* dst_mask */
1173 true), /* pcrel_offset */
1175 HOWTO (R_MICROMIPS_PC16_S1
, /* type */
1179 true, /* pc_relative */
1181 complain_overflow_signed
, /* complain_on_overflow */
1182 _bfd_mips_elf_generic_reloc
, /* special_function */
1183 "R_MICROMIPS_PC16_S1", /* name */
1184 true, /* partial_inplace */
1185 0x0000ffff, /* src_mask */
1186 0x0000ffff, /* dst_mask */
1187 true), /* pcrel_offset */
1189 /* 16 bit call through global offset table. */
1190 HOWTO (R_MICROMIPS_CALL16
, /* type */
1194 false, /* pc_relative */
1196 complain_overflow_signed
, /* complain_on_overflow */
1197 _bfd_mips_elf_generic_reloc
, /* special_function */
1198 "R_MICROMIPS_CALL16", /* name */
1199 true, /* partial_inplace */
1200 0x0000ffff, /* src_mask */
1201 0x0000ffff, /* dst_mask */
1202 false), /* pcrel_offset */
1207 /* Displacement in the global offset table. */
1208 HOWTO (R_MICROMIPS_GOT_DISP
, /* type */
1212 false, /* pc_relative */
1214 complain_overflow_signed
, /* complain_on_overflow */
1215 _bfd_mips_elf_generic_reloc
, /* special_function */
1216 "R_MICROMIPS_GOT_DISP",/* name */
1217 true, /* partial_inplace */
1218 0x0000ffff, /* src_mask */
1219 0x0000ffff, /* dst_mask */
1220 false), /* pcrel_offset */
1222 /* Displacement to page pointer in the global offset table. */
1223 HOWTO (R_MICROMIPS_GOT_PAGE
, /* type */
1227 false, /* pc_relative */
1229 complain_overflow_signed
, /* complain_on_overflow */
1230 _bfd_mips_elf_generic_reloc
, /* special_function */
1231 "R_MICROMIPS_GOT_PAGE",/* name */
1232 true, /* partial_inplace */
1233 0x0000ffff, /* src_mask */
1234 0x0000ffff, /* dst_mask */
1235 false), /* pcrel_offset */
1237 /* Offset from page pointer in the global offset table. */
1238 HOWTO (R_MICROMIPS_GOT_OFST
, /* type */
1242 false, /* pc_relative */
1244 complain_overflow_signed
, /* complain_on_overflow */
1245 _bfd_mips_elf_generic_reloc
, /* special_function */
1246 "R_MICROMIPS_GOT_OFST",/* name */
1247 true, /* partial_inplace */
1248 0x0000ffff, /* src_mask */
1249 0x0000ffff, /* dst_mask */
1250 false), /* pcrel_offset */
1252 /* High 16 bits of displacement in global offset table. */
1253 HOWTO (R_MICROMIPS_GOT_HI16
, /* type */
1257 false, /* pc_relative */
1259 complain_overflow_dont
, /* complain_on_overflow */
1260 _bfd_mips_elf_generic_reloc
, /* special_function */
1261 "R_MICROMIPS_GOT_HI16",/* name */
1262 true, /* partial_inplace */
1263 0x0000ffff, /* src_mask */
1264 0x0000ffff, /* dst_mask */
1265 false), /* pcrel_offset */
1267 /* Low 16 bits of displacement in global offset table. */
1268 HOWTO (R_MICROMIPS_GOT_LO16
, /* type */
1272 false, /* pc_relative */
1274 complain_overflow_dont
, /* complain_on_overflow */
1275 _bfd_mips_elf_generic_reloc
, /* special_function */
1276 "R_MICROMIPS_GOT_LO16",/* name */
1277 true, /* partial_inplace */
1278 0x0000ffff, /* src_mask */
1279 0x0000ffff, /* dst_mask */
1280 false), /* pcrel_offset */
1282 /* 64 bit subtraction. Used in the N32 ABI. */
1283 HOWTO (R_MICROMIPS_SUB
, /* type */
1287 false, /* pc_relative */
1289 complain_overflow_dont
, /* complain_on_overflow */
1290 _bfd_mips_elf_generic_reloc
, /* special_function */
1291 "R_MICROMIPS_SUB", /* name */
1292 true, /* partial_inplace */
1293 MINUS_ONE
, /* src_mask */
1294 MINUS_ONE
, /* dst_mask */
1295 false), /* pcrel_offset */
1297 /* Get the higher value of a 64 bit addend. */
1298 HOWTO (R_MICROMIPS_HIGHER
, /* type */
1302 false, /* pc_relative */
1304 complain_overflow_dont
, /* complain_on_overflow */
1305 _bfd_mips_elf_generic_reloc
, /* special_function */
1306 "R_MICROMIPS_HIGHER", /* name */
1307 true, /* partial_inplace */
1308 0x0000ffff, /* src_mask */
1309 0x0000ffff, /* dst_mask */
1310 false), /* pcrel_offset */
1312 /* Get the highest value of a 64 bit addend. */
1313 HOWTO (R_MICROMIPS_HIGHEST
, /* type */
1317 false, /* pc_relative */
1319 complain_overflow_dont
, /* complain_on_overflow */
1320 _bfd_mips_elf_generic_reloc
, /* special_function */
1321 "R_MICROMIPS_HIGHEST", /* name */
1322 true, /* partial_inplace */
1323 0x0000ffff, /* src_mask */
1324 0x0000ffff, /* dst_mask */
1325 false), /* pcrel_offset */
1327 /* High 16 bits of displacement in global offset table. */
1328 HOWTO (R_MICROMIPS_CALL_HI16
, /* type */
1332 false, /* pc_relative */
1334 complain_overflow_dont
, /* complain_on_overflow */
1335 _bfd_mips_elf_generic_reloc
, /* special_function */
1336 "R_MICROMIPS_CALL_HI16",/* name */
1337 true, /* partial_inplace */
1338 0x0000ffff, /* src_mask */
1339 0x0000ffff, /* dst_mask */
1340 false), /* pcrel_offset */
1342 /* Low 16 bits of displacement in global offset table. */
1343 HOWTO (R_MICROMIPS_CALL_LO16
, /* type */
1347 false, /* pc_relative */
1349 complain_overflow_dont
, /* complain_on_overflow */
1350 _bfd_mips_elf_generic_reloc
, /* special_function */
1351 "R_MICROMIPS_CALL_LO16",/* name */
1352 true, /* partial_inplace */
1353 0x0000ffff, /* src_mask */
1354 0x0000ffff, /* dst_mask */
1355 false), /* pcrel_offset */
1357 /* Section displacement. */
1358 HOWTO (R_MICROMIPS_SCN_DISP
, /* type */
1362 false, /* pc_relative */
1364 complain_overflow_dont
, /* complain_on_overflow */
1365 _bfd_mips_elf_generic_reloc
, /* special_function */
1366 "R_MICROMIPS_SCN_DISP",/* name */
1367 true, /* partial_inplace */
1368 0xffffffff, /* src_mask */
1369 0xffffffff, /* dst_mask */
1370 false), /* pcrel_offset */
1372 /* Protected jump conversion. This is an optimization hint. No
1373 relocation is required for correctness. */
1374 HOWTO (R_MICROMIPS_JALR
, /* type */
1378 false, /* pc_relative */
1380 complain_overflow_dont
, /* complain_on_overflow */
1381 _bfd_mips_elf_generic_reloc
, /* special_function */
1382 "R_MICROMIPS_JALR", /* name */
1383 false, /* partial_inplace */
1384 0x00000000, /* src_mask */
1385 0x00000000, /* dst_mask */
1386 false), /* pcrel_offset */
1388 /* Low 16 bits of symbol value. Note that the high 16 bits of symbol values
1389 must be zero. This is used for relaxation. */
1390 HOWTO (R_MICROMIPS_HI0_LO16
, /* type */
1394 false, /* pc_relative */
1396 complain_overflow_dont
, /* complain_on_overflow */
1397 _bfd_mips_elf_generic_reloc
, /* special_function */
1398 "R_MICROMIPS_HI0_LO16",/* name */
1399 true, /* partial_inplace */
1400 0x0000ffff, /* src_mask */
1401 0x0000ffff, /* dst_mask */
1402 false), /* pcrel_offset */
1409 /* TLS general dynamic variable reference. */
1410 HOWTO (R_MICROMIPS_TLS_GD
, /* type */
1414 false, /* pc_relative */
1416 complain_overflow_signed
, /* complain_on_overflow */
1417 _bfd_mips_elf_generic_reloc
, /* special_function */
1418 "R_MICROMIPS_TLS_GD", /* name */
1419 true, /* partial_inplace */
1420 0x0000ffff, /* src_mask */
1421 0x0000ffff, /* dst_mask */
1422 false), /* pcrel_offset */
1424 /* TLS local dynamic variable reference. */
1425 HOWTO (R_MICROMIPS_TLS_LDM
, /* type */
1429 false, /* pc_relative */
1431 complain_overflow_signed
, /* complain_on_overflow */
1432 _bfd_mips_elf_generic_reloc
, /* special_function */
1433 "R_MICROMIPS_TLS_LDM", /* name */
1434 true, /* partial_inplace */
1435 0x0000ffff, /* src_mask */
1436 0x0000ffff, /* dst_mask */
1437 false), /* pcrel_offset */
1439 /* TLS local dynamic offset. */
1440 HOWTO (R_MICROMIPS_TLS_DTPREL_HI16
, /* type */
1444 false, /* pc_relative */
1446 complain_overflow_signed
, /* complain_on_overflow */
1447 _bfd_mips_elf_generic_reloc
, /* special_function */
1448 "R_MICROMIPS_TLS_DTPREL_HI16", /* name */
1449 true, /* partial_inplace */
1450 0x0000ffff, /* src_mask */
1451 0x0000ffff, /* dst_mask */
1452 false), /* pcrel_offset */
1454 /* TLS local dynamic offset. */
1455 HOWTO (R_MICROMIPS_TLS_DTPREL_LO16
, /* type */
1459 false, /* pc_relative */
1461 complain_overflow_signed
, /* complain_on_overflow */
1462 _bfd_mips_elf_generic_reloc
, /* special_function */
1463 "R_MICROMIPS_TLS_DTPREL_LO16", /* name */
1464 true, /* partial_inplace */
1465 0x0000ffff, /* src_mask */
1466 0x0000ffff, /* dst_mask */
1467 false), /* pcrel_offset */
1469 /* TLS thread pointer offset. */
1470 HOWTO (R_MICROMIPS_TLS_GOTTPREL
, /* type */
1474 false, /* pc_relative */
1476 complain_overflow_signed
, /* complain_on_overflow */
1477 _bfd_mips_elf_generic_reloc
, /* special_function */
1478 "R_MICROMIPS_TLS_GOTTPREL", /* name */
1479 true, /* partial_inplace */
1480 0x0000ffff, /* src_mask */
1481 0x0000ffff, /* dst_mask */
1482 false), /* pcrel_offset */
1487 /* TLS thread pointer offset. */
1488 HOWTO (R_MICROMIPS_TLS_TPREL_HI16
, /* type */
1492 false, /* pc_relative */
1494 complain_overflow_signed
, /* complain_on_overflow */
1495 _bfd_mips_elf_generic_reloc
, /* special_function */
1496 "R_MICROMIPS_TLS_TPREL_HI16", /* name */
1497 true, /* partial_inplace */
1498 0x0000ffff, /* src_mask */
1499 0x0000ffff, /* dst_mask */
1500 false), /* pcrel_offset */
1502 /* TLS thread pointer offset. */
1503 HOWTO (R_MICROMIPS_TLS_TPREL_LO16
, /* type */
1507 false, /* pc_relative */
1509 complain_overflow_signed
, /* complain_on_overflow */
1510 _bfd_mips_elf_generic_reloc
, /* special_function */
1511 "R_MICROMIPS_TLS_TPREL_LO16", /* name */
1512 true, /* partial_inplace */
1513 0x0000ffff, /* src_mask */
1514 0x0000ffff, /* dst_mask */
1515 false), /* pcrel_offset */
1519 /* GP- and PC-relative relocations. */
1520 HOWTO (R_MICROMIPS_GPREL7_S2
, /* type */
1524 false, /* pc_relative */
1526 complain_overflow_signed
, /* complain_on_overflow */
1527 _bfd_mips_elf32_gprel16_reloc
, /* special_function */
1528 "R_MICROMIPS_GPREL7_S2", /* name */
1529 true, /* partial_inplace */
1530 0x0000007f, /* src_mask */
1531 0x0000007f, /* dst_mask */
1532 false), /* pcrel_offset */
1534 HOWTO (R_MICROMIPS_PC23_S2
, /* type */
1538 true, /* pc_relative */
1540 complain_overflow_signed
, /* complain_on_overflow */
1541 _bfd_mips_elf_generic_reloc
, /* special_function */
1542 "R_MICROMIPS_PC23_S2", /* name */
1543 true, /* partial_inplace */
1544 0x007fffff, /* src_mask */
1545 0x007fffff, /* dst_mask */
1546 true), /* pcrel_offset */
1549 /* 16 bit offset for pc-relative branches. */
1550 static reloc_howto_type elf_mips_gnu_rel16_s2
=
1551 HOWTO (R_MIPS_GNU_REL16_S2
, /* type */
1555 true, /* pc_relative */
1557 complain_overflow_signed
, /* complain_on_overflow */
1558 _bfd_mips_elf_generic_reloc
, /* special_function */
1559 "R_MIPS_GNU_REL16_S2", /* name */
1560 true, /* partial_inplace */
1561 0xffff, /* src_mask */
1562 0xffff, /* dst_mask */
1563 true); /* pcrel_offset */
1565 /* 32 bit pc-relative. This was a GNU extension used by embedded-PIC.
1566 It was co-opted by mips-linux for exception-handling data. GCC stopped
1567 using it in May, 2004, then started using it again for compact unwind
1569 static reloc_howto_type elf_mips_gnu_pcrel32
=
1570 HOWTO (R_MIPS_PC32
, /* type */
1574 true, /* pc_relative */
1576 complain_overflow_signed
, /* complain_on_overflow */
1577 _bfd_mips_elf_generic_reloc
, /* special_function */
1578 "R_MIPS_PC32", /* name */
1579 true, /* partial_inplace */
1580 0xffffffff, /* src_mask */
1581 0xffffffff, /* dst_mask */
1582 true); /* pcrel_offset */
1584 /* GNU extension to record C++ vtable hierarchy */
1585 static reloc_howto_type elf_mips_gnu_vtinherit_howto
=
1586 HOWTO (R_MIPS_GNU_VTINHERIT
, /* type */
1590 false, /* pc_relative */
1592 complain_overflow_dont
, /* complain_on_overflow */
1593 NULL
, /* special_function */
1594 "R_MIPS_GNU_VTINHERIT", /* name */
1595 false, /* partial_inplace */
1598 false); /* pcrel_offset */
1600 /* GNU extension to record C++ vtable member usage */
1601 static reloc_howto_type elf_mips_gnu_vtentry_howto
=
1602 HOWTO (R_MIPS_GNU_VTENTRY
, /* type */
1606 false, /* pc_relative */
1608 complain_overflow_dont
, /* complain_on_overflow */
1609 _bfd_elf_rel_vtable_reloc_fn
, /* special_function */
1610 "R_MIPS_GNU_VTENTRY", /* name */
1611 false, /* partial_inplace */
1614 false); /* pcrel_offset */
1616 /* Originally a VxWorks extension, but now used for other systems too. */
1617 static reloc_howto_type elf_mips_copy_howto
=
1618 HOWTO (R_MIPS_COPY
, /* type */
1620 0, /* this one is variable size */
1622 false, /* pc_relative */
1624 complain_overflow_bitfield
, /* complain_on_overflow */
1625 _bfd_mips_elf_generic_reloc
, /* special_function */
1626 "R_MIPS_COPY", /* name */
1627 false, /* partial_inplace */
1630 false); /* pcrel_offset */
1632 /* Originally a VxWorks extension, but now used for other systems too. */
1633 static reloc_howto_type elf_mips_jump_slot_howto
=
1634 HOWTO (R_MIPS_JUMP_SLOT
, /* type */
1638 false, /* pc_relative */
1640 complain_overflow_bitfield
, /* complain_on_overflow */
1641 _bfd_mips_elf_generic_reloc
, /* special_function */
1642 "R_MIPS_JUMP_SLOT", /* name */
1643 false, /* partial_inplace */
1646 false); /* pcrel_offset */
1648 /* Used in EH tables. */
1649 static reloc_howto_type elf_mips_eh_howto
=
1650 HOWTO (R_MIPS_EH
, /* type */
1654 false, /* pc_relative */
1656 complain_overflow_signed
, /* complain_on_overflow */
1657 _bfd_mips_elf_generic_reloc
, /* special_function */
1658 "R_MIPS_EH", /* name */
1659 true, /* partial_inplace */
1660 0xffffffff, /* src_mask */
1661 0xffffffff, /* dst_mask */
1662 false); /* pcrel_offset */
1664 /* Set the GP value for OUTPUT_BFD. Returns FALSE if this is a
1665 dangerous relocation. */
1668 mips_elf_assign_gp (bfd
*output_bfd
, bfd_vma
*pgp
)
1674 /* If we've already figured out what GP will be, just return it. */
1675 *pgp
= _bfd_get_gp_value (output_bfd
);
1679 count
= bfd_get_symcount (output_bfd
);
1680 sym
= bfd_get_outsymbols (output_bfd
);
1682 /* The linker script will have created a symbol named `_gp' with the
1683 appropriate value. */
1688 for (i
= 0; i
< count
; i
++, sym
++)
1690 register const char *name
;
1692 name
= bfd_asymbol_name (*sym
);
1693 if (*name
== '_' && strcmp (name
, "_gp") == 0)
1695 *pgp
= bfd_asymbol_value (*sym
);
1696 _bfd_set_gp_value (output_bfd
, *pgp
);
1704 /* Only get the error once. */
1706 _bfd_set_gp_value (output_bfd
, *pgp
);
1713 /* We have to figure out the gp value, so that we can adjust the
1714 symbol value correctly. We look up the symbol _gp in the output
1715 BFD. If we can't find it, we're stuck. We cache it in the ELF
1716 target data. We don't need to adjust the symbol value for an
1717 external symbol if we are producing relocatable output. */
1719 static bfd_reloc_status_type
1720 mips_elf_final_gp (bfd
*output_bfd
, asymbol
*symbol
, bool relocatable
,
1721 char **error_message
, bfd_vma
*pgp
)
1723 if (output_bfd
== NULL
)
1726 return bfd_reloc_undefined
;
1729 *pgp
= _bfd_get_gp_value (output_bfd
);
1732 || (symbol
->flags
& BSF_SECTION_SYM
) != 0))
1736 /* Make up a value. */
1737 *pgp
= symbol
->section
->output_section
->vma
/*+ 0x4000*/;
1738 _bfd_set_gp_value (output_bfd
, *pgp
);
1740 else if (!mips_elf_assign_gp (output_bfd
, pgp
))
1743 (char *) _("GP relative relocation when _gp not defined");
1744 return bfd_reloc_dangerous
;
1748 return bfd_reloc_ok
;
1751 /* Do a R_MIPS_GPREL16 relocation. This is a 16 bit value which must
1752 become the offset from the gp register. This function also handles
1753 R_MIPS_LITERAL relocations, although those can be handled more
1754 cleverly because the entries in the .lit8 and .lit4 sections can be
1757 bfd_reloc_status_type
1758 _bfd_mips_elf32_gprel16_reloc (bfd
*abfd
, arelent
*reloc_entry
,
1759 asymbol
*symbol
, void *data
,
1760 asection
*input_section
, bfd
*output_bfd
,
1761 char **error_message
)
1764 bfd_reloc_status_type ret
;
1768 /* R_MIPS_LITERAL/R_MICROMIPS_LITERAL relocations are defined for local
1770 if (literal_reloc_p (reloc_entry
->howto
->type
)
1771 && output_bfd
!= NULL
1772 && (symbol
->flags
& BSF_SECTION_SYM
) == 0
1773 && (symbol
->flags
& BSF_LOCAL
) != 0)
1775 *error_message
= (char *)
1776 _("literal relocation occurs for an external symbol");
1777 return bfd_reloc_outofrange
;
1780 if (output_bfd
!= NULL
)
1784 relocatable
= false;
1785 output_bfd
= input_section
->output_section
->owner
;
1788 ret
= mips_elf_final_gp (output_bfd
, symbol
, relocatable
, error_message
,
1790 if (ret
!= bfd_reloc_ok
)
1793 location
= (bfd_byte
*) data
+ reloc_entry
->address
;
1794 _bfd_mips_elf_reloc_unshuffle (abfd
, reloc_entry
->howto
->type
, false,
1796 ret
= _bfd_mips_elf_gprel16_with_gp (abfd
, symbol
, reloc_entry
,
1797 input_section
, relocatable
,
1799 _bfd_mips_elf_reloc_shuffle (abfd
, reloc_entry
->howto
->type
, !relocatable
,
1805 /* Do a R_MIPS_GPREL32 relocation. This is a 32 bit value which must
1806 become the offset from the gp register. */
1808 static bfd_reloc_status_type
1809 mips_elf_gprel32_reloc (bfd
*abfd
, arelent
*reloc_entry
, asymbol
*symbol
,
1810 void *data
, asection
*input_section
, bfd
*output_bfd
,
1811 char **error_message
)
1814 bfd_reloc_status_type ret
;
1817 /* R_MIPS_GPREL32 relocations are defined for local symbols only. */
1818 if (output_bfd
!= NULL
1819 && (symbol
->flags
& BSF_SECTION_SYM
) == 0
1820 && (symbol
->flags
& BSF_LOCAL
) != 0)
1822 *error_message
= (char *)
1823 _("32bits gp relative relocation occurs for an external symbol");
1824 return bfd_reloc_outofrange
;
1827 if (output_bfd
!= NULL
)
1831 relocatable
= false;
1832 output_bfd
= input_section
->output_section
->owner
;
1835 ret
= mips_elf_final_gp (output_bfd
, symbol
, relocatable
,
1836 error_message
, &gp
);
1837 if (ret
!= bfd_reloc_ok
)
1840 return gprel32_with_gp (abfd
, symbol
, reloc_entry
, input_section
,
1841 relocatable
, data
, gp
);
1844 static bfd_reloc_status_type
1845 gprel32_with_gp (bfd
*abfd
, asymbol
*symbol
, arelent
*reloc_entry
,
1846 asection
*input_section
, bool relocatable
,
1847 void *data
, bfd_vma gp
)
1852 if (bfd_is_com_section (symbol
->section
))
1855 relocation
= symbol
->value
;
1857 relocation
+= symbol
->section
->output_section
->vma
;
1858 relocation
+= symbol
->section
->output_offset
;
1860 if (reloc_entry
->address
> bfd_get_section_limit (abfd
, input_section
))
1861 return bfd_reloc_outofrange
;
1863 /* Set val to the offset into the section or symbol. */
1864 val
= reloc_entry
->addend
;
1866 if (reloc_entry
->howto
->partial_inplace
)
1867 val
+= bfd_get_32 (abfd
, (bfd_byte
*) data
+ reloc_entry
->address
);
1869 /* Adjust val for the final section location and GP value. If we
1870 are producing relocatable output, we don't want to do this for
1871 an external symbol. */
1873 || (symbol
->flags
& BSF_SECTION_SYM
) != 0)
1874 val
+= relocation
- gp
;
1876 if (reloc_entry
->howto
->partial_inplace
)
1877 bfd_put_32 (abfd
, val
, (bfd_byte
*) data
+ reloc_entry
->address
);
1879 reloc_entry
->addend
= val
;
1882 reloc_entry
->address
+= input_section
->output_offset
;
1884 return bfd_reloc_ok
;
1887 /* Handle a 64 bit reloc in a 32 bit MIPS ELF file. These are
1888 generated when addresses are 64 bits. The upper 32 bits are a simple
1891 static bfd_reloc_status_type
1892 mips32_64bit_reloc (bfd
*abfd
, arelent
*reloc_entry
,
1893 asymbol
*symbol ATTRIBUTE_UNUSED
,
1894 void *data
, asection
*input_section
,
1895 bfd
*output_bfd
, char **error_message
)
1897 bfd_reloc_status_type r
;
1902 /* Do a normal 32 bit relocation on the lower 32 bits. */
1903 reloc32
= *reloc_entry
;
1904 if (bfd_big_endian (abfd
))
1905 reloc32
.address
+= 4;
1906 reloc32
.howto
= &elf_mips_howto_table_rel
[R_MIPS_32
];
1907 r
= bfd_perform_relocation (abfd
, &reloc32
, data
, input_section
,
1908 output_bfd
, error_message
);
1910 /* Sign extend into the upper 32 bits. */
1911 val
= bfd_get_32 (abfd
, (bfd_byte
*) data
+ reloc32
.address
);
1912 if ((val
& 0x80000000) != 0)
1916 addr
= reloc_entry
->address
;
1917 if (bfd_little_endian (abfd
))
1919 bfd_put_32 (abfd
, val
, (bfd_byte
*) data
+ addr
);
1924 /* Handle a mips16 GP relative reloc. */
1926 static bfd_reloc_status_type
1927 mips16_gprel_reloc (bfd
*abfd
, arelent
*reloc_entry
, asymbol
*symbol
,
1928 void *data
, asection
*input_section
, bfd
*output_bfd
,
1929 char **error_message
)
1932 bfd_reloc_status_type ret
;
1936 /* If we're relocating, and this is an external symbol, we don't want
1937 to change anything. */
1938 if (output_bfd
!= NULL
1939 && (symbol
->flags
& BSF_SECTION_SYM
) == 0
1940 && (symbol
->flags
& BSF_LOCAL
) != 0)
1942 reloc_entry
->address
+= input_section
->output_offset
;
1943 return bfd_reloc_ok
;
1946 if (output_bfd
!= NULL
)
1950 relocatable
= false;
1951 output_bfd
= input_section
->output_section
->owner
;
1954 ret
= mips_elf_final_gp (output_bfd
, symbol
, relocatable
, error_message
,
1956 if (ret
!= bfd_reloc_ok
)
1959 location
= (bfd_byte
*) data
+ reloc_entry
->address
;
1960 _bfd_mips_elf_reloc_unshuffle (abfd
, reloc_entry
->howto
->type
, false,
1962 ret
= _bfd_mips_elf_gprel16_with_gp (abfd
, symbol
, reloc_entry
,
1963 input_section
, relocatable
,
1965 _bfd_mips_elf_reloc_shuffle (abfd
, reloc_entry
->howto
->type
, !relocatable
,
1971 /* A mapping from BFD reloc types to MIPS ELF reloc types. */
1973 struct elf_reloc_map
{
1974 bfd_reloc_code_real_type bfd_val
;
1975 enum elf_mips_reloc_type elf_val
;
1978 static const struct elf_reloc_map mips_reloc_map
[] =
1980 { BFD_RELOC_NONE
, R_MIPS_NONE
},
1981 { BFD_RELOC_MIPS_16
, R_MIPS_16
},
1982 { BFD_RELOC_32
, R_MIPS_32
},
1983 /* There is no BFD reloc for R_MIPS_REL32. */
1984 { BFD_RELOC_64
, R_MIPS_64
},
1985 { BFD_RELOC_MIPS_JMP
, R_MIPS_26
},
1986 { BFD_RELOC_HI16_S
, R_MIPS_HI16
},
1987 { BFD_RELOC_LO16
, R_MIPS_LO16
},
1988 { BFD_RELOC_GPREL16
, R_MIPS_GPREL16
},
1989 { BFD_RELOC_MIPS_LITERAL
, R_MIPS_LITERAL
},
1990 { BFD_RELOC_MIPS_GOT16
, R_MIPS_GOT16
},
1991 { BFD_RELOC_16_PCREL_S2
, R_MIPS_PC16
},
1992 { BFD_RELOC_MIPS_CALL16
, R_MIPS_CALL16
},
1993 { BFD_RELOC_GPREL32
, R_MIPS_GPREL32
},
1994 { BFD_RELOC_MIPS_GOT_HI16
, R_MIPS_GOT_HI16
},
1995 { BFD_RELOC_MIPS_GOT_LO16
, R_MIPS_GOT_LO16
},
1996 { BFD_RELOC_MIPS_CALL_HI16
, R_MIPS_CALL_HI16
},
1997 { BFD_RELOC_MIPS_CALL_LO16
, R_MIPS_CALL_LO16
},
1998 { BFD_RELOC_MIPS_SUB
, R_MIPS_SUB
},
1999 { BFD_RELOC_MIPS_GOT_PAGE
, R_MIPS_GOT_PAGE
},
2000 { BFD_RELOC_MIPS_GOT_OFST
, R_MIPS_GOT_OFST
},
2001 { BFD_RELOC_MIPS_GOT_DISP
, R_MIPS_GOT_DISP
},
2002 { BFD_RELOC_MIPS_JALR
, R_MIPS_JALR
},
2003 { BFD_RELOC_MIPS_TLS_DTPMOD32
, R_MIPS_TLS_DTPMOD32
},
2004 { BFD_RELOC_MIPS_TLS_DTPREL32
, R_MIPS_TLS_DTPREL32
},
2005 { BFD_RELOC_MIPS_TLS_DTPMOD64
, R_MIPS_TLS_DTPMOD64
},
2006 { BFD_RELOC_MIPS_TLS_DTPREL64
, R_MIPS_TLS_DTPREL64
},
2007 { BFD_RELOC_MIPS_TLS_GD
, R_MIPS_TLS_GD
},
2008 { BFD_RELOC_MIPS_TLS_LDM
, R_MIPS_TLS_LDM
},
2009 { BFD_RELOC_MIPS_TLS_DTPREL_HI16
, R_MIPS_TLS_DTPREL_HI16
},
2010 { BFD_RELOC_MIPS_TLS_DTPREL_LO16
, R_MIPS_TLS_DTPREL_LO16
},
2011 { BFD_RELOC_MIPS_TLS_GOTTPREL
, R_MIPS_TLS_GOTTPREL
},
2012 { BFD_RELOC_MIPS_TLS_TPREL32
, R_MIPS_TLS_TPREL32
},
2013 { BFD_RELOC_MIPS_TLS_TPREL64
, R_MIPS_TLS_TPREL64
},
2014 { BFD_RELOC_MIPS_TLS_TPREL_HI16
, R_MIPS_TLS_TPREL_HI16
},
2015 { BFD_RELOC_MIPS_TLS_TPREL_LO16
, R_MIPS_TLS_TPREL_LO16
},
2016 { BFD_RELOC_MIPS_21_PCREL_S2
, R_MIPS_PC21_S2
},
2017 { BFD_RELOC_MIPS_26_PCREL_S2
, R_MIPS_PC26_S2
},
2018 { BFD_RELOC_MIPS_18_PCREL_S3
, R_MIPS_PC18_S3
},
2019 { BFD_RELOC_MIPS_19_PCREL_S2
, R_MIPS_PC19_S2
},
2020 { BFD_RELOC_HI16_S_PCREL
, R_MIPS_PCHI16
},
2021 { BFD_RELOC_LO16_PCREL
, R_MIPS_PCLO16
}
2024 static const struct elf_reloc_map mips16_reloc_map
[] =
2026 { BFD_RELOC_MIPS16_JMP
, R_MIPS16_26
- R_MIPS16_min
},
2027 { BFD_RELOC_MIPS16_GPREL
, R_MIPS16_GPREL
- R_MIPS16_min
},
2028 { BFD_RELOC_MIPS16_GOT16
, R_MIPS16_GOT16
- R_MIPS16_min
},
2029 { BFD_RELOC_MIPS16_CALL16
, R_MIPS16_CALL16
- R_MIPS16_min
},
2030 { BFD_RELOC_MIPS16_HI16_S
, R_MIPS16_HI16
- R_MIPS16_min
},
2031 { BFD_RELOC_MIPS16_LO16
, R_MIPS16_LO16
- R_MIPS16_min
},
2032 { BFD_RELOC_MIPS16_TLS_GD
, R_MIPS16_TLS_GD
- R_MIPS16_min
},
2033 { BFD_RELOC_MIPS16_TLS_LDM
, R_MIPS16_TLS_LDM
- R_MIPS16_min
},
2034 { BFD_RELOC_MIPS16_TLS_DTPREL_HI16
,
2035 R_MIPS16_TLS_DTPREL_HI16
- R_MIPS16_min
},
2036 { BFD_RELOC_MIPS16_TLS_DTPREL_LO16
,
2037 R_MIPS16_TLS_DTPREL_LO16
- R_MIPS16_min
},
2038 { BFD_RELOC_MIPS16_TLS_GOTTPREL
, R_MIPS16_TLS_GOTTPREL
- R_MIPS16_min
},
2039 { BFD_RELOC_MIPS16_TLS_TPREL_HI16
, R_MIPS16_TLS_TPREL_HI16
- R_MIPS16_min
},
2040 { BFD_RELOC_MIPS16_TLS_TPREL_LO16
, R_MIPS16_TLS_TPREL_LO16
- R_MIPS16_min
},
2041 { BFD_RELOC_MIPS16_16_PCREL_S1
, R_MIPS16_PC16_S1
- R_MIPS16_min
}
2044 static const struct elf_reloc_map micromips_reloc_map
[] =
2046 { BFD_RELOC_MICROMIPS_JMP
, R_MICROMIPS_26_S1
- R_MICROMIPS_min
},
2047 { BFD_RELOC_MICROMIPS_HI16_S
, R_MICROMIPS_HI16
- R_MICROMIPS_min
},
2048 { BFD_RELOC_MICROMIPS_LO16
, R_MICROMIPS_LO16
- R_MICROMIPS_min
},
2049 { BFD_RELOC_MICROMIPS_GPREL16
, R_MICROMIPS_GPREL16
- R_MICROMIPS_min
},
2050 { BFD_RELOC_MICROMIPS_LITERAL
, R_MICROMIPS_LITERAL
- R_MICROMIPS_min
},
2051 { BFD_RELOC_MICROMIPS_GOT16
, R_MICROMIPS_GOT16
- R_MICROMIPS_min
},
2052 { BFD_RELOC_MICROMIPS_7_PCREL_S1
, R_MICROMIPS_PC7_S1
- R_MICROMIPS_min
},
2053 { BFD_RELOC_MICROMIPS_10_PCREL_S1
, R_MICROMIPS_PC10_S1
- R_MICROMIPS_min
},
2054 { BFD_RELOC_MICROMIPS_16_PCREL_S1
, R_MICROMIPS_PC16_S1
- R_MICROMIPS_min
},
2055 { BFD_RELOC_MICROMIPS_CALL16
, R_MICROMIPS_CALL16
- R_MICROMIPS_min
},
2056 { BFD_RELOC_MICROMIPS_GOT_DISP
, R_MICROMIPS_GOT_DISP
- R_MICROMIPS_min
},
2057 { BFD_RELOC_MICROMIPS_GOT_PAGE
, R_MICROMIPS_GOT_PAGE
- R_MICROMIPS_min
},
2058 { BFD_RELOC_MICROMIPS_GOT_OFST
, R_MICROMIPS_GOT_OFST
- R_MICROMIPS_min
},
2059 { BFD_RELOC_MICROMIPS_GOT_HI16
, R_MICROMIPS_GOT_HI16
- R_MICROMIPS_min
},
2060 { BFD_RELOC_MICROMIPS_GOT_LO16
, R_MICROMIPS_GOT_LO16
- R_MICROMIPS_min
},
2061 { BFD_RELOC_MICROMIPS_SUB
, R_MICROMIPS_SUB
- R_MICROMIPS_min
},
2062 { BFD_RELOC_MICROMIPS_HIGHER
, R_MICROMIPS_HIGHER
- R_MICROMIPS_min
},
2063 { BFD_RELOC_MICROMIPS_HIGHEST
, R_MICROMIPS_HIGHEST
- R_MICROMIPS_min
},
2064 { BFD_RELOC_MICROMIPS_CALL_HI16
, R_MICROMIPS_CALL_HI16
- R_MICROMIPS_min
},
2065 { BFD_RELOC_MICROMIPS_CALL_LO16
, R_MICROMIPS_CALL_LO16
- R_MICROMIPS_min
},
2066 { BFD_RELOC_MICROMIPS_SCN_DISP
, R_MICROMIPS_SCN_DISP
- R_MICROMIPS_min
},
2067 { BFD_RELOC_MICROMIPS_JALR
, R_MICROMIPS_JALR
- R_MICROMIPS_min
},
2068 /* There is no BFD reloc for R_MICROMIPS_HI0_LO16. */
2069 { BFD_RELOC_MICROMIPS_TLS_GD
, R_MICROMIPS_TLS_GD
- R_MICROMIPS_min
},
2070 { BFD_RELOC_MICROMIPS_TLS_LDM
, R_MICROMIPS_TLS_LDM
- R_MICROMIPS_min
},
2071 { BFD_RELOC_MICROMIPS_TLS_DTPREL_HI16
,
2072 R_MICROMIPS_TLS_DTPREL_HI16
- R_MICROMIPS_min
},
2073 { BFD_RELOC_MICROMIPS_TLS_DTPREL_LO16
,
2074 R_MICROMIPS_TLS_DTPREL_LO16
- R_MICROMIPS_min
},
2075 { BFD_RELOC_MICROMIPS_TLS_GOTTPREL
,
2076 R_MICROMIPS_TLS_GOTTPREL
- R_MICROMIPS_min
},
2077 { BFD_RELOC_MICROMIPS_TLS_TPREL_HI16
,
2078 R_MICROMIPS_TLS_TPREL_HI16
- R_MICROMIPS_min
},
2079 { BFD_RELOC_MICROMIPS_TLS_TPREL_LO16
,
2080 R_MICROMIPS_TLS_TPREL_LO16
- R_MICROMIPS_min
},
2081 /* There is no BFD reloc for R_MICROMIPS_GPREL7_S2. */
2082 /* There is no BFD reloc for R_MICROMIPS_PC23_S2. */
2085 /* Given a BFD reloc type, return a howto structure. */
2087 static reloc_howto_type
*
2088 bfd_elf32_bfd_reloc_type_lookup (bfd
*abfd
, bfd_reloc_code_real_type code
)
2091 reloc_howto_type
*howto_table
= elf_mips_howto_table_rel
;
2092 reloc_howto_type
*howto16_table
= elf_mips16_howto_table_rel
;
2093 reloc_howto_type
*howto_micromips_table
= elf_micromips_howto_table_rel
;
2095 for (i
= 0; i
< sizeof (mips_reloc_map
) / sizeof (struct elf_reloc_map
);
2098 if (mips_reloc_map
[i
].bfd_val
== code
)
2099 return &howto_table
[(int) mips_reloc_map
[i
].elf_val
];
2102 for (i
= 0; i
< sizeof (mips16_reloc_map
) / sizeof (struct elf_reloc_map
);
2105 if (mips16_reloc_map
[i
].bfd_val
== code
)
2106 return &howto16_table
[(int) mips16_reloc_map
[i
].elf_val
];
2109 for (i
= 0; i
< sizeof (micromips_reloc_map
) / sizeof (struct elf_reloc_map
);
2112 if (micromips_reloc_map
[i
].bfd_val
== code
)
2113 return &howto_micromips_table
[(int) micromips_reloc_map
[i
].elf_val
];
2119 bfd_set_error (bfd_error_bad_value
);
2122 case BFD_RELOC_CTOR
:
2123 /* We need to handle BFD_RELOC_CTOR specially.
2124 Select the right relocation (R_MIPS_32 or R_MIPS_64) based on the
2125 size of addresses of the ABI. */
2126 if ((elf_elfheader (abfd
)->e_flags
& (E_MIPS_ABI_O64
2127 | E_MIPS_ABI_EABI64
)) != 0)
2128 return &elf_mips_ctor64_howto
;
2130 return &howto_table
[(int) R_MIPS_32
];
2132 case BFD_RELOC_VTABLE_INHERIT
:
2133 return &elf_mips_gnu_vtinherit_howto
;
2134 case BFD_RELOC_VTABLE_ENTRY
:
2135 return &elf_mips_gnu_vtentry_howto
;
2136 case BFD_RELOC_32_PCREL
:
2137 return &elf_mips_gnu_pcrel32
;
2138 case BFD_RELOC_MIPS_COPY
:
2139 return &elf_mips_copy_howto
;
2140 case BFD_RELOC_MIPS_JUMP_SLOT
:
2141 return &elf_mips_jump_slot_howto
;
2142 case BFD_RELOC_MIPS_EH
:
2143 return &elf_mips_eh_howto
;
2147 static reloc_howto_type
*
2148 bfd_elf32_bfd_reloc_name_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
2154 i
< (sizeof (elf_mips_howto_table_rel
)
2155 / sizeof (elf_mips_howto_table_rel
[0]));
2157 if (elf_mips_howto_table_rel
[i
].name
!= NULL
2158 && strcasecmp (elf_mips_howto_table_rel
[i
].name
, r_name
) == 0)
2159 return &elf_mips_howto_table_rel
[i
];
2162 i
< (sizeof (elf_mips16_howto_table_rel
)
2163 / sizeof (elf_mips16_howto_table_rel
[0]));
2165 if (elf_mips16_howto_table_rel
[i
].name
!= NULL
2166 && strcasecmp (elf_mips16_howto_table_rel
[i
].name
, r_name
) == 0)
2167 return &elf_mips16_howto_table_rel
[i
];
2170 i
< (sizeof (elf_micromips_howto_table_rel
)
2171 / sizeof (elf_micromips_howto_table_rel
[0]));
2173 if (elf_micromips_howto_table_rel
[i
].name
!= NULL
2174 && strcasecmp (elf_micromips_howto_table_rel
[i
].name
, r_name
) == 0)
2175 return &elf_micromips_howto_table_rel
[i
];
2177 if (strcasecmp (elf_mips_gnu_pcrel32
.name
, r_name
) == 0)
2178 return &elf_mips_gnu_pcrel32
;
2179 if (strcasecmp (elf_mips_gnu_rel16_s2
.name
, r_name
) == 0)
2180 return &elf_mips_gnu_rel16_s2
;
2181 if (strcasecmp (elf_mips_gnu_vtinherit_howto
.name
, r_name
) == 0)
2182 return &elf_mips_gnu_vtinherit_howto
;
2183 if (strcasecmp (elf_mips_gnu_vtentry_howto
.name
, r_name
) == 0)
2184 return &elf_mips_gnu_vtentry_howto
;
2185 if (strcasecmp (elf_mips_copy_howto
.name
, r_name
) == 0)
2186 return &elf_mips_copy_howto
;
2187 if (strcasecmp (elf_mips_jump_slot_howto
.name
, r_name
) == 0)
2188 return &elf_mips_jump_slot_howto
;
2189 if (strcasecmp (elf_mips_eh_howto
.name
, r_name
) == 0)
2190 return &elf_mips_eh_howto
;
2195 /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure. */
2197 static reloc_howto_type
*
2198 mips_elf32_rtype_to_howto (bfd
*abfd
,
2199 unsigned int r_type
,
2200 bool rela_p ATTRIBUTE_UNUSED
)
2202 reloc_howto_type
*howto
= NULL
;
2206 case R_MIPS_GNU_VTINHERIT
:
2207 return &elf_mips_gnu_vtinherit_howto
;
2208 case R_MIPS_GNU_VTENTRY
:
2209 return &elf_mips_gnu_vtentry_howto
;
2210 case R_MIPS_GNU_REL16_S2
:
2211 return &elf_mips_gnu_rel16_s2
;
2213 return &elf_mips_gnu_pcrel32
;
2215 return &elf_mips_copy_howto
;
2216 case R_MIPS_JUMP_SLOT
:
2217 return &elf_mips_jump_slot_howto
;
2219 return &elf_mips_eh_howto
;
2221 if (r_type
>= R_MICROMIPS_min
&& r_type
< R_MICROMIPS_max
)
2222 howto
= &elf_micromips_howto_table_rel
[r_type
- R_MICROMIPS_min
];
2223 if (r_type
>= R_MIPS16_min
&& r_type
< R_MIPS16_max
)
2224 howto
= &elf_mips16_howto_table_rel
[r_type
- R_MIPS16_min
];
2225 if (r_type
< R_MIPS_max
)
2226 howto
= &elf_mips_howto_table_rel
[r_type
];
2227 if (howto
!= NULL
&& howto
->name
!= NULL
)
2230 _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
2232 bfd_set_error (bfd_error_bad_value
);
2237 /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure. */
2240 mips_info_to_howto_rel (bfd
*abfd
, arelent
*cache_ptr
, Elf_Internal_Rela
*dst
)
2242 unsigned int r_type
;
2244 r_type
= ELF32_R_TYPE (dst
->r_info
);
2245 cache_ptr
->howto
= mips_elf32_rtype_to_howto (abfd
, r_type
, false);
2247 if (cache_ptr
->howto
== NULL
)
2250 /* The addend for a GPREL16 or LITERAL relocation comes from the GP
2251 value for the object file. We get the addend now, rather than
2252 when we do the relocation, because the symbol manipulations done
2253 by the linker may cause us to lose track of the input BFD. */
2254 if (((*cache_ptr
->sym_ptr_ptr
)->flags
& BSF_SECTION_SYM
) != 0
2255 && (gprel16_reloc_p (r_type
) || literal_reloc_p (r_type
)))
2256 cache_ptr
->addend
= elf_gp (abfd
);
2261 /* Given a MIPS Elf_Internal_Rela, fill in an arelent structure. */
2264 mips_info_to_howto_rela (bfd
*abfd
, arelent
*cache_ptr
, Elf_Internal_Rela
*dst
)
2266 return mips_info_to_howto_rel (abfd
, cache_ptr
, dst
);
2268 /* If we ever need to do any extra processing with dst->r_addend
2269 (the field omitted in an Elf_Internal_Rel) we can do it here. */
2272 /* Determine whether a symbol is global for the purposes of splitting
2273 the symbol table into global symbols and local symbols. At least
2274 on Irix 5, this split must be between section symbols and all other
2275 symbols. On most ELF targets the split is between static symbols
2276 and externally visible symbols. */
2279 mips_elf_sym_is_global (bfd
*abfd ATTRIBUTE_UNUSED
, asymbol
*sym
)
2281 if (SGI_COMPAT (abfd
))
2282 return (sym
->flags
& BSF_SECTION_SYM
) == 0;
2284 return ((sym
->flags
& (BSF_GLOBAL
| BSF_WEAK
| BSF_GNU_UNIQUE
)) != 0
2285 || bfd_is_und_section (bfd_asymbol_section (sym
))
2286 || bfd_is_com_section (bfd_asymbol_section (sym
)));
2289 /* Likewise, return TRUE if the symbol table split overall must be
2290 between section symbols and all other symbols. */
2292 mips_elf32_elfsym_local_is_section (bfd
*abfd
)
2294 return SGI_COMPAT (abfd
);
2297 /* Set the right machine number for a MIPS ELF file. */
2300 mips_elf32_object_p (bfd
*abfd
)
2304 if (ABI_N32_P (abfd
))
2307 /* Irix 5 and 6 are broken. Object file symbol tables are not always
2308 sorted correctly such that local symbols precede global symbols,
2309 and the sh_info field in the symbol table is not always right. */
2310 if (SGI_COMPAT (abfd
))
2311 elf_bad_symtab (abfd
) = true;
2313 mach
= _bfd_elf_mips_mach (elf_elfheader (abfd
)->e_flags
);
2314 bfd_default_set_arch_mach (abfd
, bfd_arch_mips
, mach
);
2318 /* MIPS ELF local labels start with '$', not 'L'. */
2321 mips_elf_is_local_label_name (bfd
*abfd
, const char *name
)
2326 /* On Irix 6, the labels go back to starting with '.', so we accept
2327 the generic ELF local label syntax as well. */
2328 return _bfd_elf_is_local_label_name (abfd
, name
);
2331 /* Support for core dump NOTE sections. */
2333 elf32_mips_grok_prstatus (bfd
*abfd
, Elf_Internal_Note
*note
)
2338 switch (note
->descsz
)
2343 case 256: /* Linux/MIPS */
2345 elf_tdata (abfd
)->core
->signal
= bfd_get_16 (abfd
, note
->descdata
+ 12);
2348 elf_tdata (abfd
)->core
->lwpid
= bfd_get_32 (abfd
, note
->descdata
+ 24);
2357 /* Make a ".reg/999" section. */
2358 return _bfd_elfcore_make_pseudosection (abfd
, ".reg",
2359 size
, note
->descpos
+ offset
);
2363 elf32_mips_grok_psinfo (bfd
*abfd
, Elf_Internal_Note
*note
)
2365 switch (note
->descsz
)
2370 case 128: /* Linux/MIPS elf_prpsinfo */
2371 elf_tdata (abfd
)->core
->pid
2372 = bfd_get_32 (abfd
, note
->descdata
+ 16);
2373 elf_tdata (abfd
)->core
->program
2374 = _bfd_elfcore_strndup (abfd
, note
->descdata
+ 32, 16);
2375 elf_tdata (abfd
)->core
->command
2376 = _bfd_elfcore_strndup (abfd
, note
->descdata
+ 48, 80);
2379 /* Note that for some reason, a spurious space is tacked
2380 onto the end of the args in some (at least one anyway)
2381 implementations, so strip it off if it exists. */
2384 char *command
= elf_tdata (abfd
)->core
->command
;
2385 int n
= strlen (command
);
2387 if (0 < n
&& command
[n
- 1] == ' ')
2388 command
[n
- 1] = '\0';
2394 /* Write Linux core PRSTATUS note into core file. */
2397 elf32_mips_write_core_note (bfd
*abfd
, char *buf
, int *bufsiz
, int note_type
,
2417 va_start (ap
, note_type
);
2418 memset (data
, 0, 72);
2419 pid
= va_arg (ap
, long);
2420 bfd_put_32 (abfd
, pid
, data
+ 24);
2421 cursig
= va_arg (ap
, int);
2422 bfd_put_16 (abfd
, cursig
, data
+ 12);
2423 greg
= va_arg (ap
, const void *);
2424 memcpy (data
+ 72, greg
, 180);
2425 memset (data
+ 252, 0, 4);
2427 return elfcore_write_note (abfd
, buf
, bufsiz
,
2428 "CORE", note_type
, data
, sizeof (data
));
2433 /* Remove the magic _gp_disp symbol from the symbol tables. */
2436 elf32_mips_fixup_symbol (struct bfd_link_info
*info
,
2437 struct elf_link_hash_entry
*h
)
2439 if (strcmp (h
->root
.root
.string
, "_gp_disp") == 0)
2440 _bfd_elf_link_hash_hide_symbol (info
, h
, true);
2444 /* Depending on the target vector we generate some version of Irix
2445 executables or "normal" MIPS ELF ABI executables. */
2446 static irix_compat_t
2447 elf32_mips_irix_compat (bfd
*abfd
)
2449 if ((abfd
->xvec
== &mips_elf32_be_vec
)
2450 || (abfd
->xvec
== &mips_elf32_le_vec
))
2456 /* ECOFF swapping routines. These are used when dealing with the
2457 .mdebug section, which is in the ECOFF debugging format. */
2458 static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap
= {
2459 /* Symbol table magic number. */
2461 /* Alignment of debugging information. E.g., 4. */
2463 /* Sizes of external symbolic information. */
2464 sizeof (struct hdr_ext
),
2465 sizeof (struct dnr_ext
),
2466 sizeof (struct pdr_ext
),
2467 sizeof (struct sym_ext
),
2468 sizeof (struct opt_ext
),
2469 sizeof (struct fdr_ext
),
2470 sizeof (struct rfd_ext
),
2471 sizeof (struct ext_ext
),
2472 /* Functions to swap in external symbolic data. */
2481 _bfd_ecoff_swap_tir_in
,
2482 _bfd_ecoff_swap_rndx_in
,
2483 /* Functions to swap out external symbolic data. */
2492 _bfd_ecoff_swap_tir_out
,
2493 _bfd_ecoff_swap_rndx_out
,
2494 /* Function to read in symbolic data. */
2495 _bfd_mips_elf_read_ecoff_info
2498 #define ELF_ARCH bfd_arch_mips
2499 #define ELF_TARGET_ID MIPS_ELF_DATA
2500 #define ELF_MACHINE_CODE EM_MIPS
2502 #define elf_backend_collect true
2503 #define elf_backend_type_change_ok true
2504 #define elf_backend_can_gc_sections true
2505 #define elf_backend_gc_mark_extra_sections \
2506 _bfd_mips_elf_gc_mark_extra_sections
2507 #define elf_info_to_howto mips_info_to_howto_rela
2508 #define elf_info_to_howto_rel mips_info_to_howto_rel
2509 #define elf_backend_sym_is_global mips_elf_sym_is_global
2510 #define elf_backend_object_p mips_elf32_object_p
2511 #define elf_backend_symbol_processing _bfd_mips_elf_symbol_processing
2512 #define elf_backend_section_processing _bfd_mips_elf_section_processing
2513 #define elf_backend_section_from_shdr _bfd_mips_elf_section_from_shdr
2514 #define elf_backend_fake_sections _bfd_mips_elf_fake_sections
2515 #define elf_backend_section_from_bfd_section \
2516 _bfd_mips_elf_section_from_bfd_section
2517 #define elf_backend_add_symbol_hook _bfd_mips_elf_add_symbol_hook
2518 #define elf_backend_link_output_symbol_hook \
2519 _bfd_mips_elf_link_output_symbol_hook
2520 #define elf_backend_create_dynamic_sections \
2521 _bfd_mips_elf_create_dynamic_sections
2522 #define elf_backend_check_relocs _bfd_mips_elf_check_relocs
2523 #define elf_backend_merge_symbol_attribute \
2524 _bfd_mips_elf_merge_symbol_attribute
2525 #define elf_backend_get_target_dtag _bfd_mips_elf_get_target_dtag
2526 #define elf_backend_adjust_dynamic_symbol \
2527 _bfd_mips_elf_adjust_dynamic_symbol
2528 #define elf_backend_always_size_sections \
2529 _bfd_mips_elf_always_size_sections
2530 #define elf_backend_size_dynamic_sections \
2531 _bfd_mips_elf_size_dynamic_sections
2532 #define elf_backend_init_index_section _bfd_elf_init_1_index_section
2533 #define elf_backend_relocate_section _bfd_mips_elf_relocate_section
2534 #define elf_backend_finish_dynamic_symbol \
2535 _bfd_mips_elf_finish_dynamic_symbol
2536 #define elf_backend_finish_dynamic_sections \
2537 _bfd_mips_elf_finish_dynamic_sections
2538 #define elf_backend_final_write_processing \
2539 _bfd_mips_elf_final_write_processing
2540 #define elf_backend_additional_program_headers \
2541 _bfd_mips_elf_additional_program_headers
2542 #define elf_backend_modify_segment_map _bfd_mips_elf_modify_segment_map
2543 #define elf_backend_gc_mark_hook _bfd_mips_elf_gc_mark_hook
2544 #define elf_backend_copy_indirect_symbol \
2545 _bfd_mips_elf_copy_indirect_symbol
2546 #define elf_backend_hide_symbol _bfd_mips_elf_hide_symbol
2547 #define elf_backend_fixup_symbol elf32_mips_fixup_symbol
2548 #define elf_backend_grok_prstatus elf32_mips_grok_prstatus
2549 #define elf_backend_grok_psinfo elf32_mips_grok_psinfo
2550 #define elf_backend_ecoff_debug_swap &mips_elf32_ecoff_debug_swap
2552 #define elf_backend_got_header_size (4 * MIPS_RESERVED_GOTNO)
2553 #define elf_backend_want_dynrelro 1
2554 #define elf_backend_may_use_rel_p 1
2555 #define elf_backend_may_use_rela_p 0
2556 #define elf_backend_default_use_rela_p 0
2557 #define elf_backend_sign_extend_vma true
2558 #define elf_backend_plt_readonly 1
2560 #define elf_backend_discard_info _bfd_mips_elf_discard_info
2561 #define elf_backend_ignore_discarded_relocs \
2562 _bfd_mips_elf_ignore_discarded_relocs
2563 #define elf_backend_write_section _bfd_mips_elf_write_section
2564 #define elf_backend_elfsym_local_is_section \
2565 mips_elf32_elfsym_local_is_section
2566 #define elf_backend_mips_irix_compat elf32_mips_irix_compat
2567 #define elf_backend_mips_rtype_to_howto mips_elf32_rtype_to_howto
2568 #define elf_backend_sort_relocs_p _bfd_mips_elf_sort_relocs_p
2570 #define bfd_elf32_bfd_is_local_label_name \
2571 mips_elf_is_local_label_name
2572 #define bfd_elf32_bfd_is_target_special_symbol \
2573 _bfd_mips_elf_is_target_special_symbol
2574 #define bfd_elf32_get_synthetic_symtab _bfd_mips_elf_get_synthetic_symtab
2575 #define bfd_elf32_find_nearest_line _bfd_mips_elf_find_nearest_line
2576 #define bfd_elf32_find_inliner_info _bfd_mips_elf_find_inliner_info
2577 #define bfd_elf32_new_section_hook _bfd_mips_elf_new_section_hook
2578 #define bfd_elf32_set_section_contents _bfd_mips_elf_set_section_contents
2579 #define bfd_elf32_bfd_get_relocated_section_contents \
2580 _bfd_elf_mips_get_relocated_section_contents
2581 #define bfd_elf32_bfd_link_hash_table_create \
2582 _bfd_mips_elf_link_hash_table_create
2583 #define bfd_elf32_bfd_final_link _bfd_mips_elf_final_link
2584 #define bfd_elf32_bfd_merge_private_bfd_data \
2585 _bfd_mips_elf_merge_private_bfd_data
2586 #define bfd_elf32_bfd_set_private_flags _bfd_mips_elf_set_private_flags
2587 #define bfd_elf32_bfd_print_private_bfd_data \
2588 _bfd_mips_elf_print_private_bfd_data
2589 #define bfd_elf32_bfd_relax_section _bfd_mips_elf_relax_section
2590 #define bfd_elf32_mkobject _bfd_mips_elf_mkobject
2592 /* Support for SGI-ish mips targets. */
2593 #define TARGET_LITTLE_SYM mips_elf32_le_vec
2594 #define TARGET_LITTLE_NAME "elf32-littlemips"
2595 #define TARGET_BIG_SYM mips_elf32_be_vec
2596 #define TARGET_BIG_NAME "elf32-bigmips"
2598 /* The SVR4 MIPS ABI says that this should be 0x10000, but Irix 5 uses
2599 a value of 0x1000, and we are compatible. */
2600 #define ELF_MAXPAGESIZE 0x1000
2601 #define ELF_COMMONPAGESIZE 0x1000
2603 #include "elf32-target.h"
2605 /* Support for traditional mips targets. */
2606 #undef TARGET_LITTLE_SYM
2607 #undef TARGET_LITTLE_NAME
2608 #undef TARGET_BIG_SYM
2609 #undef TARGET_BIG_NAME
2611 #undef ELF_MAXPAGESIZE
2612 #undef ELF_COMMONPAGESIZE
2614 #define TARGET_LITTLE_SYM mips_elf32_trad_le_vec
2615 #define TARGET_LITTLE_NAME "elf32-tradlittlemips"
2616 #define TARGET_BIG_SYM mips_elf32_trad_be_vec
2617 #define TARGET_BIG_NAME "elf32-tradbigmips"
2619 /* The MIPS ABI says at Page 5-1:
2620 Virtual addresses and file offsets for MIPS segments are congruent
2621 modulo 64 KByte (0x10000) or larger powers of 2. Because 64 KBytes
2622 is the maximum page size, the files are suitable for paging
2623 regardless of physical page size. */
2624 #define ELF_MAXPAGESIZE 0x10000
2625 #define ELF_COMMONPAGESIZE 0x1000
2626 #define elf32_bed elf32_tradbed
2628 #undef elf_backend_write_core_note
2629 #define elf_backend_write_core_note elf32_mips_write_core_note
2631 /* Include the target file again for this target. */
2632 #include "elf32-target.h"
2634 /* FreeBSD support. */
2636 #undef TARGET_LITTLE_SYM
2637 #undef TARGET_LITTLE_NAME
2638 #undef TARGET_BIG_SYM
2639 #undef TARGET_BIG_NAME
2641 #define TARGET_LITTLE_SYM mips_elf32_tradfbsd_le_vec
2642 #define TARGET_LITTLE_NAME "elf32-tradlittlemips-freebsd"
2643 #define TARGET_BIG_SYM mips_elf32_tradfbsd_be_vec
2644 #define TARGET_BIG_NAME "elf32-tradbigmips-freebsd"
2647 #define ELF_OSABI ELFOSABI_FREEBSD
2650 #define elf32_bed elf32_fbsd_tradbed
2652 #undef elf_backend_write_core_note
2654 #include "elf32-target.h"
2655 /* Implement elf_backend_final_write_processing for VxWorks. */
2658 mips_vxworks_final_write_processing (bfd
*abfd
)
2660 _bfd_mips_final_write_processing (abfd
);
2661 return elf_vxworks_final_write_processing (abfd
);
2664 #undef TARGET_LITTLE_SYM
2665 #undef TARGET_LITTLE_NAME
2666 #undef TARGET_BIG_SYM
2667 #undef TARGET_BIG_NAME
2669 #undef ELF_MAXPAGESIZE
2670 #undef ELF_COMMONPAGESIZE
2672 #define TARGET_LITTLE_SYM mips_elf32_vxworks_le_vec
2673 #define TARGET_LITTLE_NAME "elf32-littlemips-vxworks"
2674 #define TARGET_BIG_SYM mips_elf32_vxworks_be_vec
2675 #define TARGET_BIG_NAME "elf32-bigmips-vxworks"
2679 #define elf32_bed elf32_mips_vxworks_bed
2681 #define ELF_MAXPAGESIZE 0x1000
2682 #define ELF_COMMONPAGESIZE 0x1000
2684 #undef ELF_TARGET_OS
2685 #define ELF_TARGET_OS is_vxworks
2687 #undef elf_backend_want_got_plt
2688 #define elf_backend_want_got_plt 1
2689 #undef elf_backend_want_plt_sym
2690 #define elf_backend_want_plt_sym 1
2691 #undef elf_backend_may_use_rel_p
2692 #define elf_backend_may_use_rel_p 0
2693 #undef elf_backend_may_use_rela_p
2694 #define elf_backend_may_use_rela_p 1
2695 #undef elf_backend_default_use_rela_p
2696 #define elf_backend_default_use_rela_p 1
2697 #undef elf_backend_got_header_size
2698 #define elf_backend_got_header_size (4 * 3)
2699 #undef elf_backend_dtrel_excludes_plt
2700 #define elf_backend_dtrel_excludes_plt 1
2702 #undef elf_backend_finish_dynamic_symbol
2703 #define elf_backend_finish_dynamic_symbol \
2704 _bfd_mips_vxworks_finish_dynamic_symbol
2705 #undef bfd_elf32_bfd_link_hash_table_create
2706 #define bfd_elf32_bfd_link_hash_table_create \
2707 _bfd_mips_vxworks_link_hash_table_create
2708 #undef elf_backend_add_symbol_hook
2709 #define elf_backend_add_symbol_hook \
2710 elf_vxworks_add_symbol_hook
2711 #undef elf_backend_link_output_symbol_hook
2712 #define elf_backend_link_output_symbol_hook \
2713 elf_vxworks_link_output_symbol_hook
2714 #undef elf_backend_emit_relocs
2715 #define elf_backend_emit_relocs \
2716 elf_vxworks_emit_relocs
2717 #undef elf_backend_final_write_processing
2718 #define elf_backend_final_write_processing \
2719 mips_vxworks_final_write_processing
2721 #undef elf_backend_additional_program_headers
2722 #undef elf_backend_modify_segment_map
2723 #undef elf_backend_symbol_processing
2724 /* NOTE: elf_backend_rela_normal is not defined for MIPS. */
2726 #undef bfd_elf32_get_synthetic_symtab
2728 #include "elf32-target.h"