1 /* MIPS-specific support for 64-bit ELF
2 Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
3 2006, 2007, 2008, 2009, 2010
4 Free Software Foundation, Inc.
5 Ian Lance Taylor, Cygnus Support
6 Linker support added by Mark Mitchell, CodeSourcery, LLC.
7 <mark@codesourcery.com>
9 This file is part of BFD, the Binary File Descriptor library.
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 3 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
24 MA 02110-1301, USA. */
27 /* This file supports the 64-bit MIPS ELF ABI.
29 The MIPS 64-bit ELF ABI uses an unusual reloc format. This file
30 overrides the usual ELF reloc handling, and handles reading and
31 writing the relocations here. */
33 /* TODO: Many things are unsupported, even if there is some code for it
34 . (which was mostly stolen from elf32-mips.c and slightly adapted).
36 . - Relocation handling for REL relocs is wrong in many cases and
38 . - Relocation handling for RELA relocs related to GOT support are
39 . also likely to be wrong.
40 . - Support for MIPS16 is untested.
41 . - Combined relocs with RSS_* entries are unsupported.
42 . - The whole GOT handling for NewABI is missing, some parts of
43 . the OldABI version is still lying around and should be removed.
53 #include "elfxx-mips.h"
56 /* Get the ECOFF swapping routines. The 64-bit ABI is not supposed to
57 use ECOFF. However, we support it anyhow for an easier changeover. */
59 #include "coff/symconst.h"
60 #include "coff/internal.h"
61 #include "coff/ecoff.h"
62 /* The 64 bit versions of the mdebug data structures are in alpha.h. */
63 #include "coff/alpha.h"
64 #define ECOFF_SIGNED_64
65 #include "ecoffswap.h"
67 static void mips_elf64_swap_reloc_in
68 (bfd
*, const Elf64_Mips_External_Rel
*, Elf64_Mips_Internal_Rela
*);
69 static void mips_elf64_swap_reloca_in
70 (bfd
*, const Elf64_Mips_External_Rela
*, Elf64_Mips_Internal_Rela
*);
71 static void mips_elf64_swap_reloc_out
72 (bfd
*, const Elf64_Mips_Internal_Rela
*, Elf64_Mips_External_Rel
*);
73 static void mips_elf64_swap_reloca_out
74 (bfd
*, const Elf64_Mips_Internal_Rela
*, Elf64_Mips_External_Rela
*);
75 static void mips_elf64_be_swap_reloc_in
76 (bfd
*, const bfd_byte
*, Elf_Internal_Rela
*);
77 static void mips_elf64_be_swap_reloc_out
78 (bfd
*, const Elf_Internal_Rela
*, bfd_byte
*);
79 static void mips_elf64_be_swap_reloca_in
80 (bfd
*, const bfd_byte
*, Elf_Internal_Rela
*);
81 static void mips_elf64_be_swap_reloca_out
82 (bfd
*, const Elf_Internal_Rela
*, bfd_byte
*);
83 static reloc_howto_type
*bfd_elf64_bfd_reloc_type_lookup
84 (bfd
*, bfd_reloc_code_real_type
);
85 static reloc_howto_type
*mips_elf64_rtype_to_howto
86 (unsigned int, bfd_boolean
);
87 static void mips_elf64_info_to_howto_rel
88 (bfd
*, arelent
*, Elf_Internal_Rela
*);
89 static void mips_elf64_info_to_howto_rela
90 (bfd
*, arelent
*, Elf_Internal_Rela
*);
91 static long mips_elf64_get_reloc_upper_bound
93 static long mips_elf64_canonicalize_reloc
94 (bfd
*, asection
*, arelent
**, asymbol
**);
95 static long mips_elf64_get_dynamic_reloc_upper_bound
97 static long mips_elf64_canonicalize_dynamic_reloc
98 (bfd
*, arelent
**, asymbol
**);
99 static bfd_boolean mips_elf64_slurp_one_reloc_table
100 (bfd
*, asection
*, Elf_Internal_Shdr
*, bfd_size_type
, arelent
*,
101 asymbol
**, bfd_boolean
);
102 static bfd_boolean mips_elf64_slurp_reloc_table
103 (bfd
*, asection
*, asymbol
**, bfd_boolean
);
104 static void mips_elf64_write_relocs
105 (bfd
*, asection
*, void *);
106 static void mips_elf64_write_rel
107 (bfd
*, asection
*, Elf_Internal_Shdr
*, int *, void *);
108 static void mips_elf64_write_rela
109 (bfd
*, asection
*, Elf_Internal_Shdr
*, int *, void *);
110 static bfd_reloc_status_type mips_elf64_gprel16_reloc
111 (bfd
*, arelent
*, asymbol
*, void *, asection
*, bfd
*, char **);
112 static bfd_reloc_status_type mips_elf64_literal_reloc
113 (bfd
*, arelent
*, asymbol
*, void *, asection
*, bfd
*, char **);
114 static bfd_reloc_status_type mips_elf64_gprel32_reloc
115 (bfd
*, arelent
*, asymbol
*, void *, asection
*, bfd
*, char **);
116 static bfd_reloc_status_type mips_elf64_shift6_reloc
117 (bfd
*, arelent
*, asymbol
*, void *, asection
*, bfd
*, char **);
118 static bfd_reloc_status_type mips16_gprel_reloc
119 (bfd
*, arelent
*, asymbol
*, void *, asection
*, bfd
*, char **);
120 static bfd_boolean mips_elf64_assign_gp
122 static bfd_reloc_status_type mips_elf64_final_gp
123 (bfd
*, asymbol
*, bfd_boolean
, char **, bfd_vma
*);
124 static bfd_boolean mips_elf64_object_p
126 static irix_compat_t elf64_mips_irix_compat
128 static bfd_boolean elf64_mips_grok_prstatus
129 (bfd
*, Elf_Internal_Note
*);
130 static bfd_boolean elf64_mips_grok_psinfo
131 (bfd
*, Elf_Internal_Note
*);
133 extern const bfd_target bfd_elf64_bigmips_vec
;
134 extern const bfd_target bfd_elf64_littlemips_vec
;
136 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
137 from smaller values. Start with zero, widen, *then* decrement. */
138 #define MINUS_ONE (((bfd_vma)0) - 1)
140 /* The number of local .got entries we reserve. */
141 #define MIPS_RESERVED_GOTNO (2)
143 /* The relocation table used for SHT_REL sections. */
145 static reloc_howto_type mips_elf64_howto_table_rel
[] =
148 HOWTO (R_MIPS_NONE
, /* type */
150 0, /* size (0 = byte, 1 = short, 2 = long) */
152 FALSE
, /* pc_relative */
154 complain_overflow_dont
, /* complain_on_overflow */
155 _bfd_mips_elf_generic_reloc
, /* special_function */
156 "R_MIPS_NONE", /* name */
157 FALSE
, /* partial_inplace */
160 FALSE
), /* pcrel_offset */
162 /* 16 bit relocation. */
163 HOWTO (R_MIPS_16
, /* type */
165 2, /* size (0 = byte, 1 = short, 2 = long) */
167 FALSE
, /* pc_relative */
169 complain_overflow_signed
, /* complain_on_overflow */
170 _bfd_mips_elf_generic_reloc
, /* special_function */
171 "R_MIPS_16", /* name */
172 TRUE
, /* partial_inplace */
173 0x0000ffff, /* src_mask */
174 0x0000ffff, /* dst_mask */
175 FALSE
), /* pcrel_offset */
177 /* 32 bit relocation. */
178 HOWTO (R_MIPS_32
, /* type */
180 2, /* size (0 = byte, 1 = short, 2 = long) */
182 FALSE
, /* pc_relative */
184 complain_overflow_dont
, /* complain_on_overflow */
185 _bfd_mips_elf_generic_reloc
, /* special_function */
186 "R_MIPS_32", /* name */
187 TRUE
, /* partial_inplace */
188 0xffffffff, /* src_mask */
189 0xffffffff, /* dst_mask */
190 FALSE
), /* pcrel_offset */
192 /* 32 bit symbol relative relocation. */
193 HOWTO (R_MIPS_REL32
, /* type */
195 2, /* size (0 = byte, 1 = short, 2 = long) */
197 FALSE
, /* pc_relative */
199 complain_overflow_dont
, /* complain_on_overflow */
200 _bfd_mips_elf_generic_reloc
, /* special_function */
201 "R_MIPS_REL32", /* name */
202 TRUE
, /* partial_inplace */
203 0xffffffff, /* src_mask */
204 0xffffffff, /* dst_mask */
205 FALSE
), /* pcrel_offset */
207 /* 26 bit jump address. */
208 HOWTO (R_MIPS_26
, /* type */
210 2, /* size (0 = byte, 1 = short, 2 = long) */
212 FALSE
, /* pc_relative */
214 complain_overflow_dont
, /* complain_on_overflow */
215 /* This needs complex overflow
216 detection, because the upper 36
217 bits must match the PC + 4. */
218 _bfd_mips_elf_generic_reloc
, /* special_function */
219 "R_MIPS_26", /* name */
220 TRUE
, /* partial_inplace */
221 0x03ffffff, /* src_mask */
222 0x03ffffff, /* dst_mask */
223 FALSE
), /* pcrel_offset */
225 /* R_MIPS_HI16 and R_MIPS_LO16 are unsupported for NewABI REL.
226 However, the native IRIX6 tools use them, so we try our best. */
228 /* High 16 bits of symbol value. */
229 HOWTO (R_MIPS_HI16
, /* type */
231 2, /* size (0 = byte, 1 = short, 2 = long) */
233 FALSE
, /* pc_relative */
235 complain_overflow_dont
, /* complain_on_overflow */
236 _bfd_mips_elf_hi16_reloc
, /* special_function */
237 "R_MIPS_HI16", /* name */
238 TRUE
, /* partial_inplace */
239 0x0000ffff, /* src_mask */
240 0x0000ffff, /* dst_mask */
241 FALSE
), /* pcrel_offset */
243 /* Low 16 bits of symbol value. */
244 HOWTO (R_MIPS_LO16
, /* type */
246 2, /* size (0 = byte, 1 = short, 2 = long) */
248 FALSE
, /* pc_relative */
250 complain_overflow_dont
, /* complain_on_overflow */
251 _bfd_mips_elf_lo16_reloc
, /* special_function */
252 "R_MIPS_LO16", /* name */
253 TRUE
, /* partial_inplace */
254 0x0000ffff, /* src_mask */
255 0x0000ffff, /* dst_mask */
256 FALSE
), /* pcrel_offset */
258 /* GP relative reference. */
259 HOWTO (R_MIPS_GPREL16
, /* type */
261 2, /* size (0 = byte, 1 = short, 2 = long) */
263 FALSE
, /* pc_relative */
265 complain_overflow_signed
, /* complain_on_overflow */
266 mips_elf64_gprel16_reloc
, /* special_function */
267 "R_MIPS_GPREL16", /* name */
268 TRUE
, /* partial_inplace */
269 0x0000ffff, /* src_mask */
270 0x0000ffff, /* dst_mask */
271 FALSE
), /* pcrel_offset */
273 /* Reference to literal section. */
274 HOWTO (R_MIPS_LITERAL
, /* type */
276 2, /* size (0 = byte, 1 = short, 2 = long) */
278 FALSE
, /* pc_relative */
280 complain_overflow_signed
, /* complain_on_overflow */
281 mips_elf64_literal_reloc
, /* special_function */
282 "R_MIPS_LITERAL", /* name */
283 TRUE
, /* partial_inplace */
284 0x0000ffff, /* src_mask */
285 0x0000ffff, /* dst_mask */
286 FALSE
), /* pcrel_offset */
288 /* Reference to global offset table. */
289 HOWTO (R_MIPS_GOT16
, /* type */
291 2, /* size (0 = byte, 1 = short, 2 = long) */
293 FALSE
, /* pc_relative */
295 complain_overflow_signed
, /* complain_on_overflow */
296 _bfd_mips_elf_got16_reloc
, /* special_function */
297 "R_MIPS_GOT16", /* name */
298 TRUE
, /* partial_inplace */
299 0x0000ffff, /* src_mask */
300 0x0000ffff, /* dst_mask */
301 FALSE
), /* pcrel_offset */
303 /* 16 bit PC relative reference. Note that the ABI document has a typo
304 and claims R_MIPS_PC16 to be not rightshifted, rendering it useless.
305 We do the right thing here. */
306 HOWTO (R_MIPS_PC16
, /* type */
308 2, /* size (0 = byte, 1 = short, 2 = long) */
310 TRUE
, /* pc_relative */
312 complain_overflow_signed
, /* complain_on_overflow */
313 _bfd_mips_elf_generic_reloc
, /* special_function */
314 "R_MIPS_PC16", /* name */
315 TRUE
, /* partial_inplace */
316 0x0000ffff, /* src_mask */
317 0x0000ffff, /* dst_mask */
318 TRUE
), /* pcrel_offset */
320 /* 16 bit call through global offset table. */
321 HOWTO (R_MIPS_CALL16
, /* type */
323 2, /* size (0 = byte, 1 = short, 2 = long) */
325 FALSE
, /* pc_relative */
327 complain_overflow_signed
, /* complain_on_overflow */
328 _bfd_mips_elf_generic_reloc
, /* special_function */
329 "R_MIPS_CALL16", /* name */
330 TRUE
, /* partial_inplace */
331 0x0000ffff, /* src_mask */
332 0x0000ffff, /* dst_mask */
333 FALSE
), /* pcrel_offset */
335 /* 32 bit GP relative reference. */
336 HOWTO (R_MIPS_GPREL32
, /* type */
338 2, /* size (0 = byte, 1 = short, 2 = long) */
340 FALSE
, /* pc_relative */
342 complain_overflow_dont
, /* complain_on_overflow */
343 mips_elf64_gprel32_reloc
, /* special_function */
344 "R_MIPS_GPREL32", /* name */
345 TRUE
, /* partial_inplace */
346 0xffffffff, /* src_mask */
347 0xffffffff, /* dst_mask */
348 FALSE
), /* pcrel_offset */
354 /* A 5 bit shift field. */
355 HOWTO (R_MIPS_SHIFT5
, /* type */
357 2, /* size (0 = byte, 1 = short, 2 = long) */
359 FALSE
, /* pc_relative */
361 complain_overflow_bitfield
, /* complain_on_overflow */
362 _bfd_mips_elf_generic_reloc
, /* special_function */
363 "R_MIPS_SHIFT5", /* name */
364 TRUE
, /* partial_inplace */
365 0x000007c0, /* src_mask */
366 0x000007c0, /* dst_mask */
367 FALSE
), /* pcrel_offset */
369 /* A 6 bit shift field. */
370 HOWTO (R_MIPS_SHIFT6
, /* type */
372 2, /* size (0 = byte, 1 = short, 2 = long) */
374 FALSE
, /* pc_relative */
376 complain_overflow_bitfield
, /* complain_on_overflow */
377 mips_elf64_shift6_reloc
, /* special_function */
378 "R_MIPS_SHIFT6", /* name */
379 TRUE
, /* partial_inplace */
380 0x000007c4, /* src_mask */
381 0x000007c4, /* dst_mask */
382 FALSE
), /* pcrel_offset */
384 /* 64 bit relocation. */
385 HOWTO (R_MIPS_64
, /* type */
387 4, /* size (0 = byte, 1 = short, 2 = long) */
389 FALSE
, /* pc_relative */
391 complain_overflow_dont
, /* complain_on_overflow */
392 _bfd_mips_elf_generic_reloc
, /* special_function */
393 "R_MIPS_64", /* name */
394 TRUE
, /* partial_inplace */
395 MINUS_ONE
, /* src_mask */
396 MINUS_ONE
, /* dst_mask */
397 FALSE
), /* pcrel_offset */
399 /* Displacement in the global offset table. */
400 HOWTO (R_MIPS_GOT_DISP
, /* type */
402 2, /* size (0 = byte, 1 = short, 2 = long) */
404 FALSE
, /* pc_relative */
406 complain_overflow_signed
, /* complain_on_overflow */
407 _bfd_mips_elf_generic_reloc
, /* special_function */
408 "R_MIPS_GOT_DISP", /* name */
409 TRUE
, /* partial_inplace */
410 0x0000ffff, /* src_mask */
411 0x0000ffff, /* dst_mask */
412 FALSE
), /* pcrel_offset */
414 /* Displacement to page pointer in the global offset table. */
415 HOWTO (R_MIPS_GOT_PAGE
, /* type */
417 2, /* size (0 = byte, 1 = short, 2 = long) */
419 FALSE
, /* pc_relative */
421 complain_overflow_signed
, /* complain_on_overflow */
422 _bfd_mips_elf_generic_reloc
, /* special_function */
423 "R_MIPS_GOT_PAGE", /* name */
424 TRUE
, /* partial_inplace */
425 0x0000ffff, /* src_mask */
426 0x0000ffff, /* dst_mask */
427 FALSE
), /* pcrel_offset */
429 /* Offset from page pointer in the global offset table. */
430 HOWTO (R_MIPS_GOT_OFST
, /* type */
432 2, /* size (0 = byte, 1 = short, 2 = long) */
434 FALSE
, /* pc_relative */
436 complain_overflow_signed
, /* complain_on_overflow */
437 _bfd_mips_elf_generic_reloc
, /* special_function */
438 "R_MIPS_GOT_OFST", /* name */
439 TRUE
, /* partial_inplace */
440 0x0000ffff, /* src_mask */
441 0x0000ffff, /* dst_mask */
442 FALSE
), /* pcrel_offset */
444 /* High 16 bits of displacement in global offset table. */
445 HOWTO (R_MIPS_GOT_HI16
, /* type */
447 2, /* size (0 = byte, 1 = short, 2 = long) */
449 FALSE
, /* pc_relative */
451 complain_overflow_dont
, /* complain_on_overflow */
452 _bfd_mips_elf_generic_reloc
, /* special_function */
453 "R_MIPS_GOT_HI16", /* name */
454 TRUE
, /* partial_inplace */
455 0x0000ffff, /* src_mask */
456 0x0000ffff, /* dst_mask */
457 FALSE
), /* pcrel_offset */
459 /* Low 16 bits of displacement in global offset table. */
460 HOWTO (R_MIPS_GOT_LO16
, /* type */
462 2, /* size (0 = byte, 1 = short, 2 = long) */
464 FALSE
, /* pc_relative */
466 complain_overflow_dont
, /* complain_on_overflow */
467 _bfd_mips_elf_generic_reloc
, /* special_function */
468 "R_MIPS_GOT_LO16", /* name */
469 TRUE
, /* partial_inplace */
470 0x0000ffff, /* src_mask */
471 0x0000ffff, /* dst_mask */
472 FALSE
), /* pcrel_offset */
474 /* 64 bit subtraction. */
475 HOWTO (R_MIPS_SUB
, /* type */
477 4, /* size (0 = byte, 1 = short, 2 = long) */
479 FALSE
, /* pc_relative */
481 complain_overflow_dont
, /* complain_on_overflow */
482 _bfd_mips_elf_generic_reloc
, /* special_function */
483 "R_MIPS_SUB", /* name */
484 TRUE
, /* partial_inplace */
485 MINUS_ONE
, /* src_mask */
486 MINUS_ONE
, /* dst_mask */
487 FALSE
), /* pcrel_offset */
489 /* Insert the addend as an instruction. */
490 /* FIXME: Not handled correctly. */
491 HOWTO (R_MIPS_INSERT_A
, /* type */
493 2, /* size (0 = byte, 1 = short, 2 = long) */
495 FALSE
, /* pc_relative */
497 complain_overflow_dont
, /* complain_on_overflow */
498 _bfd_mips_elf_generic_reloc
, /* special_function */
499 "R_MIPS_INSERT_A", /* name */
500 TRUE
, /* partial_inplace */
501 0xffffffff, /* src_mask */
502 0xffffffff, /* dst_mask */
503 FALSE
), /* pcrel_offset */
505 /* Insert the addend as an instruction, and change all relocations
506 to refer to the old instruction at the address. */
507 /* FIXME: Not handled correctly. */
508 HOWTO (R_MIPS_INSERT_B
, /* type */
510 2, /* size (0 = byte, 1 = short, 2 = long) */
512 FALSE
, /* pc_relative */
514 complain_overflow_dont
, /* complain_on_overflow */
515 _bfd_mips_elf_generic_reloc
, /* special_function */
516 "R_MIPS_INSERT_B", /* name */
517 TRUE
, /* partial_inplace */
518 0xffffffff, /* src_mask */
519 0xffffffff, /* dst_mask */
520 FALSE
), /* pcrel_offset */
522 /* Delete a 32 bit instruction. */
523 /* FIXME: Not handled correctly. */
524 HOWTO (R_MIPS_DELETE
, /* type */
526 2, /* size (0 = byte, 1 = short, 2 = long) */
528 FALSE
, /* pc_relative */
530 complain_overflow_dont
, /* complain_on_overflow */
531 _bfd_mips_elf_generic_reloc
, /* special_function */
532 "R_MIPS_DELETE", /* name */
533 TRUE
, /* partial_inplace */
534 0xffffffff, /* src_mask */
535 0xffffffff, /* dst_mask */
536 FALSE
), /* pcrel_offset */
538 /* The MIPS ELF64 ABI Draft wants us to support these for REL relocations.
540 a) It means building the addend from a R_MIPS_HIGHEST/R_MIPS_HIGHER/
541 R_MIPS_HI16/R_MIPS_LO16 sequence with varying ordering, using
543 b) No other NewABI toolchain actually emits such relocations. */
544 EMPTY_HOWTO (R_MIPS_HIGHER
),
545 EMPTY_HOWTO (R_MIPS_HIGHEST
),
547 /* High 16 bits of displacement in global offset table. */
548 HOWTO (R_MIPS_CALL_HI16
, /* type */
550 2, /* size (0 = byte, 1 = short, 2 = long) */
552 FALSE
, /* pc_relative */
554 complain_overflow_dont
, /* complain_on_overflow */
555 _bfd_mips_elf_generic_reloc
, /* special_function */
556 "R_MIPS_CALL_HI16", /* name */
557 TRUE
, /* partial_inplace */
558 0x0000ffff, /* src_mask */
559 0x0000ffff, /* dst_mask */
560 FALSE
), /* pcrel_offset */
562 /* Low 16 bits of displacement in global offset table. */
563 HOWTO (R_MIPS_CALL_LO16
, /* type */
565 2, /* size (0 = byte, 1 = short, 2 = long) */
567 FALSE
, /* pc_relative */
569 complain_overflow_dont
, /* complain_on_overflow */
570 _bfd_mips_elf_generic_reloc
, /* special_function */
571 "R_MIPS_CALL_LO16", /* name */
572 TRUE
, /* partial_inplace */
573 0x0000ffff, /* src_mask */
574 0x0000ffff, /* dst_mask */
575 FALSE
), /* pcrel_offset */
577 /* Section displacement, used by an associated event location section. */
578 HOWTO (R_MIPS_SCN_DISP
, /* type */
580 2, /* size (0 = byte, 1 = short, 2 = long) */
582 FALSE
, /* pc_relative */
584 complain_overflow_dont
, /* complain_on_overflow */
585 _bfd_mips_elf_generic_reloc
, /* special_function */
586 "R_MIPS_SCN_DISP", /* name */
587 TRUE
, /* partial_inplace */
588 0xffffffff, /* src_mask */
589 0xffffffff, /* dst_mask */
590 FALSE
), /* pcrel_offset */
592 HOWTO (R_MIPS_REL16
, /* type */
594 1, /* size (0 = byte, 1 = short, 2 = long) */
596 FALSE
, /* pc_relative */
598 complain_overflow_signed
, /* complain_on_overflow */
599 _bfd_mips_elf_generic_reloc
, /* special_function */
600 "R_MIPS_REL16", /* name */
601 TRUE
, /* partial_inplace */
602 0xffff, /* src_mask */
603 0xffff, /* dst_mask */
604 FALSE
), /* pcrel_offset */
606 /* These two are obsolete. */
607 EMPTY_HOWTO (R_MIPS_ADD_IMMEDIATE
),
608 EMPTY_HOWTO (R_MIPS_PJUMP
),
610 /* Similiar to R_MIPS_REL32, but used for relocations in a GOT section.
611 It must be used for multigot GOT's (and only there). */
612 HOWTO (R_MIPS_RELGOT
, /* type */
614 2, /* size (0 = byte, 1 = short, 2 = long) */
616 FALSE
, /* pc_relative */
618 complain_overflow_dont
, /* complain_on_overflow */
619 _bfd_mips_elf_generic_reloc
, /* special_function */
620 "R_MIPS_RELGOT", /* name */
621 TRUE
, /* partial_inplace */
622 0xffffffff, /* src_mask */
623 0xffffffff, /* dst_mask */
624 FALSE
), /* pcrel_offset */
626 /* Protected jump conversion. This is an optimization hint. No
627 relocation is required for correctness. */
628 HOWTO (R_MIPS_JALR
, /* type */
630 2, /* size (0 = byte, 1 = short, 2 = long) */
632 FALSE
, /* pc_relative */
634 complain_overflow_dont
, /* complain_on_overflow */
635 _bfd_mips_elf_generic_reloc
, /* special_function */
636 "R_MIPS_JALR", /* name */
637 FALSE
, /* partial_inplace */
639 0x00000000, /* dst_mask */
640 FALSE
), /* pcrel_offset */
642 /* TLS relocations. */
643 EMPTY_HOWTO (R_MIPS_TLS_DTPMOD32
),
644 EMPTY_HOWTO (R_MIPS_TLS_DTPREL32
),
646 HOWTO (R_MIPS_TLS_DTPMOD64
, /* type */
648 4, /* size (0 = byte, 1 = short, 2 = long) */
650 FALSE
, /* pc_relative */
652 complain_overflow_dont
, /* complain_on_overflow */
653 _bfd_mips_elf_generic_reloc
, /* special_function */
654 "R_MIPS_TLS_DTPMOD64", /* name */
655 TRUE
, /* partial_inplace */
656 MINUS_ONE
, /* src_mask */
657 MINUS_ONE
, /* dst_mask */
658 FALSE
), /* pcrel_offset */
660 HOWTO (R_MIPS_TLS_DTPREL64
, /* type */
662 4, /* size (0 = byte, 1 = short, 2 = long) */
664 FALSE
, /* pc_relative */
666 complain_overflow_dont
, /* complain_on_overflow */
667 _bfd_mips_elf_generic_reloc
, /* special_function */
668 "R_MIPS_TLS_DTPREL64", /* name */
669 TRUE
, /* partial_inplace */
670 MINUS_ONE
, /* src_mask */
671 MINUS_ONE
, /* dst_mask */
672 FALSE
), /* pcrel_offset */
674 /* TLS general dynamic variable reference. */
675 HOWTO (R_MIPS_TLS_GD
, /* type */
677 2, /* size (0 = byte, 1 = short, 2 = long) */
679 FALSE
, /* pc_relative */
681 complain_overflow_signed
, /* complain_on_overflow */
682 _bfd_mips_elf_generic_reloc
, /* special_function */
683 "R_MIPS_TLS_GD", /* name */
684 TRUE
, /* partial_inplace */
685 0x0000ffff, /* src_mask */
686 0x0000ffff, /* dst_mask */
687 FALSE
), /* pcrel_offset */
689 /* TLS local dynamic variable reference. */
690 HOWTO (R_MIPS_TLS_LDM
, /* type */
692 2, /* size (0 = byte, 1 = short, 2 = long) */
694 FALSE
, /* pc_relative */
696 complain_overflow_signed
, /* complain_on_overflow */
697 _bfd_mips_elf_generic_reloc
, /* special_function */
698 "R_MIPS_TLS_LDM", /* name */
699 TRUE
, /* partial_inplace */
700 0x0000ffff, /* src_mask */
701 0x0000ffff, /* dst_mask */
702 FALSE
), /* pcrel_offset */
704 /* TLS local dynamic offset. */
705 HOWTO (R_MIPS_TLS_DTPREL_HI16
, /* type */
707 2, /* size (0 = byte, 1 = short, 2 = long) */
709 FALSE
, /* pc_relative */
711 complain_overflow_signed
, /* complain_on_overflow */
712 _bfd_mips_elf_generic_reloc
, /* special_function */
713 "R_MIPS_TLS_DTPREL_HI16", /* name */
714 TRUE
, /* partial_inplace */
715 0x0000ffff, /* src_mask */
716 0x0000ffff, /* dst_mask */
717 FALSE
), /* pcrel_offset */
719 /* TLS local dynamic offset. */
720 HOWTO (R_MIPS_TLS_DTPREL_LO16
, /* type */
722 2, /* size (0 = byte, 1 = short, 2 = long) */
724 FALSE
, /* pc_relative */
726 complain_overflow_signed
, /* complain_on_overflow */
727 _bfd_mips_elf_generic_reloc
, /* special_function */
728 "R_MIPS_TLS_DTPREL_LO16", /* name */
729 TRUE
, /* partial_inplace */
730 0x0000ffff, /* src_mask */
731 0x0000ffff, /* dst_mask */
732 FALSE
), /* pcrel_offset */
734 /* TLS thread pointer offset. */
735 HOWTO (R_MIPS_TLS_GOTTPREL
, /* type */
737 2, /* size (0 = byte, 1 = short, 2 = long) */
739 FALSE
, /* pc_relative */
741 complain_overflow_signed
, /* complain_on_overflow */
742 _bfd_mips_elf_generic_reloc
, /* special_function */
743 "R_MIPS_TLS_GOTTPREL", /* name */
744 TRUE
, /* partial_inplace */
745 0x0000ffff, /* src_mask */
746 0x0000ffff, /* dst_mask */
747 FALSE
), /* pcrel_offset */
749 /* TLS IE dynamic relocations. */
750 EMPTY_HOWTO (R_MIPS_TLS_TPREL32
),
752 HOWTO (R_MIPS_TLS_TPREL64
, /* type */
754 4, /* size (0 = byte, 1 = short, 2 = long) */
756 FALSE
, /* pc_relative */
758 complain_overflow_dont
, /* complain_on_overflow */
759 _bfd_mips_elf_generic_reloc
, /* special_function */
760 "R_MIPS_TLS_TPREL64", /* name */
761 TRUE
, /* partial_inplace */
762 MINUS_ONE
, /* src_mask */
763 MINUS_ONE
, /* dst_mask */
764 FALSE
), /* pcrel_offset */
766 /* TLS thread pointer offset. */
767 HOWTO (R_MIPS_TLS_TPREL_HI16
, /* type */
769 2, /* size (0 = byte, 1 = short, 2 = long) */
771 FALSE
, /* pc_relative */
773 complain_overflow_signed
, /* complain_on_overflow */
774 _bfd_mips_elf_generic_reloc
, /* special_function */
775 "R_MIPS_TLS_TPREL_HI16", /* name */
776 TRUE
, /* partial_inplace */
777 0x0000ffff, /* src_mask */
778 0x0000ffff, /* dst_mask */
779 FALSE
), /* pcrel_offset */
781 /* TLS thread pointer offset. */
782 HOWTO (R_MIPS_TLS_TPREL_LO16
, /* type */
784 2, /* size (0 = byte, 1 = short, 2 = long) */
786 FALSE
, /* pc_relative */
788 complain_overflow_signed
, /* complain_on_overflow */
789 _bfd_mips_elf_generic_reloc
, /* special_function */
790 "R_MIPS_TLS_TPREL_LO16", /* name */
791 TRUE
, /* partial_inplace */
792 0x0000ffff, /* src_mask */
793 0x0000ffff, /* dst_mask */
794 FALSE
), /* pcrel_offset */
796 /* 32 bit relocation with no addend. */
797 HOWTO (R_MIPS_GLOB_DAT
, /* type */
799 2, /* size (0 = byte, 1 = short, 2 = long) */
801 FALSE
, /* pc_relative */
803 complain_overflow_dont
, /* complain_on_overflow */
804 _bfd_mips_elf_generic_reloc
, /* special_function */
805 "R_MIPS_GLOB_DAT", /* name */
806 FALSE
, /* partial_inplace */
808 0xffffffff, /* dst_mask */
809 FALSE
), /* pcrel_offset */
812 /* The relocation table used for SHT_RELA sections. */
814 static reloc_howto_type mips_elf64_howto_table_rela
[] =
817 HOWTO (R_MIPS_NONE
, /* type */
819 0, /* size (0 = byte, 1 = short, 2 = long) */
821 FALSE
, /* pc_relative */
823 complain_overflow_dont
, /* complain_on_overflow */
824 _bfd_mips_elf_generic_reloc
, /* special_function */
825 "R_MIPS_NONE", /* name */
826 FALSE
, /* partial_inplace */
829 FALSE
), /* pcrel_offset */
831 /* 16 bit relocation. */
832 HOWTO (R_MIPS_16
, /* type */
834 2, /* size (0 = byte, 1 = short, 2 = long) */
836 FALSE
, /* pc_relative */
838 complain_overflow_signed
, /* complain_on_overflow */
839 _bfd_mips_elf_generic_reloc
, /* special_function */
840 "R_MIPS_16", /* name */
841 FALSE
, /* partial_inplace */
843 0x0000ffff, /* dst_mask */
844 FALSE
), /* pcrel_offset */
846 /* 32 bit relocation. */
847 HOWTO (R_MIPS_32
, /* type */
849 2, /* size (0 = byte, 1 = short, 2 = long) */
851 FALSE
, /* pc_relative */
853 complain_overflow_dont
, /* complain_on_overflow */
854 _bfd_mips_elf_generic_reloc
, /* special_function */
855 "R_MIPS_32", /* name */
856 FALSE
, /* partial_inplace */
858 0xffffffff, /* dst_mask */
859 FALSE
), /* pcrel_offset */
861 /* 32 bit symbol relative relocation. */
862 HOWTO (R_MIPS_REL32
, /* type */
864 2, /* size (0 = byte, 1 = short, 2 = long) */
866 FALSE
, /* pc_relative */
868 complain_overflow_dont
, /* complain_on_overflow */
869 _bfd_mips_elf_generic_reloc
, /* special_function */
870 "R_MIPS_REL32", /* name */
871 FALSE
, /* partial_inplace */
873 0xffffffff, /* dst_mask */
874 FALSE
), /* pcrel_offset */
876 /* 26 bit jump address. */
877 HOWTO (R_MIPS_26
, /* type */
879 2, /* size (0 = byte, 1 = short, 2 = long) */
881 FALSE
, /* pc_relative */
883 complain_overflow_dont
, /* complain_on_overflow */
884 /* This needs complex overflow
885 detection, because the upper 36
886 bits must match the PC + 4. */
887 _bfd_mips_elf_generic_reloc
, /* special_function */
888 "R_MIPS_26", /* name */
889 FALSE
, /* partial_inplace */
891 0x03ffffff, /* dst_mask */
892 FALSE
), /* pcrel_offset */
894 /* High 16 bits of symbol value. */
895 HOWTO (R_MIPS_HI16
, /* type */
897 2, /* size (0 = byte, 1 = short, 2 = long) */
899 FALSE
, /* pc_relative */
901 complain_overflow_dont
, /* complain_on_overflow */
902 _bfd_mips_elf_generic_reloc
, /* special_function */
903 "R_MIPS_HI16", /* name */
904 FALSE
, /* partial_inplace */
906 0x0000ffff, /* dst_mask */
907 FALSE
), /* pcrel_offset */
909 /* Low 16 bits of symbol value. */
910 HOWTO (R_MIPS_LO16
, /* type */
912 2, /* size (0 = byte, 1 = short, 2 = long) */
914 FALSE
, /* pc_relative */
916 complain_overflow_dont
, /* complain_on_overflow */
917 _bfd_mips_elf_generic_reloc
, /* special_function */
918 "R_MIPS_LO16", /* name */
919 FALSE
, /* partial_inplace */
921 0x0000ffff, /* dst_mask */
922 FALSE
), /* pcrel_offset */
924 /* GP relative reference. */
925 HOWTO (R_MIPS_GPREL16
, /* type */
927 2, /* size (0 = byte, 1 = short, 2 = long) */
929 FALSE
, /* pc_relative */
931 complain_overflow_signed
, /* complain_on_overflow */
932 mips_elf64_gprel16_reloc
, /* special_function */
933 "R_MIPS_GPREL16", /* name */
934 FALSE
, /* partial_inplace */
936 0x0000ffff, /* dst_mask */
937 FALSE
), /* pcrel_offset */
939 /* Reference to literal section. */
940 HOWTO (R_MIPS_LITERAL
, /* type */
942 2, /* size (0 = byte, 1 = short, 2 = long) */
944 FALSE
, /* pc_relative */
946 complain_overflow_signed
, /* complain_on_overflow */
947 mips_elf64_literal_reloc
, /* special_function */
948 "R_MIPS_LITERAL", /* name */
949 FALSE
, /* partial_inplace */
951 0x0000ffff, /* dst_mask */
952 FALSE
), /* pcrel_offset */
954 /* Reference to global offset table. */
955 HOWTO (R_MIPS_GOT16
, /* type */
957 2, /* size (0 = byte, 1 = short, 2 = long) */
959 FALSE
, /* pc_relative */
961 complain_overflow_signed
, /* complain_on_overflow */
962 _bfd_mips_elf_generic_reloc
, /* special_function */
963 "R_MIPS_GOT16", /* name */
964 FALSE
, /* partial_inplace */
966 0x0000ffff, /* dst_mask */
967 FALSE
), /* pcrel_offset */
969 /* 16 bit PC relative reference. Note that the ABI document has a typo
970 and claims R_MIPS_PC16 to be not rightshifted, rendering it useless.
971 We do the right thing here. */
972 HOWTO (R_MIPS_PC16
, /* type */
974 2, /* size (0 = byte, 1 = short, 2 = long) */
976 TRUE
, /* pc_relative */
978 complain_overflow_signed
, /* complain_on_overflow */
979 _bfd_mips_elf_generic_reloc
, /* special_function */
980 "R_MIPS_PC16", /* name */
981 FALSE
, /* partial_inplace */
983 0x0000ffff, /* dst_mask */
984 TRUE
), /* pcrel_offset */
986 /* 16 bit call through global offset table. */
987 HOWTO (R_MIPS_CALL16
, /* type */
989 2, /* size (0 = byte, 1 = short, 2 = long) */
991 FALSE
, /* pc_relative */
993 complain_overflow_signed
, /* complain_on_overflow */
994 _bfd_mips_elf_generic_reloc
, /* special_function */
995 "R_MIPS_CALL16", /* name */
996 FALSE
, /* partial_inplace */
998 0x0000ffff, /* dst_mask */
999 FALSE
), /* pcrel_offset */
1001 /* 32 bit GP relative reference. */
1002 HOWTO (R_MIPS_GPREL32
, /* type */
1004 2, /* size (0 = byte, 1 = short, 2 = long) */
1006 FALSE
, /* pc_relative */
1008 complain_overflow_dont
, /* complain_on_overflow */
1009 mips_elf64_gprel32_reloc
, /* special_function */
1010 "R_MIPS_GPREL32", /* name */
1011 FALSE
, /* partial_inplace */
1013 0xffffffff, /* dst_mask */
1014 FALSE
), /* pcrel_offset */
1020 /* A 5 bit shift field. */
1021 HOWTO (R_MIPS_SHIFT5
, /* type */
1023 2, /* size (0 = byte, 1 = short, 2 = long) */
1025 FALSE
, /* pc_relative */
1027 complain_overflow_bitfield
, /* complain_on_overflow */
1028 _bfd_mips_elf_generic_reloc
, /* special_function */
1029 "R_MIPS_SHIFT5", /* name */
1030 FALSE
, /* partial_inplace */
1032 0x000007c0, /* dst_mask */
1033 FALSE
), /* pcrel_offset */
1035 /* A 6 bit shift field. */
1036 HOWTO (R_MIPS_SHIFT6
, /* type */
1038 2, /* size (0 = byte, 1 = short, 2 = long) */
1040 FALSE
, /* pc_relative */
1042 complain_overflow_bitfield
, /* complain_on_overflow */
1043 mips_elf64_shift6_reloc
, /* special_function */
1044 "R_MIPS_SHIFT6", /* name */
1045 FALSE
, /* partial_inplace */
1047 0x000007c4, /* dst_mask */
1048 FALSE
), /* pcrel_offset */
1050 /* 64 bit relocation. */
1051 HOWTO (R_MIPS_64
, /* type */
1053 4, /* size (0 = byte, 1 = short, 2 = long) */
1055 FALSE
, /* pc_relative */
1057 complain_overflow_dont
, /* complain_on_overflow */
1058 _bfd_mips_elf_generic_reloc
, /* special_function */
1059 "R_MIPS_64", /* name */
1060 FALSE
, /* partial_inplace */
1062 MINUS_ONE
, /* dst_mask */
1063 FALSE
), /* pcrel_offset */
1065 /* Displacement in the global offset table. */
1066 HOWTO (R_MIPS_GOT_DISP
, /* type */
1068 2, /* size (0 = byte, 1 = short, 2 = long) */
1070 FALSE
, /* pc_relative */
1072 complain_overflow_signed
, /* complain_on_overflow */
1073 _bfd_mips_elf_generic_reloc
, /* special_function */
1074 "R_MIPS_GOT_DISP", /* name */
1075 FALSE
, /* partial_inplace */
1077 0x0000ffff, /* dst_mask */
1078 FALSE
), /* pcrel_offset */
1080 /* Displacement to page pointer in the global offset table. */
1081 HOWTO (R_MIPS_GOT_PAGE
, /* type */
1083 2, /* size (0 = byte, 1 = short, 2 = long) */
1085 FALSE
, /* pc_relative */
1087 complain_overflow_signed
, /* complain_on_overflow */
1088 _bfd_mips_elf_generic_reloc
, /* special_function */
1089 "R_MIPS_GOT_PAGE", /* name */
1090 FALSE
, /* partial_inplace */
1092 0x0000ffff, /* dst_mask */
1093 FALSE
), /* pcrel_offset */
1095 /* Offset from page pointer in the global offset table. */
1096 HOWTO (R_MIPS_GOT_OFST
, /* type */
1098 2, /* size (0 = byte, 1 = short, 2 = long) */
1100 FALSE
, /* pc_relative */
1102 complain_overflow_signed
, /* complain_on_overflow */
1103 _bfd_mips_elf_generic_reloc
, /* special_function */
1104 "R_MIPS_GOT_OFST", /* name */
1105 FALSE
, /* partial_inplace */
1107 0x0000ffff, /* dst_mask */
1108 FALSE
), /* pcrel_offset */
1110 /* High 16 bits of displacement in global offset table. */
1111 HOWTO (R_MIPS_GOT_HI16
, /* type */
1113 2, /* size (0 = byte, 1 = short, 2 = long) */
1115 FALSE
, /* pc_relative */
1117 complain_overflow_dont
, /* complain_on_overflow */
1118 _bfd_mips_elf_generic_reloc
, /* special_function */
1119 "R_MIPS_GOT_HI16", /* name */
1120 FALSE
, /* partial_inplace */
1122 0x0000ffff, /* dst_mask */
1123 FALSE
), /* pcrel_offset */
1125 /* Low 16 bits of displacement in global offset table. */
1126 HOWTO (R_MIPS_GOT_LO16
, /* type */
1128 2, /* size (0 = byte, 1 = short, 2 = long) */
1130 FALSE
, /* pc_relative */
1132 complain_overflow_dont
, /* complain_on_overflow */
1133 _bfd_mips_elf_generic_reloc
, /* special_function */
1134 "R_MIPS_GOT_LO16", /* name */
1135 FALSE
, /* partial_inplace */
1137 0x0000ffff, /* dst_mask */
1138 FALSE
), /* pcrel_offset */
1140 /* 64 bit subtraction. */
1141 HOWTO (R_MIPS_SUB
, /* type */
1143 4, /* size (0 = byte, 1 = short, 2 = long) */
1145 FALSE
, /* pc_relative */
1147 complain_overflow_dont
, /* complain_on_overflow */
1148 _bfd_mips_elf_generic_reloc
, /* special_function */
1149 "R_MIPS_SUB", /* name */
1150 FALSE
, /* partial_inplace */
1152 MINUS_ONE
, /* dst_mask */
1153 FALSE
), /* pcrel_offset */
1155 /* Insert the addend as an instruction. */
1156 /* FIXME: Not handled correctly. */
1157 HOWTO (R_MIPS_INSERT_A
, /* type */
1159 2, /* size (0 = byte, 1 = short, 2 = long) */
1161 FALSE
, /* pc_relative */
1163 complain_overflow_dont
, /* complain_on_overflow */
1164 _bfd_mips_elf_generic_reloc
, /* special_function */
1165 "R_MIPS_INSERT_A", /* name */
1166 FALSE
, /* partial_inplace */
1168 0xffffffff, /* dst_mask */
1169 FALSE
), /* pcrel_offset */
1171 /* Insert the addend as an instruction, and change all relocations
1172 to refer to the old instruction at the address. */
1173 /* FIXME: Not handled correctly. */
1174 HOWTO (R_MIPS_INSERT_B
, /* type */
1176 2, /* size (0 = byte, 1 = short, 2 = long) */
1178 FALSE
, /* pc_relative */
1180 complain_overflow_dont
, /* complain_on_overflow */
1181 _bfd_mips_elf_generic_reloc
, /* special_function */
1182 "R_MIPS_INSERT_B", /* name */
1183 FALSE
, /* partial_inplace */
1185 0xffffffff, /* dst_mask */
1186 FALSE
), /* pcrel_offset */
1188 /* Delete a 32 bit instruction. */
1189 /* FIXME: Not handled correctly. */
1190 HOWTO (R_MIPS_DELETE
, /* type */
1192 2, /* size (0 = byte, 1 = short, 2 = long) */
1194 FALSE
, /* pc_relative */
1196 complain_overflow_dont
, /* complain_on_overflow */
1197 _bfd_mips_elf_generic_reloc
, /* special_function */
1198 "R_MIPS_DELETE", /* name */
1199 FALSE
, /* partial_inplace */
1201 0xffffffff, /* dst_mask */
1202 FALSE
), /* pcrel_offset */
1204 /* Get the higher value of a 64 bit addend. */
1205 HOWTO (R_MIPS_HIGHER
, /* type */
1207 2, /* size (0 = byte, 1 = short, 2 = long) */
1209 FALSE
, /* pc_relative */
1211 complain_overflow_dont
, /* complain_on_overflow */
1212 _bfd_mips_elf_generic_reloc
, /* special_function */
1213 "R_MIPS_HIGHER", /* name */
1214 FALSE
, /* partial_inplace */
1216 0x0000ffff, /* dst_mask */
1217 FALSE
), /* pcrel_offset */
1219 /* Get the highest value of a 64 bit addend. */
1220 HOWTO (R_MIPS_HIGHEST
, /* type */
1222 2, /* size (0 = byte, 1 = short, 2 = long) */
1224 FALSE
, /* pc_relative */
1226 complain_overflow_dont
, /* complain_on_overflow */
1227 _bfd_mips_elf_generic_reloc
, /* special_function */
1228 "R_MIPS_HIGHEST", /* name */
1229 FALSE
, /* partial_inplace */
1231 0x0000ffff, /* dst_mask */
1232 FALSE
), /* pcrel_offset */
1234 /* High 16 bits of displacement in global offset table. */
1235 HOWTO (R_MIPS_CALL_HI16
, /* type */
1237 2, /* size (0 = byte, 1 = short, 2 = long) */
1239 FALSE
, /* pc_relative */
1241 complain_overflow_dont
, /* complain_on_overflow */
1242 _bfd_mips_elf_generic_reloc
, /* special_function */
1243 "R_MIPS_CALL_HI16", /* name */
1244 FALSE
, /* partial_inplace */
1246 0x0000ffff, /* dst_mask */
1247 FALSE
), /* pcrel_offset */
1249 /* Low 16 bits of displacement in global offset table. */
1250 HOWTO (R_MIPS_CALL_LO16
, /* type */
1252 2, /* size (0 = byte, 1 = short, 2 = long) */
1254 FALSE
, /* pc_relative */
1256 complain_overflow_dont
, /* complain_on_overflow */
1257 _bfd_mips_elf_generic_reloc
, /* special_function */
1258 "R_MIPS_CALL_LO16", /* name */
1259 FALSE
, /* partial_inplace */
1261 0x0000ffff, /* dst_mask */
1262 FALSE
), /* pcrel_offset */
1264 /* Section displacement, used by an associated event location section. */
1265 HOWTO (R_MIPS_SCN_DISP
, /* type */
1267 2, /* size (0 = byte, 1 = short, 2 = long) */
1269 FALSE
, /* pc_relative */
1271 complain_overflow_dont
, /* complain_on_overflow */
1272 _bfd_mips_elf_generic_reloc
, /* special_function */
1273 "R_MIPS_SCN_DISP", /* name */
1274 FALSE
, /* partial_inplace */
1276 0xffffffff, /* dst_mask */
1277 FALSE
), /* pcrel_offset */
1279 HOWTO (R_MIPS_REL16
, /* type */
1281 1, /* size (0 = byte, 1 = short, 2 = long) */
1283 FALSE
, /* pc_relative */
1285 complain_overflow_signed
, /* complain_on_overflow */
1286 _bfd_mips_elf_generic_reloc
, /* special_function */
1287 "R_MIPS_REL16", /* name */
1288 FALSE
, /* partial_inplace */
1290 0xffff, /* dst_mask */
1291 FALSE
), /* pcrel_offset */
1293 /* These two are obsolete. */
1294 EMPTY_HOWTO (R_MIPS_ADD_IMMEDIATE
),
1295 EMPTY_HOWTO (R_MIPS_PJUMP
),
1297 /* Similiar to R_MIPS_REL32, but used for relocations in a GOT section.
1298 It must be used for multigot GOT's (and only there). */
1299 HOWTO (R_MIPS_RELGOT
, /* type */
1301 2, /* size (0 = byte, 1 = short, 2 = long) */
1303 FALSE
, /* pc_relative */
1305 complain_overflow_dont
, /* complain_on_overflow */
1306 _bfd_mips_elf_generic_reloc
, /* special_function */
1307 "R_MIPS_RELGOT", /* name */
1308 FALSE
, /* partial_inplace */
1310 0xffffffff, /* dst_mask */
1311 FALSE
), /* pcrel_offset */
1313 /* Protected jump conversion. This is an optimization hint. No
1314 relocation is required for correctness. */
1315 HOWTO (R_MIPS_JALR
, /* type */
1317 2, /* size (0 = byte, 1 = short, 2 = long) */
1319 FALSE
, /* pc_relative */
1321 complain_overflow_dont
, /* complain_on_overflow */
1322 _bfd_mips_elf_generic_reloc
, /* special_function */
1323 "R_MIPS_JALR", /* name */
1324 FALSE
, /* partial_inplace */
1326 0x00000000, /* dst_mask */
1327 FALSE
), /* pcrel_offset */
1329 /* TLS relocations. */
1330 EMPTY_HOWTO (R_MIPS_TLS_DTPMOD32
),
1331 EMPTY_HOWTO (R_MIPS_TLS_DTPREL32
),
1333 HOWTO (R_MIPS_TLS_DTPMOD64
, /* type */
1335 4, /* size (0 = byte, 1 = short, 2 = long) */
1337 FALSE
, /* pc_relative */
1339 complain_overflow_dont
, /* complain_on_overflow */
1340 _bfd_mips_elf_generic_reloc
, /* special_function */
1341 "R_MIPS_TLS_DTPMOD64", /* name */
1342 FALSE
, /* partial_inplace */
1344 MINUS_ONE
, /* dst_mask */
1345 FALSE
), /* pcrel_offset */
1347 HOWTO (R_MIPS_TLS_DTPREL64
, /* type */
1349 4, /* size (0 = byte, 1 = short, 2 = long) */
1351 FALSE
, /* pc_relative */
1353 complain_overflow_dont
, /* complain_on_overflow */
1354 _bfd_mips_elf_generic_reloc
, /* special_function */
1355 "R_MIPS_TLS_DTPREL64", /* name */
1356 FALSE
, /* partial_inplace */
1358 MINUS_ONE
, /* dst_mask */
1359 FALSE
), /* pcrel_offset */
1361 /* TLS general dynamic variable reference. */
1362 HOWTO (R_MIPS_TLS_GD
, /* type */
1364 2, /* size (0 = byte, 1 = short, 2 = long) */
1366 FALSE
, /* pc_relative */
1368 complain_overflow_signed
, /* complain_on_overflow */
1369 _bfd_mips_elf_generic_reloc
, /* special_function */
1370 "R_MIPS_TLS_GD", /* name */
1371 FALSE
, /* partial_inplace */
1373 0x0000ffff, /* dst_mask */
1374 FALSE
), /* pcrel_offset */
1376 /* TLS local dynamic variable reference. */
1377 HOWTO (R_MIPS_TLS_LDM
, /* type */
1379 2, /* size (0 = byte, 1 = short, 2 = long) */
1381 FALSE
, /* pc_relative */
1383 complain_overflow_signed
, /* complain_on_overflow */
1384 _bfd_mips_elf_generic_reloc
, /* special_function */
1385 "R_MIPS_TLS_LDM", /* name */
1386 FALSE
, /* partial_inplace */
1388 0x0000ffff, /* dst_mask */
1389 FALSE
), /* pcrel_offset */
1391 /* TLS local dynamic offset. */
1392 HOWTO (R_MIPS_TLS_DTPREL_HI16
, /* type */
1394 2, /* size (0 = byte, 1 = short, 2 = long) */
1396 FALSE
, /* pc_relative */
1398 complain_overflow_signed
, /* complain_on_overflow */
1399 _bfd_mips_elf_generic_reloc
, /* special_function */
1400 "R_MIPS_TLS_DTPREL_HI16", /* name */
1401 FALSE
, /* partial_inplace */
1403 0x0000ffff, /* dst_mask */
1404 FALSE
), /* pcrel_offset */
1406 /* TLS local dynamic offset. */
1407 HOWTO (R_MIPS_TLS_DTPREL_LO16
, /* type */
1409 2, /* size (0 = byte, 1 = short, 2 = long) */
1411 FALSE
, /* pc_relative */
1413 complain_overflow_signed
, /* complain_on_overflow */
1414 _bfd_mips_elf_generic_reloc
, /* special_function */
1415 "R_MIPS_TLS_DTPREL_LO16", /* name */
1416 FALSE
, /* partial_inplace */
1418 0x0000ffff, /* dst_mask */
1419 FALSE
), /* pcrel_offset */
1421 /* TLS thread pointer offset. */
1422 HOWTO (R_MIPS_TLS_GOTTPREL
, /* 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_GOTTPREL", /* name */
1431 FALSE
, /* partial_inplace */
1433 0x0000ffff, /* dst_mask */
1434 FALSE
), /* pcrel_offset */
1436 /* TLS IE dynamic relocations. */
1437 EMPTY_HOWTO (R_MIPS_TLS_TPREL32
),
1439 HOWTO (R_MIPS_TLS_TPREL64
, /* type */
1441 4, /* size (0 = byte, 1 = short, 2 = long) */
1443 FALSE
, /* pc_relative */
1445 complain_overflow_dont
, /* complain_on_overflow */
1446 _bfd_mips_elf_generic_reloc
, /* special_function */
1447 "R_MIPS_TLS_TPREL64", /* name */
1448 FALSE
, /* partial_inplace */
1450 MINUS_ONE
, /* dst_mask */
1451 FALSE
), /* pcrel_offset */
1453 /* TLS thread pointer offset. */
1454 HOWTO (R_MIPS_TLS_TPREL_HI16
, /* type */
1456 2, /* size (0 = byte, 1 = short, 2 = long) */
1458 FALSE
, /* pc_relative */
1460 complain_overflow_signed
, /* complain_on_overflow */
1461 _bfd_mips_elf_generic_reloc
, /* special_function */
1462 "R_MIPS_TLS_TPREL_HI16", /* name */
1463 FALSE
, /* partial_inplace */
1465 0x0000ffff, /* dst_mask */
1466 FALSE
), /* pcrel_offset */
1468 /* TLS thread pointer offset. */
1469 HOWTO (R_MIPS_TLS_TPREL_LO16
, /* type */
1471 2, /* size (0 = byte, 1 = short, 2 = long) */
1473 FALSE
, /* pc_relative */
1475 complain_overflow_signed
, /* complain_on_overflow */
1476 _bfd_mips_elf_generic_reloc
, /* special_function */
1477 "R_MIPS_TLS_TPREL_LO16", /* name */
1478 FALSE
, /* partial_inplace */
1480 0x0000ffff, /* dst_mask */
1481 FALSE
), /* pcrel_offset */
1483 /* 32 bit relocation with no addend. */
1484 HOWTO (R_MIPS_GLOB_DAT
, /* type */
1486 2, /* size (0 = byte, 1 = short, 2 = long) */
1488 FALSE
, /* pc_relative */
1490 complain_overflow_dont
, /* complain_on_overflow */
1491 _bfd_mips_elf_generic_reloc
, /* special_function */
1492 "R_MIPS_GLOB_DAT", /* name */
1493 FALSE
, /* partial_inplace */
1495 0xffffffff, /* dst_mask */
1496 FALSE
), /* pcrel_offset */
1499 static reloc_howto_type mips16_elf64_howto_table_rel
[] =
1501 /* The reloc used for the mips16 jump instruction. */
1502 HOWTO (R_MIPS16_26
, /* type */
1504 2, /* size (0 = byte, 1 = short, 2 = long) */
1506 FALSE
, /* pc_relative */
1508 complain_overflow_dont
, /* complain_on_overflow */
1509 /* This needs complex overflow
1510 detection, because the upper four
1511 bits must match the PC. */
1512 _bfd_mips_elf_generic_reloc
, /* special_function */
1513 "R_MIPS16_26", /* name */
1514 TRUE
, /* partial_inplace */
1515 0x3ffffff, /* src_mask */
1516 0x3ffffff, /* dst_mask */
1517 FALSE
), /* pcrel_offset */
1519 /* The reloc used for the mips16 gprel instruction. */
1520 HOWTO (R_MIPS16_GPREL
, /* type */
1522 2, /* size (0 = byte, 1 = short, 2 = long) */
1524 FALSE
, /* pc_relative */
1526 complain_overflow_signed
, /* complain_on_overflow */
1527 mips16_gprel_reloc
, /* special_function */
1528 "R_MIPS16_GPREL", /* name */
1529 TRUE
, /* partial_inplace */
1530 0x0000ffff, /* src_mask */
1531 0x0000ffff, /* dst_mask */
1532 FALSE
), /* pcrel_offset */
1534 /* A MIPS16 reference to the global offset table. */
1535 HOWTO (R_MIPS16_GOT16
, /* type */
1537 2, /* size (0 = byte, 1 = short, 2 = long) */
1539 FALSE
, /* pc_relative */
1541 complain_overflow_dont
, /* complain_on_overflow */
1542 _bfd_mips_elf_got16_reloc
, /* special_function */
1543 "R_MIPS16_GOT16", /* name */
1544 TRUE
, /* partial_inplace */
1545 0x0000ffff, /* src_mask */
1546 0x0000ffff, /* dst_mask */
1547 FALSE
), /* pcrel_offset */
1549 /* A MIPS16 call through the global offset table. */
1550 HOWTO (R_MIPS16_CALL16
, /* type */
1552 2, /* size (0 = byte, 1 = short, 2 = long) */
1554 FALSE
, /* pc_relative */
1556 complain_overflow_dont
, /* complain_on_overflow */
1557 _bfd_mips_elf_generic_reloc
, /* special_function */
1558 "R_MIPS16_CALL16", /* name */
1559 TRUE
, /* partial_inplace */
1560 0x0000ffff, /* src_mask */
1561 0x0000ffff, /* dst_mask */
1562 FALSE
), /* pcrel_offset */
1564 /* MIPS16 high 16 bits of symbol value. */
1565 HOWTO (R_MIPS16_HI16
, /* type */
1566 16, /* rightshift */
1567 2, /* size (0 = byte, 1 = short, 2 = long) */
1569 FALSE
, /* pc_relative */
1571 complain_overflow_dont
, /* complain_on_overflow */
1572 _bfd_mips_elf_hi16_reloc
, /* special_function */
1573 "R_MIPS16_HI16", /* name */
1574 TRUE
, /* partial_inplace */
1575 0x0000ffff, /* src_mask */
1576 0x0000ffff, /* dst_mask */
1577 FALSE
), /* pcrel_offset */
1579 /* MIPS16 low 16 bits of symbol value. */
1580 HOWTO (R_MIPS16_LO16
, /* type */
1582 2, /* size (0 = byte, 1 = short, 2 = long) */
1584 FALSE
, /* pc_relative */
1586 complain_overflow_dont
, /* complain_on_overflow */
1587 _bfd_mips_elf_lo16_reloc
, /* special_function */
1588 "R_MIPS16_LO16", /* name */
1589 TRUE
, /* partial_inplace */
1590 0x0000ffff, /* src_mask */
1591 0x0000ffff, /* dst_mask */
1592 FALSE
), /* pcrel_offset */
1594 /* MIPS16 TLS general dynamic variable reference. */
1595 HOWTO (R_MIPS16_TLS_GD
, /* type */
1597 2, /* size (0 = byte, 1 = short, 2 = long) */
1599 FALSE
, /* pc_relative */
1601 complain_overflow_signed
, /* complain_on_overflow */
1602 _bfd_mips_elf_generic_reloc
, /* special_function */
1603 "R_MIPS16_TLS_GD", /* name */
1604 TRUE
, /* partial_inplace */
1605 0x0000ffff, /* src_mask */
1606 0x0000ffff, /* dst_mask */
1607 FALSE
), /* pcrel_offset */
1609 /* MIPS16 TLS local dynamic variable reference. */
1610 HOWTO (R_MIPS16_TLS_LDM
, /* type */
1612 2, /* size (0 = byte, 1 = short, 2 = long) */
1614 FALSE
, /* pc_relative */
1616 complain_overflow_signed
, /* complain_on_overflow */
1617 _bfd_mips_elf_generic_reloc
, /* special_function */
1618 "R_MIPS16_TLS_LDM", /* name */
1619 TRUE
, /* partial_inplace */
1620 0x0000ffff, /* src_mask */
1621 0x0000ffff, /* dst_mask */
1622 FALSE
), /* pcrel_offset */
1624 /* MIPS16 TLS local dynamic offset. */
1625 HOWTO (R_MIPS16_TLS_DTPREL_HI16
, /* type */
1627 2, /* size (0 = byte, 1 = short, 2 = long) */
1629 FALSE
, /* pc_relative */
1631 complain_overflow_signed
, /* complain_on_overflow */
1632 _bfd_mips_elf_generic_reloc
, /* special_function */
1633 "R_MIPS16_TLS_DTPREL_HI16", /* name */
1634 TRUE
, /* partial_inplace */
1635 0x0000ffff, /* src_mask */
1636 0x0000ffff, /* dst_mask */
1637 FALSE
), /* pcrel_offset */
1639 /* MIPS16 TLS local dynamic offset. */
1640 HOWTO (R_MIPS16_TLS_DTPREL_LO16
, /* type */
1642 2, /* size (0 = byte, 1 = short, 2 = long) */
1644 FALSE
, /* pc_relative */
1646 complain_overflow_signed
, /* complain_on_overflow */
1647 _bfd_mips_elf_generic_reloc
, /* special_function */
1648 "R_MIPS16_TLS_DTPREL_LO16", /* name */
1649 TRUE
, /* partial_inplace */
1650 0x0000ffff, /* src_mask */
1651 0x0000ffff, /* dst_mask */
1652 FALSE
), /* pcrel_offset */
1654 /* MIPS16 TLS thread pointer offset. */
1655 HOWTO (R_MIPS16_TLS_GOTTPREL
, /* type */
1657 2, /* size (0 = byte, 1 = short, 2 = long) */
1659 FALSE
, /* pc_relative */
1661 complain_overflow_signed
, /* complain_on_overflow */
1662 _bfd_mips_elf_generic_reloc
, /* special_function */
1663 "R_MIPS16_TLS_GOTTPREL", /* name */
1664 TRUE
, /* partial_inplace */
1665 0x0000ffff, /* src_mask */
1666 0x0000ffff, /* dst_mask */
1667 FALSE
), /* pcrel_offset */
1669 /* MIPS16 TLS thread pointer offset. */
1670 HOWTO (R_MIPS16_TLS_TPREL_HI16
, /* type */
1672 2, /* size (0 = byte, 1 = short, 2 = long) */
1674 FALSE
, /* pc_relative */
1676 complain_overflow_signed
, /* complain_on_overflow */
1677 _bfd_mips_elf_generic_reloc
, /* special_function */
1678 "R_MIPS16_TLS_TPREL_HI16", /* name */
1679 TRUE
, /* partial_inplace */
1680 0x0000ffff, /* src_mask */
1681 0x0000ffff, /* dst_mask */
1682 FALSE
), /* pcrel_offset */
1684 /* MIPS16 TLS thread pointer offset. */
1685 HOWTO (R_MIPS16_TLS_TPREL_LO16
, /* type */
1687 2, /* size (0 = byte, 1 = short, 2 = long) */
1689 FALSE
, /* pc_relative */
1691 complain_overflow_signed
, /* complain_on_overflow */
1692 _bfd_mips_elf_generic_reloc
, /* special_function */
1693 "R_MIPS16_TLS_TPREL_LO16", /* name */
1694 TRUE
, /* partial_inplace */
1695 0x0000ffff, /* src_mask */
1696 0x0000ffff, /* dst_mask */
1697 FALSE
), /* pcrel_offset */
1700 static reloc_howto_type mips16_elf64_howto_table_rela
[] =
1702 /* The reloc used for the mips16 jump instruction. */
1703 HOWTO (R_MIPS16_26
, /* type */
1705 2, /* size (0 = byte, 1 = short, 2 = long) */
1707 FALSE
, /* pc_relative */
1709 complain_overflow_dont
, /* complain_on_overflow */
1710 /* This needs complex overflow
1711 detection, because the upper four
1712 bits must match the PC. */
1713 _bfd_mips_elf_generic_reloc
, /* special_function */
1714 "R_MIPS16_26", /* name */
1715 FALSE
, /* partial_inplace */
1717 0x3ffffff, /* dst_mask */
1718 FALSE
), /* pcrel_offset */
1720 /* The reloc used for the mips16 gprel instruction. */
1721 HOWTO (R_MIPS16_GPREL
, /* type */
1723 2, /* size (0 = byte, 1 = short, 2 = long) */
1725 FALSE
, /* pc_relative */
1727 complain_overflow_signed
, /* complain_on_overflow */
1728 mips16_gprel_reloc
, /* special_function */
1729 "R_MIPS16_GPREL", /* name */
1730 FALSE
, /* partial_inplace */
1732 0x0000ffff, /* dst_mask */
1733 FALSE
), /* pcrel_offset */
1735 /* A MIPS16 reference to the global offset table. */
1736 HOWTO (R_MIPS16_GOT16
, /* type */
1738 2, /* size (0 = byte, 1 = short, 2 = long) */
1740 FALSE
, /* pc_relative */
1742 complain_overflow_dont
, /* complain_on_overflow */
1743 _bfd_mips_elf_got16_reloc
, /* special_function */
1744 "R_MIPS16_GOT16", /* name */
1745 FALSE
, /* partial_inplace */
1747 0x0000ffff, /* dst_mask */
1748 FALSE
), /* pcrel_offset */
1750 /* A MIPS16 call through the global offset table. */
1751 HOWTO (R_MIPS16_CALL16
, /* type */
1753 2, /* size (0 = byte, 1 = short, 2 = long) */
1755 FALSE
, /* pc_relative */
1757 complain_overflow_dont
, /* complain_on_overflow */
1758 _bfd_mips_elf_generic_reloc
, /* special_function */
1759 "R_MIPS16_CALL16", /* name */
1760 FALSE
, /* partial_inplace */
1762 0x0000ffff, /* dst_mask */
1763 FALSE
), /* pcrel_offset */
1765 /* MIPS16 high 16 bits of symbol value. */
1766 HOWTO (R_MIPS16_HI16
, /* type */
1767 16, /* rightshift */
1768 2, /* size (0 = byte, 1 = short, 2 = long) */
1770 FALSE
, /* pc_relative */
1772 complain_overflow_dont
, /* complain_on_overflow */
1773 _bfd_mips_elf_hi16_reloc
, /* special_function */
1774 "R_MIPS16_HI16", /* name */
1775 FALSE
, /* partial_inplace */
1777 0x0000ffff, /* dst_mask */
1778 FALSE
), /* pcrel_offset */
1780 /* MIPS16 low 16 bits of symbol value. */
1781 HOWTO (R_MIPS16_LO16
, /* type */
1783 2, /* size (0 = byte, 1 = short, 2 = long) */
1785 FALSE
, /* pc_relative */
1787 complain_overflow_dont
, /* complain_on_overflow */
1788 _bfd_mips_elf_lo16_reloc
, /* special_function */
1789 "R_MIPS16_LO16", /* name */
1790 FALSE
, /* partial_inplace */
1792 0x0000ffff, /* dst_mask */
1793 FALSE
), /* pcrel_offset */
1795 /* MIPS16 TLS general dynamic variable reference. */
1796 HOWTO (R_MIPS16_TLS_GD
, /* type */
1798 2, /* size (0 = byte, 1 = short, 2 = long) */
1800 FALSE
, /* pc_relative */
1802 complain_overflow_signed
, /* complain_on_overflow */
1803 _bfd_mips_elf_generic_reloc
, /* special_function */
1804 "R_MIPS16_TLS_GD", /* name */
1805 FALSE
, /* partial_inplace */
1807 0x0000ffff, /* dst_mask */
1808 FALSE
), /* pcrel_offset */
1810 /* MIPS16 TLS local dynamic variable reference. */
1811 HOWTO (R_MIPS16_TLS_LDM
, /* type */
1813 2, /* size (0 = byte, 1 = short, 2 = long) */
1815 FALSE
, /* pc_relative */
1817 complain_overflow_signed
, /* complain_on_overflow */
1818 _bfd_mips_elf_generic_reloc
, /* special_function */
1819 "R_MIPS16_TLS_LDM", /* name */
1820 FALSE
, /* partial_inplace */
1822 0x0000ffff, /* dst_mask */
1823 FALSE
), /* pcrel_offset */
1825 /* MIPS16 TLS local dynamic offset. */
1826 HOWTO (R_MIPS16_TLS_DTPREL_HI16
, /* type */
1828 2, /* size (0 = byte, 1 = short, 2 = long) */
1830 FALSE
, /* pc_relative */
1832 complain_overflow_signed
, /* complain_on_overflow */
1833 _bfd_mips_elf_generic_reloc
, /* special_function */
1834 "R_MIPS16_TLS_DTPREL_HI16", /* name */
1835 FALSE
, /* partial_inplace */
1837 0x0000ffff, /* dst_mask */
1838 FALSE
), /* pcrel_offset */
1840 /* MIPS16 TLS local dynamic offset. */
1841 HOWTO (R_MIPS16_TLS_DTPREL_LO16
, /* type */
1843 2, /* size (0 = byte, 1 = short, 2 = long) */
1845 FALSE
, /* pc_relative */
1847 complain_overflow_signed
, /* complain_on_overflow */
1848 _bfd_mips_elf_generic_reloc
, /* special_function */
1849 "R_MIPS16_TLS_DTPREL_LO16", /* name */
1850 FALSE
, /* partial_inplace */
1852 0x0000ffff, /* dst_mask */
1853 FALSE
), /* pcrel_offset */
1855 /* MIPS16 TLS thread pointer offset. */
1856 HOWTO (R_MIPS16_TLS_GOTTPREL
, /* type */
1858 2, /* size (0 = byte, 1 = short, 2 = long) */
1860 FALSE
, /* pc_relative */
1862 complain_overflow_signed
, /* complain_on_overflow */
1863 _bfd_mips_elf_generic_reloc
, /* special_function */
1864 "R_MIPS16_TLS_GOTTPREL", /* name */
1865 FALSE
, /* partial_inplace */
1867 0x0000ffff, /* dst_mask */
1868 FALSE
), /* pcrel_offset */
1870 /* MIPS16 TLS thread pointer offset. */
1871 HOWTO (R_MIPS16_TLS_TPREL_HI16
, /* type */
1873 2, /* size (0 = byte, 1 = short, 2 = long) */
1875 FALSE
, /* pc_relative */
1877 complain_overflow_signed
, /* complain_on_overflow */
1878 _bfd_mips_elf_generic_reloc
, /* special_function */
1879 "R_MIPS16_TLS_TPREL_HI16", /* name */
1880 FALSE
, /* partial_inplace */
1882 0x0000ffff, /* dst_mask */
1883 FALSE
), /* pcrel_offset */
1885 /* MIPS16 TLS thread pointer offset. */
1886 HOWTO (R_MIPS16_TLS_TPREL_LO16
, /* type */
1888 2, /* size (0 = byte, 1 = short, 2 = long) */
1890 FALSE
, /* pc_relative */
1892 complain_overflow_signed
, /* complain_on_overflow */
1893 _bfd_mips_elf_generic_reloc
, /* special_function */
1894 "R_MIPS16_TLS_TPREL_LO16", /* name */
1895 FALSE
, /* partial_inplace */
1897 0x0000ffff, /* dst_mask */
1898 FALSE
), /* pcrel_offset */
1901 static reloc_howto_type micromips_elf64_howto_table_rel
[] =
1907 /* 26 bit jump address. */
1908 HOWTO (R_MICROMIPS_26_S1
, /* type */
1910 2, /* size (0 = byte, 1 = short, 2 = long) */
1912 FALSE
, /* pc_relative */
1914 complain_overflow_dont
, /* complain_on_overflow */
1915 /* This needs complex overflow
1916 detection, because the upper four
1917 bits must match the PC. */
1918 _bfd_mips_elf_generic_reloc
, /* special_function */
1919 "R_MICROMIPS_26_S1", /* name */
1920 TRUE
, /* partial_inplace */
1921 0x3ffffff, /* src_mask */
1922 0x3ffffff, /* dst_mask */
1923 FALSE
), /* pcrel_offset */
1925 /* High 16 bits of symbol value. */
1926 HOWTO (R_MICROMIPS_HI16
, /* type */
1927 16, /* rightshift */
1928 2, /* size (0 = byte, 1 = short, 2 = long) */
1930 FALSE
, /* pc_relative */
1932 complain_overflow_dont
, /* complain_on_overflow */
1933 _bfd_mips_elf_hi16_reloc
, /* special_function */
1934 "R_MICROMIPS_HI16", /* name */
1935 TRUE
, /* partial_inplace */
1936 0x0000ffff, /* src_mask */
1937 0x0000ffff, /* dst_mask */
1938 FALSE
), /* pcrel_offset */
1940 /* Low 16 bits of symbol value. */
1941 HOWTO (R_MICROMIPS_LO16
, /* type */
1943 2, /* size (0 = byte, 1 = short, 2 = long) */
1945 FALSE
, /* pc_relative */
1947 complain_overflow_dont
, /* complain_on_overflow */
1948 _bfd_mips_elf_lo16_reloc
, /* special_function */
1949 "R_MICROMIPS_LO16", /* name */
1950 TRUE
, /* partial_inplace */
1951 0x0000ffff, /* src_mask */
1952 0x0000ffff, /* dst_mask */
1953 FALSE
), /* pcrel_offset */
1955 /* GP relative reference. */
1956 HOWTO (R_MICROMIPS_GPREL16
, /* type */
1958 2, /* size (0 = byte, 1 = short, 2 = long) */
1960 FALSE
, /* pc_relative */
1962 complain_overflow_signed
, /* complain_on_overflow */
1963 _bfd_mips_elf32_gprel16_reloc
, /* special_function */
1964 "R_MICROMIPS_GPREL16", /* name */
1965 TRUE
, /* partial_inplace */
1966 0x0000ffff, /* src_mask */
1967 0x0000ffff, /* dst_mask */
1968 FALSE
), /* pcrel_offset */
1970 /* Reference to literal section. */
1971 HOWTO (R_MICROMIPS_LITERAL
, /* type */
1973 2, /* size (0 = byte, 1 = short, 2 = long) */
1975 FALSE
, /* pc_relative */
1977 complain_overflow_signed
, /* complain_on_overflow */
1978 _bfd_mips_elf32_gprel16_reloc
, /* special_function */
1979 "R_MICROMIPS_LITERAL", /* name */
1980 TRUE
, /* partial_inplace */
1981 0x0000ffff, /* src_mask */
1982 0x0000ffff, /* dst_mask */
1983 FALSE
), /* pcrel_offset */
1985 /* Reference to global offset table. */
1986 HOWTO (R_MICROMIPS_GOT16
, /* type */
1988 2, /* size (0 = byte, 1 = short, 2 = long) */
1990 FALSE
, /* pc_relative */
1992 complain_overflow_signed
, /* complain_on_overflow */
1993 _bfd_mips_elf_got16_reloc
, /* special_function */
1994 "R_MICROMIPS_GOT16", /* name */
1995 TRUE
, /* partial_inplace */
1996 0x0000ffff, /* src_mask */
1997 0x0000ffff, /* dst_mask */
1998 FALSE
), /* pcrel_offset */
2000 /* This is for microMIPS branches. */
2001 HOWTO (R_MICROMIPS_PC7_S1
, /* type */
2003 1, /* size (0 = byte, 1 = short, 2 = long) */
2005 TRUE
, /* pc_relative */
2007 complain_overflow_signed
, /* complain_on_overflow */
2008 _bfd_mips_elf_generic_reloc
, /* special_function */
2009 "R_MICROMIPS_PC7_S1", /* name */
2010 TRUE
, /* partial_inplace */
2011 0x0000007f, /* src_mask */
2012 0x0000007f, /* dst_mask */
2013 TRUE
), /* pcrel_offset */
2015 HOWTO (R_MICROMIPS_PC10_S1
, /* type */
2017 1, /* size (0 = byte, 1 = short, 2 = long) */
2019 TRUE
, /* pc_relative */
2021 complain_overflow_signed
, /* complain_on_overflow */
2022 _bfd_mips_elf_generic_reloc
, /* special_function */
2023 "R_MICROMIPS_PC10_S1", /* name */
2024 TRUE
, /* partial_inplace */
2025 0x000003ff, /* src_mask */
2026 0x000003ff, /* dst_mask */
2027 TRUE
), /* pcrel_offset */
2029 HOWTO (R_MICROMIPS_PC16_S1
, /* type */
2031 2, /* size (0 = byte, 1 = short, 2 = long) */
2033 TRUE
, /* pc_relative */
2035 complain_overflow_signed
, /* complain_on_overflow */
2036 _bfd_mips_elf_generic_reloc
, /* special_function */
2037 "R_MICROMIPS_PC16_S1", /* name */
2038 TRUE
, /* partial_inplace */
2039 0x0000ffff, /* src_mask */
2040 0x0000ffff, /* dst_mask */
2041 TRUE
), /* pcrel_offset */
2043 /* 16 bit call through global offset table. */
2044 HOWTO (R_MICROMIPS_CALL16
, /* type */
2046 2, /* size (0 = byte, 1 = short, 2 = long) */
2048 FALSE
, /* pc_relative */
2050 complain_overflow_signed
, /* complain_on_overflow */
2051 _bfd_mips_elf_generic_reloc
, /* special_function */
2052 "R_MICROMIPS_CALL16", /* name */
2053 TRUE
, /* partial_inplace */
2054 0x0000ffff, /* src_mask */
2055 0x0000ffff, /* dst_mask */
2056 FALSE
), /* pcrel_offset */
2061 /* Displacement in the global offset table. */
2062 HOWTO (R_MICROMIPS_GOT_DISP
, /* type */
2064 2, /* size (0 = byte, 1 = short, 2 = long) */
2066 FALSE
, /* pc_relative */
2068 complain_overflow_signed
, /* complain_on_overflow */
2069 _bfd_mips_elf_generic_reloc
, /* special_function */
2070 "R_MICROMIPS_GOT_DISP",/* name */
2071 TRUE
, /* partial_inplace */
2072 0x0000ffff, /* src_mask */
2073 0x0000ffff, /* dst_mask */
2074 FALSE
), /* pcrel_offset */
2076 /* Displacement to page pointer in the global offset table. */
2077 HOWTO (R_MICROMIPS_GOT_PAGE
, /* type */
2079 2, /* size (0 = byte, 1 = short, 2 = long) */
2081 FALSE
, /* pc_relative */
2083 complain_overflow_signed
, /* complain_on_overflow */
2084 _bfd_mips_elf_generic_reloc
, /* special_function */
2085 "R_MICROMIPS_GOT_PAGE",/* name */
2086 TRUE
, /* partial_inplace */
2087 0x0000ffff, /* src_mask */
2088 0x0000ffff, /* dst_mask */
2089 FALSE
), /* pcrel_offset */
2091 /* Offset from page pointer in the global offset table. */
2092 HOWTO (R_MICROMIPS_GOT_OFST
, /* type */
2094 2, /* size (0 = byte, 1 = short, 2 = long) */
2096 FALSE
, /* pc_relative */
2098 complain_overflow_signed
, /* complain_on_overflow */
2099 _bfd_mips_elf_generic_reloc
, /* special_function */
2100 "R_MICROMIPS_GOT_OFST",/* name */
2101 TRUE
, /* partial_inplace */
2102 0x0000ffff, /* src_mask */
2103 0x0000ffff, /* dst_mask */
2104 FALSE
), /* pcrel_offset */
2106 /* High 16 bits of displacement in global offset table. */
2107 HOWTO (R_MICROMIPS_GOT_HI16
, /* type */
2109 2, /* size (0 = byte, 1 = short, 2 = long) */
2111 FALSE
, /* pc_relative */
2113 complain_overflow_dont
, /* complain_on_overflow */
2114 _bfd_mips_elf_generic_reloc
, /* special_function */
2115 "R_MICROMIPS_GOT_HI16",/* name */
2116 TRUE
, /* partial_inplace */
2117 0x0000ffff, /* src_mask */
2118 0x0000ffff, /* dst_mask */
2119 FALSE
), /* pcrel_offset */
2121 /* Low 16 bits of displacement in global offset table. */
2122 HOWTO (R_MICROMIPS_GOT_LO16
, /* type */
2124 2, /* size (0 = byte, 1 = short, 2 = long) */
2126 FALSE
, /* pc_relative */
2128 complain_overflow_dont
, /* complain_on_overflow */
2129 _bfd_mips_elf_generic_reloc
, /* special_function */
2130 "R_MICROMIPS_GOT_LO16",/* name */
2131 TRUE
, /* partial_inplace */
2132 0x0000ffff, /* src_mask */
2133 0x0000ffff, /* dst_mask */
2134 FALSE
), /* pcrel_offset */
2136 /* 64 bit subtraction. Used in the N32 ABI. */
2137 HOWTO (R_MICROMIPS_SUB
, /* type */
2139 4, /* size (0 = byte, 1 = short, 2 = long) */
2141 FALSE
, /* pc_relative */
2143 complain_overflow_dont
, /* complain_on_overflow */
2144 _bfd_mips_elf_generic_reloc
, /* special_function */
2145 "R_MICROMIPS_SUB", /* name */
2146 TRUE
, /* partial_inplace */
2147 MINUS_ONE
, /* src_mask */
2148 MINUS_ONE
, /* dst_mask */
2149 FALSE
), /* pcrel_offset */
2151 /* We don't support these for REL relocations, because it means building
2152 the addend from a R_MICROMIPS_HIGHEST/R_MICROMIPS_HIGHER/
2153 R_MICROMIPS_HI16/R_MICROMIPS_LO16 sequence with varying ordering,
2154 using fallable heuristics. */
2155 EMPTY_HOWTO (R_MICROMIPS_HIGHER
),
2156 EMPTY_HOWTO (R_MICROMIPS_HIGHEST
),
2158 /* High 16 bits of displacement in global offset table. */
2159 HOWTO (R_MICROMIPS_CALL_HI16
, /* type */
2161 2, /* size (0 = byte, 1 = short, 2 = long) */
2163 FALSE
, /* pc_relative */
2165 complain_overflow_dont
, /* complain_on_overflow */
2166 _bfd_mips_elf_generic_reloc
, /* special_function */
2167 "R_MICROMIPS_CALL_HI16",/* name */
2168 TRUE
, /* partial_inplace */
2169 0x0000ffff, /* src_mask */
2170 0x0000ffff, /* dst_mask */
2171 FALSE
), /* pcrel_offset */
2173 /* Low 16 bits of displacement in global offset table. */
2174 HOWTO (R_MICROMIPS_CALL_LO16
, /* type */
2176 2, /* size (0 = byte, 1 = short, 2 = long) */
2178 FALSE
, /* pc_relative */
2180 complain_overflow_dont
, /* complain_on_overflow */
2181 _bfd_mips_elf_generic_reloc
, /* special_function */
2182 "R_MICROMIPS_CALL_LO16",/* name */
2183 TRUE
, /* partial_inplace */
2184 0x0000ffff, /* src_mask */
2185 0x0000ffff, /* dst_mask */
2186 FALSE
), /* pcrel_offset */
2188 /* Section displacement. */
2189 HOWTO (R_MICROMIPS_SCN_DISP
, /* type */
2191 2, /* size (0 = byte, 1 = short, 2 = long) */
2193 FALSE
, /* pc_relative */
2195 complain_overflow_dont
, /* complain_on_overflow */
2196 _bfd_mips_elf_generic_reloc
, /* special_function */
2197 "R_MICROMIPS_SCN_DISP", /* name */
2198 TRUE
, /* partial_inplace */
2199 0xffffffff, /* src_mask */
2200 0xffffffff, /* dst_mask */
2201 FALSE
), /* pcrel_offset */
2203 /* Protected jump conversion. This is an optimization hint. No
2204 relocation is required for correctness. */
2205 HOWTO (R_MICROMIPS_JALR
, /* type */
2207 2, /* size (0 = byte, 1 = short, 2 = long) */
2209 FALSE
, /* pc_relative */
2211 complain_overflow_dont
, /* complain_on_overflow */
2212 _bfd_mips_elf_generic_reloc
, /* special_function */
2213 "R_MICROMIPS_JALR", /* name */
2214 FALSE
, /* partial_inplace */
2216 0x00000000, /* dst_mask */
2217 FALSE
), /* pcrel_offset */
2220 static reloc_howto_type micromips_elf64_howto_table_rela
[] =
2226 /* 26 bit jump address. */
2227 HOWTO (R_MICROMIPS_26_S1
, /* type */
2229 2, /* size (0 = byte, 1 = short, 2 = long) */
2231 FALSE
, /* pc_relative */
2233 complain_overflow_dont
, /* complain_on_overflow */
2234 /* This needs complex overflow
2235 detection, because the upper four
2236 bits must match the PC. */
2237 _bfd_mips_elf_generic_reloc
, /* special_function */
2238 "R_MICROMIPS_26_S1", /* name */
2239 FALSE
, /* partial_inplace */
2241 0x3ffffff, /* dst_mask */
2242 FALSE
), /* pcrel_offset */
2244 /* High 16 bits of symbol value. */
2245 HOWTO (R_MICROMIPS_HI16
, /* type */
2246 16, /* rightshift */
2247 2, /* size (0 = byte, 1 = short, 2 = long) */
2249 FALSE
, /* pc_relative */
2251 complain_overflow_dont
, /* complain_on_overflow */
2252 _bfd_mips_elf_hi16_reloc
, /* special_function */
2253 "R_MICROMIPS_HI16", /* name */
2254 FALSE
, /* partial_inplace */
2256 0x0000ffff, /* dst_mask */
2257 FALSE
), /* pcrel_offset */
2259 /* Low 16 bits of symbol value. */
2260 HOWTO (R_MICROMIPS_LO16
, /* type */
2262 2, /* size (0 = byte, 1 = short, 2 = long) */
2264 FALSE
, /* pc_relative */
2266 complain_overflow_dont
, /* complain_on_overflow */
2267 _bfd_mips_elf_lo16_reloc
, /* special_function */
2268 "R_MICROMIPS_LO16", /* name */
2269 FALSE
, /* partial_inplace */
2271 0x0000ffff, /* dst_mask */
2272 FALSE
), /* pcrel_offset */
2274 /* GP relative reference. */
2275 HOWTO (R_MICROMIPS_GPREL16
, /* type */
2277 2, /* size (0 = byte, 1 = short, 2 = long) */
2279 FALSE
, /* pc_relative */
2281 complain_overflow_signed
, /* complain_on_overflow */
2282 _bfd_mips_elf32_gprel16_reloc
, /* special_function */
2283 "R_MICROMIPS_GPREL16", /* name */
2284 FALSE
, /* partial_inplace */
2286 0x0000ffff, /* dst_mask */
2287 FALSE
), /* pcrel_offset */
2289 /* Reference to literal section. */
2290 HOWTO (R_MICROMIPS_LITERAL
, /* type */
2292 2, /* size (0 = byte, 1 = short, 2 = long) */
2294 FALSE
, /* pc_relative */
2296 complain_overflow_signed
, /* complain_on_overflow */
2297 _bfd_mips_elf32_gprel16_reloc
, /* special_function */
2298 "R_MICROMIPS_LITERAL", /* name */
2299 FALSE
, /* partial_inplace */
2301 0x0000ffff, /* dst_mask */
2302 FALSE
), /* pcrel_offset */
2304 /* Reference to global offset table. */
2305 HOWTO (R_MICROMIPS_GOT16
, /* type */
2307 2, /* size (0 = byte, 1 = short, 2 = long) */
2309 FALSE
, /* pc_relative */
2311 complain_overflow_signed
, /* complain_on_overflow */
2312 _bfd_mips_elf_got16_reloc
, /* special_function */
2313 "R_MICROMIPS_GOT16", /* name */
2314 FALSE
, /* partial_inplace */
2316 0x0000ffff, /* dst_mask */
2317 FALSE
), /* pcrel_offset */
2319 /* This is for microMIPS branches. */
2320 HOWTO (R_MICROMIPS_PC7_S1
, /* type */
2322 1, /* size (0 = byte, 1 = short, 2 = long) */
2324 TRUE
, /* pc_relative */
2326 complain_overflow_signed
, /* complain_on_overflow */
2327 _bfd_mips_elf_generic_reloc
, /* special_function */
2328 "R_MICROMIPS_PC7_S1", /* name */
2329 FALSE
, /* partial_inplace */
2331 0x0000007f, /* dst_mask */
2332 TRUE
), /* pcrel_offset */
2334 HOWTO (R_MICROMIPS_PC10_S1
, /* type */
2336 1, /* size (0 = byte, 1 = short, 2 = long) */
2338 TRUE
, /* pc_relative */
2340 complain_overflow_signed
, /* complain_on_overflow */
2341 _bfd_mips_elf_generic_reloc
, /* special_function */
2342 "R_MICROMIPS_PC10_S1", /* name */
2343 FALSE
, /* partial_inplace */
2345 0x000003ff, /* dst_mask */
2346 TRUE
), /* pcrel_offset */
2348 HOWTO (R_MICROMIPS_PC16_S1
, /* type */
2350 2, /* size (0 = byte, 1 = short, 2 = long) */
2352 TRUE
, /* pc_relative */
2354 complain_overflow_signed
, /* complain_on_overflow */
2355 _bfd_mips_elf_generic_reloc
, /* special_function */
2356 "R_MICROMIPS_PC16_S1", /* name */
2357 FALSE
, /* partial_inplace */
2359 0x0000ffff, /* dst_mask */
2360 TRUE
), /* pcrel_offset */
2362 /* 16 bit call through global offset table. */
2363 HOWTO (R_MICROMIPS_CALL16
, /* type */
2365 2, /* size (0 = byte, 1 = short, 2 = long) */
2367 FALSE
, /* pc_relative */
2369 complain_overflow_signed
, /* complain_on_overflow */
2370 _bfd_mips_elf_generic_reloc
, /* special_function */
2371 "R_MICROMIPS_CALL16", /* name */
2372 FALSE
, /* partial_inplace */
2374 0x0000ffff, /* dst_mask */
2375 FALSE
), /* pcrel_offset */
2380 /* Displacement in the global offset table. */
2381 HOWTO (R_MICROMIPS_GOT_DISP
, /* type */
2383 2, /* size (0 = byte, 1 = short, 2 = long) */
2385 FALSE
, /* pc_relative */
2387 complain_overflow_signed
, /* complain_on_overflow */
2388 _bfd_mips_elf_generic_reloc
, /* special_function */
2389 "R_MICROMIPS_GOT_DISP",/* name */
2390 FALSE
, /* partial_inplace */
2392 0x0000ffff, /* dst_mask */
2393 FALSE
), /* pcrel_offset */
2395 /* Displacement to page pointer in the global offset table. */
2396 HOWTO (R_MICROMIPS_GOT_PAGE
, /* type */
2398 2, /* size (0 = byte, 1 = short, 2 = long) */
2400 FALSE
, /* pc_relative */
2402 complain_overflow_signed
, /* complain_on_overflow */
2403 _bfd_mips_elf_generic_reloc
, /* special_function */
2404 "R_MICROMIPS_GOT_PAGE",/* name */
2405 FALSE
, /* partial_inplace */
2407 0x0000ffff, /* dst_mask */
2408 FALSE
), /* pcrel_offset */
2410 /* Offset from page pointer in the global offset table. */
2411 HOWTO (R_MICROMIPS_GOT_OFST
, /* type */
2413 2, /* size (0 = byte, 1 = short, 2 = long) */
2415 FALSE
, /* pc_relative */
2417 complain_overflow_signed
, /* complain_on_overflow */
2418 _bfd_mips_elf_generic_reloc
, /* special_function */
2419 "R_MICROMIPS_GOT_OFST",/* name */
2420 FALSE
, /* partial_inplace */
2422 0x0000ffff, /* dst_mask */
2423 FALSE
), /* pcrel_offset */
2425 /* High 16 bits of displacement in global offset table. */
2426 HOWTO (R_MICROMIPS_GOT_HI16
, /* type */
2428 2, /* size (0 = byte, 1 = short, 2 = long) */
2430 FALSE
, /* pc_relative */
2432 complain_overflow_dont
, /* complain_on_overflow */
2433 _bfd_mips_elf_generic_reloc
, /* special_function */
2434 "R_MICROMIPS_GOT_HI16",/* name */
2435 FALSE
, /* partial_inplace */
2437 0x0000ffff, /* dst_mask */
2438 FALSE
), /* pcrel_offset */
2440 /* Low 16 bits of displacement in global offset table. */
2441 HOWTO (R_MICROMIPS_GOT_LO16
, /* type */
2443 2, /* size (0 = byte, 1 = short, 2 = long) */
2445 FALSE
, /* pc_relative */
2447 complain_overflow_dont
, /* complain_on_overflow */
2448 _bfd_mips_elf_generic_reloc
, /* special_function */
2449 "R_MICROMIPS_GOT_LO16",/* name */
2450 FALSE
, /* partial_inplace */
2452 0x0000ffff, /* dst_mask */
2453 FALSE
), /* pcrel_offset */
2455 /* 64 bit subtraction. Used in the N32 ABI. */
2456 HOWTO (R_MICROMIPS_SUB
, /* type */
2458 4, /* size (0 = byte, 1 = short, 2 = long) */
2460 FALSE
, /* pc_relative */
2462 complain_overflow_dont
, /* complain_on_overflow */
2463 _bfd_mips_elf_generic_reloc
, /* special_function */
2464 "R_MICROMIPS_SUB", /* name */
2465 FALSE
, /* partial_inplace */
2467 MINUS_ONE
, /* dst_mask */
2468 FALSE
), /* pcrel_offset */
2470 /* Get the higher value of a 64 bit addend. */
2471 HOWTO (R_MICROMIPS_HIGHER
, /* type */
2473 2, /* size (0 = byte, 1 = short, 2 = long) */
2475 FALSE
, /* pc_relative */
2477 complain_overflow_dont
, /* complain_on_overflow */
2478 _bfd_mips_elf_generic_reloc
, /* special_function */
2479 "R_MICROMIPS_HIGHER", /* name */
2480 FALSE
, /* partial_inplace */
2482 0x0000ffff, /* dst_mask */
2483 FALSE
), /* pcrel_offset */
2485 /* Get the highest value of a 64 bit addend. */
2486 HOWTO (R_MICROMIPS_HIGHEST
, /* type */
2488 2, /* size (0 = byte, 1 = short, 2 = long) */
2490 FALSE
, /* pc_relative */
2492 complain_overflow_dont
, /* complain_on_overflow */
2493 _bfd_mips_elf_generic_reloc
, /* special_function */
2494 "R_MICROMIPS_HIGHEST", /* name */
2495 FALSE
, /* partial_inplace */
2497 0x0000ffff, /* dst_mask */
2498 FALSE
), /* pcrel_offset */
2500 /* High 16 bits of displacement in global offset table. */
2501 HOWTO (R_MICROMIPS_CALL_HI16
, /* type */
2503 2, /* size (0 = byte, 1 = short, 2 = long) */
2505 FALSE
, /* pc_relative */
2507 complain_overflow_dont
, /* complain_on_overflow */
2508 _bfd_mips_elf_generic_reloc
, /* special_function */
2509 "R_MICROMIPS_CALL_HI16",/* name */
2510 FALSE
, /* partial_inplace */
2512 0x0000ffff, /* dst_mask */
2513 FALSE
), /* pcrel_offset */
2515 /* Low 16 bits of displacement in global offset table. */
2516 HOWTO (R_MICROMIPS_CALL_LO16
, /* type */
2518 2, /* size (0 = byte, 1 = short, 2 = long) */
2520 FALSE
, /* pc_relative */
2522 complain_overflow_dont
, /* complain_on_overflow */
2523 _bfd_mips_elf_generic_reloc
, /* special_function */
2524 "R_MICROMIPS_CALL_LO16",/* name */
2525 FALSE
, /* partial_inplace */
2527 0x0000ffff, /* dst_mask */
2528 FALSE
), /* pcrel_offset */
2530 /* Section displacement. */
2531 HOWTO (R_MICROMIPS_SCN_DISP
, /* type */
2533 2, /* size (0 = byte, 1 = short, 2 = long) */
2535 FALSE
, /* pc_relative */
2537 complain_overflow_dont
, /* complain_on_overflow */
2538 _bfd_mips_elf_generic_reloc
, /* special_function */
2539 "R_MICROMIPS_SCN_DISP", /* name */
2540 FALSE
, /* partial_inplace */
2542 0xffffffff, /* dst_mask */
2543 FALSE
), /* pcrel_offset */
2545 /* Protected jump conversion. This is an optimization hint. No
2546 relocation is required for correctness. */
2547 HOWTO (R_MICROMIPS_JALR
, /* type */
2549 2, /* size (0 = byte, 1 = short, 2 = long) */
2551 FALSE
, /* pc_relative */
2553 complain_overflow_dont
, /* complain_on_overflow */
2554 _bfd_mips_elf_generic_reloc
, /* special_function */
2555 "R_MICROMIPS_JALR", /* name */
2556 FALSE
, /* partial_inplace */
2558 0x00000000, /* dst_mask */
2559 FALSE
), /* pcrel_offset */
2562 /* GNU extension to record C++ vtable hierarchy */
2563 static reloc_howto_type elf_mips_gnu_vtinherit_howto
=
2564 HOWTO (R_MIPS_GNU_VTINHERIT
, /* type */
2566 2, /* size (0 = byte, 1 = short, 2 = long) */
2568 FALSE
, /* pc_relative */
2570 complain_overflow_dont
, /* complain_on_overflow */
2571 NULL
, /* special_function */
2572 "R_MIPS_GNU_VTINHERIT", /* name */
2573 FALSE
, /* partial_inplace */
2576 FALSE
); /* pcrel_offset */
2578 /* GNU extension to record C++ vtable member usage */
2579 static reloc_howto_type elf_mips_gnu_vtentry_howto
=
2580 HOWTO (R_MIPS_GNU_VTENTRY
, /* type */
2582 2, /* size (0 = byte, 1 = short, 2 = long) */
2584 FALSE
, /* pc_relative */
2586 complain_overflow_dont
, /* complain_on_overflow */
2587 _bfd_elf_rel_vtable_reloc_fn
, /* special_function */
2588 "R_MIPS_GNU_VTENTRY", /* name */
2589 FALSE
, /* partial_inplace */
2592 FALSE
); /* pcrel_offset */
2594 /* 16 bit offset for pc-relative branches. */
2595 static reloc_howto_type elf_mips_gnu_rel16_s2
=
2596 HOWTO (R_MIPS_GNU_REL16_S2
, /* type */
2598 2, /* size (0 = byte, 1 = short, 2 = long) */
2600 TRUE
, /* pc_relative */
2602 complain_overflow_signed
, /* complain_on_overflow */
2603 _bfd_mips_elf_generic_reloc
, /* special_function */
2604 "R_MIPS_GNU_REL16_S2", /* name */
2605 TRUE
, /* partial_inplace */
2606 0x0000ffff, /* src_mask */
2607 0x0000ffff, /* dst_mask */
2608 TRUE
); /* pcrel_offset */
2610 /* 16 bit offset for pc-relative branches. */
2611 static reloc_howto_type elf_mips_gnu_rela16_s2
=
2612 HOWTO (R_MIPS_GNU_REL16_S2
, /* type */
2614 2, /* size (0 = byte, 1 = short, 2 = long) */
2616 TRUE
, /* pc_relative */
2618 complain_overflow_signed
, /* complain_on_overflow */
2619 _bfd_mips_elf_generic_reloc
, /* special_function */
2620 "R_MIPS_GNU_REL16_S2", /* name */
2621 FALSE
, /* partial_inplace */
2623 0x0000ffff, /* dst_mask */
2624 TRUE
); /* pcrel_offset */
2626 /* 32 bit pc-relative. Used for compact EH tables. */
2627 static reloc_howto_type elf_mips_gnu_pcrel32
=
2628 HOWTO (R_MIPS_PC32
, /* type */
2630 2, /* size (0 = byte, 1 = short, 2 = long) */
2632 TRUE
, /* pc_relative */
2634 complain_overflow_signed
, /* complain_on_overflow */
2635 _bfd_mips_elf_generic_reloc
, /* special_function */
2636 "R_MIPS_PC32", /* name */
2637 TRUE
, /* partial_inplace */
2638 0xffffffff, /* src_mask */
2639 0xffffffff, /* dst_mask */
2640 TRUE
); /* pcrel_offset */
2643 /* Originally a VxWorks extension, but now used for other systems too. */
2644 static reloc_howto_type elf_mips_copy_howto
=
2645 HOWTO (R_MIPS_COPY
, /* type */
2647 0, /* this one is variable size */
2649 FALSE
, /* pc_relative */
2651 complain_overflow_bitfield
, /* complain_on_overflow */
2652 _bfd_mips_elf_generic_reloc
, /* special_function */
2653 "R_MIPS_COPY", /* name */
2654 FALSE
, /* partial_inplace */
2657 FALSE
); /* pcrel_offset */
2659 /* Originally a VxWorks extension, but now used for other systems too. */
2660 static reloc_howto_type elf_mips_jump_slot_howto
=
2661 HOWTO (R_MIPS_JUMP_SLOT
, /* type */
2663 4, /* size (0 = byte, 1 = short, 2 = long) */
2665 FALSE
, /* pc_relative */
2667 complain_overflow_bitfield
, /* complain_on_overflow */
2668 _bfd_mips_elf_generic_reloc
, /* special_function */
2669 "R_MIPS_JUMP_SLOT", /* name */
2670 FALSE
, /* partial_inplace */
2673 FALSE
); /* pcrel_offset */
2675 /* Used in EH tables. */
2676 static reloc_howto_type elf_mips_eh_howto
=
2677 HOWTO (R_MIPS_EH
, /* type */
2679 2, /* size (0 = byte, 1 = short, 2 = long) */
2681 FALSE
, /* pc_relative */
2683 complain_overflow_signed
, /* complain_on_overflow */
2684 _bfd_mips_elf_generic_reloc
, /* special_function */
2685 "R_MIPS_EH", /* name */
2686 TRUE
, /* partial_inplace */
2687 0xffffffff, /* src_mask */
2688 0xffffffff, /* dst_mask */
2689 FALSE
); /* pcrel_offset */
2692 /* Swap in a MIPS 64-bit Rel reloc. */
2695 mips_elf64_swap_reloc_in (bfd
*abfd
, const Elf64_Mips_External_Rel
*src
,
2696 Elf64_Mips_Internal_Rela
*dst
)
2698 dst
->r_offset
= H_GET_64 (abfd
, src
->r_offset
);
2699 dst
->r_sym
= H_GET_32 (abfd
, src
->r_sym
);
2700 dst
->r_ssym
= H_GET_8 (abfd
, src
->r_ssym
);
2701 dst
->r_type3
= H_GET_8 (abfd
, src
->r_type3
);
2702 dst
->r_type2
= H_GET_8 (abfd
, src
->r_type2
);
2703 dst
->r_type
= H_GET_8 (abfd
, src
->r_type
);
2707 /* Swap in a MIPS 64-bit Rela reloc. */
2710 mips_elf64_swap_reloca_in (bfd
*abfd
, const Elf64_Mips_External_Rela
*src
,
2711 Elf64_Mips_Internal_Rela
*dst
)
2713 dst
->r_offset
= H_GET_64 (abfd
, src
->r_offset
);
2714 dst
->r_sym
= H_GET_32 (abfd
, src
->r_sym
);
2715 dst
->r_ssym
= H_GET_8 (abfd
, src
->r_ssym
);
2716 dst
->r_type3
= H_GET_8 (abfd
, src
->r_type3
);
2717 dst
->r_type2
= H_GET_8 (abfd
, src
->r_type2
);
2718 dst
->r_type
= H_GET_8 (abfd
, src
->r_type
);
2719 dst
->r_addend
= H_GET_S64 (abfd
, src
->r_addend
);
2722 /* Swap out a MIPS 64-bit Rel reloc. */
2725 mips_elf64_swap_reloc_out (bfd
*abfd
, const Elf64_Mips_Internal_Rela
*src
,
2726 Elf64_Mips_External_Rel
*dst
)
2728 H_PUT_64 (abfd
, src
->r_offset
, dst
->r_offset
);
2729 H_PUT_32 (abfd
, src
->r_sym
, dst
->r_sym
);
2730 H_PUT_8 (abfd
, src
->r_ssym
, dst
->r_ssym
);
2731 H_PUT_8 (abfd
, src
->r_type3
, dst
->r_type3
);
2732 H_PUT_8 (abfd
, src
->r_type2
, dst
->r_type2
);
2733 H_PUT_8 (abfd
, src
->r_type
, dst
->r_type
);
2736 /* Swap out a MIPS 64-bit Rela reloc. */
2739 mips_elf64_swap_reloca_out (bfd
*abfd
, const Elf64_Mips_Internal_Rela
*src
,
2740 Elf64_Mips_External_Rela
*dst
)
2742 H_PUT_64 (abfd
, src
->r_offset
, dst
->r_offset
);
2743 H_PUT_32 (abfd
, src
->r_sym
, dst
->r_sym
);
2744 H_PUT_8 (abfd
, src
->r_ssym
, dst
->r_ssym
);
2745 H_PUT_8 (abfd
, src
->r_type3
, dst
->r_type3
);
2746 H_PUT_8 (abfd
, src
->r_type2
, dst
->r_type2
);
2747 H_PUT_8 (abfd
, src
->r_type
, dst
->r_type
);
2748 H_PUT_S64 (abfd
, src
->r_addend
, dst
->r_addend
);
2751 /* Swap in a MIPS 64-bit Rel reloc. */
2754 mips_elf64_be_swap_reloc_in (bfd
*abfd
, const bfd_byte
*src
,
2755 Elf_Internal_Rela
*dst
)
2757 Elf64_Mips_Internal_Rela mirel
;
2759 mips_elf64_swap_reloc_in (abfd
,
2760 (const Elf64_Mips_External_Rel
*) src
,
2763 dst
[0].r_offset
= mirel
.r_offset
;
2764 dst
[0].r_info
= ELF64_R_INFO (mirel
.r_sym
, mirel
.r_type
);
2765 dst
[0].r_addend
= 0;
2766 dst
[1].r_offset
= mirel
.r_offset
;
2767 dst
[1].r_info
= ELF64_R_INFO (mirel
.r_ssym
, mirel
.r_type2
);
2768 dst
[1].r_addend
= 0;
2769 dst
[2].r_offset
= mirel
.r_offset
;
2770 dst
[2].r_info
= ELF64_R_INFO (STN_UNDEF
, mirel
.r_type3
);
2771 dst
[2].r_addend
= 0;
2774 /* Swap in a MIPS 64-bit Rela reloc. */
2777 mips_elf64_be_swap_reloca_in (bfd
*abfd
, const bfd_byte
*src
,
2778 Elf_Internal_Rela
*dst
)
2780 Elf64_Mips_Internal_Rela mirela
;
2782 mips_elf64_swap_reloca_in (abfd
,
2783 (const Elf64_Mips_External_Rela
*) src
,
2786 dst
[0].r_offset
= mirela
.r_offset
;
2787 dst
[0].r_info
= ELF64_R_INFO (mirela
.r_sym
, mirela
.r_type
);
2788 dst
[0].r_addend
= mirela
.r_addend
;
2789 dst
[1].r_offset
= mirela
.r_offset
;
2790 dst
[1].r_info
= ELF64_R_INFO (mirela
.r_ssym
, mirela
.r_type2
);
2791 dst
[1].r_addend
= 0;
2792 dst
[2].r_offset
= mirela
.r_offset
;
2793 dst
[2].r_info
= ELF64_R_INFO (STN_UNDEF
, mirela
.r_type3
);
2794 dst
[2].r_addend
= 0;
2797 /* Swap out a MIPS 64-bit Rel reloc. */
2800 mips_elf64_be_swap_reloc_out (bfd
*abfd
, const Elf_Internal_Rela
*src
,
2803 Elf64_Mips_Internal_Rela mirel
;
2805 mirel
.r_offset
= src
[0].r_offset
;
2806 BFD_ASSERT(src
[0].r_offset
== src
[1].r_offset
);
2807 BFD_ASSERT(src
[0].r_offset
== src
[2].r_offset
);
2809 mirel
.r_type
= ELF64_MIPS_R_TYPE (src
[0].r_info
);
2810 mirel
.r_sym
= ELF64_R_SYM (src
[0].r_info
);
2811 mirel
.r_type2
= ELF64_MIPS_R_TYPE (src
[1].r_info
);
2812 mirel
.r_ssym
= ELF64_MIPS_R_SSYM (src
[1].r_info
);
2813 mirel
.r_type3
= ELF64_MIPS_R_TYPE (src
[2].r_info
);
2815 mips_elf64_swap_reloc_out (abfd
, &mirel
,
2816 (Elf64_Mips_External_Rel
*) dst
);
2819 /* Swap out a MIPS 64-bit Rela reloc. */
2822 mips_elf64_be_swap_reloca_out (bfd
*abfd
, const Elf_Internal_Rela
*src
,
2825 Elf64_Mips_Internal_Rela mirela
;
2827 mirela
.r_offset
= src
[0].r_offset
;
2828 BFD_ASSERT(src
[0].r_offset
== src
[1].r_offset
);
2829 BFD_ASSERT(src
[0].r_offset
== src
[2].r_offset
);
2831 mirela
.r_type
= ELF64_MIPS_R_TYPE (src
[0].r_info
);
2832 mirela
.r_sym
= ELF64_R_SYM (src
[0].r_info
);
2833 mirela
.r_addend
= src
[0].r_addend
;
2834 BFD_ASSERT(src
[1].r_addend
== 0);
2835 BFD_ASSERT(src
[2].r_addend
== 0);
2837 mirela
.r_type2
= ELF64_MIPS_R_TYPE (src
[1].r_info
);
2838 mirela
.r_ssym
= ELF64_MIPS_R_SSYM (src
[1].r_info
);
2839 mirela
.r_type3
= ELF64_MIPS_R_TYPE (src
[2].r_info
);
2841 mips_elf64_swap_reloca_out (abfd
, &mirela
,
2842 (Elf64_Mips_External_Rela
*) dst
);
2845 /* Set the GP value for OUTPUT_BFD. Returns FALSE if this is a
2846 dangerous relocation. */
2849 mips_elf64_assign_gp (bfd
*output_bfd
, bfd_vma
*pgp
)
2855 /* If we've already figured out what GP will be, just return it. */
2856 *pgp
= _bfd_get_gp_value (output_bfd
);
2860 count
= bfd_get_symcount (output_bfd
);
2861 sym
= bfd_get_outsymbols (output_bfd
);
2863 /* The linker script will have created a symbol named `_gp' with the
2864 appropriate value. */
2869 for (i
= 0; i
< count
; i
++, sym
++)
2871 register const char *name
;
2873 name
= bfd_asymbol_name (*sym
);
2874 if (*name
== '_' && strcmp (name
, "_gp") == 0)
2876 *pgp
= bfd_asymbol_value (*sym
);
2877 _bfd_set_gp_value (output_bfd
, *pgp
);
2885 /* Only get the error once. */
2887 _bfd_set_gp_value (output_bfd
, *pgp
);
2894 /* We have to figure out the gp value, so that we can adjust the
2895 symbol value correctly. We look up the symbol _gp in the output
2896 BFD. If we can't find it, we're stuck. We cache it in the ELF
2897 target data. We don't need to adjust the symbol value for an
2898 external symbol if we are producing relocatable output. */
2900 static bfd_reloc_status_type
2901 mips_elf64_final_gp (bfd
*output_bfd
, asymbol
*symbol
, bfd_boolean relocatable
,
2902 char **error_message
, bfd_vma
*pgp
)
2904 if (bfd_is_und_section (symbol
->section
)
2908 return bfd_reloc_undefined
;
2911 *pgp
= _bfd_get_gp_value (output_bfd
);
2914 || (symbol
->flags
& BSF_SECTION_SYM
) != 0))
2918 /* Make up a value. */
2919 *pgp
= symbol
->section
->output_section
->vma
/*+ 0x4000*/;
2920 _bfd_set_gp_value (output_bfd
, *pgp
);
2922 else if (!mips_elf64_assign_gp (output_bfd
, pgp
))
2925 (char *) _("GP relative relocation when _gp not defined");
2926 return bfd_reloc_dangerous
;
2930 return bfd_reloc_ok
;
2933 /* Do a R_MIPS_GPREL16 relocation. This is a 16 bit value which must
2934 become the offset from the gp register. */
2936 static bfd_reloc_status_type
2937 mips_elf64_gprel16_reloc (bfd
*abfd
, arelent
*reloc_entry
, asymbol
*symbol
,
2938 void *data
, asection
*input_section
, bfd
*output_bfd
,
2939 char **error_message
)
2941 bfd_boolean relocatable
;
2942 bfd_reloc_status_type ret
;
2945 /* If we're relocating, and this is an external symbol, we don't want
2946 to change anything. */
2947 if (output_bfd
!= NULL
2948 && (symbol
->flags
& BSF_SECTION_SYM
) == 0
2949 && (symbol
->flags
& BSF_LOCAL
) != 0)
2951 reloc_entry
->address
+= input_section
->output_offset
;
2952 return bfd_reloc_ok
;
2955 if (output_bfd
!= NULL
)
2959 relocatable
= FALSE
;
2960 output_bfd
= symbol
->section
->output_section
->owner
;
2963 ret
= mips_elf64_final_gp (output_bfd
, symbol
, relocatable
, error_message
,
2965 if (ret
!= bfd_reloc_ok
)
2968 return _bfd_mips_elf_gprel16_with_gp (abfd
, symbol
, reloc_entry
,
2969 input_section
, relocatable
,
2973 /* Do a R_MIPS_LITERAL relocation. */
2975 static bfd_reloc_status_type
2976 mips_elf64_literal_reloc (bfd
*abfd
, arelent
*reloc_entry
, asymbol
*symbol
,
2977 void *data
, asection
*input_section
, bfd
*output_bfd
,
2978 char **error_message
)
2980 bfd_boolean relocatable
;
2981 bfd_reloc_status_type ret
;
2984 /* R_MIPS_LITERAL relocations are defined for local symbols only. */
2985 if (output_bfd
!= NULL
2986 && (symbol
->flags
& BSF_SECTION_SYM
) == 0
2987 && (symbol
->flags
& BSF_LOCAL
) != 0)
2989 *error_message
= (char *)
2990 _("literal relocation occurs for an external symbol");
2991 return bfd_reloc_outofrange
;
2994 /* FIXME: The entries in the .lit8 and .lit4 sections should be merged. */
2995 if (output_bfd
!= NULL
)
2999 relocatable
= FALSE
;
3000 output_bfd
= symbol
->section
->output_section
->owner
;
3003 ret
= mips_elf64_final_gp (output_bfd
, symbol
, relocatable
, error_message
,
3005 if (ret
!= bfd_reloc_ok
)
3008 return _bfd_mips_elf_gprel16_with_gp (abfd
, symbol
, reloc_entry
,
3009 input_section
, relocatable
,
3013 /* Do a R_MIPS_GPREL32 relocation. This is a 32 bit value which must
3014 become the offset from the gp register. */
3016 static bfd_reloc_status_type
3017 mips_elf64_gprel32_reloc (bfd
*abfd
, arelent
*reloc_entry
, asymbol
*symbol
,
3018 void *data
, asection
*input_section
, bfd
*output_bfd
,
3019 char **error_message
)
3021 bfd_boolean relocatable
;
3022 bfd_reloc_status_type ret
;
3027 /* R_MIPS_GPREL32 relocations are defined for local symbols only. */
3028 if (output_bfd
!= NULL
3029 && (symbol
->flags
& BSF_SECTION_SYM
) == 0
3030 && (symbol
->flags
& BSF_LOCAL
) != 0)
3032 *error_message
= (char *)
3033 _("32bits gp relative relocation occurs for an external symbol");
3034 return bfd_reloc_outofrange
;
3037 if (output_bfd
!= NULL
)
3041 relocatable
= FALSE
;
3042 output_bfd
= symbol
->section
->output_section
->owner
;
3045 ret
= mips_elf64_final_gp (output_bfd
, symbol
, relocatable
,
3046 error_message
, &gp
);
3047 if (ret
!= bfd_reloc_ok
)
3050 if (bfd_is_com_section (symbol
->section
))
3053 relocation
= symbol
->value
;
3055 relocation
+= symbol
->section
->output_section
->vma
;
3056 relocation
+= symbol
->section
->output_offset
;
3058 if (reloc_entry
->address
> bfd_get_section_limit (abfd
, input_section
))
3059 return bfd_reloc_outofrange
;
3061 /* Set val to the offset into the section or symbol. */
3062 val
= reloc_entry
->addend
;
3064 if (reloc_entry
->howto
->partial_inplace
)
3065 val
+= bfd_get_32 (abfd
, (bfd_byte
*) data
+ reloc_entry
->address
);
3067 /* Adjust val for the final section location and GP value. If we
3068 are producing relocatable output, we don't want to do this for
3069 an external symbol. */
3071 || (symbol
->flags
& BSF_SECTION_SYM
) != 0)
3072 val
+= relocation
- gp
;
3074 if (reloc_entry
->howto
->partial_inplace
)
3075 bfd_put_32 (abfd
, val
, (bfd_byte
*) data
+ reloc_entry
->address
);
3077 reloc_entry
->addend
= val
;
3080 reloc_entry
->address
+= input_section
->output_offset
;
3082 return bfd_reloc_ok
;
3085 /* Do a R_MIPS_SHIFT6 relocation. The MSB of the shift is stored at bit 2,
3086 the rest is at bits 6-10. The bitpos already got right by the howto. */
3088 static bfd_reloc_status_type
3089 mips_elf64_shift6_reloc (bfd
*abfd
, arelent
*reloc_entry
, asymbol
*symbol
,
3090 void *data
, asection
*input_section
, bfd
*output_bfd
,
3091 char **error_message
)
3093 if (reloc_entry
->howto
->partial_inplace
)
3095 reloc_entry
->addend
= ((reloc_entry
->addend
& 0x00007c0)
3096 | (reloc_entry
->addend
& 0x00000800) >> 9);
3099 return _bfd_mips_elf_generic_reloc (abfd
, reloc_entry
, symbol
, data
,
3100 input_section
, output_bfd
,
3104 /* Handle a mips16 GP relative reloc. */
3106 static bfd_reloc_status_type
3107 mips16_gprel_reloc (bfd
*abfd
, arelent
*reloc_entry
, asymbol
*symbol
,
3108 void *data
, asection
*input_section
, bfd
*output_bfd
,
3109 char **error_message
)
3111 bfd_boolean relocatable
;
3112 bfd_reloc_status_type ret
;
3116 /* If we're relocating, and this is an external symbol, we don't want
3117 to change anything. */
3118 if (output_bfd
!= NULL
3119 && (symbol
->flags
& BSF_SECTION_SYM
) == 0
3120 && (symbol
->flags
& BSF_LOCAL
) != 0)
3122 reloc_entry
->address
+= input_section
->output_offset
;
3123 return bfd_reloc_ok
;
3126 if (output_bfd
!= NULL
)
3130 relocatable
= FALSE
;
3131 output_bfd
= symbol
->section
->output_section
->owner
;
3134 ret
= mips_elf64_final_gp (output_bfd
, symbol
, relocatable
, error_message
,
3136 if (ret
!= bfd_reloc_ok
)
3139 location
= (bfd_byte
*) data
+ reloc_entry
->address
;
3140 _bfd_mips_elf_reloc_unshuffle (abfd
, reloc_entry
->howto
->type
, FALSE
,
3142 ret
= _bfd_mips_elf_gprel16_with_gp (abfd
, symbol
, reloc_entry
,
3143 input_section
, relocatable
,
3145 _bfd_mips_elf_reloc_shuffle (abfd
, reloc_entry
->howto
->type
, !relocatable
,
3151 /* A mapping from BFD reloc types to MIPS ELF reloc types. */
3153 struct elf_reloc_map
{
3154 bfd_reloc_code_real_type bfd_val
;
3155 enum elf_mips_reloc_type elf_val
;
3158 static const struct elf_reloc_map mips_reloc_map
[] =
3160 { BFD_RELOC_NONE
, R_MIPS_NONE
},
3161 { BFD_RELOC_16
, R_MIPS_16
},
3162 { BFD_RELOC_32
, R_MIPS_32
},
3163 /* There is no BFD reloc for R_MIPS_REL32. */
3164 { BFD_RELOC_64
, R_MIPS_64
},
3165 { BFD_RELOC_CTOR
, R_MIPS_64
},
3166 { BFD_RELOC_16_PCREL_S2
, R_MIPS_PC16
},
3167 { BFD_RELOC_HI16_S
, R_MIPS_HI16
},
3168 { BFD_RELOC_LO16
, R_MIPS_LO16
},
3169 { BFD_RELOC_GPREL16
, R_MIPS_GPREL16
},
3170 { BFD_RELOC_GPREL32
, R_MIPS_GPREL32
},
3171 { BFD_RELOC_MIPS_JMP
, R_MIPS_26
},
3172 { BFD_RELOC_MIPS_LITERAL
, R_MIPS_LITERAL
},
3173 { BFD_RELOC_MIPS_GOT16
, R_MIPS_GOT16
},
3174 { BFD_RELOC_MIPS_CALL16
, R_MIPS_CALL16
},
3175 { BFD_RELOC_MIPS_SHIFT5
, R_MIPS_SHIFT5
},
3176 { BFD_RELOC_MIPS_SHIFT6
, R_MIPS_SHIFT6
},
3177 { BFD_RELOC_MIPS_GOT_DISP
, R_MIPS_GOT_DISP
},
3178 { BFD_RELOC_MIPS_GOT_PAGE
, R_MIPS_GOT_PAGE
},
3179 { BFD_RELOC_MIPS_GOT_OFST
, R_MIPS_GOT_OFST
},
3180 { BFD_RELOC_MIPS_GOT_HI16
, R_MIPS_GOT_HI16
},
3181 { BFD_RELOC_MIPS_GOT_LO16
, R_MIPS_GOT_LO16
},
3182 { BFD_RELOC_MIPS_SUB
, R_MIPS_SUB
},
3183 { BFD_RELOC_MIPS_INSERT_A
, R_MIPS_INSERT_A
},
3184 { BFD_RELOC_MIPS_INSERT_B
, R_MIPS_INSERT_B
},
3185 { BFD_RELOC_MIPS_DELETE
, R_MIPS_DELETE
},
3186 { BFD_RELOC_MIPS_HIGHEST
, R_MIPS_HIGHEST
},
3187 { BFD_RELOC_MIPS_HIGHER
, R_MIPS_HIGHER
},
3188 { BFD_RELOC_MIPS_CALL_HI16
, R_MIPS_CALL_HI16
},
3189 { BFD_RELOC_MIPS_CALL_LO16
, R_MIPS_CALL_LO16
},
3190 { BFD_RELOC_MIPS_SCN_DISP
, R_MIPS_SCN_DISP
},
3191 { BFD_RELOC_MIPS_REL16
, R_MIPS_REL16
},
3192 /* Use of R_MIPS_ADD_IMMEDIATE and R_MIPS_PJUMP is deprecated. */
3193 { BFD_RELOC_MIPS_RELGOT
, R_MIPS_RELGOT
},
3194 { BFD_RELOC_MIPS_JALR
, R_MIPS_JALR
},
3195 { BFD_RELOC_MIPS_TLS_DTPMOD32
, R_MIPS_TLS_DTPMOD32
},
3196 { BFD_RELOC_MIPS_TLS_DTPREL32
, R_MIPS_TLS_DTPREL32
},
3197 { BFD_RELOC_MIPS_TLS_DTPMOD64
, R_MIPS_TLS_DTPMOD64
},
3198 { BFD_RELOC_MIPS_TLS_DTPREL64
, R_MIPS_TLS_DTPREL64
},
3199 { BFD_RELOC_MIPS_TLS_GD
, R_MIPS_TLS_GD
},
3200 { BFD_RELOC_MIPS_TLS_LDM
, R_MIPS_TLS_LDM
},
3201 { BFD_RELOC_MIPS_TLS_DTPREL_HI16
, R_MIPS_TLS_DTPREL_HI16
},
3202 { BFD_RELOC_MIPS_TLS_DTPREL_LO16
, R_MIPS_TLS_DTPREL_LO16
},
3203 { BFD_RELOC_MIPS_TLS_GOTTPREL
, R_MIPS_TLS_GOTTPREL
},
3204 { BFD_RELOC_MIPS_TLS_TPREL32
, R_MIPS_TLS_TPREL32
},
3205 { BFD_RELOC_MIPS_TLS_TPREL64
, R_MIPS_TLS_TPREL64
},
3206 { BFD_RELOC_MIPS_TLS_TPREL_HI16
, R_MIPS_TLS_TPREL_HI16
},
3207 { BFD_RELOC_MIPS_TLS_TPREL_LO16
, R_MIPS_TLS_TPREL_LO16
}
3210 static const struct elf_reloc_map mips16_reloc_map
[] =
3212 { BFD_RELOC_MIPS16_JMP
, R_MIPS16_26
- R_MIPS16_min
},
3213 { BFD_RELOC_MIPS16_GPREL
, R_MIPS16_GPREL
- R_MIPS16_min
},
3214 { BFD_RELOC_MIPS16_GOT16
, R_MIPS16_GOT16
- R_MIPS16_min
},
3215 { BFD_RELOC_MIPS16_CALL16
, R_MIPS16_CALL16
- R_MIPS16_min
},
3216 { BFD_RELOC_MIPS16_HI16_S
, R_MIPS16_HI16
- R_MIPS16_min
},
3217 { BFD_RELOC_MIPS16_LO16
, R_MIPS16_LO16
- R_MIPS16_min
},
3218 { BFD_RELOC_MIPS16_TLS_GD
, R_MIPS16_TLS_GD
- R_MIPS16_min
},
3219 { BFD_RELOC_MIPS16_TLS_LDM
, R_MIPS16_TLS_LDM
- R_MIPS16_min
},
3220 { BFD_RELOC_MIPS16_TLS_DTPREL_HI16
,
3221 R_MIPS16_TLS_DTPREL_HI16
- R_MIPS16_min
},
3222 { BFD_RELOC_MIPS16_TLS_DTPREL_LO16
,
3223 R_MIPS16_TLS_DTPREL_LO16
- R_MIPS16_min
},
3224 { BFD_RELOC_MIPS16_TLS_GOTTPREL
, R_MIPS16_TLS_GOTTPREL
- R_MIPS16_min
},
3225 { BFD_RELOC_MIPS16_TLS_TPREL_HI16
, R_MIPS16_TLS_TPREL_HI16
- R_MIPS16_min
},
3226 { BFD_RELOC_MIPS16_TLS_TPREL_LO16
, R_MIPS16_TLS_TPREL_LO16
- R_MIPS16_min
}
3229 static const struct elf_reloc_map micromips_reloc_map
[] =
3231 { BFD_RELOC_MICROMIPS_JMP
, R_MICROMIPS_26_S1
- R_MICROMIPS_min
},
3232 { BFD_RELOC_MICROMIPS_HI16_S
, R_MICROMIPS_HI16
- R_MICROMIPS_min
},
3233 { BFD_RELOC_MICROMIPS_LO16
, R_MICROMIPS_LO16
- R_MICROMIPS_min
},
3234 { BFD_RELOC_MICROMIPS_GPREL16
, R_MICROMIPS_GPREL16
- R_MICROMIPS_min
},
3235 { BFD_RELOC_MICROMIPS_LITERAL
, R_MICROMIPS_LITERAL
- R_MICROMIPS_min
},
3236 { BFD_RELOC_MICROMIPS_GOT16
, R_MICROMIPS_GOT16
- R_MICROMIPS_min
},
3237 { BFD_RELOC_MICROMIPS_7_PCREL_S1
, R_MICROMIPS_PC7_S1
- R_MICROMIPS_min
},
3238 { BFD_RELOC_MICROMIPS_10_PCREL_S1
, R_MICROMIPS_PC10_S1
- R_MICROMIPS_min
},
3239 { BFD_RELOC_MICROMIPS_16_PCREL_S1
, R_MICROMIPS_PC16_S1
- R_MICROMIPS_min
},
3240 { BFD_RELOC_MICROMIPS_CALL16
, R_MICROMIPS_CALL16
- R_MICROMIPS_min
},
3241 { BFD_RELOC_MICROMIPS_GOT_DISP
, R_MICROMIPS_GOT_DISP
- R_MICROMIPS_min
},
3242 { BFD_RELOC_MICROMIPS_GOT_PAGE
, R_MICROMIPS_GOT_PAGE
- R_MICROMIPS_min
},
3243 { BFD_RELOC_MICROMIPS_GOT_OFST
, R_MICROMIPS_GOT_OFST
- R_MICROMIPS_min
},
3244 { BFD_RELOC_MICROMIPS_GOT_HI16
, R_MICROMIPS_GOT_HI16
- R_MICROMIPS_min
},
3245 { BFD_RELOC_MICROMIPS_GOT_LO16
, R_MICROMIPS_GOT_LO16
- R_MICROMIPS_min
},
3246 { BFD_RELOC_MICROMIPS_SUB
, R_MICROMIPS_SUB
- R_MICROMIPS_min
},
3247 { BFD_RELOC_MICROMIPS_HIGHER
, R_MICROMIPS_HIGHER
- R_MICROMIPS_min
},
3248 { BFD_RELOC_MICROMIPS_HIGHEST
, R_MICROMIPS_HIGHEST
- R_MICROMIPS_min
},
3249 { BFD_RELOC_MICROMIPS_CALL_HI16
, R_MICROMIPS_CALL_HI16
- R_MICROMIPS_min
},
3250 { BFD_RELOC_MICROMIPS_CALL_LO16
, R_MICROMIPS_CALL_LO16
- R_MICROMIPS_min
},
3251 { BFD_RELOC_MICROMIPS_SCN_DISP
, R_MICROMIPS_SCN_DISP
- R_MICROMIPS_min
},
3252 { BFD_RELOC_MICROMIPS_JALR
, R_MICROMIPS_JALR
- R_MICROMIPS_min
},
3254 /* Given a BFD reloc type, return a howto structure. */
3256 static reloc_howto_type
*
3257 bfd_elf64_bfd_reloc_type_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
3258 bfd_reloc_code_real_type code
)
3261 /* FIXME: We default to RELA here instead of choosing the right
3262 relocation variant. */
3263 reloc_howto_type
*howto_table
= mips_elf64_howto_table_rela
;
3264 reloc_howto_type
*howto16_table
= mips16_elf64_howto_table_rela
;
3265 reloc_howto_type
*howto_micromips_table
= micromips_elf64_howto_table_rela
;
3267 for (i
= 0; i
< sizeof (mips_reloc_map
) / sizeof (struct elf_reloc_map
);
3270 if (mips_reloc_map
[i
].bfd_val
== code
)
3271 return &howto_table
[(int) mips_reloc_map
[i
].elf_val
];
3274 for (i
= 0; i
< sizeof (mips16_reloc_map
) / sizeof (struct elf_reloc_map
);
3277 if (mips16_reloc_map
[i
].bfd_val
== code
)
3278 return &howto16_table
[(int) mips16_reloc_map
[i
].elf_val
];
3281 for (i
= 0; i
< sizeof (micromips_reloc_map
) / sizeof (struct elf_reloc_map
);
3284 if (micromips_reloc_map
[i
].bfd_val
== code
)
3285 return &howto_micromips_table
[(int) micromips_reloc_map
[i
].elf_val
];
3290 case BFD_RELOC_VTABLE_INHERIT
:
3291 return &elf_mips_gnu_vtinherit_howto
;
3292 case BFD_RELOC_VTABLE_ENTRY
:
3293 return &elf_mips_gnu_vtentry_howto
;
3294 case BFD_RELOC_32_PCREL
:
3295 return &elf_mips_gnu_pcrel32
;
3296 case BFD_RELOC_MIPS_EH
:
3297 return &elf_mips_eh_howto
;
3298 case BFD_RELOC_MIPS_COPY
:
3299 return &elf_mips_copy_howto
;
3300 case BFD_RELOC_MIPS_JUMP_SLOT
:
3301 return &elf_mips_jump_slot_howto
;
3303 bfd_set_error (bfd_error_bad_value
);
3308 static reloc_howto_type
*
3309 bfd_elf64_bfd_reloc_name_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
3315 i
< (sizeof (mips_elf64_howto_table_rela
)
3316 / sizeof (mips_elf64_howto_table_rela
[0])); i
++)
3317 if (mips_elf64_howto_table_rela
[i
].name
!= NULL
3318 && strcasecmp (mips_elf64_howto_table_rela
[i
].name
, r_name
) == 0)
3319 return &mips_elf64_howto_table_rela
[i
];
3322 i
< (sizeof (mips16_elf64_howto_table_rela
)
3323 / sizeof (mips16_elf64_howto_table_rela
[0]));
3325 if (mips16_elf64_howto_table_rela
[i
].name
!= NULL
3326 && strcasecmp (mips16_elf64_howto_table_rela
[i
].name
, r_name
) == 0)
3327 return &mips16_elf64_howto_table_rela
[i
];
3330 i
< (sizeof (micromips_elf64_howto_table_rela
)
3331 / sizeof (micromips_elf64_howto_table_rela
[0]));
3333 if (micromips_elf64_howto_table_rela
[i
].name
!= NULL
3334 && strcasecmp (micromips_elf64_howto_table_rela
[i
].name
, r_name
) == 0)
3335 return µmips_elf64_howto_table_rela
[i
];
3337 if (strcasecmp (elf_mips_gnu_vtinherit_howto
.name
, r_name
) == 0)
3338 return &elf_mips_gnu_vtinherit_howto
;
3339 if (strcasecmp (elf_mips_gnu_vtentry_howto
.name
, r_name
) == 0)
3340 return &elf_mips_gnu_vtentry_howto
;
3341 if (strcasecmp (elf_mips_gnu_rel16_s2
.name
, r_name
) == 0)
3342 return &elf_mips_gnu_rel16_s2
;
3343 if (strcasecmp (elf_mips_gnu_rela16_s2
.name
, r_name
) == 0)
3344 return &elf_mips_gnu_rela16_s2
;
3345 if (strcasecmp (elf_mips_gnu_pcrel32
.name
, r_name
) == 0)
3346 return &elf_mips_gnu_pcrel32
;
3347 if (strcasecmp (elf_mips_eh_howto
.name
, r_name
) == 0)
3348 return &elf_mips_eh_howto
;
3349 if (strcasecmp (elf_mips_copy_howto
.name
, r_name
) == 0)
3350 return &elf_mips_copy_howto
;
3351 if (strcasecmp (elf_mips_jump_slot_howto
.name
, r_name
) == 0)
3352 return &elf_mips_jump_slot_howto
;
3357 /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure. */
3359 static reloc_howto_type
*
3360 mips_elf64_rtype_to_howto (unsigned int r_type
, bfd_boolean rela_p
)
3364 case R_MIPS_GNU_VTINHERIT
:
3365 return &elf_mips_gnu_vtinherit_howto
;
3366 case R_MIPS_GNU_VTENTRY
:
3367 return &elf_mips_gnu_vtentry_howto
;
3368 case R_MIPS_GNU_REL16_S2
:
3370 return &elf_mips_gnu_rela16_s2
;
3372 return &elf_mips_gnu_rel16_s2
;
3374 return &elf_mips_gnu_pcrel32
;
3376 return &elf_mips_eh_howto
;
3378 return &elf_mips_copy_howto
;
3379 case R_MIPS_JUMP_SLOT
:
3380 return &elf_mips_jump_slot_howto
;
3382 if (r_type
>= R_MICROMIPS_min
&& r_type
< R_MICROMIPS_max
)
3385 return µmips_elf64_howto_table_rela
[r_type
- R_MICROMIPS_min
];
3387 return µmips_elf64_howto_table_rel
[r_type
- R_MICROMIPS_min
];
3389 if (r_type
>= R_MIPS16_min
&& r_type
< R_MIPS16_max
)
3392 return &mips16_elf64_howto_table_rela
[r_type
- R_MIPS16_min
];
3394 return &mips16_elf64_howto_table_rel
[r_type
- R_MIPS16_min
];
3396 BFD_ASSERT (r_type
< (unsigned int) R_MIPS_max
);
3398 return &mips_elf64_howto_table_rela
[r_type
];
3400 return &mips_elf64_howto_table_rel
[r_type
];
3405 /* Prevent relocation handling by bfd for MIPS ELF64. */
3408 mips_elf64_info_to_howto_rel (bfd
*abfd ATTRIBUTE_UNUSED
,
3409 arelent
*cache_ptr ATTRIBUTE_UNUSED
,
3410 Elf_Internal_Rela
*dst ATTRIBUTE_UNUSED
)
3416 mips_elf64_info_to_howto_rela (bfd
*abfd ATTRIBUTE_UNUSED
,
3417 arelent
*cache_ptr ATTRIBUTE_UNUSED
,
3418 Elf_Internal_Rela
*dst ATTRIBUTE_UNUSED
)
3423 /* Since each entry in an SHT_REL or SHT_RELA section can represent up
3424 to three relocs, we must tell the user to allocate more space. */
3427 mips_elf64_get_reloc_upper_bound (bfd
*abfd ATTRIBUTE_UNUSED
, asection
*sec
)
3429 return (sec
->reloc_count
* 3 + 1) * sizeof (arelent
*);
3433 mips_elf64_get_dynamic_reloc_upper_bound (bfd
*abfd
)
3435 return _bfd_elf_get_dynamic_reloc_upper_bound (abfd
) * 3;
3438 /* We must also copy more relocations than the corresponding functions
3439 in elf.c would, so the two following functions are slightly
3440 modified from elf.c, that multiply the external relocation count by
3441 3 to obtain the internal relocation count. */
3444 mips_elf64_canonicalize_reloc (bfd
*abfd
, sec_ptr section
,
3445 arelent
**relptr
, asymbol
**symbols
)
3449 const struct elf_backend_data
*bed
= get_elf_backend_data (abfd
);
3451 if (! bed
->s
->slurp_reloc_table (abfd
, section
, symbols
, FALSE
))
3454 tblptr
= section
->relocation
;
3455 for (i
= 0; i
< section
->reloc_count
* 3; i
++)
3456 *relptr
++ = tblptr
++;
3460 return section
->reloc_count
* 3;
3464 mips_elf64_canonicalize_dynamic_reloc (bfd
*abfd
, arelent
**storage
,
3467 bfd_boolean (*slurp_relocs
) (bfd
*, asection
*, asymbol
**, bfd_boolean
);
3471 if (elf_dynsymtab (abfd
) == 0)
3473 bfd_set_error (bfd_error_invalid_operation
);
3477 slurp_relocs
= get_elf_backend_data (abfd
)->s
->slurp_reloc_table
;
3479 for (s
= abfd
->sections
; s
!= NULL
; s
= s
->next
)
3481 if (elf_section_data (s
)->this_hdr
.sh_link
== elf_dynsymtab (abfd
)
3482 && (elf_section_data (s
)->this_hdr
.sh_type
== SHT_REL
3483 || elf_section_data (s
)->this_hdr
.sh_type
== SHT_RELA
))
3488 if (! (*slurp_relocs
) (abfd
, s
, syms
, TRUE
))
3490 count
= s
->size
/ elf_section_data (s
)->this_hdr
.sh_entsize
* 3;
3492 for (i
= 0; i
< count
; i
++)
3503 /* Read the relocations from one reloc section. This is mostly copied
3504 from elfcode.h, except for the changes to expand one external
3505 relocation to 3 internal ones. We must unfortunately set
3506 reloc_count to the number of external relocations, because a lot of
3507 generic code seems to depend on this. */
3510 mips_elf64_slurp_one_reloc_table (bfd
*abfd
, asection
*asect
,
3511 Elf_Internal_Shdr
*rel_hdr
,
3512 bfd_size_type reloc_count
,
3513 arelent
*relents
, asymbol
**symbols
,
3514 bfd_boolean dynamic
)
3517 bfd_byte
*native_relocs
;
3523 allocated
= bfd_malloc (rel_hdr
->sh_size
);
3524 if (allocated
== NULL
)
3527 if (bfd_seek (abfd
, rel_hdr
->sh_offset
, SEEK_SET
) != 0
3528 || (bfd_bread (allocated
, rel_hdr
->sh_size
, abfd
)
3529 != rel_hdr
->sh_size
))
3532 native_relocs
= allocated
;
3534 entsize
= rel_hdr
->sh_entsize
;
3535 BFD_ASSERT (entsize
== sizeof (Elf64_Mips_External_Rel
)
3536 || entsize
== sizeof (Elf64_Mips_External_Rela
));
3538 if (entsize
== sizeof (Elf64_Mips_External_Rel
))
3543 for (i
= 0, relent
= relents
;
3545 i
++, native_relocs
+= entsize
)
3547 Elf64_Mips_Internal_Rela rela
;
3548 bfd_boolean used_sym
, used_ssym
;
3551 if (entsize
== sizeof (Elf64_Mips_External_Rela
))
3552 mips_elf64_swap_reloca_in (abfd
,
3553 (Elf64_Mips_External_Rela
*) native_relocs
,
3556 mips_elf64_swap_reloc_in (abfd
,
3557 (Elf64_Mips_External_Rel
*) native_relocs
,
3560 /* Each entry represents exactly three actual relocations. */
3564 for (ir
= 0; ir
< 3; ir
++)
3566 enum elf_mips_reloc_type type
;
3573 type
= (enum elf_mips_reloc_type
) rela
.r_type
;
3576 type
= (enum elf_mips_reloc_type
) rela
.r_type2
;
3579 type
= (enum elf_mips_reloc_type
) rela
.r_type3
;
3583 /* Some types require symbols, whereas some do not. */
3587 case R_MIPS_LITERAL
:
3588 case R_MIPS_INSERT_A
:
3589 case R_MIPS_INSERT_B
:
3591 relent
->sym_ptr_ptr
= bfd_abs_section_ptr
->symbol_ptr_ptr
;
3597 if (rela
.r_sym
== STN_UNDEF
)
3598 relent
->sym_ptr_ptr
= bfd_abs_section_ptr
->symbol_ptr_ptr
;
3603 ps
= symbols
+ rela
.r_sym
- 1;
3605 if ((s
->flags
& BSF_SECTION_SYM
) == 0)
3606 relent
->sym_ptr_ptr
= ps
;
3608 relent
->sym_ptr_ptr
= s
->section
->symbol_ptr_ptr
;
3613 else if (! used_ssym
)
3615 switch (rela
.r_ssym
)
3618 relent
->sym_ptr_ptr
=
3619 bfd_abs_section_ptr
->symbol_ptr_ptr
;
3625 /* FIXME: I think these need to be handled using
3626 special howto structures. */
3638 relent
->sym_ptr_ptr
= bfd_abs_section_ptr
->symbol_ptr_ptr
;
3643 /* The address of an ELF reloc is section relative for an
3644 object file, and absolute for an executable file or
3645 shared library. The address of a BFD reloc is always
3646 section relative. */
3647 if ((abfd
->flags
& (EXEC_P
| DYNAMIC
)) == 0 || dynamic
)
3648 relent
->address
= rela
.r_offset
;
3650 relent
->address
= rela
.r_offset
- asect
->vma
;
3652 relent
->addend
= rela
.r_addend
;
3654 relent
->howto
= mips_elf64_rtype_to_howto (type
, rela_p
);
3660 asect
->reloc_count
+= (relent
- relents
) / 3;
3662 if (allocated
!= NULL
)
3668 if (allocated
!= NULL
)
3673 /* Read the relocations. On Irix 6, there can be two reloc sections
3674 associated with a single data section. This is copied from
3675 elfcode.h as well, with changes as small as accounting for 3
3676 internal relocs per external reloc and resetting reloc_count to
3677 zero before processing the relocs of a section. */
3680 mips_elf64_slurp_reloc_table (bfd
*abfd
, asection
*asect
,
3681 asymbol
**symbols
, bfd_boolean dynamic
)
3683 struct bfd_elf_section_data
* const d
= elf_section_data (asect
);
3684 Elf_Internal_Shdr
*rel_hdr
;
3685 Elf_Internal_Shdr
*rel_hdr2
;
3686 bfd_size_type reloc_count
;
3687 bfd_size_type reloc_count2
;
3691 if (asect
->relocation
!= NULL
)
3696 if ((asect
->flags
& SEC_RELOC
) == 0
3697 || asect
->reloc_count
== 0)
3700 rel_hdr
= d
->rel
.hdr
;
3701 reloc_count
= rel_hdr
? NUM_SHDR_ENTRIES (rel_hdr
) : 0;
3702 rel_hdr2
= d
->rela
.hdr
;
3703 reloc_count2
= (rel_hdr2
? NUM_SHDR_ENTRIES (rel_hdr2
) : 0);
3705 BFD_ASSERT (asect
->reloc_count
== reloc_count
+ reloc_count2
);
3706 BFD_ASSERT ((rel_hdr
&& asect
->rel_filepos
== rel_hdr
->sh_offset
)
3707 || (rel_hdr2
&& asect
->rel_filepos
== rel_hdr2
->sh_offset
));
3712 /* Note that ASECT->RELOC_COUNT tends not to be accurate in this
3713 case because relocations against this section may use the
3714 dynamic symbol table, and in that case bfd_section_from_shdr
3715 in elf.c does not update the RELOC_COUNT. */
3716 if (asect
->size
== 0)
3719 rel_hdr
= &d
->this_hdr
;
3720 reloc_count
= NUM_SHDR_ENTRIES (rel_hdr
);
3725 /* Allocate space for 3 arelent structures for each Rel structure. */
3726 amt
= (reloc_count
+ reloc_count2
) * 3 * sizeof (arelent
);
3727 relents
= bfd_alloc (abfd
, amt
);
3728 if (relents
== NULL
)
3731 /* The slurp_one_reloc_table routine increments reloc_count. */
3732 asect
->reloc_count
= 0;
3735 && ! mips_elf64_slurp_one_reloc_table (abfd
, asect
,
3736 rel_hdr
, reloc_count
,
3740 if (rel_hdr2
!= NULL
3741 && ! mips_elf64_slurp_one_reloc_table (abfd
, asect
,
3742 rel_hdr2
, reloc_count2
,
3743 relents
+ reloc_count
* 3,
3747 asect
->relocation
= relents
;
3751 /* Write out the relocations. */
3754 mips_elf64_write_relocs (bfd
*abfd
, asection
*sec
, void *data
)
3756 bfd_boolean
*failedp
= data
;
3758 Elf_Internal_Shdr
*rel_hdr
;
3761 /* If we have already failed, don't do anything. */
3765 if ((sec
->flags
& SEC_RELOC
) == 0)
3768 /* The linker backend writes the relocs out itself, and sets the
3769 reloc_count field to zero to inhibit writing them here. Also,
3770 sometimes the SEC_RELOC flag gets set even when there aren't any
3772 if (sec
->reloc_count
== 0)
3775 /* We can combine up to three relocs that refer to the same address
3776 if the latter relocs have no associated symbol. */
3778 for (idx
= 0; idx
< sec
->reloc_count
; idx
++)
3785 addr
= sec
->orelocation
[idx
]->address
;
3786 for (i
= 0; i
< 2; i
++)
3790 if (idx
+ 1 >= sec
->reloc_count
)
3792 r
= sec
->orelocation
[idx
+ 1];
3793 if (r
->address
!= addr
3794 || ! bfd_is_abs_section ((*r
->sym_ptr_ptr
)->section
)
3795 || (*r
->sym_ptr_ptr
)->value
!= 0)
3798 /* We can merge the reloc at IDX + 1 with the reloc at IDX. */
3804 rel_hdr
= _bfd_elf_single_rel_hdr (sec
);
3806 /* Do the actual relocation. */
3808 if (rel_hdr
->sh_entsize
== sizeof(Elf64_Mips_External_Rel
))
3809 mips_elf64_write_rel (abfd
, sec
, rel_hdr
, &count
, data
);
3810 else if (rel_hdr
->sh_entsize
== sizeof(Elf64_Mips_External_Rela
))
3811 mips_elf64_write_rela (abfd
, sec
, rel_hdr
, &count
, data
);
3817 mips_elf64_write_rel (bfd
*abfd
, asection
*sec
,
3818 Elf_Internal_Shdr
*rel_hdr
,
3819 int *count
, void *data
)
3821 bfd_boolean
*failedp
= data
;
3822 Elf64_Mips_External_Rel
*ext_rel
;
3824 asymbol
*last_sym
= 0;
3825 int last_sym_idx
= 0;
3827 rel_hdr
->sh_size
= rel_hdr
->sh_entsize
* *count
;
3828 rel_hdr
->contents
= bfd_alloc (abfd
, rel_hdr
->sh_size
);
3829 if (rel_hdr
->contents
== NULL
)
3835 ext_rel
= (Elf64_Mips_External_Rel
*) rel_hdr
->contents
;
3836 for (idx
= 0; idx
< sec
->reloc_count
; idx
++, ext_rel
++)
3839 Elf64_Mips_Internal_Rela int_rel
;
3844 ptr
= sec
->orelocation
[idx
];
3846 /* The address of an ELF reloc is section relative for an object
3847 file, and absolute for an executable file or shared library.
3848 The address of a BFD reloc is always section relative. */
3849 if ((abfd
->flags
& (EXEC_P
| DYNAMIC
)) == 0)
3850 int_rel
.r_offset
= ptr
->address
;
3852 int_rel
.r_offset
= ptr
->address
+ sec
->vma
;
3854 sym
= *ptr
->sym_ptr_ptr
;
3855 if (sym
== last_sym
)
3857 else if (bfd_is_abs_section (sym
->section
) && sym
->value
== 0)
3862 n
= _bfd_elf_symbol_from_bfd_symbol (abfd
, &sym
);
3872 int_rel
.r_ssym
= RSS_UNDEF
;
3874 if ((*ptr
->sym_ptr_ptr
)->the_bfd
->xvec
!= abfd
->xvec
3875 && ! _bfd_elf_validate_reloc (abfd
, ptr
))
3881 int_rel
.r_type
= ptr
->howto
->type
;
3882 int_rel
.r_type2
= (int) R_MIPS_NONE
;
3883 int_rel
.r_type3
= (int) R_MIPS_NONE
;
3885 for (i
= 0; i
< 2; i
++)
3889 if (idx
+ 1 >= sec
->reloc_count
)
3891 r
= sec
->orelocation
[idx
+ 1];
3892 if (r
->address
!= ptr
->address
3893 || ! bfd_is_abs_section ((*r
->sym_ptr_ptr
)->section
)
3894 || (*r
->sym_ptr_ptr
)->value
!= 0)
3897 /* We can merge the reloc at IDX + 1 with the reloc at IDX. */
3900 int_rel
.r_type2
= r
->howto
->type
;
3902 int_rel
.r_type3
= r
->howto
->type
;
3907 mips_elf64_swap_reloc_out (abfd
, &int_rel
, ext_rel
);
3910 BFD_ASSERT (ext_rel
- (Elf64_Mips_External_Rel
*) rel_hdr
->contents
3915 mips_elf64_write_rela (bfd
*abfd
, asection
*sec
,
3916 Elf_Internal_Shdr
*rela_hdr
,
3917 int *count
, void *data
)
3919 bfd_boolean
*failedp
= data
;
3920 Elf64_Mips_External_Rela
*ext_rela
;
3922 asymbol
*last_sym
= 0;
3923 int last_sym_idx
= 0;
3925 rela_hdr
->sh_size
= rela_hdr
->sh_entsize
* *count
;
3926 rela_hdr
->contents
= bfd_alloc (abfd
, rela_hdr
->sh_size
);
3927 if (rela_hdr
->contents
== NULL
)
3933 ext_rela
= (Elf64_Mips_External_Rela
*) rela_hdr
->contents
;
3934 for (idx
= 0; idx
< sec
->reloc_count
; idx
++, ext_rela
++)
3937 Elf64_Mips_Internal_Rela int_rela
;
3942 ptr
= sec
->orelocation
[idx
];
3944 /* The address of an ELF reloc is section relative for an object
3945 file, and absolute for an executable file or shared library.
3946 The address of a BFD reloc is always section relative. */
3947 if ((abfd
->flags
& (EXEC_P
| DYNAMIC
)) == 0)
3948 int_rela
.r_offset
= ptr
->address
;
3950 int_rela
.r_offset
= ptr
->address
+ sec
->vma
;
3952 sym
= *ptr
->sym_ptr_ptr
;
3953 if (sym
== last_sym
)
3955 else if (bfd_is_abs_section (sym
->section
) && sym
->value
== 0)
3960 n
= _bfd_elf_symbol_from_bfd_symbol (abfd
, &sym
);
3970 int_rela
.r_addend
= ptr
->addend
;
3971 int_rela
.r_ssym
= RSS_UNDEF
;
3973 if ((*ptr
->sym_ptr_ptr
)->the_bfd
->xvec
!= abfd
->xvec
3974 && ! _bfd_elf_validate_reloc (abfd
, ptr
))
3980 int_rela
.r_type
= ptr
->howto
->type
;
3981 int_rela
.r_type2
= (int) R_MIPS_NONE
;
3982 int_rela
.r_type3
= (int) R_MIPS_NONE
;
3984 for (i
= 0; i
< 2; i
++)
3988 if (idx
+ 1 >= sec
->reloc_count
)
3990 r
= sec
->orelocation
[idx
+ 1];
3991 if (r
->address
!= ptr
->address
3992 || ! bfd_is_abs_section ((*r
->sym_ptr_ptr
)->section
)
3993 || (*r
->sym_ptr_ptr
)->value
!= 0)
3996 /* We can merge the reloc at IDX + 1 with the reloc at IDX. */
3999 int_rela
.r_type2
= r
->howto
->type
;
4001 int_rela
.r_type3
= r
->howto
->type
;
4006 mips_elf64_swap_reloca_out (abfd
, &int_rela
, ext_rela
);
4009 BFD_ASSERT (ext_rela
- (Elf64_Mips_External_Rela
*) rela_hdr
->contents
4013 /* Set the right machine number for a MIPS ELF file. */
4016 mips_elf64_object_p (bfd
*abfd
)
4020 /* Irix 6 is broken. Object file symbol tables are not always
4021 sorted correctly such that local symbols precede global symbols,
4022 and the sh_info field in the symbol table is not always right. */
4023 if (elf64_mips_irix_compat (abfd
) != ict_none
)
4024 elf_bad_symtab (abfd
) = TRUE
;
4026 mach
= _bfd_elf_mips_mach (elf_elfheader (abfd
)->e_flags
);
4027 bfd_default_set_arch_mach (abfd
, bfd_arch_mips
, mach
);
4031 /* Depending on the target vector we generate some version of Irix
4032 executables or "normal" MIPS ELF ABI executables. */
4033 static irix_compat_t
4034 elf64_mips_irix_compat (bfd
*abfd
)
4036 if ((abfd
->xvec
== &bfd_elf64_bigmips_vec
)
4037 || (abfd
->xvec
== &bfd_elf64_littlemips_vec
))
4043 /* Support for core dump NOTE sections. */
4045 elf64_mips_grok_prstatus (bfd
*abfd
, Elf_Internal_Note
*note
)
4050 switch (note
->descsz
)
4055 case 480: /* Linux/MIPS - N64 kernel */
4057 elf_tdata (abfd
)->core
->signal
= bfd_get_16 (abfd
, note
->descdata
+ 12);
4060 elf_tdata (abfd
)->core
->lwpid
= bfd_get_32 (abfd
, note
->descdata
+ 32);
4069 /* Make a ".reg/999" section. */
4070 return _bfd_elfcore_make_pseudosection (abfd
, ".reg",
4071 size
, note
->descpos
+ offset
);
4075 elf64_mips_grok_psinfo (bfd
*abfd
, Elf_Internal_Note
*note
)
4077 switch (note
->descsz
)
4082 case 136: /* Linux/MIPS - N64 kernel elf_prpsinfo */
4083 elf_tdata (abfd
)->core
->program
4084 = _bfd_elfcore_strndup (abfd
, note
->descdata
+ 40, 16);
4085 elf_tdata (abfd
)->core
->command
4086 = _bfd_elfcore_strndup (abfd
, note
->descdata
+ 56, 80);
4089 /* Note that for some reason, a spurious space is tacked
4090 onto the end of the args in some (at least one anyway)
4091 implementations, so strip it off if it exists. */
4094 char *command
= elf_tdata (abfd
)->core
->command
;
4095 int n
= strlen (command
);
4097 if (0 < n
&& command
[n
- 1] == ' ')
4098 command
[n
- 1] = '\0';
4104 /* ECOFF swapping routines. These are used when dealing with the
4105 .mdebug section, which is in the ECOFF debugging format. */
4106 static const struct ecoff_debug_swap mips_elf64_ecoff_debug_swap
=
4108 /* Symbol table magic number. */
4110 /* Alignment of debugging information. E.g., 4. */
4112 /* Sizes of external symbolic information. */
4113 sizeof (struct hdr_ext
),
4114 sizeof (struct dnr_ext
),
4115 sizeof (struct pdr_ext
),
4116 sizeof (struct sym_ext
),
4117 sizeof (struct opt_ext
),
4118 sizeof (struct fdr_ext
),
4119 sizeof (struct rfd_ext
),
4120 sizeof (struct ext_ext
),
4121 /* Functions to swap in external symbolic data. */
4130 _bfd_ecoff_swap_tir_in
,
4131 _bfd_ecoff_swap_rndx_in
,
4132 /* Functions to swap out external symbolic data. */
4141 _bfd_ecoff_swap_tir_out
,
4142 _bfd_ecoff_swap_rndx_out
,
4143 /* Function to read in symbolic data. */
4144 _bfd_mips_elf_read_ecoff_info
4147 /* Relocations in the 64 bit MIPS ELF ABI are more complex than in
4148 standard ELF. This structure is used to redirect the relocation
4149 handling routines. */
4151 const struct elf_size_info mips_elf64_size_info
=
4153 sizeof (Elf64_External_Ehdr
),
4154 sizeof (Elf64_External_Phdr
),
4155 sizeof (Elf64_External_Shdr
),
4156 sizeof (Elf64_Mips_External_Rel
),
4157 sizeof (Elf64_Mips_External_Rela
),
4158 sizeof (Elf64_External_Sym
),
4159 sizeof (Elf64_External_Dyn
),
4160 sizeof (Elf_External_Note
),
4161 4, /* hash-table entry size */
4162 3, /* internal relocations per external relocations */
4164 3, /* log_file_align */
4167 bfd_elf64_write_out_phdrs
,
4168 bfd_elf64_write_shdrs_and_ehdr
,
4169 bfd_elf64_checksum_contents
,
4170 mips_elf64_write_relocs
,
4171 bfd_elf64_swap_symbol_in
,
4172 bfd_elf64_swap_symbol_out
,
4173 mips_elf64_slurp_reloc_table
,
4174 bfd_elf64_slurp_symbol_table
,
4175 bfd_elf64_swap_dyn_in
,
4176 bfd_elf64_swap_dyn_out
,
4177 mips_elf64_be_swap_reloc_in
,
4178 mips_elf64_be_swap_reloc_out
,
4179 mips_elf64_be_swap_reloca_in
,
4180 mips_elf64_be_swap_reloca_out
4183 #define ELF_ARCH bfd_arch_mips
4184 #define ELF_TARGET_ID MIPS_ELF_DATA
4185 #define ELF_MACHINE_CODE EM_MIPS
4187 #define elf_backend_collect TRUE
4188 #define elf_backend_type_change_ok TRUE
4189 #define elf_backend_can_gc_sections TRUE
4190 #define elf_info_to_howto mips_elf64_info_to_howto_rela
4191 #define elf_info_to_howto_rel mips_elf64_info_to_howto_rel
4192 #define elf_backend_object_p mips_elf64_object_p
4193 #define elf_backend_symbol_processing _bfd_mips_elf_symbol_processing
4194 #define elf_backend_section_processing _bfd_mips_elf_section_processing
4195 #define elf_backend_section_from_shdr _bfd_mips_elf_section_from_shdr
4196 #define elf_backend_fake_sections _bfd_mips_elf_fake_sections
4197 #define elf_backend_section_from_bfd_section \
4198 _bfd_mips_elf_section_from_bfd_section
4199 #define elf_backend_add_symbol_hook _bfd_mips_elf_add_symbol_hook
4200 #define elf_backend_link_output_symbol_hook \
4201 _bfd_mips_elf_link_output_symbol_hook
4202 #define elf_backend_create_dynamic_sections \
4203 _bfd_mips_elf_create_dynamic_sections
4204 #define elf_backend_check_relocs _bfd_mips_elf_check_relocs
4205 #define elf_backend_merge_symbol_attribute \
4206 _bfd_mips_elf_merge_symbol_attribute
4207 #define elf_backend_get_target_dtag _bfd_mips_elf_get_target_dtag
4208 #define elf_backend_adjust_dynamic_symbol \
4209 _bfd_mips_elf_adjust_dynamic_symbol
4210 #define elf_backend_always_size_sections \
4211 _bfd_mips_elf_always_size_sections
4212 #define elf_backend_size_dynamic_sections \
4213 _bfd_mips_elf_size_dynamic_sections
4214 #define elf_backend_init_index_section _bfd_elf_init_1_index_section
4215 #define elf_backend_relocate_section _bfd_mips_elf_relocate_section
4216 #define elf_backend_finish_dynamic_symbol \
4217 _bfd_mips_elf_finish_dynamic_symbol
4218 #define elf_backend_finish_dynamic_sections \
4219 _bfd_mips_elf_finish_dynamic_sections
4220 #define elf_backend_final_write_processing \
4221 _bfd_mips_elf_final_write_processing
4222 #define elf_backend_additional_program_headers \
4223 _bfd_mips_elf_additional_program_headers
4224 #define elf_backend_modify_segment_map _bfd_mips_elf_modify_segment_map
4225 #define elf_backend_gc_mark_hook _bfd_mips_elf_gc_mark_hook
4226 #define elf_backend_gc_sweep_hook _bfd_mips_elf_gc_sweep_hook
4227 #define elf_backend_copy_indirect_symbol \
4228 _bfd_mips_elf_copy_indirect_symbol
4229 #define elf_backend_ignore_discarded_relocs \
4230 _bfd_mips_elf_ignore_discarded_relocs
4231 #define elf_backend_mips_irix_compat elf64_mips_irix_compat
4232 #define elf_backend_mips_rtype_to_howto mips_elf64_rtype_to_howto
4233 #define elf_backend_ecoff_debug_swap &mips_elf64_ecoff_debug_swap
4234 #define elf_backend_size_info mips_elf64_size_info
4236 #define elf_backend_grok_prstatus elf64_mips_grok_prstatus
4237 #define elf_backend_grok_psinfo elf64_mips_grok_psinfo
4239 #define elf_backend_got_header_size (8 * MIPS_RESERVED_GOTNO)
4241 /* MIPS ELF64 can use a mixture of REL and RELA, but some Relocations
4242 work better/work only in RELA, so we default to this. */
4243 #define elf_backend_may_use_rel_p 1
4244 #define elf_backend_may_use_rela_p 1
4245 #define elf_backend_default_use_rela_p 1
4246 #define elf_backend_rela_plts_and_copies_p 0
4247 #define elf_backend_plt_readonly 1
4248 #define elf_backend_plt_sym_val _bfd_mips_elf_plt_sym_val
4250 #define elf_backend_sign_extend_vma TRUE
4252 #define elf_backend_write_section _bfd_mips_elf_write_section
4254 /* We don't set bfd_elf64_bfd_is_local_label_name because the 32-bit
4255 MIPS-specific function only applies to IRIX5, which had no 64-bit
4257 #define bfd_elf64_bfd_is_target_special_symbol \
4258 _bfd_mips_elf_is_target_special_symbol
4259 #define bfd_elf64_find_nearest_line _bfd_mips_elf_find_nearest_line
4260 #define bfd_elf64_find_inliner_info _bfd_mips_elf_find_inliner_info
4261 #define bfd_elf64_new_section_hook _bfd_mips_elf_new_section_hook
4262 #define bfd_elf64_set_section_contents _bfd_mips_elf_set_section_contents
4263 #define bfd_elf64_bfd_get_relocated_section_contents \
4264 _bfd_elf_mips_get_relocated_section_contents
4265 #define bfd_elf64_bfd_link_hash_table_create \
4266 _bfd_mips_elf_link_hash_table_create
4267 #define bfd_elf64_bfd_final_link _bfd_mips_elf_final_link
4268 #define bfd_elf64_bfd_merge_private_bfd_data \
4269 _bfd_mips_elf_merge_private_bfd_data
4270 #define bfd_elf64_bfd_set_private_flags _bfd_mips_elf_set_private_flags
4271 #define bfd_elf64_bfd_print_private_bfd_data \
4272 _bfd_mips_elf_print_private_bfd_data
4274 #define bfd_elf64_get_reloc_upper_bound mips_elf64_get_reloc_upper_bound
4275 #define bfd_elf64_canonicalize_reloc mips_elf64_canonicalize_reloc
4276 #define bfd_elf64_get_dynamic_reloc_upper_bound mips_elf64_get_dynamic_reloc_upper_bound
4277 #define bfd_elf64_canonicalize_dynamic_reloc mips_elf64_canonicalize_dynamic_reloc
4278 #define bfd_elf64_bfd_relax_section _bfd_mips_relax_section
4279 #define bfd_elf64_mkobject _bfd_mips_elf_mkobject
4281 /* MIPS ELF64 archive functions. */
4282 #define bfd_elf64_archive_functions
4283 extern bfd_boolean bfd_elf64_archive_slurp_armap
4285 extern bfd_boolean bfd_elf64_archive_write_armap
4286 (bfd
*, unsigned int, struct orl
*, unsigned int, int);
4287 #define bfd_elf64_archive_slurp_extended_name_table \
4288 _bfd_archive_coff_slurp_extended_name_table
4289 #define bfd_elf64_archive_construct_extended_name_table \
4290 _bfd_archive_coff_construct_extended_name_table
4291 #define bfd_elf64_archive_truncate_arname \
4292 _bfd_archive_coff_truncate_arname
4293 #define bfd_elf64_archive_read_ar_hdr _bfd_archive_coff_read_ar_hdr
4294 #define bfd_elf64_archive_write_ar_hdr _bfd_archive_coff_write_ar_hdr
4295 #define bfd_elf64_archive_openr_next_archived_file \
4296 _bfd_archive_coff_openr_next_archived_file
4297 #define bfd_elf64_archive_get_elt_at_index \
4298 _bfd_archive_coff_get_elt_at_index
4299 #define bfd_elf64_archive_generic_stat_arch_elt \
4300 _bfd_archive_coff_generic_stat_arch_elt
4301 #define bfd_elf64_archive_update_armap_timestamp \
4302 _bfd_archive_coff_update_armap_timestamp
4304 /* The SGI style (n)64 NewABI. */
4305 #define TARGET_LITTLE_SYM bfd_elf64_littlemips_vec
4306 #define TARGET_LITTLE_NAME "elf64-littlemips"
4307 #define TARGET_BIG_SYM bfd_elf64_bigmips_vec
4308 #define TARGET_BIG_NAME "elf64-bigmips"
4310 #define ELF_MAXPAGESIZE 0x10000
4311 #define ELF_COMMONPAGESIZE 0x1000
4313 #include "elf64-target.h"
4315 /* The SYSV-style 'traditional' (n)64 NewABI. */
4316 #undef TARGET_LITTLE_SYM
4317 #undef TARGET_LITTLE_NAME
4318 #undef TARGET_BIG_SYM
4319 #undef TARGET_BIG_NAME
4321 #undef ELF_MAXPAGESIZE
4322 #undef ELF_COMMONPAGESIZE
4324 #define TARGET_LITTLE_SYM bfd_elf64_tradlittlemips_vec
4325 #define TARGET_LITTLE_NAME "elf64-tradlittlemips"
4326 #define TARGET_BIG_SYM bfd_elf64_tradbigmips_vec
4327 #define TARGET_BIG_NAME "elf64-tradbigmips"
4329 #define ELF_MAXPAGESIZE 0x10000
4330 #define ELF_COMMONPAGESIZE 0x1000
4331 #define elf64_bed elf64_tradbed
4333 /* Include the target file again for this target. */
4334 #include "elf64-target.h"
4337 /* FreeBSD support. */
4339 #undef TARGET_LITTLE_SYM
4340 #undef TARGET_LITTLE_NAME
4341 #undef TARGET_BIG_SYM
4342 #undef TARGET_BIG_NAME
4344 #define TARGET_LITTLE_SYM bfd_elf64_tradlittlemips_freebsd_vec
4345 #define TARGET_LITTLE_NAME "elf64-tradlittlemips-freebsd"
4346 #define TARGET_BIG_SYM bfd_elf64_tradbigmips_freebsd_vec
4347 #define TARGET_BIG_NAME "elf64-tradbigmips-freebsd"
4350 #define ELF_OSABI ELFOSABI_FREEBSD
4352 /* The kernel recognizes executables as valid only if they carry a
4353 "FreeBSD" label in the ELF header. So we put this label on all
4354 executables and (for simplicity) also all other object files. */
4357 elf_fbsd_post_process_headers (bfd
*abfd
, struct bfd_link_info
*info
)
4359 _bfd_elf_set_osabi (abfd
, info
);
4362 #undef elf_backend_post_process_headers
4363 #define elf_backend_post_process_headers elf_fbsd_post_process_headers
4365 #define elf64_bed elf64_fbsd_tradbed
4367 #include "elf64-target.h"