1 /* MIPS-specific support for 32-bit ELF
2 Copyright (C) 1993-2019 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"
42 /* Get the ECOFF swapping routines. */
44 #include "coff/symconst.h"
45 #include "coff/internal.h"
46 #include "coff/ecoff.h"
47 #include "coff/mips.h"
48 #define ECOFF_SIGNED_32
49 #include "ecoffswap.h"
51 static bfd_boolean mips_elf_assign_gp
53 static bfd_reloc_status_type mips_elf_final_gp
54 (bfd *, asymbol *, bfd_boolean, char **, bfd_vma *);
55 static bfd_reloc_status_type mips_elf_gprel16_reloc
56 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
57 static bfd_reloc_status_type mips_elf_literal_reloc
58 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
59 static bfd_reloc_status_type mips_elf_gprel32_reloc
60 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
61 static bfd_reloc_status_type gprel32_with_gp
62 (bfd *, asymbol *, arelent *, asection *, bfd_boolean, void *, bfd_vma);
63 static bfd_reloc_status_type mips_elf_shift6_reloc
64 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
65 static bfd_reloc_status_type mips16_gprel_reloc
66 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
67 static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
68 (bfd *, bfd_reloc_code_real_type);
69 static bfd_boolean mips_info_to_howto_rel
70 (bfd *, arelent *, Elf_Internal_Rela *);
71 static bfd_boolean mips_info_to_howto_rela
72 (bfd *, arelent *, Elf_Internal_Rela *);
73 static bfd_boolean mips_elf_sym_is_global
75 static bfd_boolean mips_elf_n32_object_p
77 static bfd_boolean elf32_mips_grok_prstatus
78 (bfd *, Elf_Internal_Note *);
79 static bfd_boolean elf32_mips_grok_psinfo
80 (bfd *, Elf_Internal_Note *);
81 static bfd_boolean elf_n32_mips_grok_freebsd_prstatus
82 (bfd *, Elf_Internal_Note *);
83 static irix_compat_t elf_n32_mips_irix_compat
85 static bfd_boolean mips_elf_n32_mkobject
88 extern const bfd_target mips_elf32_n_be_vec;
89 extern const bfd_target mips_elf32_n_le_vec;
91 /* Nonzero if ABFD is using the N32 ABI. */
92 #define ABI_N32_P(abfd) \
93 ((elf_elfheader (abfd)->e_flags & EF_MIPS_ABI2) != 0)
95 /* Whether we are trying to be compatible with IRIX at all. */
96 #define SGI_COMPAT(abfd) \
97 (elf_n32_mips_irix_compat (abfd) != ict_none)
99 /* The number of local .got entries we reserve. */
100 #define MIPS_RESERVED_GOTNO (2)
102 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
103 from smaller values. Start with zero, widen, *then* decrement. */
104 #define MINUS_ONE (((bfd_vma)0) - 1)
106 /* The relocation table used for SHT_REL sections. */
108 static reloc_howto_type elf_mips_howto_table_rel[] =
111 HOWTO (R_MIPS_NONE, /* type */
113 3, /* size (0 = byte, 1 = short, 2 = long) */
115 FALSE, /* pc_relative */
117 complain_overflow_dont, /* complain_on_overflow */
118 _bfd_mips_elf_generic_reloc, /* special_function */
119 "R_MIPS_NONE", /* name */
120 FALSE, /* partial_inplace */
123 FALSE), /* pcrel_offset */
125 /* 16 bit relocation. */
126 HOWTO (R_MIPS_16, /* type */
128 2, /* size (0 = byte, 1 = short, 2 = long) */
130 FALSE, /* pc_relative */
132 complain_overflow_signed, /* complain_on_overflow */
133 _bfd_mips_elf_generic_reloc, /* special_function */
134 "R_MIPS_16", /* name */
135 TRUE, /* partial_inplace */
136 0x0000ffff, /* src_mask */
137 0x0000ffff, /* dst_mask */
138 FALSE), /* pcrel_offset */
140 /* 32 bit relocation. */
141 HOWTO (R_MIPS_32, /* type */
143 2, /* size (0 = byte, 1 = short, 2 = long) */
145 FALSE, /* pc_relative */
147 complain_overflow_dont, /* complain_on_overflow */
148 _bfd_mips_elf_generic_reloc, /* special_function */
149 "R_MIPS_32", /* name */
150 TRUE, /* partial_inplace */
151 0xffffffff, /* src_mask */
152 0xffffffff, /* dst_mask */
153 FALSE), /* pcrel_offset */
155 /* 32 bit symbol relative relocation. */
156 HOWTO (R_MIPS_REL32, /* type */
158 2, /* size (0 = byte, 1 = short, 2 = long) */
160 FALSE, /* pc_relative */
162 complain_overflow_dont, /* complain_on_overflow */
163 _bfd_mips_elf_generic_reloc, /* special_function */
164 "R_MIPS_REL32", /* name */
165 TRUE, /* partial_inplace */
166 0xffffffff, /* src_mask */
167 0xffffffff, /* dst_mask */
168 FALSE), /* pcrel_offset */
170 /* 26 bit jump address. */
171 HOWTO (R_MIPS_26, /* type */
173 2, /* size (0 = byte, 1 = short, 2 = long) */
175 FALSE, /* pc_relative */
177 complain_overflow_dont, /* complain_on_overflow */
178 /* This needs complex overflow
179 detection, because the upper four
180 bits must match the PC + 4. */
181 _bfd_mips_elf_generic_reloc, /* special_function */
182 "R_MIPS_26", /* name */
183 TRUE, /* partial_inplace */
184 0x03ffffff, /* src_mask */
185 0x03ffffff, /* dst_mask */
186 FALSE), /* pcrel_offset */
188 /* R_MIPS_HI16 and R_MIPS_LO16 are unsupported for NewABI REL.
189 However, the native IRIX6 tools use them, so we try our best. */
191 /* High 16 bits of symbol value. */
192 HOWTO (R_MIPS_HI16, /* type */
194 2, /* size (0 = byte, 1 = short, 2 = long) */
196 FALSE, /* pc_relative */
198 complain_overflow_dont, /* complain_on_overflow */
199 _bfd_mips_elf_hi16_reloc, /* special_function */
200 "R_MIPS_HI16", /* name */
201 TRUE, /* partial_inplace */
202 0x0000ffff, /* src_mask */
203 0x0000ffff, /* dst_mask */
204 FALSE), /* pcrel_offset */
206 /* Low 16 bits of symbol value. */
207 HOWTO (R_MIPS_LO16, /* type */
209 2, /* size (0 = byte, 1 = short, 2 = long) */
211 FALSE, /* pc_relative */
213 complain_overflow_dont, /* complain_on_overflow */
214 _bfd_mips_elf_lo16_reloc, /* special_function */
215 "R_MIPS_LO16", /* name */
216 TRUE, /* partial_inplace */
217 0x0000ffff, /* src_mask */
218 0x0000ffff, /* dst_mask */
219 FALSE), /* pcrel_offset */
221 /* GP relative reference. */
222 HOWTO (R_MIPS_GPREL16, /* type */
224 2, /* size (0 = byte, 1 = short, 2 = long) */
226 FALSE, /* pc_relative */
228 complain_overflow_signed, /* complain_on_overflow */
229 mips_elf_gprel16_reloc, /* special_function */
230 "R_MIPS_GPREL16", /* name */
231 TRUE, /* partial_inplace */
232 0x0000ffff, /* src_mask */
233 0x0000ffff, /* dst_mask */
234 FALSE), /* pcrel_offset */
236 /* Reference to literal section. */
237 HOWTO (R_MIPS_LITERAL, /* type */
239 2, /* size (0 = byte, 1 = short, 2 = long) */
241 FALSE, /* pc_relative */
243 complain_overflow_signed, /* complain_on_overflow */
244 mips_elf_literal_reloc, /* special_function */
245 "R_MIPS_LITERAL", /* name */
246 TRUE, /* partial_inplace */
247 0x0000ffff, /* src_mask */
248 0x0000ffff, /* dst_mask */
249 FALSE), /* pcrel_offset */
251 /* Reference to global offset table. */
252 HOWTO (R_MIPS_GOT16, /* type */
254 2, /* size (0 = byte, 1 = short, 2 = long) */
256 FALSE, /* pc_relative */
258 complain_overflow_signed, /* complain_on_overflow */
259 _bfd_mips_elf_got16_reloc, /* special_function */
260 "R_MIPS_GOT16", /* name */
261 TRUE, /* partial_inplace */
262 0x0000ffff, /* src_mask */
263 0x0000ffff, /* dst_mask */
264 FALSE), /* pcrel_offset */
266 /* 16 bit PC relative reference. Note that the ABI document has a typo
267 and claims R_MIPS_PC16 to be not rightshifted, rendering it useless.
268 We do the right thing here. */
269 HOWTO (R_MIPS_PC16, /* type */
271 2, /* size (0 = byte, 1 = short, 2 = long) */
273 TRUE, /* pc_relative */
275 complain_overflow_signed, /* complain_on_overflow */
276 _bfd_mips_elf_generic_reloc, /* special_function */
277 "R_MIPS_PC16", /* name */
278 TRUE, /* partial_inplace */
279 0x0000ffff, /* src_mask */
280 0x0000ffff, /* dst_mask */
281 TRUE), /* pcrel_offset */
283 /* 16 bit call through global offset table. */
284 HOWTO (R_MIPS_CALL16, /* type */
286 2, /* size (0 = byte, 1 = short, 2 = long) */
288 FALSE, /* pc_relative */
290 complain_overflow_signed, /* complain_on_overflow */
291 _bfd_mips_elf_generic_reloc, /* special_function */
292 "R_MIPS_CALL16", /* name */
293 TRUE, /* partial_inplace */
294 0x0000ffff, /* src_mask */
295 0x0000ffff, /* dst_mask */
296 FALSE), /* pcrel_offset */
298 /* 32 bit GP relative reference. */
299 HOWTO (R_MIPS_GPREL32, /* type */
301 2, /* size (0 = byte, 1 = short, 2 = long) */
303 FALSE, /* pc_relative */
305 complain_overflow_dont, /* complain_on_overflow */
306 mips_elf_gprel32_reloc, /* special_function */
307 "R_MIPS_GPREL32", /* name */
308 TRUE, /* partial_inplace */
309 0xffffffff, /* src_mask */
310 0xffffffff, /* dst_mask */
311 FALSE), /* pcrel_offset */
313 /* The remaining relocs are defined on Irix 5, although they are
314 not defined by the ABI. */
319 /* A 5 bit shift field. */
320 HOWTO (R_MIPS_SHIFT5, /* type */
322 2, /* size (0 = byte, 1 = short, 2 = long) */
324 FALSE, /* pc_relative */
326 complain_overflow_bitfield, /* complain_on_overflow */
327 _bfd_mips_elf_generic_reloc, /* special_function */
328 "R_MIPS_SHIFT5", /* name */
329 TRUE, /* partial_inplace */
330 0x000007c0, /* src_mask */
331 0x000007c0, /* dst_mask */
332 FALSE), /* pcrel_offset */
334 /* A 6 bit shift field. */
335 HOWTO (R_MIPS_SHIFT6, /* type */
337 2, /* size (0 = byte, 1 = short, 2 = long) */
339 FALSE, /* pc_relative */
341 complain_overflow_bitfield, /* complain_on_overflow */
342 mips_elf_shift6_reloc, /* special_function */
343 "R_MIPS_SHIFT6", /* name */
344 TRUE, /* partial_inplace */
345 0x000007c4, /* src_mask */
346 0x000007c4, /* dst_mask */
347 FALSE), /* pcrel_offset */
349 /* A 64 bit relocation. */
350 HOWTO (R_MIPS_64, /* type */
352 4, /* size (0 = byte, 1 = short, 2 = long) */
354 FALSE, /* pc_relative */
356 complain_overflow_dont, /* complain_on_overflow */
357 _bfd_mips_elf_generic_reloc, /* special_function */
358 "R_MIPS_64", /* name */
359 TRUE, /* partial_inplace */
360 MINUS_ONE, /* src_mask */
361 MINUS_ONE, /* dst_mask */
362 FALSE), /* pcrel_offset */
364 /* Displacement in the global offset table. */
365 HOWTO (R_MIPS_GOT_DISP, /* type */
367 2, /* size (0 = byte, 1 = short, 2 = long) */
369 FALSE, /* pc_relative */
371 complain_overflow_signed, /* complain_on_overflow */
372 _bfd_mips_elf_generic_reloc, /* special_function */
373 "R_MIPS_GOT_DISP", /* name */
374 TRUE, /* partial_inplace */
375 0x0000ffff, /* src_mask */
376 0x0000ffff, /* dst_mask */
377 FALSE), /* pcrel_offset */
379 /* Displacement to page pointer in the global offset table. */
380 HOWTO (R_MIPS_GOT_PAGE, /* type */
382 2, /* size (0 = byte, 1 = short, 2 = long) */
384 FALSE, /* pc_relative */
386 complain_overflow_signed, /* complain_on_overflow */
387 _bfd_mips_elf_generic_reloc, /* special_function */
388 "R_MIPS_GOT_PAGE", /* name */
389 TRUE, /* partial_inplace */
390 0x0000ffff, /* src_mask */
391 0x0000ffff, /* dst_mask */
392 FALSE), /* pcrel_offset */
394 /* Offset from page pointer in the global offset table. */
395 HOWTO (R_MIPS_GOT_OFST, /* type */
397 2, /* size (0 = byte, 1 = short, 2 = long) */
399 FALSE, /* pc_relative */
401 complain_overflow_signed, /* complain_on_overflow */
402 _bfd_mips_elf_generic_reloc, /* special_function */
403 "R_MIPS_GOT_OFST", /* name */
404 TRUE, /* partial_inplace */
405 0x0000ffff, /* src_mask */
406 0x0000ffff, /* dst_mask */
407 FALSE), /* pcrel_offset */
409 /* High 16 bits of displacement in global offset table. */
410 HOWTO (R_MIPS_GOT_HI16, /* type */
412 2, /* size (0 = byte, 1 = short, 2 = long) */
414 FALSE, /* pc_relative */
416 complain_overflow_dont, /* complain_on_overflow */
417 _bfd_mips_elf_generic_reloc, /* special_function */
418 "R_MIPS_GOT_HI16", /* name */
419 TRUE, /* partial_inplace */
420 0x0000ffff, /* src_mask */
421 0x0000ffff, /* dst_mask */
422 FALSE), /* pcrel_offset */
424 /* Low 16 bits of displacement in global offset table. */
425 HOWTO (R_MIPS_GOT_LO16, /* type */
427 2, /* size (0 = byte, 1 = short, 2 = long) */
429 FALSE, /* pc_relative */
431 complain_overflow_dont, /* complain_on_overflow */
432 _bfd_mips_elf_generic_reloc, /* special_function */
433 "R_MIPS_GOT_LO16", /* name */
434 TRUE, /* partial_inplace */
435 0x0000ffff, /* src_mask */
436 0x0000ffff, /* dst_mask */
437 FALSE), /* pcrel_offset */
439 /* 64 bit subtraction. */
440 HOWTO (R_MIPS_SUB, /* type */
442 4, /* size (0 = byte, 1 = short, 2 = long) */
444 FALSE, /* pc_relative */
446 complain_overflow_dont, /* complain_on_overflow */
447 _bfd_mips_elf_generic_reloc, /* special_function */
448 "R_MIPS_SUB", /* name */
449 TRUE, /* partial_inplace */
450 MINUS_ONE, /* src_mask */
451 MINUS_ONE, /* dst_mask */
452 FALSE), /* pcrel_offset */
454 /* Insert the addend as an instruction. */
455 /* FIXME: Not handled correctly. */
456 HOWTO (R_MIPS_INSERT_A, /* type */
458 2, /* size (0 = byte, 1 = short, 2 = long) */
460 FALSE, /* pc_relative */
462 complain_overflow_dont, /* complain_on_overflow */
463 _bfd_mips_elf_generic_reloc, /* special_function */
464 "R_MIPS_INSERT_A", /* name */
465 TRUE, /* partial_inplace */
466 0xffffffff, /* src_mask */
467 0xffffffff, /* dst_mask */
468 FALSE), /* pcrel_offset */
470 /* Insert the addend as an instruction, and change all relocations
471 to refer to the old instruction at the address. */
472 /* FIXME: Not handled correctly. */
473 HOWTO (R_MIPS_INSERT_B, /* type */
475 2, /* size (0 = byte, 1 = short, 2 = long) */
477 FALSE, /* pc_relative */
479 complain_overflow_dont, /* complain_on_overflow */
480 _bfd_mips_elf_generic_reloc, /* special_function */
481 "R_MIPS_INSERT_B", /* name */
482 TRUE, /* partial_inplace */
483 0xffffffff, /* src_mask */
484 0xffffffff, /* dst_mask */
485 FALSE), /* pcrel_offset */
487 /* Delete a 32 bit instruction. */
488 /* FIXME: Not handled correctly. */
489 HOWTO (R_MIPS_DELETE, /* type */
491 2, /* size (0 = byte, 1 = short, 2 = long) */
493 FALSE, /* pc_relative */
495 complain_overflow_dont, /* complain_on_overflow */
496 _bfd_mips_elf_generic_reloc, /* special_function */
497 "R_MIPS_DELETE", /* name */
498 TRUE, /* partial_inplace */
499 0xffffffff, /* src_mask */
500 0xffffffff, /* dst_mask */
501 FALSE), /* pcrel_offset */
503 /* The MIPS ELF64 ABI Draft wants us to support these for REL relocations.
505 a) It means building the addend from a R_MIPS_HIGHEST/R_MIPS_HIGHER/
506 R_MIPS_HI16/R_MIPS_LO16 sequence with varying ordering, using
508 b) No other NewABI toolchain actually emits such relocations. */
509 EMPTY_HOWTO (R_MIPS_HIGHER),
510 EMPTY_HOWTO (R_MIPS_HIGHEST),
512 /* High 16 bits of displacement in global offset table. */
513 HOWTO (R_MIPS_CALL_HI16, /* type */
515 2, /* size (0 = byte, 1 = short, 2 = long) */
517 FALSE, /* pc_relative */
519 complain_overflow_dont, /* complain_on_overflow */
520 _bfd_mips_elf_generic_reloc, /* special_function */
521 "R_MIPS_CALL_HI16", /* name */
522 TRUE, /* partial_inplace */
523 0x0000ffff, /* src_mask */
524 0x0000ffff, /* dst_mask */
525 FALSE), /* pcrel_offset */
527 /* Low 16 bits of displacement in global offset table. */
528 HOWTO (R_MIPS_CALL_LO16, /* type */
530 2, /* size (0 = byte, 1 = short, 2 = long) */
532 FALSE, /* pc_relative */
534 complain_overflow_dont, /* complain_on_overflow */
535 _bfd_mips_elf_generic_reloc, /* special_function */
536 "R_MIPS_CALL_LO16", /* name */
537 TRUE, /* partial_inplace */
538 0x0000ffff, /* src_mask */
539 0x0000ffff, /* dst_mask */
540 FALSE), /* pcrel_offset */
542 /* Section displacement. */
543 HOWTO (R_MIPS_SCN_DISP, /* type */
545 2, /* size (0 = byte, 1 = short, 2 = long) */
547 FALSE, /* pc_relative */
549 complain_overflow_dont, /* complain_on_overflow */
550 _bfd_mips_elf_generic_reloc, /* special_function */
551 "R_MIPS_SCN_DISP", /* name */
552 TRUE, /* partial_inplace */
553 0xffffffff, /* src_mask */
554 0xffffffff, /* dst_mask */
555 FALSE), /* pcrel_offset */
557 HOWTO (R_MIPS_REL16, /* type */
559 1, /* size (0 = byte, 1 = short, 2 = long) */
561 FALSE, /* pc_relative */
563 complain_overflow_signed, /* complain_on_overflow */
564 _bfd_mips_elf_generic_reloc, /* special_function */
565 "R_MIPS_REL16", /* name */
566 TRUE, /* partial_inplace */
567 0xffff, /* src_mask */
568 0xffff, /* dst_mask */
569 FALSE), /* pcrel_offset */
571 /* These two are obsolete. */
572 EMPTY_HOWTO (R_MIPS_ADD_IMMEDIATE),
573 EMPTY_HOWTO (R_MIPS_PJUMP),
575 /* Similiar to R_MIPS_REL32, but used for relocations in a GOT section.
576 It must be used for multigot GOT's (and only there). */
577 HOWTO (R_MIPS_RELGOT, /* type */
579 2, /* size (0 = byte, 1 = short, 2 = long) */
581 FALSE, /* pc_relative */
583 complain_overflow_dont, /* complain_on_overflow */
584 _bfd_mips_elf_generic_reloc, /* special_function */
585 "R_MIPS_RELGOT", /* name */
586 TRUE, /* partial_inplace */
587 0xffffffff, /* src_mask */
588 0xffffffff, /* dst_mask */
589 FALSE), /* pcrel_offset */
591 /* Protected jump conversion. This is an optimization hint. No
592 relocation is required for correctness. */
593 HOWTO (R_MIPS_JALR, /* type */
595 2, /* size (0 = byte, 1 = short, 2 = long) */
597 FALSE, /* pc_relative */
599 complain_overflow_dont, /* complain_on_overflow */
600 _bfd_mips_elf_generic_reloc, /* special_function */
601 "R_MIPS_JALR", /* name */
602 FALSE, /* partial_inplace */
603 0x00000000, /* src_mask */
604 0x00000000, /* dst_mask */
605 FALSE), /* pcrel_offset */
607 /* TLS GD/LD dynamic relocations. */
608 HOWTO (R_MIPS_TLS_DTPMOD32, /* type */
610 2, /* size (0 = byte, 1 = short, 2 = long) */
612 FALSE, /* pc_relative */
614 complain_overflow_dont, /* complain_on_overflow */
615 _bfd_mips_elf_generic_reloc, /* special_function */
616 "R_MIPS_TLS_DTPMOD32", /* name */
617 TRUE, /* partial_inplace */
618 0xffffffff, /* src_mask */
619 0xffffffff, /* dst_mask */
620 FALSE), /* pcrel_offset */
622 HOWTO (R_MIPS_TLS_DTPREL32, /* type */
624 2, /* size (0 = byte, 1 = short, 2 = long) */
626 FALSE, /* pc_relative */
628 complain_overflow_dont, /* complain_on_overflow */
629 _bfd_mips_elf_generic_reloc, /* special_function */
630 "R_MIPS_TLS_DTPREL32", /* name */
631 TRUE, /* partial_inplace */
632 0xffffffff, /* src_mask */
633 0xffffffff, /* dst_mask */
634 FALSE), /* pcrel_offset */
636 EMPTY_HOWTO (R_MIPS_TLS_DTPMOD64),
637 EMPTY_HOWTO (R_MIPS_TLS_DTPREL64),
639 /* TLS general dynamic variable reference. */
640 HOWTO (R_MIPS_TLS_GD, /* type */
642 2, /* size (0 = byte, 1 = short, 2 = long) */
644 FALSE, /* pc_relative */
646 complain_overflow_signed, /* complain_on_overflow */
647 _bfd_mips_elf_generic_reloc, /* special_function */
648 "R_MIPS_TLS_GD", /* name */
649 TRUE, /* partial_inplace */
650 0x0000ffff, /* src_mask */
651 0x0000ffff, /* dst_mask */
652 FALSE), /* pcrel_offset */
654 /* TLS local dynamic variable reference. */
655 HOWTO (R_MIPS_TLS_LDM, /* type */
657 2, /* size (0 = byte, 1 = short, 2 = long) */
659 FALSE, /* pc_relative */
661 complain_overflow_signed, /* complain_on_overflow */
662 _bfd_mips_elf_generic_reloc, /* special_function */
663 "R_MIPS_TLS_LDM", /* name */
664 TRUE, /* partial_inplace */
665 0x0000ffff, /* src_mask */
666 0x0000ffff, /* dst_mask */
667 FALSE), /* pcrel_offset */
669 /* TLS local dynamic offset. */
670 HOWTO (R_MIPS_TLS_DTPREL_HI16, /* type */
672 2, /* size (0 = byte, 1 = short, 2 = long) */
674 FALSE, /* pc_relative */
676 complain_overflow_signed, /* complain_on_overflow */
677 _bfd_mips_elf_generic_reloc, /* special_function */
678 "R_MIPS_TLS_DTPREL_HI16", /* name */
679 TRUE, /* partial_inplace */
680 0x0000ffff, /* src_mask */
681 0x0000ffff, /* dst_mask */
682 FALSE), /* pcrel_offset */
684 /* TLS local dynamic offset. */
685 HOWTO (R_MIPS_TLS_DTPREL_LO16, /* type */
687 2, /* size (0 = byte, 1 = short, 2 = long) */
689 FALSE, /* pc_relative */
691 complain_overflow_signed, /* complain_on_overflow */
692 _bfd_mips_elf_generic_reloc, /* special_function */
693 "R_MIPS_TLS_DTPREL_LO16", /* name */
694 TRUE, /* partial_inplace */
695 0x0000ffff, /* src_mask */
696 0x0000ffff, /* dst_mask */
697 FALSE), /* pcrel_offset */
699 /* TLS thread pointer offset. */
700 HOWTO (R_MIPS_TLS_GOTTPREL, /* type */
702 2, /* size (0 = byte, 1 = short, 2 = long) */
704 FALSE, /* pc_relative */
706 complain_overflow_signed, /* complain_on_overflow */
707 _bfd_mips_elf_generic_reloc, /* special_function */
708 "R_MIPS_TLS_GOTTPREL", /* name */
709 TRUE, /* partial_inplace */
710 0x0000ffff, /* src_mask */
711 0x0000ffff, /* dst_mask */
712 FALSE), /* pcrel_offset */
714 /* TLS IE dynamic relocations. */
715 HOWTO (R_MIPS_TLS_TPREL32, /* type */
717 2, /* size (0 = byte, 1 = short, 2 = long) */
719 FALSE, /* pc_relative */
721 complain_overflow_dont, /* complain_on_overflow */
722 _bfd_mips_elf_generic_reloc, /* special_function */
723 "R_MIPS_TLS_TPREL32", /* name */
724 TRUE, /* partial_inplace */
725 0xffffffff, /* src_mask */
726 0xffffffff, /* dst_mask */
727 FALSE), /* pcrel_offset */
729 EMPTY_HOWTO (R_MIPS_TLS_TPREL64),
731 /* TLS thread pointer offset. */
732 HOWTO (R_MIPS_TLS_TPREL_HI16, /* type */
734 2, /* size (0 = byte, 1 = short, 2 = long) */
736 FALSE, /* pc_relative */
738 complain_overflow_signed, /* complain_on_overflow */
739 _bfd_mips_elf_generic_reloc, /* special_function */
740 "R_MIPS_TLS_TPREL_HI16", /* name */
741 TRUE, /* partial_inplace */
742 0x0000ffff, /* src_mask */
743 0x0000ffff, /* dst_mask */
744 FALSE), /* pcrel_offset */
746 /* TLS thread pointer offset. */
747 HOWTO (R_MIPS_TLS_TPREL_LO16, /* type */
749 2, /* size (0 = byte, 1 = short, 2 = long) */
751 FALSE, /* pc_relative */
753 complain_overflow_signed, /* complain_on_overflow */
754 _bfd_mips_elf_generic_reloc, /* special_function */
755 "R_MIPS_TLS_TPREL_LO16", /* name */
756 TRUE, /* partial_inplace */
757 0x0000ffff, /* src_mask */
758 0x0000ffff, /* dst_mask */
759 FALSE), /* pcrel_offset */
761 /* 32 bit relocation with no addend. */
762 HOWTO (R_MIPS_GLOB_DAT, /* type */
764 2, /* size (0 = byte, 1 = short, 2 = long) */
766 FALSE, /* pc_relative */
768 complain_overflow_dont, /* complain_on_overflow */
769 _bfd_mips_elf_generic_reloc, /* special_function */
770 "R_MIPS_GLOB_DAT", /* name */
771 FALSE, /* partial_inplace */
773 0xffffffff, /* dst_mask */
774 FALSE), /* pcrel_offset */
785 HOWTO (R_MIPS_PC21_S2, /* type */
787 2, /* size (0 = byte, 1 = short, 2 = long) */
789 TRUE, /* pc_relative */
791 complain_overflow_signed, /* complain_on_overflow */
792 _bfd_mips_elf_generic_reloc, /* special_function */
793 "R_MIPS_PC21_S2", /* name */
794 TRUE, /* partial_inplace */
795 0x001fffff, /* src_mask */
796 0x001fffff, /* dst_mask */
797 TRUE), /* pcrel_offset */
799 HOWTO (R_MIPS_PC26_S2, /* type */
801 2, /* size (0 = byte, 1 = short, 2 = long) */
803 TRUE, /* pc_relative */
805 complain_overflow_signed, /* complain_on_overflow */
806 _bfd_mips_elf_generic_reloc, /* special_function */
807 "R_MIPS_PC26_S2", /* name */
808 TRUE, /* partial_inplace */
809 0x03ffffff, /* src_mask */
810 0x03ffffff, /* dst_mask */
811 TRUE), /* pcrel_offset */
813 HOWTO (R_MIPS_PC18_S3, /* type */
815 2, /* size (0 = byte, 1 = short, 2 = long) */
817 TRUE, /* pc_relative */
819 complain_overflow_signed, /* complain_on_overflow */
820 _bfd_mips_elf_generic_reloc, /* special_function */
821 "R_MIPS_PC18_S3", /* name */
822 TRUE, /* partial_inplace */
823 0x0003ffff, /* src_mask */
824 0x0003ffff, /* dst_mask */
825 TRUE), /* pcrel_offset */
827 HOWTO (R_MIPS_PC19_S2, /* type */
829 2, /* size (0 = byte, 1 = short, 2 = long) */
831 TRUE, /* pc_relative */
833 complain_overflow_signed, /* complain_on_overflow */
834 _bfd_mips_elf_generic_reloc, /* special_function */
835 "R_MIPS_PC19_S2", /* name */
836 TRUE, /* partial_inplace */
837 0x0007ffff, /* src_mask */
838 0x0007ffff, /* dst_mask */
839 TRUE), /* pcrel_offset */
841 HOWTO (R_MIPS_PCHI16, /* type */
843 2, /* size (0 = byte, 1 = short, 2 = long) */
845 TRUE, /* pc_relative */
847 complain_overflow_signed, /* complain_on_overflow */
848 _bfd_mips_elf_generic_reloc, /* special_function */
849 "R_MIPS_PCHI16", /* name */
850 TRUE, /* partial_inplace */
851 0x0000ffff, /* src_mask */
852 0x0000ffff, /* dst_mask */
853 TRUE), /* pcrel_offset */
855 HOWTO (R_MIPS_PCLO16, /* type */
857 2, /* size (0 = byte, 1 = short, 2 = long) */
859 TRUE, /* pc_relative */
861 complain_overflow_dont, /* complain_on_overflow */
862 _bfd_mips_elf_generic_reloc, /* special_function */
863 "R_MIPS_PCLO16", /* name */
864 TRUE, /* partial_inplace */
865 0x0000ffff, /* src_mask */
866 0x0000ffff, /* dst_mask */
867 TRUE), /* pcrel_offset */
871 /* The relocation table used for SHT_RELA sections. */
873 static reloc_howto_type elf_mips_howto_table_rela[] =
876 HOWTO (R_MIPS_NONE, /* type */
878 0, /* size (0 = byte, 1 = short, 2 = long) */
880 FALSE, /* pc_relative */
882 complain_overflow_dont, /* complain_on_overflow */
883 _bfd_mips_elf_generic_reloc, /* special_function */
884 "R_MIPS_NONE", /* name */
885 FALSE, /* partial_inplace */
888 FALSE), /* pcrel_offset */
890 /* 16 bit relocation. */
891 HOWTO (R_MIPS_16, /* type */
893 2, /* size (0 = byte, 1 = short, 2 = long) */
895 FALSE, /* pc_relative */
897 complain_overflow_signed, /* complain_on_overflow */
898 _bfd_mips_elf_generic_reloc, /* special_function */
899 "R_MIPS_16", /* name */
900 FALSE, /* partial_inplace */
902 0x0000, /* dst_mask */
903 FALSE), /* pcrel_offset */
905 /* 32 bit relocation. */
906 HOWTO (R_MIPS_32, /* type */
908 2, /* size (0 = byte, 1 = short, 2 = long) */
910 FALSE, /* pc_relative */
912 complain_overflow_dont, /* complain_on_overflow */
913 _bfd_mips_elf_generic_reloc, /* special_function */
914 "R_MIPS_32", /* name */
915 FALSE, /* partial_inplace */
917 0xffffffff, /* dst_mask */
918 FALSE), /* pcrel_offset */
920 /* 32 bit symbol relative relocation. */
921 HOWTO (R_MIPS_REL32, /* type */
923 2, /* size (0 = byte, 1 = short, 2 = long) */
925 FALSE, /* pc_relative */
927 complain_overflow_dont, /* complain_on_overflow */
928 _bfd_mips_elf_generic_reloc, /* special_function */
929 "R_MIPS_REL32", /* name */
930 FALSE, /* partial_inplace */
932 0xffffffff, /* dst_mask */
933 FALSE), /* pcrel_offset */
935 /* 26 bit jump address. */
936 HOWTO (R_MIPS_26, /* type */
938 2, /* size (0 = byte, 1 = short, 2 = long) */
940 FALSE, /* pc_relative */
942 complain_overflow_dont, /* complain_on_overflow */
943 /* This needs complex overflow
944 detection, because the upper 36
945 bits must match the PC + 4. */
946 _bfd_mips_elf_generic_reloc, /* special_function */
947 "R_MIPS_26", /* name */
948 FALSE, /* partial_inplace */
950 0x03ffffff, /* dst_mask */
951 FALSE), /* pcrel_offset */
953 /* High 16 bits of symbol value. */
954 HOWTO (R_MIPS_HI16, /* type */
956 2, /* size (0 = byte, 1 = short, 2 = long) */
958 FALSE, /* pc_relative */
960 complain_overflow_dont, /* complain_on_overflow */
961 _bfd_mips_elf_generic_reloc, /* special_function */
962 "R_MIPS_HI16", /* name */
963 FALSE, /* partial_inplace */
965 0x0000ffff, /* dst_mask */
966 FALSE), /* pcrel_offset */
968 /* Low 16 bits of symbol value. */
969 HOWTO (R_MIPS_LO16, /* type */
971 2, /* size (0 = byte, 1 = short, 2 = long) */
973 FALSE, /* pc_relative */
975 complain_overflow_dont, /* complain_on_overflow */
976 _bfd_mips_elf_generic_reloc, /* special_function */
977 "R_MIPS_LO16", /* name */
978 FALSE, /* partial_inplace */
980 0x0000ffff, /* dst_mask */
981 FALSE), /* pcrel_offset */
983 /* GP relative reference. */
984 HOWTO (R_MIPS_GPREL16, /* type */
986 2, /* size (0 = byte, 1 = short, 2 = long) */
988 FALSE, /* pc_relative */
990 complain_overflow_signed, /* complain_on_overflow */
991 mips_elf_gprel16_reloc, /* special_function */
992 "R_MIPS_GPREL16", /* name */
993 FALSE, /* partial_inplace */
995 0x0000ffff, /* dst_mask */
996 FALSE), /* pcrel_offset */
998 /* Reference to literal section. */
999 HOWTO (R_MIPS_LITERAL, /* type */
1001 2, /* size (0 = byte, 1 = short, 2 = long) */
1003 FALSE, /* pc_relative */
1005 complain_overflow_signed, /* complain_on_overflow */
1006 mips_elf_literal_reloc, /* special_function */
1007 "R_MIPS_LITERAL", /* name */
1008 FALSE, /* partial_inplace */
1010 0x0000ffff, /* dst_mask */
1011 FALSE), /* pcrel_offset */
1013 /* Reference to global offset table. */
1014 HOWTO (R_MIPS_GOT16, /* type */
1016 2, /* size (0 = byte, 1 = short, 2 = long) */
1018 FALSE, /* pc_relative */
1020 complain_overflow_signed, /* complain_on_overflow */
1021 _bfd_mips_elf_generic_reloc, /* special_function */
1022 "R_MIPS_GOT16", /* name */
1023 FALSE, /* partial_inplace */
1025 0x0000ffff, /* dst_mask */
1026 FALSE), /* pcrel_offset */
1028 /* 16 bit PC relative reference. Note that the ABI document has a typo
1029 and claims R_MIPS_PC16 to be not rightshifted, rendering it useless.
1030 We do the right thing here. */
1031 HOWTO (R_MIPS_PC16, /* type */
1033 2, /* size (0 = byte, 1 = short, 2 = long) */
1035 TRUE, /* pc_relative */
1037 complain_overflow_signed, /* complain_on_overflow */
1038 _bfd_mips_elf_generic_reloc, /* special_function */
1039 "R_MIPS_PC16", /* name */
1040 FALSE, /* partial_inplace */
1042 0x0000ffff, /* dst_mask */
1043 TRUE), /* pcrel_offset */
1045 /* 16 bit call through global offset table. */
1046 HOWTO (R_MIPS_CALL16, /* type */
1048 2, /* size (0 = byte, 1 = short, 2 = long) */
1050 FALSE, /* pc_relative */
1052 complain_overflow_signed, /* complain_on_overflow */
1053 _bfd_mips_elf_generic_reloc, /* special_function */
1054 "R_MIPS_CALL16", /* name */
1055 FALSE, /* partial_inplace */
1057 0x0000ffff, /* dst_mask */
1058 FALSE), /* pcrel_offset */
1060 /* 32 bit GP relative reference. */
1061 HOWTO (R_MIPS_GPREL32, /* type */
1063 2, /* size (0 = byte, 1 = short, 2 = long) */
1065 FALSE, /* pc_relative */
1067 complain_overflow_dont, /* complain_on_overflow */
1068 mips_elf_gprel32_reloc, /* special_function */
1069 "R_MIPS_GPREL32", /* name */
1070 FALSE, /* partial_inplace */
1072 0xffffffff, /* dst_mask */
1073 FALSE), /* pcrel_offset */
1079 /* A 5 bit shift field. */
1080 HOWTO (R_MIPS_SHIFT5, /* type */
1082 2, /* size (0 = byte, 1 = short, 2 = long) */
1084 FALSE, /* pc_relative */
1086 complain_overflow_bitfield, /* complain_on_overflow */
1087 _bfd_mips_elf_generic_reloc, /* special_function */
1088 "R_MIPS_SHIFT5", /* name */
1089 FALSE, /* partial_inplace */
1091 0x000007c0, /* dst_mask */
1092 FALSE), /* pcrel_offset */
1094 /* A 6 bit shift field. */
1095 HOWTO (R_MIPS_SHIFT6, /* type */
1097 2, /* size (0 = byte, 1 = short, 2 = long) */
1099 FALSE, /* pc_relative */
1101 complain_overflow_bitfield, /* complain_on_overflow */
1102 mips_elf_shift6_reloc, /* special_function */
1103 "R_MIPS_SHIFT6", /* name */
1104 FALSE, /* partial_inplace */
1106 0x000007c4, /* dst_mask */
1107 FALSE), /* pcrel_offset */
1109 /* 64 bit relocation. */
1110 HOWTO (R_MIPS_64, /* type */
1112 4, /* size (0 = byte, 1 = short, 2 = long) */
1114 FALSE, /* pc_relative */
1116 complain_overflow_dont, /* complain_on_overflow */
1117 _bfd_mips_elf_generic_reloc, /* special_function */
1118 "R_MIPS_64", /* name */
1119 FALSE, /* partial_inplace */
1121 MINUS_ONE, /* dst_mask */
1122 FALSE), /* pcrel_offset */
1124 /* Displacement in the global offset table. */
1125 HOWTO (R_MIPS_GOT_DISP, /* type */
1127 2, /* size (0 = byte, 1 = short, 2 = long) */
1129 FALSE, /* pc_relative */
1131 complain_overflow_signed, /* complain_on_overflow */
1132 _bfd_mips_elf_generic_reloc, /* special_function */
1133 "R_MIPS_GOT_DISP", /* name */
1134 FALSE, /* partial_inplace */
1136 0x0000ffff, /* dst_mask */
1137 FALSE), /* pcrel_offset */
1139 /* Displacement to page pointer in the global offset table. */
1140 HOWTO (R_MIPS_GOT_PAGE, /* type */
1142 2, /* size (0 = byte, 1 = short, 2 = long) */
1144 FALSE, /* pc_relative */
1146 complain_overflow_signed, /* complain_on_overflow */
1147 _bfd_mips_elf_generic_reloc, /* special_function */
1148 "R_MIPS_GOT_PAGE", /* name */
1149 FALSE, /* partial_inplace */
1151 0x0000ffff, /* dst_mask */
1152 FALSE), /* pcrel_offset */
1154 /* Offset from page pointer in the global offset table. */
1155 HOWTO (R_MIPS_GOT_OFST, /* type */
1157 2, /* size (0 = byte, 1 = short, 2 = long) */
1159 FALSE, /* pc_relative */
1161 complain_overflow_signed, /* complain_on_overflow */
1162 _bfd_mips_elf_generic_reloc, /* special_function */
1163 "R_MIPS_GOT_OFST", /* name */
1164 FALSE, /* partial_inplace */
1166 0x0000ffff, /* dst_mask */
1167 FALSE), /* pcrel_offset */
1169 /* High 16 bits of displacement in global offset table. */
1170 HOWTO (R_MIPS_GOT_HI16, /* type */
1172 2, /* size (0 = byte, 1 = short, 2 = long) */
1174 FALSE, /* pc_relative */
1176 complain_overflow_dont, /* complain_on_overflow */
1177 _bfd_mips_elf_generic_reloc, /* special_function */
1178 "R_MIPS_GOT_HI16", /* name */
1179 FALSE, /* partial_inplace */
1181 0x0000ffff, /* dst_mask */
1182 FALSE), /* pcrel_offset */
1184 /* Low 16 bits of displacement in global offset table. */
1185 HOWTO (R_MIPS_GOT_LO16, /* type */
1187 2, /* size (0 = byte, 1 = short, 2 = long) */
1189 FALSE, /* pc_relative */
1191 complain_overflow_dont, /* complain_on_overflow */
1192 _bfd_mips_elf_generic_reloc, /* special_function */
1193 "R_MIPS_GOT_LO16", /* name */
1194 FALSE, /* partial_inplace */
1196 0x0000ffff, /* dst_mask */
1197 FALSE), /* pcrel_offset */
1199 /* 64 bit subtraction. */
1200 HOWTO (R_MIPS_SUB, /* type */
1202 4, /* size (0 = byte, 1 = short, 2 = long) */
1204 FALSE, /* pc_relative */
1206 complain_overflow_dont, /* complain_on_overflow */
1207 _bfd_mips_elf_generic_reloc, /* special_function */
1208 "R_MIPS_SUB", /* name */
1209 FALSE, /* partial_inplace */
1211 MINUS_ONE, /* dst_mask */
1212 FALSE), /* pcrel_offset */
1214 /* Insert the addend as an instruction. */
1215 /* FIXME: Not handled correctly. */
1216 HOWTO (R_MIPS_INSERT_A, /* type */
1218 2, /* size (0 = byte, 1 = short, 2 = long) */
1220 FALSE, /* pc_relative */
1222 complain_overflow_dont, /* complain_on_overflow */
1223 _bfd_mips_elf_generic_reloc, /* special_function */
1224 "R_MIPS_INSERT_A", /* name */
1225 FALSE, /* partial_inplace */
1227 0xffffffff, /* dst_mask */
1228 FALSE), /* pcrel_offset */
1230 /* Insert the addend as an instruction, and change all relocations
1231 to refer to the old instruction at the address. */
1232 /* FIXME: Not handled correctly. */
1233 HOWTO (R_MIPS_INSERT_B, /* type */
1235 2, /* size (0 = byte, 1 = short, 2 = long) */
1237 FALSE, /* pc_relative */
1239 complain_overflow_dont, /* complain_on_overflow */
1240 _bfd_mips_elf_generic_reloc, /* special_function */
1241 "R_MIPS_INSERT_B", /* name */
1242 FALSE, /* partial_inplace */
1244 0xffffffff, /* dst_mask */
1245 FALSE), /* pcrel_offset */
1247 /* Delete a 32 bit instruction. */
1248 /* FIXME: Not handled correctly. */
1249 HOWTO (R_MIPS_DELETE, /* type */
1251 2, /* size (0 = byte, 1 = short, 2 = long) */
1253 FALSE, /* pc_relative */
1255 complain_overflow_dont, /* complain_on_overflow */
1256 _bfd_mips_elf_generic_reloc, /* special_function */
1257 "R_MIPS_DELETE", /* name */
1258 FALSE, /* partial_inplace */
1260 0xffffffff, /* dst_mask */
1261 FALSE), /* pcrel_offset */
1263 /* Get the higher value of a 64 bit addend. */
1264 HOWTO (R_MIPS_HIGHER, /* type */
1266 2, /* size (0 = byte, 1 = short, 2 = long) */
1268 FALSE, /* pc_relative */
1270 complain_overflow_dont, /* complain_on_overflow */
1271 _bfd_mips_elf_generic_reloc, /* special_function */
1272 "R_MIPS_HIGHER", /* name */
1273 FALSE, /* partial_inplace */
1275 0x0000ffff, /* dst_mask */
1276 FALSE), /* pcrel_offset */
1278 /* Get the highest value of a 64 bit addend. */
1279 HOWTO (R_MIPS_HIGHEST, /* type */
1281 2, /* size (0 = byte, 1 = short, 2 = long) */
1283 FALSE, /* pc_relative */
1285 complain_overflow_dont, /* complain_on_overflow */
1286 _bfd_mips_elf_generic_reloc, /* special_function */
1287 "R_MIPS_HIGHEST", /* name */
1288 FALSE, /* partial_inplace */
1290 0x0000ffff, /* dst_mask */
1291 FALSE), /* pcrel_offset */
1293 /* High 16 bits of displacement in global offset table. */
1294 HOWTO (R_MIPS_CALL_HI16, /* type */
1296 2, /* size (0 = byte, 1 = short, 2 = long) */
1298 FALSE, /* pc_relative */
1300 complain_overflow_dont, /* complain_on_overflow */
1301 _bfd_mips_elf_generic_reloc, /* special_function */
1302 "R_MIPS_CALL_HI16", /* name */
1303 FALSE, /* partial_inplace */
1305 0x0000ffff, /* dst_mask */
1306 FALSE), /* pcrel_offset */
1308 /* Low 16 bits of displacement in global offset table. */
1309 HOWTO (R_MIPS_CALL_LO16, /* type */
1311 2, /* size (0 = byte, 1 = short, 2 = long) */
1313 FALSE, /* pc_relative */
1315 complain_overflow_dont, /* complain_on_overflow */
1316 _bfd_mips_elf_generic_reloc, /* special_function */
1317 "R_MIPS_CALL_LO16", /* name */
1318 FALSE, /* partial_inplace */
1320 0x0000ffff, /* dst_mask */
1321 FALSE), /* pcrel_offset */
1323 /* Section displacement, used by an associated event location section. */
1324 HOWTO (R_MIPS_SCN_DISP, /* type */
1326 2, /* size (0 = byte, 1 = short, 2 = long) */
1328 FALSE, /* pc_relative */
1330 complain_overflow_dont, /* complain_on_overflow */
1331 _bfd_mips_elf_generic_reloc, /* special_function */
1332 "R_MIPS_SCN_DISP", /* name */
1333 FALSE, /* partial_inplace */
1335 0xffffffff, /* dst_mask */
1336 FALSE), /* pcrel_offset */
1338 /* 16 bit relocation. */
1339 HOWTO (R_MIPS_REL16, /* type */
1341 1, /* size (0 = byte, 1 = short, 2 = long) */
1343 FALSE, /* pc_relative */
1345 complain_overflow_signed, /* complain_on_overflow */
1346 _bfd_mips_elf_generic_reloc, /* special_function */
1347 "R_MIPS_REL16", /* name */
1348 FALSE, /* partial_inplace */
1350 0xffff, /* dst_mask */
1351 FALSE), /* pcrel_offset */
1353 /* These two are obsolete. */
1354 EMPTY_HOWTO (R_MIPS_ADD_IMMEDIATE),
1355 EMPTY_HOWTO (R_MIPS_PJUMP),
1357 /* Similiar to R_MIPS_REL32, but used for relocations in a GOT section.
1358 It must be used for multigot GOT's (and only there). */
1359 HOWTO (R_MIPS_RELGOT, /* type */
1361 2, /* size (0 = byte, 1 = short, 2 = long) */
1363 FALSE, /* pc_relative */
1365 complain_overflow_dont, /* complain_on_overflow */
1366 _bfd_mips_elf_generic_reloc, /* special_function */
1367 "R_MIPS_RELGOT", /* name */
1368 FALSE, /* partial_inplace */
1370 0xffffffff, /* dst_mask */
1371 FALSE), /* pcrel_offset */
1373 /* Protected jump conversion. This is an optimization hint. No
1374 relocation is required for correctness. */
1375 HOWTO (R_MIPS_JALR, /* type */
1377 2, /* size (0 = byte, 1 = short, 2 = long) */
1379 FALSE, /* pc_relative */
1381 complain_overflow_dont, /* complain_on_overflow */
1382 _bfd_mips_elf_generic_reloc, /* special_function */
1383 "R_MIPS_JALR", /* name */
1384 FALSE, /* partial_inplace */
1387 FALSE), /* pcrel_offset */
1389 /* TLS GD/LD dynamic relocations. */
1390 HOWTO (R_MIPS_TLS_DTPMOD32, /* type */
1392 2, /* size (0 = byte, 1 = short, 2 = long) */
1394 FALSE, /* pc_relative */
1396 complain_overflow_dont, /* complain_on_overflow */
1397 _bfd_mips_elf_generic_reloc, /* special_function */
1398 "R_MIPS_TLS_DTPMOD32", /* name */
1399 FALSE, /* partial_inplace */
1401 0xffffffff, /* dst_mask */
1402 FALSE), /* pcrel_offset */
1404 HOWTO (R_MIPS_TLS_DTPREL32, /* type */
1406 2, /* size (0 = byte, 1 = short, 2 = long) */
1408 FALSE, /* pc_relative */
1410 complain_overflow_dont, /* complain_on_overflow */
1411 _bfd_mips_elf_generic_reloc, /* special_function */
1412 "R_MIPS_TLS_DTPREL32", /* name */
1413 FALSE, /* partial_inplace */
1415 0xffffffff, /* dst_mask */
1416 FALSE), /* pcrel_offset */
1418 EMPTY_HOWTO (R_MIPS_TLS_DTPMOD64),
1419 EMPTY_HOWTO (R_MIPS_TLS_DTPREL64),
1421 /* TLS general dynamic variable reference. */
1422 HOWTO (R_MIPS_TLS_GD, /* type */
1424 2, /* size (0 = byte, 1 = short, 2 = long) */
1426 FALSE, /* pc_relative */
1428 complain_overflow_signed, /* complain_on_overflow */
1429 _bfd_mips_elf_generic_reloc, /* special_function */
1430 "R_MIPS_TLS_GD", /* name */
1431 FALSE, /* partial_inplace */
1433 0x0000ffff, /* dst_mask */
1434 FALSE), /* pcrel_offset */
1436 /* TLS local dynamic variable reference. */
1437 HOWTO (R_MIPS_TLS_LDM, /* type */
1439 2, /* size (0 = byte, 1 = short, 2 = long) */
1441 FALSE, /* pc_relative */
1443 complain_overflow_signed, /* complain_on_overflow */
1444 _bfd_mips_elf_generic_reloc, /* special_function */
1445 "R_MIPS_TLS_LDM", /* name */
1446 FALSE, /* partial_inplace */
1448 0x0000ffff, /* dst_mask */
1449 FALSE), /* pcrel_offset */
1451 /* TLS local dynamic offset. */
1452 HOWTO (R_MIPS_TLS_DTPREL_HI16, /* type */
1454 2, /* size (0 = byte, 1 = short, 2 = long) */
1456 FALSE, /* pc_relative */
1458 complain_overflow_signed, /* complain_on_overflow */
1459 _bfd_mips_elf_generic_reloc, /* special_function */
1460 "R_MIPS_TLS_DTPREL_HI16", /* name */
1461 FALSE, /* partial_inplace */
1463 0x0000ffff, /* dst_mask */
1464 FALSE), /* pcrel_offset */
1466 /* TLS local dynamic offset. */
1467 HOWTO (R_MIPS_TLS_DTPREL_LO16, /* type */
1469 2, /* size (0 = byte, 1 = short, 2 = long) */
1471 FALSE, /* pc_relative */
1473 complain_overflow_signed, /* complain_on_overflow */
1474 _bfd_mips_elf_generic_reloc, /* special_function */
1475 "R_MIPS_TLS_DTPREL_LO16", /* name */
1476 FALSE, /* partial_inplace */
1478 0x0000ffff, /* dst_mask */
1479 FALSE), /* pcrel_offset */
1481 /* TLS thread pointer offset. */
1482 HOWTO (R_MIPS_TLS_GOTTPREL, /* type */
1484 2, /* size (0 = byte, 1 = short, 2 = long) */
1486 FALSE, /* pc_relative */
1488 complain_overflow_signed, /* complain_on_overflow */
1489 _bfd_mips_elf_generic_reloc, /* special_function */
1490 "R_MIPS_TLS_GOTTPREL", /* name */
1491 FALSE, /* partial_inplace */
1493 0x0000ffff, /* dst_mask */
1494 FALSE), /* pcrel_offset */
1496 /* TLS IE dynamic relocations. */
1497 HOWTO (R_MIPS_TLS_TPREL32, /* type */
1499 2, /* size (0 = byte, 1 = short, 2 = long) */
1501 FALSE, /* pc_relative */
1503 complain_overflow_dont, /* complain_on_overflow */
1504 _bfd_mips_elf_generic_reloc, /* special_function */
1505 "R_MIPS_TLS_TPREL32", /* name */
1506 FALSE, /* partial_inplace */
1508 0xffffffff, /* dst_mask */
1509 FALSE), /* pcrel_offset */
1511 EMPTY_HOWTO (R_MIPS_TLS_TPREL64),
1513 /* TLS thread pointer offset. */
1514 HOWTO (R_MIPS_TLS_TPREL_HI16, /* type */
1516 2, /* size (0 = byte, 1 = short, 2 = long) */
1518 FALSE, /* pc_relative */
1520 complain_overflow_signed, /* complain_on_overflow */
1521 _bfd_mips_elf_generic_reloc, /* special_function */
1522 "R_MIPS_TLS_TPREL_HI16", /* name */
1523 FALSE, /* partial_inplace */
1525 0x0000ffff, /* dst_mask */
1526 FALSE), /* pcrel_offset */
1528 /* TLS thread pointer offset. */
1529 HOWTO (R_MIPS_TLS_TPREL_LO16, /* type */
1531 2, /* size (0 = byte, 1 = short, 2 = long) */
1533 FALSE, /* pc_relative */
1535 complain_overflow_signed, /* complain_on_overflow */
1536 _bfd_mips_elf_generic_reloc, /* special_function */
1537 "R_MIPS_TLS_TPREL_LO16", /* name */
1538 FALSE, /* partial_inplace */
1540 0x0000ffff, /* dst_mask */
1541 FALSE), /* pcrel_offset */
1543 /* 32 bit relocation with no addend. */
1544 HOWTO (R_MIPS_GLOB_DAT, /* type */
1546 2, /* size (0 = byte, 1 = short, 2 = long) */
1548 FALSE, /* pc_relative */
1550 complain_overflow_dont, /* complain_on_overflow */
1551 _bfd_mips_elf_generic_reloc, /* special_function */
1552 "R_MIPS_GLOB_DAT", /* name */
1553 FALSE, /* partial_inplace */
1555 0xffffffff, /* dst_mask */
1556 FALSE), /* pcrel_offset */
1567 HOWTO (R_MIPS_PC21_S2, /* type */
1569 2, /* size (0 = byte, 1 = short, 2 = long) */
1571 TRUE, /* pc_relative */
1573 complain_overflow_signed, /* complain_on_overflow */
1574 _bfd_mips_elf_generic_reloc, /* special_function */
1575 "R_MIPS_PC21_S2", /* name */
1576 FALSE, /* partial_inplace */
1578 0x001fffff, /* dst_mask */
1579 TRUE), /* pcrel_offset */
1581 HOWTO (R_MIPS_PC26_S2, /* type */
1583 2, /* size (0 = byte, 1 = short, 2 = long) */
1585 TRUE, /* pc_relative */
1587 complain_overflow_signed, /* complain_on_overflow */
1588 _bfd_mips_elf_generic_reloc, /* special_function */
1589 "R_MIPS_PC26_S2", /* name */
1590 FALSE, /* partial_inplace */
1592 0x03ffffff, /* dst_mask */
1593 TRUE), /* pcrel_offset */
1595 HOWTO (R_MIPS_PC18_S3, /* type */
1597 2, /* size (0 = byte, 1 = short, 2 = long) */
1599 TRUE, /* pc_relative */
1601 complain_overflow_signed, /* complain_on_overflow */
1602 _bfd_mips_elf_generic_reloc, /* special_function */
1603 "R_MIPS_PC18_S3", /* name */
1604 FALSE, /* partial_inplace */
1606 0x0003ffff, /* dst_mask */
1607 TRUE), /* pcrel_offset */
1609 HOWTO (R_MIPS_PC19_S2, /* type */
1611 2, /* size (0 = byte, 1 = short, 2 = long) */
1613 TRUE, /* pc_relative */
1615 complain_overflow_signed, /* complain_on_overflow */
1616 _bfd_mips_elf_generic_reloc, /* special_function */
1617 "R_MIPS_PC19_S2", /* name */
1618 FALSE, /* partial_inplace */
1620 0x0007ffff, /* dst_mask */
1621 TRUE), /* pcrel_offset */
1623 HOWTO (R_MIPS_PCHI16, /* type */
1624 16, /* rightshift */
1625 2, /* size (0 = byte, 1 = short, 2 = long) */
1627 TRUE, /* pc_relative */
1629 complain_overflow_signed, /* complain_on_overflow */
1630 _bfd_mips_elf_generic_reloc, /* special_function */
1631 "R_MIPS_PCHI16", /* name */
1632 FALSE, /* partial_inplace */
1634 0x0000ffff, /* dst_mask */
1635 TRUE), /* pcrel_offset */
1637 HOWTO (R_MIPS_PCLO16, /* type */
1639 2, /* size (0 = byte, 1 = short, 2 = long) */
1641 TRUE, /* pc_relative */
1643 complain_overflow_dont, /* complain_on_overflow */
1644 _bfd_mips_elf_generic_reloc, /* special_function */
1645 "R_MIPS_PCLO16", /* name */
1646 FALSE, /* partial_inplace */
1648 0x0000ffff, /* dst_mask */
1649 TRUE), /* pcrel_offset */
1653 static reloc_howto_type elf_mips16_howto_table_rel[] =
1655 /* The reloc used for the mips16 jump instruction. */
1656 HOWTO (R_MIPS16_26, /* type */
1658 2, /* size (0 = byte, 1 = short, 2 = long) */
1660 FALSE, /* pc_relative */
1662 complain_overflow_dont, /* complain_on_overflow */
1663 /* This needs complex overflow
1664 detection, because the upper four
1665 bits must match the PC. */
1666 _bfd_mips_elf_generic_reloc, /* special_function */
1667 "R_MIPS16_26", /* name */
1668 TRUE, /* partial_inplace */
1669 0x3ffffff, /* src_mask */
1670 0x3ffffff, /* dst_mask */
1671 FALSE), /* pcrel_offset */
1673 /* The reloc used for the mips16 gprel instruction. */
1674 HOWTO (R_MIPS16_GPREL, /* type */
1676 2, /* size (0 = byte, 1 = short, 2 = long) */
1678 FALSE, /* pc_relative */
1680 complain_overflow_signed, /* complain_on_overflow */
1681 mips16_gprel_reloc, /* special_function */
1682 "R_MIPS16_GPREL", /* name */
1683 TRUE, /* partial_inplace */
1684 0x0000ffff, /* src_mask */
1685 0x0000ffff, /* dst_mask */
1686 FALSE), /* pcrel_offset */
1688 /* A MIPS16 reference to the global offset table. */
1689 HOWTO (R_MIPS16_GOT16, /* type */
1691 2, /* size (0 = byte, 1 = short, 2 = long) */
1693 FALSE, /* pc_relative */
1695 complain_overflow_dont, /* complain_on_overflow */
1696 _bfd_mips_elf_got16_reloc, /* special_function */
1697 "R_MIPS16_GOT16", /* name */
1698 TRUE, /* partial_inplace */
1699 0x0000ffff, /* src_mask */
1700 0x0000ffff, /* dst_mask */
1701 FALSE), /* pcrel_offset */
1703 /* A MIPS16 call through the global offset table. */
1704 HOWTO (R_MIPS16_CALL16, /* type */
1706 2, /* size (0 = byte, 1 = short, 2 = long) */
1708 FALSE, /* pc_relative */
1710 complain_overflow_dont, /* complain_on_overflow */
1711 _bfd_mips_elf_generic_reloc, /* special_function */
1712 "R_MIPS16_CALL16", /* name */
1713 TRUE, /* partial_inplace */
1714 0x0000ffff, /* src_mask */
1715 0x0000ffff, /* dst_mask */
1716 FALSE), /* pcrel_offset */
1718 /* MIPS16 high 16 bits of symbol value. */
1719 HOWTO (R_MIPS16_HI16, /* type */
1720 16, /* rightshift */
1721 2, /* size (0 = byte, 1 = short, 2 = long) */
1723 FALSE, /* pc_relative */
1725 complain_overflow_dont, /* complain_on_overflow */
1726 _bfd_mips_elf_hi16_reloc, /* special_function */
1727 "R_MIPS16_HI16", /* name */
1728 TRUE, /* partial_inplace */
1729 0x0000ffff, /* src_mask */
1730 0x0000ffff, /* dst_mask */
1731 FALSE), /* pcrel_offset */
1733 /* MIPS16 low 16 bits of symbol value. */
1734 HOWTO (R_MIPS16_LO16, /* type */
1736 2, /* size (0 = byte, 1 = short, 2 = long) */
1738 FALSE, /* pc_relative */
1740 complain_overflow_dont, /* complain_on_overflow */
1741 _bfd_mips_elf_lo16_reloc, /* special_function */
1742 "R_MIPS16_LO16", /* name */
1743 TRUE, /* partial_inplace */
1744 0x0000ffff, /* src_mask */
1745 0x0000ffff, /* dst_mask */
1746 FALSE), /* pcrel_offset */
1748 /* MIPS16 TLS general dynamic variable reference. */
1749 HOWTO (R_MIPS16_TLS_GD, /* type */
1751 2, /* size (0 = byte, 1 = short, 2 = long) */
1753 FALSE, /* pc_relative */
1755 complain_overflow_signed, /* complain_on_overflow */
1756 _bfd_mips_elf_generic_reloc, /* special_function */
1757 "R_MIPS16_TLS_GD", /* name */
1758 TRUE, /* partial_inplace */
1759 0x0000ffff, /* src_mask */
1760 0x0000ffff, /* dst_mask */
1761 FALSE), /* pcrel_offset */
1763 /* MIPS16 TLS local dynamic variable reference. */
1764 HOWTO (R_MIPS16_TLS_LDM, /* type */
1766 2, /* size (0 = byte, 1 = short, 2 = long) */
1768 FALSE, /* pc_relative */
1770 complain_overflow_signed, /* complain_on_overflow */
1771 _bfd_mips_elf_generic_reloc, /* special_function */
1772 "R_MIPS16_TLS_LDM", /* name */
1773 TRUE, /* partial_inplace */
1774 0x0000ffff, /* src_mask */
1775 0x0000ffff, /* dst_mask */
1776 FALSE), /* pcrel_offset */
1778 /* MIPS16 TLS local dynamic offset. */
1779 HOWTO (R_MIPS16_TLS_DTPREL_HI16, /* type */
1781 2, /* size (0 = byte, 1 = short, 2 = long) */
1783 FALSE, /* pc_relative */
1785 complain_overflow_signed, /* complain_on_overflow */
1786 _bfd_mips_elf_generic_reloc, /* special_function */
1787 "R_MIPS16_TLS_DTPREL_HI16", /* name */
1788 TRUE, /* partial_inplace */
1789 0x0000ffff, /* src_mask */
1790 0x0000ffff, /* dst_mask */
1791 FALSE), /* pcrel_offset */
1793 /* MIPS16 TLS local dynamic offset. */
1794 HOWTO (R_MIPS16_TLS_DTPREL_LO16, /* type */
1796 2, /* size (0 = byte, 1 = short, 2 = long) */
1798 FALSE, /* pc_relative */
1800 complain_overflow_signed, /* complain_on_overflow */
1801 _bfd_mips_elf_generic_reloc, /* special_function */
1802 "R_MIPS16_TLS_DTPREL_LO16", /* name */
1803 TRUE, /* partial_inplace */
1804 0x0000ffff, /* src_mask */
1805 0x0000ffff, /* dst_mask */
1806 FALSE), /* pcrel_offset */
1808 /* MIPS16 TLS thread pointer offset. */
1809 HOWTO (R_MIPS16_TLS_GOTTPREL, /* type */
1811 2, /* size (0 = byte, 1 = short, 2 = long) */
1813 FALSE, /* pc_relative */
1815 complain_overflow_signed, /* complain_on_overflow */
1816 _bfd_mips_elf_generic_reloc, /* special_function */
1817 "R_MIPS16_TLS_GOTTPREL", /* name */
1818 TRUE, /* partial_inplace */
1819 0x0000ffff, /* src_mask */
1820 0x0000ffff, /* dst_mask */
1821 FALSE), /* pcrel_offset */
1823 /* MIPS16 TLS thread pointer offset. */
1824 HOWTO (R_MIPS16_TLS_TPREL_HI16, /* type */
1826 2, /* size (0 = byte, 1 = short, 2 = long) */
1828 FALSE, /* pc_relative */
1830 complain_overflow_signed, /* complain_on_overflow */
1831 _bfd_mips_elf_generic_reloc, /* special_function */
1832 "R_MIPS16_TLS_TPREL_HI16", /* name */
1833 TRUE, /* partial_inplace */
1834 0x0000ffff, /* src_mask */
1835 0x0000ffff, /* dst_mask */
1836 FALSE), /* pcrel_offset */
1838 /* MIPS16 TLS thread pointer offset. */
1839 HOWTO (R_MIPS16_TLS_TPREL_LO16, /* type */
1841 2, /* size (0 = byte, 1 = short, 2 = long) */
1843 FALSE, /* pc_relative */
1845 complain_overflow_signed, /* complain_on_overflow */
1846 _bfd_mips_elf_generic_reloc, /* special_function */
1847 "R_MIPS16_TLS_TPREL_LO16", /* name */
1848 TRUE, /* partial_inplace */
1849 0x0000ffff, /* src_mask */
1850 0x0000ffff, /* dst_mask */
1851 FALSE), /* pcrel_offset */
1853 /* MIPS16 16-bit PC-relative branch offset. */
1854 HOWTO (R_MIPS16_PC16_S1, /* type */
1856 2, /* size (0 = byte, 1 = short, 2 = long) */
1858 TRUE, /* pc_relative */
1860 complain_overflow_signed, /* complain_on_overflow */
1861 _bfd_mips_elf_generic_reloc, /* special_function */
1862 "R_MIPS16_PC16_S1", /* name */
1863 TRUE, /* partial_inplace */
1864 0x0000ffff, /* src_mask */
1865 0x0000ffff, /* dst_mask */
1866 TRUE), /* pcrel_offset */
1869 static reloc_howto_type elf_mips16_howto_table_rela[] =
1871 /* The reloc used for the mips16 jump instruction. */
1872 HOWTO (R_MIPS16_26, /* type */
1874 2, /* size (0 = byte, 1 = short, 2 = long) */
1876 FALSE, /* pc_relative */
1878 complain_overflow_dont, /* complain_on_overflow */
1879 /* This needs complex overflow
1880 detection, because the upper four
1881 bits must match the PC. */
1882 _bfd_mips_elf_generic_reloc, /* special_function */
1883 "R_MIPS16_26", /* name */
1884 FALSE, /* partial_inplace */
1886 0x3ffffff, /* dst_mask */
1887 FALSE), /* pcrel_offset */
1889 /* The reloc used for the mips16 gprel instruction. */
1890 HOWTO (R_MIPS16_GPREL, /* type */
1892 2, /* size (0 = byte, 1 = short, 2 = long) */
1894 FALSE, /* pc_relative */
1896 complain_overflow_signed, /* complain_on_overflow */
1897 mips16_gprel_reloc, /* special_function */
1898 "R_MIPS16_GPREL", /* name */
1899 FALSE, /* partial_inplace */
1901 0x0000ffff, /* dst_mask */
1902 FALSE), /* pcrel_offset */
1904 /* A MIPS16 reference to the global offset table. */
1905 HOWTO (R_MIPS16_GOT16, /* type */
1907 2, /* size (0 = byte, 1 = short, 2 = long) */
1909 FALSE, /* pc_relative */
1911 complain_overflow_dont, /* complain_on_overflow */
1912 _bfd_mips_elf_got16_reloc, /* special_function */
1913 "R_MIPS16_GOT16", /* name */
1914 FALSE, /* partial_inplace */
1916 0x0000ffff, /* dst_mask */
1917 FALSE), /* pcrel_offset */
1919 /* A MIPS16 call through the global offset table. */
1920 HOWTO (R_MIPS16_CALL16, /* type */
1922 2, /* size (0 = byte, 1 = short, 2 = long) */
1924 FALSE, /* pc_relative */
1926 complain_overflow_dont, /* complain_on_overflow */
1927 _bfd_mips_elf_generic_reloc, /* special_function */
1928 "R_MIPS16_CALL16", /* name */
1929 FALSE, /* partial_inplace */
1931 0x0000ffff, /* dst_mask */
1932 FALSE), /* pcrel_offset */
1934 /* MIPS16 high 16 bits of symbol value. */
1935 HOWTO (R_MIPS16_HI16, /* type */
1936 16, /* rightshift */
1937 2, /* size (0 = byte, 1 = short, 2 = long) */
1939 FALSE, /* pc_relative */
1941 complain_overflow_dont, /* complain_on_overflow */
1942 _bfd_mips_elf_hi16_reloc, /* special_function */
1943 "R_MIPS16_HI16", /* name */
1944 FALSE, /* partial_inplace */
1946 0x0000ffff, /* dst_mask */
1947 FALSE), /* pcrel_offset */
1949 /* MIPS16 low 16 bits of symbol value. */
1950 HOWTO (R_MIPS16_LO16, /* type */
1952 2, /* size (0 = byte, 1 = short, 2 = long) */
1954 FALSE, /* pc_relative */
1956 complain_overflow_dont, /* complain_on_overflow */
1957 _bfd_mips_elf_lo16_reloc, /* special_function */
1958 "R_MIPS16_LO16", /* name */
1959 FALSE, /* partial_inplace */
1961 0x0000ffff, /* dst_mask */
1962 FALSE), /* pcrel_offset */
1964 /* MIPS16 TLS general dynamic variable reference. */
1965 HOWTO (R_MIPS16_TLS_GD, /* type */
1967 2, /* size (0 = byte, 1 = short, 2 = long) */
1969 FALSE, /* pc_relative */
1971 complain_overflow_signed, /* complain_on_overflow */
1972 _bfd_mips_elf_generic_reloc, /* special_function */
1973 "R_MIPS16_TLS_GD", /* name */
1974 FALSE, /* partial_inplace */
1976 0x0000ffff, /* dst_mask */
1977 FALSE), /* pcrel_offset */
1979 /* MIPS16 TLS local dynamic variable reference. */
1980 HOWTO (R_MIPS16_TLS_LDM, /* type */
1982 2, /* size (0 = byte, 1 = short, 2 = long) */
1984 FALSE, /* pc_relative */
1986 complain_overflow_signed, /* complain_on_overflow */
1987 _bfd_mips_elf_generic_reloc, /* special_function */
1988 "R_MIPS16_TLS_LDM", /* name */
1989 FALSE, /* partial_inplace */
1991 0x0000ffff, /* dst_mask */
1992 FALSE), /* pcrel_offset */
1994 /* MIPS16 TLS local dynamic offset. */
1995 HOWTO (R_MIPS16_TLS_DTPREL_HI16, /* type */
1997 2, /* size (0 = byte, 1 = short, 2 = long) */
1999 FALSE, /* pc_relative */
2001 complain_overflow_signed, /* complain_on_overflow */
2002 _bfd_mips_elf_generic_reloc, /* special_function */
2003 "R_MIPS16_TLS_DTPREL_HI16", /* name */
2004 FALSE, /* partial_inplace */
2006 0x0000ffff, /* dst_mask */
2007 FALSE), /* pcrel_offset */
2009 /* MIPS16 TLS local dynamic offset. */
2010 HOWTO (R_MIPS16_TLS_DTPREL_LO16, /* type */
2012 2, /* size (0 = byte, 1 = short, 2 = long) */
2014 FALSE, /* pc_relative */
2016 complain_overflow_signed, /* complain_on_overflow */
2017 _bfd_mips_elf_generic_reloc, /* special_function */
2018 "R_MIPS16_TLS_DTPREL_LO16", /* name */
2019 FALSE, /* partial_inplace */
2021 0x0000ffff, /* dst_mask */
2022 FALSE), /* pcrel_offset */
2024 /* MIPS16 TLS thread pointer offset. */
2025 HOWTO (R_MIPS16_TLS_GOTTPREL, /* type */
2027 2, /* size (0 = byte, 1 = short, 2 = long) */
2029 FALSE, /* pc_relative */
2031 complain_overflow_signed, /* complain_on_overflow */
2032 _bfd_mips_elf_generic_reloc, /* special_function */
2033 "R_MIPS16_TLS_GOTTPREL", /* name */
2034 FALSE, /* partial_inplace */
2036 0x0000ffff, /* dst_mask */
2037 FALSE), /* pcrel_offset */
2039 /* MIPS16 TLS thread pointer offset. */
2040 HOWTO (R_MIPS16_TLS_TPREL_HI16, /* type */
2042 2, /* size (0 = byte, 1 = short, 2 = long) */
2044 FALSE, /* pc_relative */
2046 complain_overflow_signed, /* complain_on_overflow */
2047 _bfd_mips_elf_generic_reloc, /* special_function */
2048 "R_MIPS16_TLS_TPREL_HI16", /* name */
2049 FALSE, /* partial_inplace */
2051 0x0000ffff, /* dst_mask */
2052 FALSE), /* pcrel_offset */
2054 /* MIPS16 TLS thread pointer offset. */
2055 HOWTO (R_MIPS16_TLS_TPREL_LO16, /* type */
2057 2, /* size (0 = byte, 1 = short, 2 = long) */
2059 FALSE, /* pc_relative */
2061 complain_overflow_signed, /* complain_on_overflow */
2062 _bfd_mips_elf_generic_reloc, /* special_function */
2063 "R_MIPS16_TLS_TPREL_LO16", /* name */
2064 FALSE, /* partial_inplace */
2066 0x0000ffff, /* dst_mask */
2067 FALSE), /* pcrel_offset */
2069 /* MIPS16 16-bit PC-relative branch offset. */
2070 HOWTO (R_MIPS16_PC16_S1, /* type */
2072 2, /* size (0 = byte, 1 = short, 2 = long) */
2074 TRUE, /* pc_relative */
2076 complain_overflow_signed, /* complain_on_overflow */
2077 _bfd_mips_elf_generic_reloc, /* special_function */
2078 "R_MIPS16_PC16_S1", /* name */
2079 FALSE, /* partial_inplace */
2081 0x0000ffff, /* dst_mask */
2082 TRUE), /* pcrel_offset */
2085 static reloc_howto_type elf_micromips_howto_table_rel[] =
2091 /* 26 bit jump address. */
2092 HOWTO (R_MICROMIPS_26_S1, /* type */
2094 2, /* size (0 = byte, 1 = short, 2 = long) */
2096 FALSE, /* pc_relative */
2098 complain_overflow_dont, /* complain_on_overflow */
2099 /* This needs complex overflow
2100 detection, because the upper four
2101 bits must match the PC. */
2102 _bfd_mips_elf_generic_reloc, /* special_function */
2103 "R_MICROMIPS_26_S1", /* name */
2104 TRUE, /* partial_inplace */
2105 0x3ffffff, /* src_mask */
2106 0x3ffffff, /* dst_mask */
2107 FALSE), /* pcrel_offset */
2109 /* High 16 bits of symbol value. */
2110 HOWTO (R_MICROMIPS_HI16, /* type */
2111 16, /* rightshift */
2112 2, /* size (0 = byte, 1 = short, 2 = long) */
2114 FALSE, /* pc_relative */
2116 complain_overflow_dont, /* complain_on_overflow */
2117 _bfd_mips_elf_hi16_reloc, /* special_function */
2118 "R_MICROMIPS_HI16", /* name */
2119 TRUE, /* partial_inplace */
2120 0x0000ffff, /* src_mask */
2121 0x0000ffff, /* dst_mask */
2122 FALSE), /* pcrel_offset */
2124 /* Low 16 bits of symbol value. */
2125 HOWTO (R_MICROMIPS_LO16, /* type */
2127 2, /* size (0 = byte, 1 = short, 2 = long) */
2129 FALSE, /* pc_relative */
2131 complain_overflow_dont, /* complain_on_overflow */
2132 _bfd_mips_elf_lo16_reloc, /* special_function */
2133 "R_MICROMIPS_LO16", /* name */
2134 TRUE, /* partial_inplace */
2135 0x0000ffff, /* src_mask */
2136 0x0000ffff, /* dst_mask */
2137 FALSE), /* pcrel_offset */
2139 /* GP relative reference. */
2140 HOWTO (R_MICROMIPS_GPREL16, /* type */
2142 2, /* size (0 = byte, 1 = short, 2 = long) */
2144 FALSE, /* pc_relative */
2146 complain_overflow_signed, /* complain_on_overflow */
2147 _bfd_mips_elf32_gprel16_reloc, /* special_function */
2148 "R_MICROMIPS_GPREL16", /* name */
2149 TRUE, /* partial_inplace */
2150 0x0000ffff, /* src_mask */
2151 0x0000ffff, /* dst_mask */
2152 FALSE), /* pcrel_offset */
2154 /* Reference to literal section. */
2155 HOWTO (R_MICROMIPS_LITERAL, /* type */
2157 2, /* size (0 = byte, 1 = short, 2 = long) */
2159 FALSE, /* pc_relative */
2161 complain_overflow_signed, /* complain_on_overflow */
2162 _bfd_mips_elf32_gprel16_reloc, /* special_function */
2163 "R_MICROMIPS_LITERAL", /* name */
2164 TRUE, /* partial_inplace */
2165 0x0000ffff, /* src_mask */
2166 0x0000ffff, /* dst_mask */
2167 FALSE), /* pcrel_offset */
2169 /* Reference to global offset table. */
2170 HOWTO (R_MICROMIPS_GOT16, /* type */
2172 2, /* size (0 = byte, 1 = short, 2 = long) */
2174 FALSE, /* pc_relative */
2176 complain_overflow_signed, /* complain_on_overflow */
2177 _bfd_mips_elf_got16_reloc, /* special_function */
2178 "R_MICROMIPS_GOT16", /* name */
2179 TRUE, /* partial_inplace */
2180 0x0000ffff, /* src_mask */
2181 0x0000ffff, /* dst_mask */
2182 FALSE), /* pcrel_offset */
2184 /* This is for microMIPS branches. */
2185 HOWTO (R_MICROMIPS_PC7_S1, /* type */
2187 1, /* size (0 = byte, 1 = short, 2 = long) */
2189 TRUE, /* pc_relative */
2191 complain_overflow_signed, /* complain_on_overflow */
2192 _bfd_mips_elf_generic_reloc, /* special_function */
2193 "R_MICROMIPS_PC7_S1", /* name */
2194 TRUE, /* partial_inplace */
2195 0x0000007f, /* src_mask */
2196 0x0000007f, /* dst_mask */
2197 TRUE), /* pcrel_offset */
2199 HOWTO (R_MICROMIPS_PC10_S1, /* type */
2201 1, /* size (0 = byte, 1 = short, 2 = long) */
2203 TRUE, /* pc_relative */
2205 complain_overflow_signed, /* complain_on_overflow */
2206 _bfd_mips_elf_generic_reloc, /* special_function */
2207 "R_MICROMIPS_PC10_S1", /* name */
2208 TRUE, /* partial_inplace */
2209 0x000003ff, /* src_mask */
2210 0x000003ff, /* dst_mask */
2211 TRUE), /* pcrel_offset */
2213 HOWTO (R_MICROMIPS_PC16_S1, /* type */
2215 2, /* size (0 = byte, 1 = short, 2 = long) */
2217 TRUE, /* pc_relative */
2219 complain_overflow_signed, /* complain_on_overflow */
2220 _bfd_mips_elf_generic_reloc, /* special_function */
2221 "R_MICROMIPS_PC16_S1", /* name */
2222 TRUE, /* partial_inplace */
2223 0x0000ffff, /* src_mask */
2224 0x0000ffff, /* dst_mask */
2225 TRUE), /* pcrel_offset */
2227 /* 16 bit call through global offset table. */
2228 HOWTO (R_MICROMIPS_CALL16, /* type */
2230 2, /* size (0 = byte, 1 = short, 2 = long) */
2232 FALSE, /* pc_relative */
2234 complain_overflow_signed, /* complain_on_overflow */
2235 _bfd_mips_elf_generic_reloc, /* special_function */
2236 "R_MICROMIPS_CALL16", /* name */
2237 TRUE, /* partial_inplace */
2238 0x0000ffff, /* src_mask */
2239 0x0000ffff, /* dst_mask */
2240 FALSE), /* pcrel_offset */
2245 /* Displacement in the global offset table. */
2246 HOWTO (R_MICROMIPS_GOT_DISP, /* type */
2248 2, /* size (0 = byte, 1 = short, 2 = long) */
2250 FALSE, /* pc_relative */
2252 complain_overflow_signed, /* complain_on_overflow */
2253 _bfd_mips_elf_generic_reloc, /* special_function */
2254 "R_MICROMIPS_GOT_DISP",/* name */
2255 TRUE, /* partial_inplace */
2256 0x0000ffff, /* src_mask */
2257 0x0000ffff, /* dst_mask */
2258 FALSE), /* pcrel_offset */
2260 /* Displacement to page pointer in the global offset table. */
2261 HOWTO (R_MICROMIPS_GOT_PAGE, /* type */
2263 2, /* size (0 = byte, 1 = short, 2 = long) */
2265 FALSE, /* pc_relative */
2267 complain_overflow_signed, /* complain_on_overflow */
2268 _bfd_mips_elf_generic_reloc, /* special_function */
2269 "R_MICROMIPS_GOT_PAGE",/* name */
2270 TRUE, /* partial_inplace */
2271 0x0000ffff, /* src_mask */
2272 0x0000ffff, /* dst_mask */
2273 FALSE), /* pcrel_offset */
2275 /* Offset from page pointer in the global offset table. */
2276 HOWTO (R_MICROMIPS_GOT_OFST, /* type */
2278 2, /* size (0 = byte, 1 = short, 2 = long) */
2280 FALSE, /* pc_relative */
2282 complain_overflow_signed, /* complain_on_overflow */
2283 _bfd_mips_elf_generic_reloc, /* special_function */
2284 "R_MICROMIPS_GOT_OFST",/* name */
2285 TRUE, /* partial_inplace */
2286 0x0000ffff, /* src_mask */
2287 0x0000ffff, /* dst_mask */
2288 FALSE), /* pcrel_offset */
2290 /* High 16 bits of displacement in global offset table. */
2291 HOWTO (R_MICROMIPS_GOT_HI16, /* type */
2293 2, /* size (0 = byte, 1 = short, 2 = long) */
2295 FALSE, /* pc_relative */
2297 complain_overflow_dont, /* complain_on_overflow */
2298 _bfd_mips_elf_generic_reloc, /* special_function */
2299 "R_MICROMIPS_GOT_HI16",/* name */
2300 TRUE, /* partial_inplace */
2301 0x0000ffff, /* src_mask */
2302 0x0000ffff, /* dst_mask */
2303 FALSE), /* pcrel_offset */
2305 /* Low 16 bits of displacement in global offset table. */
2306 HOWTO (R_MICROMIPS_GOT_LO16, /* type */
2308 2, /* size (0 = byte, 1 = short, 2 = long) */
2310 FALSE, /* pc_relative */
2312 complain_overflow_dont, /* complain_on_overflow */
2313 _bfd_mips_elf_generic_reloc, /* special_function */
2314 "R_MICROMIPS_GOT_LO16",/* name */
2315 TRUE, /* partial_inplace */
2316 0x0000ffff, /* src_mask */
2317 0x0000ffff, /* dst_mask */
2318 FALSE), /* pcrel_offset */
2320 /* 64 bit subtraction. Used in the N32 ABI. */
2321 HOWTO (R_MICROMIPS_SUB, /* type */
2323 4, /* size (0 = byte, 1 = short, 2 = long) */
2325 FALSE, /* pc_relative */
2327 complain_overflow_dont, /* complain_on_overflow */
2328 _bfd_mips_elf_generic_reloc, /* special_function */
2329 "R_MICROMIPS_SUB", /* name */
2330 TRUE, /* partial_inplace */
2331 MINUS_ONE, /* src_mask */
2332 MINUS_ONE, /* dst_mask */
2333 FALSE), /* pcrel_offset */
2335 /* We don't support these for REL relocations, because it means building
2336 the addend from a R_MICROMIPS_HIGHEST/R_MICROMIPS_HIGHER/
2337 R_MICROMIPS_HI16/R_MICROMIPS_LO16 sequence with varying ordering,
2338 using fallable heuristics. */
2339 EMPTY_HOWTO (R_MICROMIPS_HIGHER),
2340 EMPTY_HOWTO (R_MICROMIPS_HIGHEST),
2342 /* High 16 bits of displacement in global offset table. */
2343 HOWTO (R_MICROMIPS_CALL_HI16, /* type */
2345 2, /* size (0 = byte, 1 = short, 2 = long) */
2347 FALSE, /* pc_relative */
2349 complain_overflow_dont, /* complain_on_overflow */
2350 _bfd_mips_elf_generic_reloc, /* special_function */
2351 "R_MICROMIPS_CALL_HI16",/* name */
2352 TRUE, /* partial_inplace */
2353 0x0000ffff, /* src_mask */
2354 0x0000ffff, /* dst_mask */
2355 FALSE), /* pcrel_offset */
2357 /* Low 16 bits of displacement in global offset table. */
2358 HOWTO (R_MICROMIPS_CALL_LO16, /* type */
2360 2, /* size (0 = byte, 1 = short, 2 = long) */
2362 FALSE, /* pc_relative */
2364 complain_overflow_dont, /* complain_on_overflow */
2365 _bfd_mips_elf_generic_reloc, /* special_function */
2366 "R_MICROMIPS_CALL_LO16",/* name */
2367 TRUE, /* partial_inplace */
2368 0x0000ffff, /* src_mask */
2369 0x0000ffff, /* dst_mask */
2370 FALSE), /* pcrel_offset */
2372 /* Section displacement. */
2373 HOWTO (R_MICROMIPS_SCN_DISP, /* type */
2375 2, /* size (0 = byte, 1 = short, 2 = long) */
2377 FALSE, /* pc_relative */
2379 complain_overflow_dont, /* complain_on_overflow */
2380 _bfd_mips_elf_generic_reloc, /* special_function */
2381 "R_MICROMIPS_SCN_DISP", /* name */
2382 TRUE, /* partial_inplace */
2383 0xffffffff, /* src_mask */
2384 0xffffffff, /* dst_mask */
2385 FALSE), /* pcrel_offset */
2387 /* Protected jump conversion. This is an optimization hint. No
2388 relocation is required for correctness. */
2389 HOWTO (R_MICROMIPS_JALR, /* type */
2391 2, /* size (0 = byte, 1 = short, 2 = long) */
2393 FALSE, /* pc_relative */
2395 complain_overflow_dont, /* complain_on_overflow */
2396 _bfd_mips_elf_generic_reloc, /* special_function */
2397 "R_MICROMIPS_JALR", /* name */
2398 FALSE, /* partial_inplace */
2400 0x00000000, /* dst_mask */
2401 FALSE), /* pcrel_offset */
2403 /* Low 16 bits of symbol value. Note that the high 16 bits of symbol values
2404 must be zero. This is used for relaxation. */
2405 HOWTO (R_MICROMIPS_HI0_LO16, /* type */
2407 2, /* size (0 = byte, 1 = short, 2 = long) */
2409 FALSE, /* pc_relative */
2411 complain_overflow_dont, /* complain_on_overflow */
2412 _bfd_mips_elf_generic_reloc, /* special_function */
2413 "R_MICROMIPS_HI0_LO16",/* name */
2414 TRUE, /* partial_inplace */
2415 0x0000ffff, /* src_mask */
2416 0x0000ffff, /* dst_mask */
2417 FALSE), /* pcrel_offset */
2424 /* TLS general dynamic variable reference. */
2425 HOWTO (R_MICROMIPS_TLS_GD, /* type */
2427 2, /* size (0 = byte, 1 = short, 2 = long) */
2429 FALSE, /* pc_relative */
2431 complain_overflow_signed, /* complain_on_overflow */
2432 _bfd_mips_elf_generic_reloc, /* special_function */
2433 "R_MICROMIPS_TLS_GD", /* name */
2434 TRUE, /* partial_inplace */
2435 0x0000ffff, /* src_mask */
2436 0x0000ffff, /* dst_mask */
2437 FALSE), /* pcrel_offset */
2439 /* TLS local dynamic variable reference. */
2440 HOWTO (R_MICROMIPS_TLS_LDM, /* type */
2442 2, /* size (0 = byte, 1 = short, 2 = long) */
2444 FALSE, /* pc_relative */
2446 complain_overflow_signed, /* complain_on_overflow */
2447 _bfd_mips_elf_generic_reloc, /* special_function */
2448 "R_MICROMIPS_TLS_LDM", /* name */
2449 TRUE, /* partial_inplace */
2450 0x0000ffff, /* src_mask */
2451 0x0000ffff, /* dst_mask */
2452 FALSE), /* pcrel_offset */
2454 /* TLS local dynamic offset. */
2455 HOWTO (R_MICROMIPS_TLS_DTPREL_HI16, /* type */
2457 2, /* size (0 = byte, 1 = short, 2 = long) */
2459 FALSE, /* pc_relative */
2461 complain_overflow_signed, /* complain_on_overflow */
2462 _bfd_mips_elf_generic_reloc, /* special_function */
2463 "R_MICROMIPS_TLS_DTPREL_HI16", /* name */
2464 TRUE, /* partial_inplace */
2465 0x0000ffff, /* src_mask */
2466 0x0000ffff, /* dst_mask */
2467 FALSE), /* pcrel_offset */
2469 /* TLS local dynamic offset. */
2470 HOWTO (R_MICROMIPS_TLS_DTPREL_LO16, /* type */
2472 2, /* size (0 = byte, 1 = short, 2 = long) */
2474 FALSE, /* pc_relative */
2476 complain_overflow_signed, /* complain_on_overflow */
2477 _bfd_mips_elf_generic_reloc, /* special_function */
2478 "R_MICROMIPS_TLS_DTPREL_LO16", /* name */
2479 TRUE, /* partial_inplace */
2480 0x0000ffff, /* src_mask */
2481 0x0000ffff, /* dst_mask */
2482 FALSE), /* pcrel_offset */
2484 /* TLS thread pointer offset. */
2485 HOWTO (R_MICROMIPS_TLS_GOTTPREL, /* type */
2487 2, /* size (0 = byte, 1 = short, 2 = long) */
2489 FALSE, /* pc_relative */
2491 complain_overflow_signed, /* complain_on_overflow */
2492 _bfd_mips_elf_generic_reloc, /* special_function */
2493 "R_MICROMIPS_TLS_GOTTPREL", /* name */
2494 TRUE, /* partial_inplace */
2495 0x0000ffff, /* src_mask */
2496 0x0000ffff, /* dst_mask */
2497 FALSE), /* pcrel_offset */
2502 /* TLS thread pointer offset. */
2503 HOWTO (R_MICROMIPS_TLS_TPREL_HI16, /* type */
2505 2, /* size (0 = byte, 1 = short, 2 = long) */
2507 FALSE, /* pc_relative */
2509 complain_overflow_signed, /* complain_on_overflow */
2510 _bfd_mips_elf_generic_reloc, /* special_function */
2511 "R_MICROMIPS_TLS_TPREL_HI16", /* name */
2512 TRUE, /* partial_inplace */
2513 0x0000ffff, /* src_mask */
2514 0x0000ffff, /* dst_mask */
2515 FALSE), /* pcrel_offset */
2517 /* TLS thread pointer offset. */
2518 HOWTO (R_MICROMIPS_TLS_TPREL_LO16, /* type */
2520 2, /* size (0 = byte, 1 = short, 2 = long) */
2522 FALSE, /* pc_relative */
2524 complain_overflow_signed, /* complain_on_overflow */
2525 _bfd_mips_elf_generic_reloc, /* special_function */
2526 "R_MICROMIPS_TLS_TPREL_LO16", /* name */
2527 TRUE, /* partial_inplace */
2528 0x0000ffff, /* src_mask */
2529 0x0000ffff, /* dst_mask */
2530 FALSE), /* pcrel_offset */
2534 /* GP- and PC-relative relocations. */
2535 HOWTO (R_MICROMIPS_GPREL7_S2, /* type */
2537 1, /* size (0 = byte, 1 = short, 2 = long) */
2539 FALSE, /* pc_relative */
2541 complain_overflow_signed, /* complain_on_overflow */
2542 _bfd_mips_elf32_gprel16_reloc, /* special_function */
2543 "R_MICROMIPS_GPREL7_S2", /* name */
2544 TRUE, /* partial_inplace */
2545 0x0000007f, /* src_mask */
2546 0x0000007f, /* dst_mask */
2547 FALSE), /* pcrel_offset */
2549 HOWTO (R_MICROMIPS_PC23_S2, /* type */
2551 2, /* size (0 = byte, 1 = short, 2 = long) */
2553 TRUE, /* pc_relative */
2555 complain_overflow_signed, /* complain_on_overflow */
2556 _bfd_mips_elf_generic_reloc, /* special_function */
2557 "R_MICROMIPS_PC23_S2", /* name */
2558 TRUE, /* partial_inplace */
2559 0x007fffff, /* src_mask */
2560 0x007fffff, /* dst_mask */
2561 TRUE), /* pcrel_offset */
2564 static reloc_howto_type elf_micromips_howto_table_rela[] =
2570 /* 26 bit jump address. */
2571 HOWTO (R_MICROMIPS_26_S1, /* type */
2573 2, /* size (0 = byte, 1 = short, 2 = long) */
2575 FALSE, /* pc_relative */
2577 complain_overflow_dont, /* complain_on_overflow */
2578 /* This needs complex overflow
2579 detection, because the upper four
2580 bits must match the PC. */
2581 _bfd_mips_elf_generic_reloc, /* special_function */
2582 "R_MICROMIPS_26_S1", /* name */
2583 FALSE, /* partial_inplace */
2585 0x3ffffff, /* dst_mask */
2586 FALSE), /* pcrel_offset */
2588 /* High 16 bits of symbol value. */
2589 HOWTO (R_MICROMIPS_HI16, /* type */
2590 16, /* rightshift */
2591 2, /* size (0 = byte, 1 = short, 2 = long) */
2593 FALSE, /* pc_relative */
2595 complain_overflow_dont, /* complain_on_overflow */
2596 _bfd_mips_elf_hi16_reloc, /* special_function */
2597 "R_MICROMIPS_HI16", /* name */
2598 FALSE, /* partial_inplace */
2600 0x0000ffff, /* dst_mask */
2601 FALSE), /* pcrel_offset */
2603 /* Low 16 bits of symbol value. */
2604 HOWTO (R_MICROMIPS_LO16, /* type */
2606 2, /* size (0 = byte, 1 = short, 2 = long) */
2608 FALSE, /* pc_relative */
2610 complain_overflow_dont, /* complain_on_overflow */
2611 _bfd_mips_elf_lo16_reloc, /* special_function */
2612 "R_MICROMIPS_LO16", /* name */
2613 FALSE, /* partial_inplace */
2615 0x0000ffff, /* dst_mask */
2616 FALSE), /* pcrel_offset */
2618 /* GP relative reference. */
2619 HOWTO (R_MICROMIPS_GPREL16, /* type */
2621 2, /* size (0 = byte, 1 = short, 2 = long) */
2623 FALSE, /* pc_relative */
2625 complain_overflow_signed, /* complain_on_overflow */
2626 _bfd_mips_elf32_gprel16_reloc, /* special_function */
2627 "R_MICROMIPS_GPREL16", /* name */
2628 FALSE, /* partial_inplace */
2630 0x0000ffff, /* dst_mask */
2631 FALSE), /* pcrel_offset */
2633 /* Reference to literal section. */
2634 HOWTO (R_MICROMIPS_LITERAL, /* type */
2636 2, /* size (0 = byte, 1 = short, 2 = long) */
2638 FALSE, /* pc_relative */
2640 complain_overflow_signed, /* complain_on_overflow */
2641 _bfd_mips_elf32_gprel16_reloc, /* special_function */
2642 "R_MICROMIPS_LITERAL", /* name */
2643 FALSE, /* partial_inplace */
2645 0x0000ffff, /* dst_mask */
2646 FALSE), /* pcrel_offset */
2648 /* Reference to global offset table. */
2649 HOWTO (R_MICROMIPS_GOT16, /* type */
2651 2, /* size (0 = byte, 1 = short, 2 = long) */
2653 FALSE, /* pc_relative */
2655 complain_overflow_signed, /* complain_on_overflow */
2656 _bfd_mips_elf_got16_reloc, /* special_function */
2657 "R_MICROMIPS_GOT16", /* name */
2658 FALSE, /* partial_inplace */
2660 0x0000ffff, /* dst_mask */
2661 FALSE), /* pcrel_offset */
2663 /* This is for microMIPS branches. */
2664 HOWTO (R_MICROMIPS_PC7_S1, /* type */
2666 1, /* size (0 = byte, 1 = short, 2 = long) */
2668 TRUE, /* pc_relative */
2670 complain_overflow_signed, /* complain_on_overflow */
2671 _bfd_mips_elf_generic_reloc, /* special_function */
2672 "R_MICROMIPS_PC7_S1", /* name */
2673 FALSE, /* partial_inplace */
2675 0x0000007f, /* dst_mask */
2676 TRUE), /* pcrel_offset */
2678 HOWTO (R_MICROMIPS_PC10_S1, /* type */
2680 1, /* size (0 = byte, 1 = short, 2 = long) */
2682 TRUE, /* pc_relative */
2684 complain_overflow_signed, /* complain_on_overflow */
2685 _bfd_mips_elf_generic_reloc, /* special_function */
2686 "R_MICROMIPS_PC10_S1", /* name */
2687 FALSE, /* partial_inplace */
2689 0x000003ff, /* dst_mask */
2690 TRUE), /* pcrel_offset */
2692 HOWTO (R_MICROMIPS_PC16_S1, /* type */
2694 2, /* size (0 = byte, 1 = short, 2 = long) */
2696 TRUE, /* pc_relative */
2698 complain_overflow_signed, /* complain_on_overflow */
2699 _bfd_mips_elf_generic_reloc, /* special_function */
2700 "R_MICROMIPS_PC16_S1", /* name */
2701 FALSE, /* partial_inplace */
2703 0x0000ffff, /* dst_mask */
2704 TRUE), /* pcrel_offset */
2706 /* 16 bit call through global offset table. */
2707 HOWTO (R_MICROMIPS_CALL16, /* type */
2709 2, /* size (0 = byte, 1 = short, 2 = long) */
2711 FALSE, /* pc_relative */
2713 complain_overflow_signed, /* complain_on_overflow */
2714 _bfd_mips_elf_generic_reloc, /* special_function */
2715 "R_MICROMIPS_CALL16", /* name */
2716 FALSE, /* partial_inplace */
2718 0x0000ffff, /* dst_mask */
2719 FALSE), /* pcrel_offset */
2724 /* Displacement in the global offset table. */
2725 HOWTO (R_MICROMIPS_GOT_DISP, /* type */
2727 2, /* size (0 = byte, 1 = short, 2 = long) */
2729 FALSE, /* pc_relative */
2731 complain_overflow_signed, /* complain_on_overflow */
2732 _bfd_mips_elf_generic_reloc, /* special_function */
2733 "R_MICROMIPS_GOT_DISP",/* name */
2734 FALSE, /* partial_inplace */
2736 0x0000ffff, /* dst_mask */
2737 FALSE), /* pcrel_offset */
2739 /* Displacement to page pointer in the global offset table. */
2740 HOWTO (R_MICROMIPS_GOT_PAGE, /* type */
2742 2, /* size (0 = byte, 1 = short, 2 = long) */
2744 FALSE, /* pc_relative */
2746 complain_overflow_signed, /* complain_on_overflow */
2747 _bfd_mips_elf_generic_reloc, /* special_function */
2748 "R_MICROMIPS_GOT_PAGE",/* name */
2749 FALSE, /* partial_inplace */
2751 0x0000ffff, /* dst_mask */
2752 FALSE), /* pcrel_offset */
2754 /* Offset from page pointer in the global offset table. */
2755 HOWTO (R_MICROMIPS_GOT_OFST, /* type */
2757 2, /* size (0 = byte, 1 = short, 2 = long) */
2759 FALSE, /* pc_relative */
2761 complain_overflow_signed, /* complain_on_overflow */
2762 _bfd_mips_elf_generic_reloc, /* special_function */
2763 "R_MICROMIPS_GOT_OFST",/* name */
2764 FALSE, /* partial_inplace */
2766 0x0000ffff, /* dst_mask */
2767 FALSE), /* pcrel_offset */
2769 /* High 16 bits of displacement in global offset table. */
2770 HOWTO (R_MICROMIPS_GOT_HI16, /* type */
2772 2, /* size (0 = byte, 1 = short, 2 = long) */
2774 FALSE, /* pc_relative */
2776 complain_overflow_dont, /* complain_on_overflow */
2777 _bfd_mips_elf_generic_reloc, /* special_function */
2778 "R_MICROMIPS_GOT_HI16",/* name */
2779 FALSE, /* partial_inplace */
2781 0x0000ffff, /* dst_mask */
2782 FALSE), /* pcrel_offset */
2784 /* Low 16 bits of displacement in global offset table. */
2785 HOWTO (R_MICROMIPS_GOT_LO16, /* type */
2787 2, /* size (0 = byte, 1 = short, 2 = long) */
2789 FALSE, /* pc_relative */
2791 complain_overflow_dont, /* complain_on_overflow */
2792 _bfd_mips_elf_generic_reloc, /* special_function */
2793 "R_MICROMIPS_GOT_LO16",/* name */
2794 FALSE, /* partial_inplace */
2796 0x0000ffff, /* dst_mask */
2797 FALSE), /* pcrel_offset */
2799 /* 64 bit subtraction. Used in the N32 ABI. */
2800 HOWTO (R_MICROMIPS_SUB, /* type */
2802 4, /* size (0 = byte, 1 = short, 2 = long) */
2804 FALSE, /* pc_relative */
2806 complain_overflow_dont, /* complain_on_overflow */
2807 _bfd_mips_elf_generic_reloc, /* special_function */
2808 "R_MICROMIPS_SUB", /* name */
2809 FALSE, /* partial_inplace */
2811 MINUS_ONE, /* dst_mask */
2812 FALSE), /* pcrel_offset */
2814 /* Get the higher value of a 64 bit addend. */
2815 HOWTO (R_MICROMIPS_HIGHER, /* type */
2817 2, /* size (0 = byte, 1 = short, 2 = long) */
2819 FALSE, /* pc_relative */
2821 complain_overflow_dont, /* complain_on_overflow */
2822 _bfd_mips_elf_generic_reloc, /* special_function */
2823 "R_MICROMIPS_HIGHER", /* name */
2824 FALSE, /* partial_inplace */
2826 0x0000ffff, /* dst_mask */
2827 FALSE), /* pcrel_offset */
2829 /* Get the highest value of a 64 bit addend. */
2830 HOWTO (R_MICROMIPS_HIGHEST, /* type */
2832 2, /* size (0 = byte, 1 = short, 2 = long) */
2834 FALSE, /* pc_relative */
2836 complain_overflow_dont, /* complain_on_overflow */
2837 _bfd_mips_elf_generic_reloc, /* special_function */
2838 "R_MICROMIPS_HIGHEST", /* name */
2839 FALSE, /* partial_inplace */
2841 0x0000ffff, /* dst_mask */
2842 FALSE), /* pcrel_offset */
2844 /* High 16 bits of displacement in global offset table. */
2845 HOWTO (R_MICROMIPS_CALL_HI16, /* type */
2847 2, /* size (0 = byte, 1 = short, 2 = long) */
2849 FALSE, /* pc_relative */
2851 complain_overflow_dont, /* complain_on_overflow */
2852 _bfd_mips_elf_generic_reloc, /* special_function */
2853 "R_MICROMIPS_CALL_HI16",/* name */
2854 FALSE, /* partial_inplace */
2856 0x0000ffff, /* dst_mask */
2857 FALSE), /* pcrel_offset */
2859 /* Low 16 bits of displacement in global offset table. */
2860 HOWTO (R_MICROMIPS_CALL_LO16, /* type */
2862 2, /* size (0 = byte, 1 = short, 2 = long) */
2864 FALSE, /* pc_relative */
2866 complain_overflow_dont, /* complain_on_overflow */
2867 _bfd_mips_elf_generic_reloc, /* special_function */
2868 "R_MICROMIPS_CALL_LO16",/* name */
2869 FALSE, /* partial_inplace */
2871 0x0000ffff, /* dst_mask */
2872 FALSE), /* pcrel_offset */
2874 /* Section displacement. */
2875 HOWTO (R_MICROMIPS_SCN_DISP, /* type */
2877 2, /* size (0 = byte, 1 = short, 2 = long) */
2879 FALSE, /* pc_relative */
2881 complain_overflow_dont, /* complain_on_overflow */
2882 _bfd_mips_elf_generic_reloc, /* special_function */
2883 "R_MICROMIPS_SCN_DISP", /* name */
2884 FALSE, /* partial_inplace */
2886 0xffffffff, /* dst_mask */
2887 FALSE), /* pcrel_offset */
2889 /* Protected jump conversion. This is an optimization hint. No
2890 relocation is required for correctness. */
2891 HOWTO (R_MICROMIPS_JALR, /* type */
2893 2, /* size (0 = byte, 1 = short, 2 = long) */
2895 FALSE, /* pc_relative */
2897 complain_overflow_dont, /* complain_on_overflow */
2898 _bfd_mips_elf_generic_reloc, /* special_function */
2899 "R_MICROMIPS_JALR", /* name */
2900 FALSE, /* partial_inplace */
2902 0x00000000, /* dst_mask */
2903 FALSE), /* pcrel_offset */
2905 /* Low 16 bits of symbol value. Note that the high 16 bits of symbol values
2906 must be zero. This is used for relaxation. */
2907 HOWTO (R_MICROMIPS_HI0_LO16, /* type */
2909 2, /* size (0 = byte, 1 = short, 2 = long) */
2911 FALSE, /* pc_relative */
2913 complain_overflow_dont, /* complain_on_overflow */
2914 _bfd_mips_elf_generic_reloc, /* special_function */
2915 "R_MICROMIPS_HI0_LO16",/* name */
2916 FALSE, /* partial_inplace */
2918 0x0000ffff, /* dst_mask */
2919 FALSE), /* pcrel_offset */
2926 /* TLS general dynamic variable reference. */
2927 HOWTO (R_MICROMIPS_TLS_GD, /* type */
2929 2, /* size (0 = byte, 1 = short, 2 = long) */
2931 FALSE, /* pc_relative */
2933 complain_overflow_signed, /* complain_on_overflow */
2934 _bfd_mips_elf_generic_reloc, /* special_function */
2935 "R_MICROMIPS_TLS_GD", /* name */
2936 FALSE, /* partial_inplace */
2938 0x0000ffff, /* dst_mask */
2939 FALSE), /* pcrel_offset */
2941 /* TLS local dynamic variable reference. */
2942 HOWTO (R_MICROMIPS_TLS_LDM, /* type */
2944 2, /* size (0 = byte, 1 = short, 2 = long) */
2946 FALSE, /* pc_relative */
2948 complain_overflow_signed, /* complain_on_overflow */
2949 _bfd_mips_elf_generic_reloc, /* special_function */
2950 "R_MICROMIPS_TLS_LDM", /* name */
2951 FALSE, /* partial_inplace */
2953 0x0000ffff, /* dst_mask */
2954 FALSE), /* pcrel_offset */
2956 /* TLS local dynamic offset. */
2957 HOWTO (R_MICROMIPS_TLS_DTPREL_HI16, /* type */
2959 2, /* size (0 = byte, 1 = short, 2 = long) */
2961 FALSE, /* pc_relative */
2963 complain_overflow_signed, /* complain_on_overflow */
2964 _bfd_mips_elf_generic_reloc, /* special_function */
2965 "R_MICROMIPS_TLS_DTPREL_HI16", /* name */
2966 FALSE, /* partial_inplace */
2968 0x0000ffff, /* dst_mask */
2969 FALSE), /* pcrel_offset */
2971 /* TLS local dynamic offset. */
2972 HOWTO (R_MICROMIPS_TLS_DTPREL_LO16, /* type */
2974 2, /* size (0 = byte, 1 = short, 2 = long) */
2976 FALSE, /* pc_relative */
2978 complain_overflow_signed, /* complain_on_overflow */
2979 _bfd_mips_elf_generic_reloc, /* special_function */
2980 "R_MICROMIPS_TLS_DTPREL_LO16", /* name */
2981 FALSE, /* partial_inplace */
2983 0x0000ffff, /* dst_mask */
2984 FALSE), /* pcrel_offset */
2986 /* TLS thread pointer offset. */
2987 HOWTO (R_MICROMIPS_TLS_GOTTPREL, /* type */
2989 2, /* size (0 = byte, 1 = short, 2 = long) */
2991 FALSE, /* pc_relative */
2993 complain_overflow_signed, /* complain_on_overflow */
2994 _bfd_mips_elf_generic_reloc, /* special_function */
2995 "R_MICROMIPS_TLS_GOTTPREL", /* name */
2996 FALSE, /* partial_inplace */
2998 0x0000ffff, /* dst_mask */
2999 FALSE), /* pcrel_offset */
3004 /* TLS thread pointer offset. */
3005 HOWTO (R_MICROMIPS_TLS_TPREL_HI16, /* type */
3007 2, /* size (0 = byte, 1 = short, 2 = long) */
3009 FALSE, /* pc_relative */
3011 complain_overflow_signed, /* complain_on_overflow */
3012 _bfd_mips_elf_generic_reloc, /* special_function */
3013 "R_MICROMIPS_TLS_TPREL_HI16", /* name */
3014 FALSE, /* partial_inplace */
3016 0x0000ffff, /* dst_mask */
3017 FALSE), /* pcrel_offset */
3019 /* TLS thread pointer offset. */
3020 HOWTO (R_MICROMIPS_TLS_TPREL_LO16, /* type */
3022 2, /* size (0 = byte, 1 = short, 2 = long) */
3024 FALSE, /* pc_relative */
3026 complain_overflow_signed, /* complain_on_overflow */
3027 _bfd_mips_elf_generic_reloc, /* special_function */
3028 "R_MICROMIPS_TLS_TPREL_LO16", /* name */
3029 FALSE, /* partial_inplace */
3031 0x0000ffff, /* dst_mask */
3032 FALSE), /* pcrel_offset */
3036 /* GP- and PC-relative relocations. */
3037 HOWTO (R_MICROMIPS_GPREL7_S2, /* type */
3039 1, /* size (0 = byte, 1 = short, 2 = long) */
3041 FALSE, /* pc_relative */
3043 complain_overflow_signed, /* complain_on_overflow */
3044 _bfd_mips_elf32_gprel16_reloc, /* special_function */
3045 "R_MICROMIPS_GPREL7_S2", /* name */
3046 FALSE, /* partial_inplace */
3048 0x0000007f, /* dst_mask */
3049 FALSE), /* pcrel_offset */
3051 HOWTO (R_MICROMIPS_PC23_S2, /* type */
3053 2, /* size (0 = byte, 1 = short, 2 = long) */
3055 TRUE, /* pc_relative */
3057 complain_overflow_signed, /* complain_on_overflow */
3058 _bfd_mips_elf_generic_reloc, /* special_function */
3059 "R_MICROMIPS_PC23_S2", /* name */
3060 FALSE, /* partial_inplace */
3062 0x007fffff, /* dst_mask */
3063 TRUE), /* pcrel_offset */
3066 /* GNU extension to record C++ vtable hierarchy */
3067 static reloc_howto_type elf_mips_gnu_vtinherit_howto =
3068 HOWTO (R_MIPS_GNU_VTINHERIT, /* type */
3070 2, /* size (0 = byte, 1 = short, 2 = long) */
3072 FALSE, /* pc_relative */
3074 complain_overflow_dont, /* complain_on_overflow */
3075 NULL, /* special_function */
3076 "R_MIPS_GNU_VTINHERIT", /* name */
3077 FALSE, /* partial_inplace */
3080 FALSE); /* pcrel_offset */
3082 /* GNU extension to record C++ vtable member usage */
3083 static reloc_howto_type elf_mips_gnu_vtentry_howto =
3084 HOWTO (R_MIPS_GNU_VTENTRY, /* type */
3086 2, /* size (0 = byte, 1 = short, 2 = long) */
3088 FALSE, /* pc_relative */
3090 complain_overflow_dont, /* complain_on_overflow */
3091 _bfd_elf_rel_vtable_reloc_fn, /* special_function */
3092 "R_MIPS_GNU_VTENTRY", /* name */
3093 FALSE, /* partial_inplace */
3096 FALSE); /* pcrel_offset */
3098 /* 16 bit offset for pc-relative branches. */
3099 static reloc_howto_type elf_mips_gnu_rel16_s2 =
3100 HOWTO (R_MIPS_GNU_REL16_S2, /* type */
3102 2, /* size (0 = byte, 1 = short, 2 = long) */
3104 TRUE, /* pc_relative */
3106 complain_overflow_signed, /* complain_on_overflow */
3107 _bfd_mips_elf_generic_reloc, /* special_function */
3108 "R_MIPS_GNU_REL16_S2", /* name */
3109 TRUE, /* partial_inplace */
3110 0x0000ffff, /* src_mask */
3111 0x0000ffff, /* dst_mask */
3112 TRUE); /* pcrel_offset */
3114 /* 16 bit offset for pc-relative branches. */
3115 static reloc_howto_type elf_mips_gnu_rela16_s2 =
3116 HOWTO (R_MIPS_GNU_REL16_S2, /* type */
3118 2, /* size (0 = byte, 1 = short, 2 = long) */
3120 TRUE, /* pc_relative */
3122 complain_overflow_signed, /* complain_on_overflow */
3123 _bfd_mips_elf_generic_reloc, /* special_function */
3124 "R_MIPS_GNU_REL16_S2", /* name */
3125 FALSE, /* partial_inplace */
3127 0x0000ffff, /* dst_mask */
3128 TRUE); /* pcrel_offset */
3130 /* 32 bit pc-relative. Used for compact EH tables. */
3131 static reloc_howto_type elf_mips_gnu_pcrel32 =
3132 HOWTO (R_MIPS_PC32, /* type */
3134 2, /* size (0 = byte, 1 = short, 2 = long) */
3136 TRUE, /* pc_relative */
3138 complain_overflow_signed, /* complain_on_overflow */
3139 _bfd_mips_elf_generic_reloc, /* special_function */
3140 "R_MIPS_PC32", /* name */
3141 TRUE, /* partial_inplace */
3142 0xffffffff, /* src_mask */
3143 0xffffffff, /* dst_mask */
3144 TRUE); /* pcrel_offset */
3147 /* Originally a VxWorks extension, but now used for other systems too. */
3148 static reloc_howto_type elf_mips_copy_howto =
3149 HOWTO (R_MIPS_COPY, /* type */
3151 0, /* this one is variable size */
3153 FALSE, /* pc_relative */
3155 complain_overflow_bitfield, /* complain_on_overflow */
3156 _bfd_mips_elf_generic_reloc, /* special_function */
3157 "R_MIPS_COPY", /* name */
3158 FALSE, /* partial_inplace */
3161 FALSE); /* pcrel_offset */
3163 /* Originally a VxWorks extension, but now used for other systems too. */
3164 static reloc_howto_type elf_mips_jump_slot_howto =
3165 HOWTO (R_MIPS_JUMP_SLOT, /* type */
3167 2, /* size (0 = byte, 1 = short, 2 = long) */
3169 FALSE, /* pc_relative */
3171 complain_overflow_bitfield, /* complain_on_overflow */
3172 _bfd_mips_elf_generic_reloc, /* special_function */
3173 "R_MIPS_JUMP_SLOT", /* name */
3174 FALSE, /* partial_inplace */
3177 FALSE); /* pcrel_offset */
3179 /* Used in EH tables. */
3180 static reloc_howto_type elf_mips_eh_howto =
3181 HOWTO (R_MIPS_EH, /* type */
3183 2, /* size (0 = byte, 1 = short, 2 = long) */
3185 FALSE, /* pc_relative */
3187 complain_overflow_signed, /* complain_on_overflow */
3188 _bfd_mips_elf_generic_reloc, /* special_function */
3189 "R_MIPS_EH", /* name */
3190 TRUE, /* partial_inplace */
3191 0xffffffff, /* src_mask */
3192 0xffffffff, /* dst_mask */
3193 FALSE); /* pcrel_offset */
3196 /* Set the GP value for OUTPUT_BFD. Returns FALSE if this is a
3197 dangerous relocation. */
3200 mips_elf_assign_gp (bfd *output_bfd, bfd_vma *pgp)
3206 /* If we've already figured out what GP will be, just return it. */
3207 *pgp = _bfd_get_gp_value (output_bfd);
3211 count = bfd_get_symcount (output_bfd);
3212 sym = bfd_get_outsymbols (output_bfd);
3214 /* The linker script will have created a symbol named `_gp' with the
3215 appropriate value. */
3220 for (i = 0; i < count; i++, sym++)
3222 register const char *name;
3224 name = bfd_asymbol_name (*sym);
3225 if (*name == '_' && strcmp (name, "_gp") == 0)
3227 *pgp = bfd_asymbol_value (*sym);
3228 _bfd_set_gp_value (output_bfd, *pgp);
3236 /* Only get the error once. */
3238 _bfd_set_gp_value (output_bfd, *pgp);
3245 /* We have to figure out the gp value, so that we can adjust the
3246 symbol value correctly. We look up the symbol _gp in the output
3247 BFD. If we can't find it, we're stuck. We cache it in the ELF
3248 target data. We don't need to adjust the symbol value for an
3249 external symbol if we are producing relocatable output. */
3251 static bfd_reloc_status_type
3252 mips_elf_final_gp (bfd *output_bfd, asymbol *symbol, bfd_boolean relocatable,
3253 char **error_message, bfd_vma *pgp)
3255 if (bfd_is_und_section (symbol->section)
3259 return bfd_reloc_undefined;
3262 *pgp = _bfd_get_gp_value (output_bfd);
3265 || (symbol->flags & BSF_SECTION_SYM) != 0))
3269 /* Make up a value. */
3270 *pgp = symbol->section->output_section->vma /*+ 0x4000*/;
3271 _bfd_set_gp_value (output_bfd, *pgp);
3273 else if (!mips_elf_assign_gp (output_bfd, pgp))
3276 (char *) _("GP relative relocation when _gp not defined");
3277 return bfd_reloc_dangerous;
3281 return bfd_reloc_ok;
3284 /* Do a R_MIPS_GPREL16 relocation. This is a 16 bit value which must
3285 become the offset from the gp register. */
3287 static bfd_reloc_status_type
3288 mips_elf_gprel16_reloc (bfd *abfd ATTRIBUTE_UNUSED, arelent *reloc_entry,
3289 asymbol *symbol, void *data ATTRIBUTE_UNUSED,
3290 asection *input_section, bfd *output_bfd,
3291 char **error_message ATTRIBUTE_UNUSED)
3293 bfd_boolean relocatable;
3294 bfd_reloc_status_type ret;
3297 if (output_bfd != NULL)
3301 relocatable = FALSE;
3302 output_bfd = symbol->section->output_section->owner;
3305 ret = mips_elf_final_gp (output_bfd, symbol, relocatable, error_message,
3307 if (ret != bfd_reloc_ok)
3310 return _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
3311 input_section, relocatable,
3315 /* Do a R_MIPS_LITERAL relocation. */
3317 static bfd_reloc_status_type
3318 mips_elf_literal_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
3319 void *data, asection *input_section, bfd *output_bfd,
3320 char **error_message)
3322 bfd_boolean relocatable;
3323 bfd_reloc_status_type ret;
3326 /* R_MIPS_LITERAL relocations are defined for local symbols only. */
3327 if (output_bfd != NULL
3328 && (symbol->flags & BSF_SECTION_SYM) == 0
3329 && (symbol->flags & BSF_LOCAL) != 0)
3331 *error_message = (char *)
3332 _("literal relocation occurs for an external symbol");
3333 return bfd_reloc_outofrange;
3336 /* FIXME: The entries in the .lit8 and .lit4 sections should be merged. */
3337 if (output_bfd != NULL)
3341 relocatable = FALSE;
3342 output_bfd = symbol->section->output_section->owner;
3345 ret = mips_elf_final_gp (output_bfd, symbol, relocatable, error_message,
3347 if (ret != bfd_reloc_ok)
3350 return _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
3351 input_section, relocatable,
3355 /* Do a R_MIPS_GPREL32 relocation. This is a 32 bit value which must
3356 become the offset from the gp register. */
3358 static bfd_reloc_status_type
3359 mips_elf_gprel32_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
3360 void *data, asection *input_section, bfd *output_bfd,
3361 char **error_message)
3363 bfd_boolean relocatable;
3364 bfd_reloc_status_type ret;
3367 /* R_MIPS_GPREL32 relocations are defined for local symbols only. */
3368 if (output_bfd != NULL
3369 && (symbol->flags & BSF_SECTION_SYM) == 0
3370 && (symbol->flags & BSF_LOCAL) != 0)
3372 *error_message = (char *)
3373 _("32bits gp relative relocation occurs for an external symbol");
3374 return bfd_reloc_outofrange;
3377 if (output_bfd != NULL)
3380 gp = _bfd_get_gp_value (output_bfd);
3384 relocatable = FALSE;
3385 output_bfd = symbol->section->output_section->owner;
3387 ret = mips_elf_final_gp (output_bfd, symbol, relocatable,
3388 error_message, &gp);
3389 if (ret != bfd_reloc_ok)
3393 return gprel32_with_gp (abfd, symbol, reloc_entry, input_section,
3394 relocatable, data, gp);
3397 static bfd_reloc_status_type
3398 gprel32_with_gp (bfd *abfd, asymbol *symbol, arelent *reloc_entry,
3399 asection *input_section, bfd_boolean relocatable,
3400 void *data, bfd_vma gp)
3405 if (bfd_is_com_section (symbol->section))
3408 relocation = symbol->value;
3410 relocation += symbol->section->output_section->vma;
3411 relocation += symbol->section->output_offset;
3413 if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
3414 return bfd_reloc_outofrange;
3416 if (reloc_entry->howto->src_mask == 0)
3419 val = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
3421 /* Set val to the offset into the section or symbol. */
3422 val += reloc_entry->addend;
3424 /* Adjust val for the final section location and GP value. If we
3425 are producing relocatable output, we don't want to do this for
3426 an external symbol. */
3428 || (symbol->flags & BSF_SECTION_SYM) != 0)
3429 val += relocation - gp;
3431 bfd_put_32 (abfd, val, (bfd_byte *) data + reloc_entry->address);
3434 reloc_entry->address += input_section->output_offset;
3436 return bfd_reloc_ok;
3439 /* Do a R_MIPS_SHIFT6 relocation. The MSB of the shift is stored at bit 2,
3440 the rest is at bits 6-10. The bitpos already got right by the howto. */
3442 static bfd_reloc_status_type
3443 mips_elf_shift6_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
3444 void *data, asection *input_section, bfd *output_bfd,
3445 char **error_message)
3447 if (reloc_entry->howto->partial_inplace)
3449 reloc_entry->addend = ((reloc_entry->addend & 0x00007c0)
3450 | (reloc_entry->addend & 0x00000800) >> 9);
3453 return _bfd_mips_elf_generic_reloc (abfd, reloc_entry, symbol, data,
3454 input_section, output_bfd,
3458 /* Handle a mips16 GP relative reloc. */
3460 static bfd_reloc_status_type
3461 mips16_gprel_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
3462 void *data, asection *input_section, bfd *output_bfd,
3463 char **error_message)
3465 bfd_boolean relocatable;
3466 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 = symbol->section->output_section->owner;
3488 ret = mips_elf_final_gp (output_bfd, symbol, relocatable, error_message,
3490 if (ret != bfd_reloc_ok)
3493 location = (bfd_byte *) data + reloc_entry->address;
3494 _bfd_mips_elf_reloc_unshuffle (abfd, reloc_entry->howto->type, FALSE,
3496 ret = _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
3497 input_section, relocatable,
3499 _bfd_mips_elf_reloc_shuffle (abfd, reloc_entry->howto->type, !relocatable,
3505 /* A mapping from BFD reloc types to MIPS ELF reloc types. */
3507 struct elf_reloc_map {
3508 bfd_reloc_code_real_type bfd_val;
3509 enum elf_mips_reloc_type elf_val;
3512 static const struct elf_reloc_map mips_reloc_map[] =
3514 { BFD_RELOC_NONE, R_MIPS_NONE },
3515 { BFD_RELOC_16, R_MIPS_16 },
3516 { BFD_RELOC_32, R_MIPS_32 },
3517 /* There is no BFD reloc for R_MIPS_REL32. */
3518 { BFD_RELOC_CTOR, R_MIPS_32 },
3519 { BFD_RELOC_64, R_MIPS_64 },
3520 { BFD_RELOC_16_PCREL_S2, R_MIPS_PC16 },
3521 { BFD_RELOC_HI16_S, R_MIPS_HI16 },
3522 { BFD_RELOC_LO16, R_MIPS_LO16 },
3523 { BFD_RELOC_GPREL16, R_MIPS_GPREL16 },
3524 { BFD_RELOC_GPREL32, R_MIPS_GPREL32 },
3525 { BFD_RELOC_MIPS_JMP, R_MIPS_26 },
3526 { BFD_RELOC_MIPS_LITERAL, R_MIPS_LITERAL },
3527 { BFD_RELOC_MIPS_GOT16, R_MIPS_GOT16 },
3528 { BFD_RELOC_MIPS_CALL16, R_MIPS_CALL16 },
3529 { BFD_RELOC_MIPS_SHIFT5, R_MIPS_SHIFT5 },
3530 { BFD_RELOC_MIPS_SHIFT6, R_MIPS_SHIFT6 },
3531 { BFD_RELOC_MIPS_GOT_DISP, R_MIPS_GOT_DISP },
3532 { BFD_RELOC_MIPS_GOT_PAGE, R_MIPS_GOT_PAGE },
3533 { BFD_RELOC_MIPS_GOT_OFST, R_MIPS_GOT_OFST },
3534 { BFD_RELOC_MIPS_GOT_HI16, R_MIPS_GOT_HI16 },
3535 { BFD_RELOC_MIPS_GOT_LO16, R_MIPS_GOT_LO16 },
3536 { BFD_RELOC_MIPS_SUB, R_MIPS_SUB },
3537 { BFD_RELOC_MIPS_INSERT_A, R_MIPS_INSERT_A },
3538 { BFD_RELOC_MIPS_INSERT_B, R_MIPS_INSERT_B },
3539 { BFD_RELOC_MIPS_DELETE, R_MIPS_DELETE },
3540 { BFD_RELOC_MIPS_HIGHEST, R_MIPS_HIGHEST },
3541 { BFD_RELOC_MIPS_HIGHER, R_MIPS_HIGHER },
3542 { BFD_RELOC_MIPS_CALL_HI16, R_MIPS_CALL_HI16 },
3543 { BFD_RELOC_MIPS_CALL_LO16, R_MIPS_CALL_LO16 },
3544 { BFD_RELOC_MIPS_SCN_DISP, R_MIPS_SCN_DISP },
3545 { BFD_RELOC_MIPS_REL16, R_MIPS_REL16 },
3546 /* Use of R_MIPS_ADD_IMMEDIATE and R_MIPS_PJUMP is deprecated. */
3547 { BFD_RELOC_MIPS_RELGOT, R_MIPS_RELGOT },
3548 { BFD_RELOC_MIPS_JALR, R_MIPS_JALR },
3549 { BFD_RELOC_MIPS_TLS_DTPMOD32, R_MIPS_TLS_DTPMOD32 },
3550 { BFD_RELOC_MIPS_TLS_DTPREL32, R_MIPS_TLS_DTPREL32 },
3551 { BFD_RELOC_MIPS_TLS_DTPMOD64, R_MIPS_TLS_DTPMOD64 },
3552 { BFD_RELOC_MIPS_TLS_DTPREL64, R_MIPS_TLS_DTPREL64 },
3553 { BFD_RELOC_MIPS_TLS_GD, R_MIPS_TLS_GD },
3554 { BFD_RELOC_MIPS_TLS_LDM, R_MIPS_TLS_LDM },
3555 { BFD_RELOC_MIPS_TLS_DTPREL_HI16, R_MIPS_TLS_DTPREL_HI16 },
3556 { BFD_RELOC_MIPS_TLS_DTPREL_LO16, R_MIPS_TLS_DTPREL_LO16 },
3557 { BFD_RELOC_MIPS_TLS_GOTTPREL, R_MIPS_TLS_GOTTPREL },
3558 { BFD_RELOC_MIPS_TLS_TPREL32, R_MIPS_TLS_TPREL32 },
3559 { BFD_RELOC_MIPS_TLS_TPREL64, R_MIPS_TLS_TPREL64 },
3560 { BFD_RELOC_MIPS_TLS_TPREL_HI16, R_MIPS_TLS_TPREL_HI16 },
3561 { BFD_RELOC_MIPS_TLS_TPREL_LO16, R_MIPS_TLS_TPREL_LO16 },
3562 { BFD_RELOC_MIPS_21_PCREL_S2, R_MIPS_PC21_S2 },
3563 { BFD_RELOC_MIPS_26_PCREL_S2, R_MIPS_PC26_S2 },
3564 { BFD_RELOC_MIPS_18_PCREL_S3, R_MIPS_PC18_S3 },
3565 { BFD_RELOC_MIPS_19_PCREL_S2, R_MIPS_PC19_S2 },
3566 { BFD_RELOC_HI16_S_PCREL, R_MIPS_PCHI16 },
3567 { BFD_RELOC_LO16_PCREL, R_MIPS_PCLO16 }
3570 static const struct elf_reloc_map mips16_reloc_map[] =
3572 { BFD_RELOC_MIPS16_JMP, R_MIPS16_26 - R_MIPS16_min },
3573 { BFD_RELOC_MIPS16_GPREL, R_MIPS16_GPREL - R_MIPS16_min },
3574 { BFD_RELOC_MIPS16_GOT16, R_MIPS16_GOT16 - R_MIPS16_min },
3575 { BFD_RELOC_MIPS16_CALL16, R_MIPS16_CALL16 - R_MIPS16_min },
3576 { BFD_RELOC_MIPS16_HI16_S, R_MIPS16_HI16 - R_MIPS16_min },
3577 { BFD_RELOC_MIPS16_LO16, R_MIPS16_LO16 - R_MIPS16_min },
3578 { BFD_RELOC_MIPS16_TLS_GD, R_MIPS16_TLS_GD - R_MIPS16_min },
3579 { BFD_RELOC_MIPS16_TLS_LDM, R_MIPS16_TLS_LDM - R_MIPS16_min },
3580 { BFD_RELOC_MIPS16_TLS_DTPREL_HI16,
3581 R_MIPS16_TLS_DTPREL_HI16 - R_MIPS16_min },
3582 { BFD_RELOC_MIPS16_TLS_DTPREL_LO16,
3583 R_MIPS16_TLS_DTPREL_LO16 - R_MIPS16_min },
3584 { BFD_RELOC_MIPS16_TLS_GOTTPREL, R_MIPS16_TLS_GOTTPREL - R_MIPS16_min },
3585 { BFD_RELOC_MIPS16_TLS_TPREL_HI16, R_MIPS16_TLS_TPREL_HI16 - R_MIPS16_min },
3586 { BFD_RELOC_MIPS16_TLS_TPREL_LO16, R_MIPS16_TLS_TPREL_LO16 - R_MIPS16_min },
3587 { BFD_RELOC_MIPS16_16_PCREL_S1, R_MIPS16_PC16_S1 - R_MIPS16_min }
3590 static const struct elf_reloc_map micromips_reloc_map[] =
3592 { BFD_RELOC_MICROMIPS_JMP, R_MICROMIPS_26_S1 - R_MICROMIPS_min },
3593 { BFD_RELOC_MICROMIPS_HI16_S, R_MICROMIPS_HI16 - R_MICROMIPS_min },
3594 { BFD_RELOC_MICROMIPS_LO16, R_MICROMIPS_LO16 - R_MICROMIPS_min },
3595 { BFD_RELOC_MICROMIPS_GPREL16, R_MICROMIPS_GPREL16 - R_MICROMIPS_min },
3596 { BFD_RELOC_MICROMIPS_LITERAL, R_MICROMIPS_LITERAL - R_MICROMIPS_min },
3597 { BFD_RELOC_MICROMIPS_GOT16, R_MICROMIPS_GOT16 - R_MICROMIPS_min },
3598 { BFD_RELOC_MICROMIPS_7_PCREL_S1, R_MICROMIPS_PC7_S1 - R_MICROMIPS_min },
3599 { BFD_RELOC_MICROMIPS_10_PCREL_S1, R_MICROMIPS_PC10_S1 - R_MICROMIPS_min },
3600 { BFD_RELOC_MICROMIPS_16_PCREL_S1, R_MICROMIPS_PC16_S1 - R_MICROMIPS_min },
3601 { BFD_RELOC_MICROMIPS_CALL16, R_MICROMIPS_CALL16 - R_MICROMIPS_min },
3602 { BFD_RELOC_MICROMIPS_GOT_DISP, R_MICROMIPS_GOT_DISP - R_MICROMIPS_min },
3603 { BFD_RELOC_MICROMIPS_GOT_PAGE, R_MICROMIPS_GOT_PAGE - R_MICROMIPS_min },
3604 { BFD_RELOC_MICROMIPS_GOT_OFST, R_MICROMIPS_GOT_OFST - R_MICROMIPS_min },
3605 { BFD_RELOC_MICROMIPS_GOT_HI16, R_MICROMIPS_GOT_HI16 - R_MICROMIPS_min },
3606 { BFD_RELOC_MICROMIPS_GOT_LO16, R_MICROMIPS_GOT_LO16 - R_MICROMIPS_min },
3607 { BFD_RELOC_MICROMIPS_SUB, R_MICROMIPS_SUB - R_MICROMIPS_min },
3608 { BFD_RELOC_MICROMIPS_HIGHER, R_MICROMIPS_HIGHER - R_MICROMIPS_min },
3609 { BFD_RELOC_MICROMIPS_HIGHEST, R_MICROMIPS_HIGHEST - R_MICROMIPS_min },
3610 { BFD_RELOC_MICROMIPS_CALL_HI16, R_MICROMIPS_CALL_HI16 - R_MICROMIPS_min },
3611 { BFD_RELOC_MICROMIPS_CALL_LO16, R_MICROMIPS_CALL_LO16 - R_MICROMIPS_min },
3612 { BFD_RELOC_MICROMIPS_SCN_DISP, R_MICROMIPS_SCN_DISP - R_MICROMIPS_min },
3613 { BFD_RELOC_MICROMIPS_JALR, R_MICROMIPS_JALR - R_MICROMIPS_min },
3614 /* There is no BFD reloc for R_MICROMIPS_HI0_LO16. */
3615 { BFD_RELOC_MICROMIPS_TLS_GD, R_MICROMIPS_TLS_GD - R_MICROMIPS_min },
3616 { BFD_RELOC_MICROMIPS_TLS_LDM, R_MICROMIPS_TLS_LDM - R_MICROMIPS_min },
3617 { BFD_RELOC_MICROMIPS_TLS_DTPREL_HI16,
3618 R_MICROMIPS_TLS_DTPREL_HI16 - R_MICROMIPS_min },
3619 { BFD_RELOC_MICROMIPS_TLS_DTPREL_LO16,
3620 R_MICROMIPS_TLS_DTPREL_LO16 - R_MICROMIPS_min },
3621 { BFD_RELOC_MICROMIPS_TLS_GOTTPREL,
3622 R_MICROMIPS_TLS_GOTTPREL - R_MICROMIPS_min },
3623 { BFD_RELOC_MICROMIPS_TLS_TPREL_HI16,
3624 R_MICROMIPS_TLS_TPREL_HI16 - R_MICROMIPS_min },
3625 { BFD_RELOC_MICROMIPS_TLS_TPREL_LO16,
3626 R_MICROMIPS_TLS_TPREL_LO16 - R_MICROMIPS_min },
3627 /* There is no BFD reloc for R_MICROMIPS_GPREL7_S2. */
3628 /* There is no BFD reloc for R_MICROMIPS_PC23_S2. */
3631 /* Given a BFD reloc type, return a howto structure. */
3633 static reloc_howto_type *
3634 bfd_elf32_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
3635 bfd_reloc_code_real_type code)
3638 /* FIXME: We default to RELA here instead of choosing the right
3639 relocation variant. */
3640 reloc_howto_type *howto_table = elf_mips_howto_table_rela;
3641 reloc_howto_type *howto16_table = elf_mips16_howto_table_rela;
3642 reloc_howto_type *howto_micromips_table = elf_micromips_howto_table_rela;
3644 for (i = 0; i < sizeof (mips_reloc_map) / sizeof (struct elf_reloc_map);
3647 if (mips_reloc_map[i].bfd_val == code)
3648 return &howto_table[(int) mips_reloc_map[i].elf_val];
3651 for (i = 0; i < sizeof (mips16_reloc_map) / sizeof (struct elf_reloc_map);
3654 if (mips16_reloc_map[i].bfd_val == code)
3655 return &howto16_table[(int) mips16_reloc_map[i].elf_val];
3658 for (i = 0; i < sizeof (micromips_reloc_map) / sizeof (struct elf_reloc_map);
3661 if (micromips_reloc_map[i].bfd_val == code)
3662 return &howto_micromips_table[(int) micromips_reloc_map[i].elf_val];
3667 case BFD_RELOC_VTABLE_INHERIT:
3668 return &elf_mips_gnu_vtinherit_howto;
3669 case BFD_RELOC_VTABLE_ENTRY:
3670 return &elf_mips_gnu_vtentry_howto;
3671 case BFD_RELOC_32_PCREL:
3672 return &elf_mips_gnu_pcrel32;
3673 case BFD_RELOC_MIPS_EH:
3674 return &elf_mips_eh_howto;
3675 case BFD_RELOC_MIPS_COPY:
3676 return &elf_mips_copy_howto;
3677 case BFD_RELOC_MIPS_JUMP_SLOT:
3678 return &elf_mips_jump_slot_howto;
3680 bfd_set_error (bfd_error_bad_value);
3685 static reloc_howto_type *
3686 bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
3692 i < (sizeof (elf_mips_howto_table_rela)
3693 / sizeof (elf_mips_howto_table_rela[0]));
3695 if (elf_mips_howto_table_rela[i].name != NULL
3696 && strcasecmp (elf_mips_howto_table_rela[i].name, r_name) == 0)
3697 return &elf_mips_howto_table_rela[i];
3700 i < (sizeof (elf_mips16_howto_table_rela)
3701 / sizeof (elf_mips16_howto_table_rela[0]));
3703 if (elf_mips16_howto_table_rela[i].name != NULL
3704 && strcasecmp (elf_mips16_howto_table_rela[i].name, r_name) == 0)
3705 return &elf_mips16_howto_table_rela[i];
3708 i < (sizeof (elf_micromips_howto_table_rela)
3709 / sizeof (elf_micromips_howto_table_rela[0]));
3711 if (elf_micromips_howto_table_rela[i].name != NULL
3712 && strcasecmp (elf_micromips_howto_table_rela[i].name, r_name) == 0)
3713 return &elf_micromips_howto_table_rela[i];
3715 if (strcasecmp (elf_mips_gnu_vtinherit_howto.name, r_name) == 0)
3716 return &elf_mips_gnu_vtinherit_howto;
3717 if (strcasecmp (elf_mips_gnu_vtentry_howto.name, r_name) == 0)
3718 return &elf_mips_gnu_vtentry_howto;
3719 if (strcasecmp (elf_mips_gnu_rel16_s2.name, r_name) == 0)
3720 return &elf_mips_gnu_rel16_s2;
3721 if (strcasecmp (elf_mips_gnu_rela16_s2.name, r_name) == 0)
3722 return &elf_mips_gnu_rela16_s2;
3723 if (strcasecmp (elf_mips_gnu_pcrel32.name, r_name) == 0)
3724 return &elf_mips_gnu_pcrel32;
3725 if (strcasecmp (elf_mips_eh_howto.name, r_name) == 0)
3726 return &elf_mips_eh_howto;
3727 if (strcasecmp (elf_mips_copy_howto.name, r_name) == 0)
3728 return &elf_mips_copy_howto;
3729 if (strcasecmp (elf_mips_jump_slot_howto.name, r_name) == 0)
3730 return &elf_mips_jump_slot_howto;
3735 /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure. */
3737 static reloc_howto_type *
3738 mips_elf_n32_rtype_to_howto (bfd *abfd, unsigned int r_type, bfd_boolean rela_p)
3740 reloc_howto_type *howto = NULL;
3744 case R_MIPS_GNU_VTINHERIT:
3745 return &elf_mips_gnu_vtinherit_howto;
3746 case R_MIPS_GNU_VTENTRY:
3747 return &elf_mips_gnu_vtentry_howto;
3748 case R_MIPS_GNU_REL16_S2:
3750 return &elf_mips_gnu_rela16_s2;
3752 return &elf_mips_gnu_rel16_s2;
3754 return &elf_mips_gnu_pcrel32;
3756 return &elf_mips_eh_howto;
3758 return &elf_mips_copy_howto;
3759 case R_MIPS_JUMP_SLOT:
3760 return &elf_mips_jump_slot_howto;
3762 if (r_type >= R_MICROMIPS_min && r_type < R_MICROMIPS_max)
3765 howto = &elf_micromips_howto_table_rela[r_type - R_MICROMIPS_min];
3767 howto = &elf_micromips_howto_table_rel[r_type - R_MICROMIPS_min];
3769 if (r_type >= R_MIPS16_min && r_type < R_MIPS16_max)
3772 howto = &elf_mips16_howto_table_rela[r_type - R_MIPS16_min];
3774 howto = &elf_mips16_howto_table_rel[r_type - R_MIPS16_min];
3776 if (r_type < R_MIPS_max)
3779 howto = &elf_mips_howto_table_rela[r_type];
3781 howto = &elf_mips_howto_table_rel[r_type];
3783 if (howto != NULL && howto->name != NULL)
3786 _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
3788 bfd_set_error (bfd_error_bad_value);
3793 /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure. */
3796 mips_info_to_howto_rel (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst)
3798 unsigned int r_type;
3800 r_type = ELF32_R_TYPE (dst->r_info);
3801 cache_ptr->howto = mips_elf_n32_rtype_to_howto (abfd, r_type, FALSE);
3803 if (cache_ptr->howto == NULL)
3806 /* The addend for a GPREL16 or LITERAL relocation comes from the GP
3807 value for the object file. We get the addend now, rather than
3808 when we do the relocation, because the symbol manipulations done
3809 by the linker may cause us to lose track of the input BFD. */
3810 if (((*cache_ptr->sym_ptr_ptr)->flags & BSF_SECTION_SYM) != 0
3811 && (gprel16_reloc_p (r_type) || r_type == (unsigned int) R_MIPS_LITERAL))
3812 cache_ptr->addend = elf_gp (abfd);
3817 /* Given a MIPS Elf_Internal_Rela, fill in an arelent structure. */
3820 mips_info_to_howto_rela (bfd *abfd,
3821 arelent *cache_ptr, Elf_Internal_Rela *dst)
3823 unsigned int r_type;
3825 r_type = ELF32_R_TYPE (dst->r_info);
3826 cache_ptr->howto = mips_elf_n32_rtype_to_howto (abfd, r_type, TRUE);
3827 cache_ptr->addend = dst->r_addend;
3828 return cache_ptr->howto != NULL;
3831 /* Determine whether a symbol is global for the purposes of splitting
3832 the symbol table into global symbols and local symbols. At least
3833 on Irix 5, this split must be between section symbols and all other
3834 symbols. On most ELF targets the split is between static symbols
3835 and externally visible symbols. */
3838 mips_elf_sym_is_global (bfd *abfd ATTRIBUTE_UNUSED, asymbol *sym)
3840 if (SGI_COMPAT (abfd))
3841 return (sym->flags & BSF_SECTION_SYM) == 0;
3843 return ((sym->flags & (BSF_GLOBAL | BSF_WEAK | BSF_GNU_UNIQUE)) != 0
3844 || bfd_is_und_section (bfd_get_section (sym))
3845 || bfd_is_com_section (bfd_get_section (sym)));
3848 /* Set the right machine number for a MIPS ELF file. */
3851 mips_elf_n32_object_p (bfd *abfd)
3855 if (!ABI_N32_P (abfd))
3858 /* Irix 5 and 6 are broken. Object file symbol tables are not always
3859 sorted correctly such that local symbols precede global symbols,
3860 and the sh_info field in the symbol table is not always right. */
3861 if (SGI_COMPAT (abfd))
3862 elf_bad_symtab (abfd) = TRUE;
3864 mach = _bfd_elf_mips_mach (elf_elfheader (abfd)->e_flags);
3865 bfd_default_set_arch_mach (abfd, bfd_arch_mips, mach);
3869 /* Support for core dump NOTE sections. */
3871 elf32_mips_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
3876 switch (note->descsz)
3881 case 440: /* Linux/MIPS N32 */
3883 elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
3886 elf_tdata (abfd)->core->lwpid = bfd_get_32 (abfd, note->descdata + 24);
3895 /* Make a ".reg/999" section. */
3896 return _bfd_elfcore_make_pseudosection (abfd, ".reg", size,
3897 note->descpos + offset);
3901 elf32_mips_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
3903 switch (note->descsz)
3908 case 128: /* Linux/MIPS elf_prpsinfo */
3909 elf_tdata (abfd)->core->pid
3910 = bfd_get_32 (abfd, note->descdata + 16);
3911 elf_tdata (abfd)->core->program
3912 = _bfd_elfcore_strndup (abfd, note->descdata + 32, 16);
3913 elf_tdata (abfd)->core->command
3914 = _bfd_elfcore_strndup (abfd, note->descdata + 48, 80);
3917 /* Note that for some reason, a spurious space is tacked
3918 onto the end of the args in some (at least one anyway)
3919 implementations, so strip it off if it exists. */
3922 char *command = elf_tdata (abfd)->core->command;
3923 int n = strlen (command);
3925 if (0 < n && command[n - 1] == ' ')
3926 command[n - 1] = '\0';
3933 elf_n32_mips_grok_freebsd_prstatus (bfd *abfd, Elf_Internal_Note *note)
3939 /* Compute offset of pr_getregsz, skipping over pr_statussz.
3940 Also compute minimum size of this note. */
3942 min_size = offset + 4 * 2 + 4 + 4 + 4;
3944 if (note->descsz < min_size)
3947 /* Check for version 1 in pr_version. */
3948 if (bfd_h_get_32 (abfd, (bfd_byte *) note->descdata) != 1)
3951 /* Extract size of pr_reg from pr_gregsetsz. */
3952 /* Skip over pr_gregsetsz and pr_fpregsetsz. */
3953 size = bfd_h_get_32 (abfd, (bfd_byte *) note->descdata + offset);
3956 /* Skip over pr_osreldate. */
3959 /* Read signal from pr_cursig. */
3960 if (elf_tdata (abfd)->core->signal == 0)
3961 elf_tdata (abfd)->core->signal
3962 = bfd_h_get_32 (abfd, (bfd_byte *) note->descdata + offset);
3965 /* Read TID from pr_pid. */
3966 elf_tdata (abfd)->core->lwpid
3967 = bfd_h_get_32 (abfd, (bfd_byte *) note->descdata + offset);
3970 /* Padding before pr_reg. */
3973 /* Make sure that there is enough data remaining in the note. */
3974 if (note->descsz - offset < size)
3977 /* Make a ".reg/999" section and a ".reg" section. */
3978 return _bfd_elfcore_make_pseudosection (abfd, ".reg",
3979 size, note->descpos + offset);
3982 /* Write Linux core PRSTATUS note into core file. */
3985 elf32_mips_write_core_note (bfd *abfd, char *buf, int *bufsiz, int note_type,
4005 va_start (ap, note_type);
4006 memset (data, 0, 72);
4007 pid = va_arg (ap, long);
4008 bfd_put_32 (abfd, pid, data + 24);
4009 cursig = va_arg (ap, int);
4010 bfd_put_16 (abfd, cursig, data + 12);
4011 greg = va_arg (ap, const void *);
4012 memcpy (data + 72, greg, 360);
4013 memset (data + 432, 0, 8);
4015 return elfcore_write_note (abfd, buf, bufsiz,
4016 "CORE", note_type, data, sizeof (data));
4021 /* Depending on the target vector we generate some version of Irix
4022 executables or "normal" MIPS ELF ABI executables. */
4023 static irix_compat_t
4024 elf_n32_mips_irix_compat (bfd *abfd)
4026 if ((abfd->xvec == &mips_elf32_n_be_vec)
4027 || (abfd->xvec == &mips_elf32_n_le_vec))
4033 /* Make an n32 MIPS object. We need to set the n32 ABI flag in
4034 `e_flags' to tell the object apart from an o32 object. */
4037 mips_elf_n32_mkobject (bfd *abfd)
4041 ret = _bfd_mips_elf_mkobject (abfd);
4043 elf_elfheader (abfd)->e_flags |= EF_MIPS_ABI2;
4048 /* ECOFF swapping routines. These are used when dealing with the
4049 .mdebug section, which is in the ECOFF debugging format. */
4050 static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = {
4051 /* Symbol table magic number. */
4053 /* Alignment of debugging information. E.g., 4. */
4055 /* Sizes of external symbolic information. */
4056 sizeof (struct hdr_ext),
4057 sizeof (struct dnr_ext),
4058 sizeof (struct pdr_ext),
4059 sizeof (struct sym_ext),
4060 sizeof (struct opt_ext),
4061 sizeof (struct fdr_ext),
4062 sizeof (struct rfd_ext),
4063 sizeof (struct ext_ext),
4064 /* Functions to swap in external symbolic data. */
4073 _bfd_ecoff_swap_tir_in,
4074 _bfd_ecoff_swap_rndx_in,
4075 /* Functions to swap out external symbolic data. */
4084 _bfd_ecoff_swap_tir_out,
4085 _bfd_ecoff_swap_rndx_out,
4086 /* Function to read in symbolic data. */
4087 _bfd_mips_elf_read_ecoff_info
4090 #define ELF_ARCH bfd_arch_mips
4091 #define ELF_TARGET_ID MIPS_ELF_DATA
4092 #define ELF_MACHINE_CODE EM_MIPS
4094 #define elf_backend_collect TRUE
4095 #define elf_backend_type_change_ok TRUE
4096 #define elf_backend_can_gc_sections TRUE
4097 #define elf_backend_gc_mark_extra_sections \
4098 _bfd_mips_elf_gc_mark_extra_sections
4099 #define elf_info_to_howto mips_info_to_howto_rela
4100 #define elf_info_to_howto_rel mips_info_to_howto_rel
4101 #define elf_backend_sym_is_global mips_elf_sym_is_global
4102 #define elf_backend_object_p mips_elf_n32_object_p
4103 #define elf_backend_symbol_processing _bfd_mips_elf_symbol_processing
4104 #define elf_backend_section_processing _bfd_mips_elf_section_processing
4105 #define elf_backend_section_from_shdr _bfd_mips_elf_section_from_shdr
4106 #define elf_backend_fake_sections _bfd_mips_elf_fake_sections
4107 #define elf_backend_section_from_bfd_section \
4108 _bfd_mips_elf_section_from_bfd_section
4109 #define elf_backend_add_symbol_hook _bfd_mips_elf_add_symbol_hook
4110 #define elf_backend_link_output_symbol_hook \
4111 _bfd_mips_elf_link_output_symbol_hook
4112 #define elf_backend_create_dynamic_sections \
4113 _bfd_mips_elf_create_dynamic_sections
4114 #define elf_backend_check_relocs _bfd_mips_elf_check_relocs
4115 #define elf_backend_merge_symbol_attribute \
4116 _bfd_mips_elf_merge_symbol_attribute
4117 #define elf_backend_get_target_dtag _bfd_mips_elf_get_target_dtag
4118 #define elf_backend_adjust_dynamic_symbol \
4119 _bfd_mips_elf_adjust_dynamic_symbol
4120 #define elf_backend_always_size_sections \
4121 _bfd_mips_elf_always_size_sections
4122 #define elf_backend_size_dynamic_sections \
4123 _bfd_mips_elf_size_dynamic_sections
4124 #define elf_backend_init_index_section _bfd_elf_init_1_index_section
4125 #define elf_backend_relocate_section _bfd_mips_elf_relocate_section
4126 #define elf_backend_finish_dynamic_symbol \
4127 _bfd_mips_elf_finish_dynamic_symbol
4128 #define elf_backend_finish_dynamic_sections \
4129 _bfd_mips_elf_finish_dynamic_sections
4130 #define elf_backend_final_write_processing \
4131 _bfd_mips_elf_final_write_processing
4132 #define elf_backend_additional_program_headers \
4133 _bfd_mips_elf_additional_program_headers
4134 #define elf_backend_modify_segment_map _bfd_mips_elf_modify_segment_map
4135 #define elf_backend_gc_mark_hook _bfd_mips_elf_gc_mark_hook
4136 #define elf_backend_gc_sweep_hook _bfd_mips_elf_gc_sweep_hook
4137 #define elf_backend_copy_indirect_symbol \
4138 _bfd_mips_elf_copy_indirect_symbol
4139 #define elf_backend_hide_symbol _bfd_mips_elf_hide_symbol
4140 #define elf_backend_grok_prstatus elf32_mips_grok_prstatus
4141 #define elf_backend_grok_psinfo elf32_mips_grok_psinfo
4142 #define elf_backend_grok_freebsd_prstatus \
4143 elf_n32_mips_grok_freebsd_prstatus
4144 #define elf_backend_ecoff_debug_swap &mips_elf32_ecoff_debug_swap
4146 #define elf_backend_got_header_size (4 * MIPS_RESERVED_GOTNO)
4147 #define elf_backend_want_dynrelro 1
4149 /* MIPS n32 ELF can use a mixture of REL and RELA, but some Relocations
4150 work better/work only in RELA, so we default to this. */
4151 #define elf_backend_may_use_rel_p 1
4152 #define elf_backend_may_use_rela_p 1
4153 #define elf_backend_default_use_rela_p 1
4154 #define elf_backend_rela_plts_and_copies_p 0
4155 #define elf_backend_sign_extend_vma TRUE
4156 #define elf_backend_plt_readonly 1
4157 #define elf_backend_plt_sym_val _bfd_mips_elf_plt_sym_val
4159 #define elf_backend_discard_info _bfd_mips_elf_discard_info
4160 #define elf_backend_ignore_discarded_relocs \
4161 _bfd_mips_elf_ignore_discarded_relocs
4162 #define elf_backend_write_section _bfd_mips_elf_write_section
4163 #define elf_backend_mips_irix_compat elf_n32_mips_irix_compat
4164 #define elf_backend_mips_rtype_to_howto mips_elf_n32_rtype_to_howto
4165 #define bfd_elf32_bfd_is_target_special_symbol \
4166 _bfd_mips_elf_is_target_special_symbol
4167 #define bfd_elf32_find_nearest_line _bfd_mips_elf_find_nearest_line
4168 #define bfd_elf32_find_inliner_info _bfd_mips_elf_find_inliner_info
4169 #define bfd_elf32_new_section_hook _bfd_mips_elf_new_section_hook
4170 #define bfd_elf32_set_section_contents _bfd_mips_elf_set_section_contents
4171 #define bfd_elf32_bfd_get_relocated_section_contents \
4172 _bfd_elf_mips_get_relocated_section_contents
4173 #define bfd_elf32_bfd_link_hash_table_create \
4174 _bfd_mips_elf_link_hash_table_create
4175 #define bfd_elf32_bfd_final_link _bfd_mips_elf_final_link
4176 #define bfd_elf32_bfd_merge_private_bfd_data \
4177 _bfd_mips_elf_merge_private_bfd_data
4178 #define bfd_elf32_bfd_set_private_flags _bfd_mips_elf_set_private_flags
4179 #define bfd_elf32_bfd_print_private_bfd_data \
4180 _bfd_mips_elf_print_private_bfd_data
4181 #define bfd_elf32_mkobject mips_elf_n32_mkobject
4183 /* Support for SGI-ish mips targets using n32 ABI. */
4185 #define TARGET_LITTLE_SYM mips_elf32_n_le_vec
4186 #define TARGET_LITTLE_NAME "elf32-nlittlemips"
4187 #define TARGET_BIG_SYM mips_elf32_n_be_vec
4188 #define TARGET_BIG_NAME "elf32-nbigmips"
4190 #define ELF_MAXPAGESIZE 0x10000
4191 #define ELF_COMMONPAGESIZE 0x1000
4193 #include "elf32-target.h"
4195 /* Support for traditional mips targets using n32 ABI. */
4196 #undef TARGET_LITTLE_SYM
4197 #undef TARGET_LITTLE_NAME
4198 #undef TARGET_BIG_SYM
4199 #undef TARGET_BIG_NAME
4201 #undef ELF_MAXPAGESIZE
4202 #undef ELF_COMMONPAGESIZE
4204 #define TARGET_LITTLE_SYM mips_elf32_ntrad_le_vec
4205 #define TARGET_LITTLE_NAME "elf32-ntradlittlemips"
4206 #define TARGET_BIG_SYM mips_elf32_ntrad_be_vec
4207 #define TARGET_BIG_NAME "elf32-ntradbigmips"
4209 #define ELF_MAXPAGESIZE 0x10000
4210 #define ELF_COMMONPAGESIZE 0x1000
4211 #define elf32_bed elf32_tradbed
4213 #undef elf_backend_write_core_note
4214 #define elf_backend_write_core_note elf32_mips_write_core_note
4216 /* Include the target file again for this target. */
4217 #include "elf32-target.h"
4220 /* FreeBSD support. */
4222 #undef TARGET_LITTLE_SYM
4223 #undef TARGET_LITTLE_NAME
4224 #undef TARGET_BIG_SYM
4225 #undef TARGET_BIG_NAME
4227 #define TARGET_LITTLE_SYM mips_elf32_ntradfbsd_le_vec
4228 #define TARGET_LITTLE_NAME "elf32-ntradlittlemips-freebsd"
4229 #define TARGET_BIG_SYM mips_elf32_ntradfbsd_be_vec
4230 #define TARGET_BIG_NAME "elf32-ntradbigmips-freebsd"
4233 #define ELF_OSABI ELFOSABI_FREEBSD
4236 #define elf32_bed elf32_fbsd_tradbed
4238 #undef elf_backend_write_core_note
4240 #include "elf32-target.h"