1 /* MIPS-specific support for 64-bit ELF
2 Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
3 2007 Free Software Foundation, Inc.
4 Ian Lance Taylor, Cygnus Support
5 Linker support added by Mark Mitchell, CodeSourcery, LLC.
6 <mark@codesourcery.com>
8 This file is part of BFD, the Binary File Descriptor library.
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
23 MA 02110-1301, USA. */
26 /* This file supports the 64-bit MIPS ELF ABI.
28 The MIPS 64-bit ELF ABI uses an unusual reloc format. This file
29 overrides the usual ELF reloc handling, and handles reading and
30 writing the relocations here. */
32 /* TODO: Many things are unsupported, even if there is some code for it
33 . (which was mostly stolen from elf32-mips.c and slightly adapted).
35 . - Relocation handling for REL relocs is wrong in many cases and
37 . - Relocation handling for RELA relocs related to GOT support are
38 . also likely to be wrong.
39 . - Support for MIPS16 is untested.
40 . - Combined relocs with RSS_* entries are unsupported.
41 . - The whole GOT handling for NewABI is missing, some parts of
42 . the OldABI version is still lying around and should be removed.
52 #include "elfxx-mips.h"
55 /* Get the ECOFF swapping routines. The 64-bit ABI is not supposed to
56 use ECOFF. However, we support it anyhow for an easier changeover. */
58 #include "coff/symconst.h"
59 #include "coff/internal.h"
60 #include "coff/ecoff.h"
61 /* The 64 bit versions of the mdebug data structures are in alpha.h. */
62 #include "coff/alpha.h"
63 #define ECOFF_SIGNED_64
64 #include "ecoffswap.h"
66 static void mips_elf64_swap_reloc_in
67 (bfd
*, const Elf64_Mips_External_Rel
*, Elf64_Mips_Internal_Rela
*);
68 static void mips_elf64_swap_reloca_in
69 (bfd
*, const Elf64_Mips_External_Rela
*, Elf64_Mips_Internal_Rela
*);
70 static void mips_elf64_swap_reloc_out
71 (bfd
*, const Elf64_Mips_Internal_Rela
*, Elf64_Mips_External_Rel
*);
72 static void mips_elf64_swap_reloca_out
73 (bfd
*, const Elf64_Mips_Internal_Rela
*, Elf64_Mips_External_Rela
*);
74 static void mips_elf64_be_swap_reloc_in
75 (bfd
*, const bfd_byte
*, Elf_Internal_Rela
*);
76 static void mips_elf64_be_swap_reloc_out
77 (bfd
*, const Elf_Internal_Rela
*, bfd_byte
*);
78 static void mips_elf64_be_swap_reloca_in
79 (bfd
*, const bfd_byte
*, Elf_Internal_Rela
*);
80 static void mips_elf64_be_swap_reloca_out
81 (bfd
*, const Elf_Internal_Rela
*, bfd_byte
*);
82 static reloc_howto_type
*bfd_elf64_bfd_reloc_type_lookup
83 (bfd
*, bfd_reloc_code_real_type
);
84 static reloc_howto_type
*mips_elf64_rtype_to_howto
85 (unsigned int, bfd_boolean
);
86 static void mips_elf64_info_to_howto_rel
87 (bfd
*, arelent
*, Elf_Internal_Rela
*);
88 static void mips_elf64_info_to_howto_rela
89 (bfd
*, arelent
*, Elf_Internal_Rela
*);
90 static long mips_elf64_get_reloc_upper_bound
92 static long mips_elf64_canonicalize_reloc
93 (bfd
*, asection
*, arelent
**, asymbol
**);
94 static long mips_elf64_get_dynamic_reloc_upper_bound
96 static long mips_elf64_canonicalize_dynamic_reloc
97 (bfd
*, arelent
**, asymbol
**);
98 static bfd_boolean mips_elf64_slurp_one_reloc_table
99 (bfd
*, asection
*, Elf_Internal_Shdr
*, bfd_size_type
, arelent
*,
100 asymbol
**, bfd_boolean
);
101 static bfd_boolean mips_elf64_slurp_reloc_table
102 (bfd
*, asection
*, asymbol
**, bfd_boolean
);
103 static void mips_elf64_write_relocs
104 (bfd
*, asection
*, void *);
105 static void mips_elf64_write_rel
106 (bfd
*, asection
*, Elf_Internal_Shdr
*, int *, void *);
107 static void mips_elf64_write_rela
108 (bfd
*, asection
*, Elf_Internal_Shdr
*, int *, void *);
109 static bfd_reloc_status_type mips_elf64_gprel16_reloc
110 (bfd
*, arelent
*, asymbol
*, void *, asection
*, bfd
*, char **);
111 static bfd_reloc_status_type mips_elf64_literal_reloc
112 (bfd
*, arelent
*, asymbol
*, void *, asection
*, bfd
*, char **);
113 static bfd_reloc_status_type mips_elf64_gprel32_reloc
114 (bfd
*, arelent
*, asymbol
*, void *, asection
*, bfd
*, char **);
115 static bfd_reloc_status_type mips_elf64_shift6_reloc
116 (bfd
*, arelent
*, asymbol
*, void *, asection
*, bfd
*, char **);
117 static bfd_reloc_status_type mips16_gprel_reloc
118 (bfd
*, arelent
*, asymbol
*, void *, asection
*, bfd
*, char **);
119 static bfd_boolean mips_elf64_assign_gp
121 static bfd_reloc_status_type mips_elf64_final_gp
122 (bfd
*, asymbol
*, bfd_boolean
, char **, bfd_vma
*);
123 static bfd_boolean mips_elf64_object_p
125 static bfd_boolean mips_elf64_is_local_label_name
126 (bfd
*, const char *);
127 static irix_compat_t elf64_mips_irix_compat
129 static bfd_boolean elf64_mips_grok_prstatus
130 (bfd
*, Elf_Internal_Note
*);
131 static bfd_boolean elf64_mips_grok_psinfo
132 (bfd
*, Elf_Internal_Note
*);
134 extern const bfd_target bfd_elf64_bigmips_vec
;
135 extern const bfd_target bfd_elf64_littlemips_vec
;
137 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
138 from smaller values. Start with zero, widen, *then* decrement. */
139 #define MINUS_ONE (((bfd_vma)0) - 1)
141 /* The number of local .got entries we reserve. */
142 #define MIPS_RESERVED_GOTNO (2)
144 /* The relocation table used for SHT_REL sections. */
146 static reloc_howto_type mips_elf64_howto_table_rel
[] =
149 HOWTO (R_MIPS_NONE
, /* type */
151 0, /* size (0 = byte, 1 = short, 2 = long) */
153 FALSE
, /* pc_relative */
155 complain_overflow_dont
, /* complain_on_overflow */
156 _bfd_mips_elf_generic_reloc
, /* special_function */
157 "R_MIPS_NONE", /* name */
158 FALSE
, /* partial_inplace */
161 FALSE
), /* pcrel_offset */
163 /* 16 bit relocation. */
164 HOWTO (R_MIPS_16
, /* type */
166 2, /* size (0 = byte, 1 = short, 2 = long) */
168 FALSE
, /* pc_relative */
170 complain_overflow_signed
, /* complain_on_overflow */
171 _bfd_mips_elf_generic_reloc
, /* special_function */
172 "R_MIPS_16", /* name */
173 TRUE
, /* partial_inplace */
174 0x0000ffff, /* src_mask */
175 0x0000ffff, /* dst_mask */
176 FALSE
), /* pcrel_offset */
178 /* 32 bit relocation. */
179 HOWTO (R_MIPS_32
, /* type */
181 2, /* size (0 = byte, 1 = short, 2 = long) */
183 FALSE
, /* pc_relative */
185 complain_overflow_dont
, /* complain_on_overflow */
186 _bfd_mips_elf_generic_reloc
, /* special_function */
187 "R_MIPS_32", /* name */
188 TRUE
, /* partial_inplace */
189 0xffffffff, /* src_mask */
190 0xffffffff, /* dst_mask */
191 FALSE
), /* pcrel_offset */
193 /* 32 bit symbol relative relocation. */
194 HOWTO (R_MIPS_REL32
, /* type */
196 2, /* size (0 = byte, 1 = short, 2 = long) */
198 FALSE
, /* pc_relative */
200 complain_overflow_dont
, /* complain_on_overflow */
201 _bfd_mips_elf_generic_reloc
, /* special_function */
202 "R_MIPS_REL32", /* name */
203 TRUE
, /* partial_inplace */
204 0xffffffff, /* src_mask */
205 0xffffffff, /* dst_mask */
206 FALSE
), /* pcrel_offset */
208 /* 26 bit jump address. */
209 HOWTO (R_MIPS_26
, /* type */
211 2, /* size (0 = byte, 1 = short, 2 = long) */
213 FALSE
, /* pc_relative */
215 complain_overflow_dont
, /* complain_on_overflow */
216 /* This needs complex overflow
217 detection, because the upper 36
218 bits must match the PC + 4. */
219 _bfd_mips_elf_generic_reloc
, /* special_function */
220 "R_MIPS_26", /* name */
221 TRUE
, /* partial_inplace */
222 0x03ffffff, /* src_mask */
223 0x03ffffff, /* dst_mask */
224 FALSE
), /* pcrel_offset */
226 /* R_MIPS_HI16 and R_MIPS_LO16 are unsupported for NewABI REL.
227 However, the native IRIX6 tools use them, so we try our best. */
229 /* High 16 bits of symbol value. */
230 HOWTO (R_MIPS_HI16
, /* type */
232 2, /* size (0 = byte, 1 = short, 2 = long) */
234 FALSE
, /* pc_relative */
236 complain_overflow_dont
, /* complain_on_overflow */
237 _bfd_mips_elf_hi16_reloc
, /* special_function */
238 "R_MIPS_HI16", /* name */
239 TRUE
, /* partial_inplace */
240 0x0000ffff, /* src_mask */
241 0x0000ffff, /* dst_mask */
242 FALSE
), /* pcrel_offset */
244 /* Low 16 bits of symbol value. */
245 HOWTO (R_MIPS_LO16
, /* type */
247 2, /* size (0 = byte, 1 = short, 2 = long) */
249 FALSE
, /* pc_relative */
251 complain_overflow_dont
, /* complain_on_overflow */
252 _bfd_mips_elf_lo16_reloc
, /* special_function */
253 "R_MIPS_LO16", /* name */
254 TRUE
, /* partial_inplace */
255 0x0000ffff, /* src_mask */
256 0x0000ffff, /* dst_mask */
257 FALSE
), /* pcrel_offset */
259 /* GP relative reference. */
260 HOWTO (R_MIPS_GPREL16
, /* type */
262 2, /* size (0 = byte, 1 = short, 2 = long) */
264 FALSE
, /* pc_relative */
266 complain_overflow_signed
, /* complain_on_overflow */
267 mips_elf64_gprel16_reloc
, /* special_function */
268 "R_MIPS_GPREL16", /* name */
269 TRUE
, /* partial_inplace */
270 0x0000ffff, /* src_mask */
271 0x0000ffff, /* dst_mask */
272 FALSE
), /* pcrel_offset */
274 /* Reference to literal section. */
275 HOWTO (R_MIPS_LITERAL
, /* type */
277 2, /* size (0 = byte, 1 = short, 2 = long) */
279 FALSE
, /* pc_relative */
281 complain_overflow_signed
, /* complain_on_overflow */
282 mips_elf64_literal_reloc
, /* special_function */
283 "R_MIPS_LITERAL", /* name */
284 TRUE
, /* partial_inplace */
285 0x0000ffff, /* src_mask */
286 0x0000ffff, /* dst_mask */
287 FALSE
), /* pcrel_offset */
289 /* Reference to global offset table. */
290 HOWTO (R_MIPS_GOT16
, /* type */
292 2, /* size (0 = byte, 1 = short, 2 = long) */
294 FALSE
, /* pc_relative */
296 complain_overflow_signed
, /* complain_on_overflow */
297 _bfd_mips_elf_got16_reloc
, /* special_function */
298 "R_MIPS_GOT16", /* name */
299 TRUE
, /* partial_inplace */
300 0x0000ffff, /* src_mask */
301 0x0000ffff, /* dst_mask */
302 FALSE
), /* pcrel_offset */
304 /* 16 bit PC relative reference. Note that the ABI document has a typo
305 and claims R_MIPS_PC16 to be not rightshifted, rendering it useless.
306 We do the right thing here. */
307 HOWTO (R_MIPS_PC16
, /* type */
309 2, /* size (0 = byte, 1 = short, 2 = long) */
311 TRUE
, /* pc_relative */
313 complain_overflow_signed
, /* complain_on_overflow */
314 _bfd_mips_elf_generic_reloc
, /* special_function */
315 "R_MIPS_PC16", /* name */
316 TRUE
, /* partial_inplace */
317 0x0000ffff, /* src_mask */
318 0x0000ffff, /* dst_mask */
319 TRUE
), /* pcrel_offset */
321 /* 16 bit call through global offset table. */
322 HOWTO (R_MIPS_CALL16
, /* type */
324 2, /* size (0 = byte, 1 = short, 2 = long) */
326 FALSE
, /* pc_relative */
328 complain_overflow_signed
, /* complain_on_overflow */
329 _bfd_mips_elf_generic_reloc
, /* special_function */
330 "R_MIPS_CALL16", /* name */
331 TRUE
, /* partial_inplace */
332 0x0000ffff, /* src_mask */
333 0x0000ffff, /* dst_mask */
334 FALSE
), /* pcrel_offset */
336 /* 32 bit GP relative reference. */
337 HOWTO (R_MIPS_GPREL32
, /* type */
339 2, /* size (0 = byte, 1 = short, 2 = long) */
341 FALSE
, /* pc_relative */
343 complain_overflow_dont
, /* complain_on_overflow */
344 mips_elf64_gprel32_reloc
, /* special_function */
345 "R_MIPS_GPREL32", /* name */
346 TRUE
, /* partial_inplace */
347 0xffffffff, /* src_mask */
348 0xffffffff, /* dst_mask */
349 FALSE
), /* pcrel_offset */
355 /* A 5 bit shift field. */
356 HOWTO (R_MIPS_SHIFT5
, /* type */
358 2, /* size (0 = byte, 1 = short, 2 = long) */
360 FALSE
, /* pc_relative */
362 complain_overflow_bitfield
, /* complain_on_overflow */
363 _bfd_mips_elf_generic_reloc
, /* special_function */
364 "R_MIPS_SHIFT5", /* name */
365 TRUE
, /* partial_inplace */
366 0x000007c0, /* src_mask */
367 0x000007c0, /* dst_mask */
368 FALSE
), /* pcrel_offset */
370 /* A 6 bit shift field. */
371 HOWTO (R_MIPS_SHIFT6
, /* type */
373 2, /* size (0 = byte, 1 = short, 2 = long) */
375 FALSE
, /* pc_relative */
377 complain_overflow_bitfield
, /* complain_on_overflow */
378 mips_elf64_shift6_reloc
, /* special_function */
379 "R_MIPS_SHIFT6", /* name */
380 TRUE
, /* partial_inplace */
381 0x000007c4, /* src_mask */
382 0x000007c4, /* dst_mask */
383 FALSE
), /* pcrel_offset */
385 /* 64 bit relocation. */
386 HOWTO (R_MIPS_64
, /* type */
388 4, /* size (0 = byte, 1 = short, 2 = long) */
390 FALSE
, /* pc_relative */
392 complain_overflow_dont
, /* complain_on_overflow */
393 _bfd_mips_elf_generic_reloc
, /* special_function */
394 "R_MIPS_64", /* name */
395 TRUE
, /* partial_inplace */
396 MINUS_ONE
, /* src_mask */
397 MINUS_ONE
, /* dst_mask */
398 FALSE
), /* pcrel_offset */
400 /* Displacement in the global offset table. */
401 HOWTO (R_MIPS_GOT_DISP
, /* type */
403 2, /* size (0 = byte, 1 = short, 2 = long) */
405 FALSE
, /* pc_relative */
407 complain_overflow_signed
, /* complain_on_overflow */
408 _bfd_mips_elf_generic_reloc
, /* special_function */
409 "R_MIPS_GOT_DISP", /* name */
410 TRUE
, /* partial_inplace */
411 0x0000ffff, /* src_mask */
412 0x0000ffff, /* dst_mask */
413 FALSE
), /* pcrel_offset */
415 /* Displacement to page pointer in the global offset table. */
416 HOWTO (R_MIPS_GOT_PAGE
, /* type */
418 2, /* size (0 = byte, 1 = short, 2 = long) */
420 FALSE
, /* pc_relative */
422 complain_overflow_signed
, /* complain_on_overflow */
423 _bfd_mips_elf_generic_reloc
, /* special_function */
424 "R_MIPS_GOT_PAGE", /* name */
425 TRUE
, /* partial_inplace */
426 0x0000ffff, /* src_mask */
427 0x0000ffff, /* dst_mask */
428 FALSE
), /* pcrel_offset */
430 /* Offset from page pointer in the global offset table. */
431 HOWTO (R_MIPS_GOT_OFST
, /* type */
433 2, /* size (0 = byte, 1 = short, 2 = long) */
435 FALSE
, /* pc_relative */
437 complain_overflow_signed
, /* complain_on_overflow */
438 _bfd_mips_elf_generic_reloc
, /* special_function */
439 "R_MIPS_GOT_OFST", /* name */
440 TRUE
, /* partial_inplace */
441 0x0000ffff, /* src_mask */
442 0x0000ffff, /* dst_mask */
443 FALSE
), /* pcrel_offset */
445 /* High 16 bits of displacement in global offset table. */
446 HOWTO (R_MIPS_GOT_HI16
, /* type */
448 2, /* size (0 = byte, 1 = short, 2 = long) */
450 FALSE
, /* pc_relative */
452 complain_overflow_dont
, /* complain_on_overflow */
453 _bfd_mips_elf_generic_reloc
, /* special_function */
454 "R_MIPS_GOT_HI16", /* name */
455 TRUE
, /* partial_inplace */
456 0x0000ffff, /* src_mask */
457 0x0000ffff, /* dst_mask */
458 FALSE
), /* pcrel_offset */
460 /* Low 16 bits of displacement in global offset table. */
461 HOWTO (R_MIPS_GOT_LO16
, /* type */
463 2, /* size (0 = byte, 1 = short, 2 = long) */
465 FALSE
, /* pc_relative */
467 complain_overflow_dont
, /* complain_on_overflow */
468 _bfd_mips_elf_generic_reloc
, /* special_function */
469 "R_MIPS_GOT_LO16", /* name */
470 TRUE
, /* partial_inplace */
471 0x0000ffff, /* src_mask */
472 0x0000ffff, /* dst_mask */
473 FALSE
), /* pcrel_offset */
475 /* 64 bit subtraction. */
476 HOWTO (R_MIPS_SUB
, /* type */
478 4, /* size (0 = byte, 1 = short, 2 = long) */
480 FALSE
, /* pc_relative */
482 complain_overflow_dont
, /* complain_on_overflow */
483 _bfd_mips_elf_generic_reloc
, /* special_function */
484 "R_MIPS_SUB", /* name */
485 TRUE
, /* partial_inplace */
486 MINUS_ONE
, /* src_mask */
487 MINUS_ONE
, /* dst_mask */
488 FALSE
), /* pcrel_offset */
490 /* Insert the addend as an instruction. */
491 /* FIXME: Not handled correctly. */
492 HOWTO (R_MIPS_INSERT_A
, /* type */
494 2, /* size (0 = byte, 1 = short, 2 = long) */
496 FALSE
, /* pc_relative */
498 complain_overflow_dont
, /* complain_on_overflow */
499 _bfd_mips_elf_generic_reloc
, /* special_function */
500 "R_MIPS_INSERT_A", /* name */
501 TRUE
, /* partial_inplace */
502 0xffffffff, /* src_mask */
503 0xffffffff, /* dst_mask */
504 FALSE
), /* pcrel_offset */
506 /* Insert the addend as an instruction, and change all relocations
507 to refer to the old instruction at the address. */
508 /* FIXME: Not handled correctly. */
509 HOWTO (R_MIPS_INSERT_B
, /* type */
511 2, /* size (0 = byte, 1 = short, 2 = long) */
513 FALSE
, /* pc_relative */
515 complain_overflow_dont
, /* complain_on_overflow */
516 _bfd_mips_elf_generic_reloc
, /* special_function */
517 "R_MIPS_INSERT_B", /* name */
518 TRUE
, /* partial_inplace */
519 0xffffffff, /* src_mask */
520 0xffffffff, /* dst_mask */
521 FALSE
), /* pcrel_offset */
523 /* Delete a 32 bit instruction. */
524 /* FIXME: Not handled correctly. */
525 HOWTO (R_MIPS_DELETE
, /* type */
527 2, /* size (0 = byte, 1 = short, 2 = long) */
529 FALSE
, /* pc_relative */
531 complain_overflow_dont
, /* complain_on_overflow */
532 _bfd_mips_elf_generic_reloc
, /* special_function */
533 "R_MIPS_DELETE", /* name */
534 TRUE
, /* partial_inplace */
535 0xffffffff, /* src_mask */
536 0xffffffff, /* dst_mask */
537 FALSE
), /* pcrel_offset */
539 /* The MIPS ELF64 ABI Draft wants us to support these for REL relocations.
541 a) It means building the addend from a R_MIPS_HIGHEST/R_MIPS_HIGHER/
542 R_MIPS_HI16/R_MIPS_LO16 sequence with varying ordering, using
544 b) No other NewABI toolchain actually emits such relocations. */
545 EMPTY_HOWTO (R_MIPS_HIGHER
),
546 EMPTY_HOWTO (R_MIPS_HIGHEST
),
548 /* High 16 bits of displacement in global offset table. */
549 HOWTO (R_MIPS_CALL_HI16
, /* type */
551 2, /* size (0 = byte, 1 = short, 2 = long) */
553 FALSE
, /* pc_relative */
555 complain_overflow_dont
, /* complain_on_overflow */
556 _bfd_mips_elf_generic_reloc
, /* special_function */
557 "R_MIPS_CALL_HI16", /* name */
558 TRUE
, /* partial_inplace */
559 0x0000ffff, /* src_mask */
560 0x0000ffff, /* dst_mask */
561 FALSE
), /* pcrel_offset */
563 /* Low 16 bits of displacement in global offset table. */
564 HOWTO (R_MIPS_CALL_LO16
, /* type */
566 2, /* size (0 = byte, 1 = short, 2 = long) */
568 FALSE
, /* pc_relative */
570 complain_overflow_dont
, /* complain_on_overflow */
571 _bfd_mips_elf_generic_reloc
, /* special_function */
572 "R_MIPS_CALL_LO16", /* name */
573 TRUE
, /* partial_inplace */
574 0x0000ffff, /* src_mask */
575 0x0000ffff, /* dst_mask */
576 FALSE
), /* pcrel_offset */
578 /* Section displacement, used by an associated event location section. */
579 HOWTO (R_MIPS_SCN_DISP
, /* type */
581 2, /* size (0 = byte, 1 = short, 2 = long) */
583 FALSE
, /* pc_relative */
585 complain_overflow_dont
, /* complain_on_overflow */
586 _bfd_mips_elf_generic_reloc
, /* special_function */
587 "R_MIPS_SCN_DISP", /* name */
588 TRUE
, /* partial_inplace */
589 0xffffffff, /* src_mask */
590 0xffffffff, /* dst_mask */
591 FALSE
), /* pcrel_offset */
593 HOWTO (R_MIPS_REL16
, /* type */
595 1, /* size (0 = byte, 1 = short, 2 = long) */
597 FALSE
, /* pc_relative */
599 complain_overflow_signed
, /* complain_on_overflow */
600 _bfd_mips_elf_generic_reloc
, /* special_function */
601 "R_MIPS_REL16", /* name */
602 TRUE
, /* partial_inplace */
603 0xffff, /* src_mask */
604 0xffff, /* dst_mask */
605 FALSE
), /* pcrel_offset */
607 /* These two are obsolete. */
608 EMPTY_HOWTO (R_MIPS_ADD_IMMEDIATE
),
609 EMPTY_HOWTO (R_MIPS_PJUMP
),
611 /* Similiar to R_MIPS_REL32, but used for relocations in a GOT section.
612 It must be used for multigot GOT's (and only there). */
613 HOWTO (R_MIPS_RELGOT
, /* type */
615 2, /* size (0 = byte, 1 = short, 2 = long) */
617 FALSE
, /* pc_relative */
619 complain_overflow_dont
, /* complain_on_overflow */
620 _bfd_mips_elf_generic_reloc
, /* special_function */
621 "R_MIPS_RELGOT", /* name */
622 TRUE
, /* partial_inplace */
623 0xffffffff, /* src_mask */
624 0xffffffff, /* dst_mask */
625 FALSE
), /* pcrel_offset */
627 /* Protected jump conversion. This is an optimization hint. No
628 relocation is required for correctness. */
629 HOWTO (R_MIPS_JALR
, /* type */
631 2, /* size (0 = byte, 1 = short, 2 = long) */
633 FALSE
, /* pc_relative */
635 complain_overflow_dont
, /* complain_on_overflow */
636 _bfd_mips_elf_generic_reloc
, /* special_function */
637 "R_MIPS_JALR", /* name */
638 FALSE
, /* partial_inplace */
640 0x00000000, /* dst_mask */
641 FALSE
), /* pcrel_offset */
643 /* TLS relocations. */
644 EMPTY_HOWTO (R_MIPS_TLS_DTPMOD32
),
645 EMPTY_HOWTO (R_MIPS_TLS_DTPREL32
),
647 HOWTO (R_MIPS_TLS_DTPMOD64
, /* type */
649 4, /* size (0 = byte, 1 = short, 2 = long) */
651 FALSE
, /* pc_relative */
653 complain_overflow_dont
, /* complain_on_overflow */
654 _bfd_mips_elf_generic_reloc
, /* special_function */
655 "R_MIPS_TLS_DTPMOD64", /* name */
656 TRUE
, /* partial_inplace */
657 MINUS_ONE
, /* src_mask */
658 MINUS_ONE
, /* dst_mask */
659 FALSE
), /* pcrel_offset */
661 HOWTO (R_MIPS_TLS_DTPREL64
, /* type */
663 4, /* size (0 = byte, 1 = short, 2 = long) */
665 FALSE
, /* pc_relative */
667 complain_overflow_dont
, /* complain_on_overflow */
668 _bfd_mips_elf_generic_reloc
, /* special_function */
669 "R_MIPS_TLS_DTPREL64", /* name */
670 TRUE
, /* partial_inplace */
671 MINUS_ONE
, /* src_mask */
672 MINUS_ONE
, /* dst_mask */
673 FALSE
), /* pcrel_offset */
675 /* TLS general dynamic variable reference. */
676 HOWTO (R_MIPS_TLS_GD
, /* type */
678 2, /* size (0 = byte, 1 = short, 2 = long) */
680 FALSE
, /* pc_relative */
682 complain_overflow_signed
, /* complain_on_overflow */
683 _bfd_mips_elf_generic_reloc
, /* special_function */
684 "R_MIPS_TLS_GD", /* name */
685 TRUE
, /* partial_inplace */
686 0x0000ffff, /* src_mask */
687 0x0000ffff, /* dst_mask */
688 FALSE
), /* pcrel_offset */
690 /* TLS local dynamic variable reference. */
691 HOWTO (R_MIPS_TLS_LDM
, /* type */
693 2, /* size (0 = byte, 1 = short, 2 = long) */
695 FALSE
, /* pc_relative */
697 complain_overflow_signed
, /* complain_on_overflow */
698 _bfd_mips_elf_generic_reloc
, /* special_function */
699 "R_MIPS_TLS_LDM", /* name */
700 TRUE
, /* partial_inplace */
701 0x0000ffff, /* src_mask */
702 0x0000ffff, /* dst_mask */
703 FALSE
), /* pcrel_offset */
705 /* TLS local dynamic offset. */
706 HOWTO (R_MIPS_TLS_DTPREL_HI16
, /* type */
708 2, /* size (0 = byte, 1 = short, 2 = long) */
710 FALSE
, /* pc_relative */
712 complain_overflow_signed
, /* complain_on_overflow */
713 _bfd_mips_elf_generic_reloc
, /* special_function */
714 "R_MIPS_TLS_DTPREL_HI16", /* name */
715 TRUE
, /* partial_inplace */
716 0x0000ffff, /* src_mask */
717 0x0000ffff, /* dst_mask */
718 FALSE
), /* pcrel_offset */
720 /* TLS local dynamic offset. */
721 HOWTO (R_MIPS_TLS_DTPREL_LO16
, /* type */
723 2, /* size (0 = byte, 1 = short, 2 = long) */
725 FALSE
, /* pc_relative */
727 complain_overflow_signed
, /* complain_on_overflow */
728 _bfd_mips_elf_generic_reloc
, /* special_function */
729 "R_MIPS_TLS_DTPREL_LO16", /* name */
730 TRUE
, /* partial_inplace */
731 0x0000ffff, /* src_mask */
732 0x0000ffff, /* dst_mask */
733 FALSE
), /* pcrel_offset */
735 /* TLS thread pointer offset. */
736 HOWTO (R_MIPS_TLS_GOTTPREL
, /* type */
738 2, /* size (0 = byte, 1 = short, 2 = long) */
740 FALSE
, /* pc_relative */
742 complain_overflow_signed
, /* complain_on_overflow */
743 _bfd_mips_elf_generic_reloc
, /* special_function */
744 "R_MIPS_TLS_GOTTPREL", /* name */
745 TRUE
, /* partial_inplace */
746 0x0000ffff, /* src_mask */
747 0x0000ffff, /* dst_mask */
748 FALSE
), /* pcrel_offset */
750 /* TLS IE dynamic relocations. */
751 EMPTY_HOWTO (R_MIPS_TLS_TPREL32
),
753 HOWTO (R_MIPS_TLS_TPREL64
, /* type */
755 4, /* size (0 = byte, 1 = short, 2 = long) */
757 FALSE
, /* pc_relative */
759 complain_overflow_dont
, /* complain_on_overflow */
760 _bfd_mips_elf_generic_reloc
, /* special_function */
761 "R_MIPS_TLS_TPREL64", /* name */
762 TRUE
, /* partial_inplace */
763 MINUS_ONE
, /* src_mask */
764 MINUS_ONE
, /* dst_mask */
765 FALSE
), /* pcrel_offset */
767 /* TLS thread pointer offset. */
768 HOWTO (R_MIPS_TLS_TPREL_HI16
, /* type */
770 2, /* size (0 = byte, 1 = short, 2 = long) */
772 FALSE
, /* pc_relative */
774 complain_overflow_signed
, /* complain_on_overflow */
775 _bfd_mips_elf_generic_reloc
, /* special_function */
776 "R_MIPS_TLS_TPREL_HI16", /* name */
777 TRUE
, /* partial_inplace */
778 0x0000ffff, /* src_mask */
779 0x0000ffff, /* dst_mask */
780 FALSE
), /* pcrel_offset */
782 /* TLS thread pointer offset. */
783 HOWTO (R_MIPS_TLS_TPREL_LO16
, /* type */
785 2, /* size (0 = byte, 1 = short, 2 = long) */
787 FALSE
, /* pc_relative */
789 complain_overflow_signed
, /* complain_on_overflow */
790 _bfd_mips_elf_generic_reloc
, /* special_function */
791 "R_MIPS_TLS_TPREL_LO16", /* name */
792 TRUE
, /* partial_inplace */
793 0x0000ffff, /* src_mask */
794 0x0000ffff, /* dst_mask */
795 FALSE
), /* pcrel_offset */
797 /* 32 bit relocation with no addend. */
798 HOWTO (R_MIPS_GLOB_DAT
, /* type */
800 2, /* size (0 = byte, 1 = short, 2 = long) */
802 FALSE
, /* pc_relative */
804 complain_overflow_dont
, /* complain_on_overflow */
805 _bfd_mips_elf_generic_reloc
, /* special_function */
806 "R_MIPS_GLOB_DAT", /* name */
807 FALSE
, /* partial_inplace */
809 0xffffffff, /* dst_mask */
810 FALSE
), /* pcrel_offset */
813 /* The relocation table used for SHT_RELA sections. */
815 static reloc_howto_type mips_elf64_howto_table_rela
[] =
818 HOWTO (R_MIPS_NONE
, /* type */
820 0, /* size (0 = byte, 1 = short, 2 = long) */
822 FALSE
, /* pc_relative */
824 complain_overflow_dont
, /* complain_on_overflow */
825 _bfd_mips_elf_generic_reloc
, /* special_function */
826 "R_MIPS_NONE", /* name */
827 FALSE
, /* partial_inplace */
830 FALSE
), /* pcrel_offset */
832 /* 16 bit relocation. */
833 HOWTO (R_MIPS_16
, /* type */
835 2, /* size (0 = byte, 1 = short, 2 = long) */
837 FALSE
, /* pc_relative */
839 complain_overflow_signed
, /* complain_on_overflow */
840 _bfd_mips_elf_generic_reloc
, /* special_function */
841 "R_MIPS_16", /* name */
842 FALSE
, /* partial_inplace */
844 0x0000ffff, /* dst_mask */
845 FALSE
), /* pcrel_offset */
847 /* 32 bit relocation. */
848 HOWTO (R_MIPS_32
, /* type */
850 2, /* size (0 = byte, 1 = short, 2 = long) */
852 FALSE
, /* pc_relative */
854 complain_overflow_dont
, /* complain_on_overflow */
855 _bfd_mips_elf_generic_reloc
, /* special_function */
856 "R_MIPS_32", /* name */
857 FALSE
, /* partial_inplace */
859 0xffffffff, /* dst_mask */
860 FALSE
), /* pcrel_offset */
862 /* 32 bit symbol relative relocation. */
863 HOWTO (R_MIPS_REL32
, /* type */
865 2, /* size (0 = byte, 1 = short, 2 = long) */
867 FALSE
, /* pc_relative */
869 complain_overflow_dont
, /* complain_on_overflow */
870 _bfd_mips_elf_generic_reloc
, /* special_function */
871 "R_MIPS_REL32", /* name */
872 FALSE
, /* partial_inplace */
874 0xffffffff, /* dst_mask */
875 FALSE
), /* pcrel_offset */
877 /* 26 bit jump address. */
878 HOWTO (R_MIPS_26
, /* type */
880 2, /* size (0 = byte, 1 = short, 2 = long) */
882 FALSE
, /* pc_relative */
884 complain_overflow_dont
, /* complain_on_overflow */
885 /* This needs complex overflow
886 detection, because the upper 36
887 bits must match the PC + 4. */
888 _bfd_mips_elf_generic_reloc
, /* special_function */
889 "R_MIPS_26", /* name */
890 FALSE
, /* partial_inplace */
892 0x03ffffff, /* dst_mask */
893 FALSE
), /* pcrel_offset */
895 /* High 16 bits of symbol value. */
896 HOWTO (R_MIPS_HI16
, /* type */
898 2, /* size (0 = byte, 1 = short, 2 = long) */
900 FALSE
, /* pc_relative */
902 complain_overflow_dont
, /* complain_on_overflow */
903 _bfd_mips_elf_generic_reloc
, /* special_function */
904 "R_MIPS_HI16", /* name */
905 FALSE
, /* partial_inplace */
907 0x0000ffff, /* dst_mask */
908 FALSE
), /* pcrel_offset */
910 /* Low 16 bits of symbol value. */
911 HOWTO (R_MIPS_LO16
, /* type */
913 2, /* size (0 = byte, 1 = short, 2 = long) */
915 FALSE
, /* pc_relative */
917 complain_overflow_dont
, /* complain_on_overflow */
918 _bfd_mips_elf_generic_reloc
, /* special_function */
919 "R_MIPS_LO16", /* name */
920 FALSE
, /* partial_inplace */
922 0x0000ffff, /* dst_mask */
923 FALSE
), /* pcrel_offset */
925 /* GP relative reference. */
926 HOWTO (R_MIPS_GPREL16
, /* type */
928 2, /* size (0 = byte, 1 = short, 2 = long) */
930 FALSE
, /* pc_relative */
932 complain_overflow_signed
, /* complain_on_overflow */
933 mips_elf64_gprel16_reloc
, /* special_function */
934 "R_MIPS_GPREL16", /* name */
935 FALSE
, /* partial_inplace */
937 0x0000ffff, /* dst_mask */
938 FALSE
), /* pcrel_offset */
940 /* Reference to literal section. */
941 HOWTO (R_MIPS_LITERAL
, /* type */
943 2, /* size (0 = byte, 1 = short, 2 = long) */
945 FALSE
, /* pc_relative */
947 complain_overflow_signed
, /* complain_on_overflow */
948 mips_elf64_literal_reloc
, /* special_function */
949 "R_MIPS_LITERAL", /* name */
950 FALSE
, /* partial_inplace */
952 0x0000ffff, /* dst_mask */
953 FALSE
), /* pcrel_offset */
955 /* Reference to global offset table. */
956 HOWTO (R_MIPS_GOT16
, /* type */
958 2, /* size (0 = byte, 1 = short, 2 = long) */
960 FALSE
, /* pc_relative */
962 complain_overflow_signed
, /* complain_on_overflow */
963 _bfd_mips_elf_generic_reloc
, /* special_function */
964 "R_MIPS_GOT16", /* name */
965 FALSE
, /* partial_inplace */
967 0x0000ffff, /* dst_mask */
968 FALSE
), /* pcrel_offset */
970 /* 16 bit PC relative reference. Note that the ABI document has a typo
971 and claims R_MIPS_PC16 to be not rightshifted, rendering it useless.
972 We do the right thing here. */
973 HOWTO (R_MIPS_PC16
, /* type */
975 2, /* size (0 = byte, 1 = short, 2 = long) */
977 TRUE
, /* pc_relative */
979 complain_overflow_signed
, /* complain_on_overflow */
980 _bfd_mips_elf_generic_reloc
, /* special_function */
981 "R_MIPS_PC16", /* name */
982 FALSE
, /* partial_inplace */
984 0x0000ffff, /* dst_mask */
985 TRUE
), /* pcrel_offset */
987 /* 16 bit call through global offset table. */
988 HOWTO (R_MIPS_CALL16
, /* type */
990 2, /* size (0 = byte, 1 = short, 2 = long) */
992 FALSE
, /* pc_relative */
994 complain_overflow_signed
, /* complain_on_overflow */
995 _bfd_mips_elf_generic_reloc
, /* special_function */
996 "R_MIPS_CALL16", /* name */
997 FALSE
, /* partial_inplace */
999 0x0000ffff, /* dst_mask */
1000 FALSE
), /* pcrel_offset */
1002 /* 32 bit GP relative reference. */
1003 HOWTO (R_MIPS_GPREL32
, /* type */
1005 2, /* size (0 = byte, 1 = short, 2 = long) */
1007 FALSE
, /* pc_relative */
1009 complain_overflow_dont
, /* complain_on_overflow */
1010 mips_elf64_gprel32_reloc
, /* special_function */
1011 "R_MIPS_GPREL32", /* name */
1012 FALSE
, /* partial_inplace */
1014 0xffffffff, /* dst_mask */
1015 FALSE
), /* pcrel_offset */
1021 /* A 5 bit shift field. */
1022 HOWTO (R_MIPS_SHIFT5
, /* type */
1024 2, /* size (0 = byte, 1 = short, 2 = long) */
1026 FALSE
, /* pc_relative */
1028 complain_overflow_bitfield
, /* complain_on_overflow */
1029 _bfd_mips_elf_generic_reloc
, /* special_function */
1030 "R_MIPS_SHIFT5", /* name */
1031 FALSE
, /* partial_inplace */
1033 0x000007c0, /* dst_mask */
1034 FALSE
), /* pcrel_offset */
1036 /* A 6 bit shift field. */
1037 HOWTO (R_MIPS_SHIFT6
, /* type */
1039 2, /* size (0 = byte, 1 = short, 2 = long) */
1041 FALSE
, /* pc_relative */
1043 complain_overflow_bitfield
, /* complain_on_overflow */
1044 mips_elf64_shift6_reloc
, /* special_function */
1045 "R_MIPS_SHIFT6", /* name */
1046 FALSE
, /* partial_inplace */
1048 0x000007c4, /* dst_mask */
1049 FALSE
), /* pcrel_offset */
1051 /* 64 bit relocation. */
1052 HOWTO (R_MIPS_64
, /* type */
1054 4, /* size (0 = byte, 1 = short, 2 = long) */
1056 FALSE
, /* pc_relative */
1058 complain_overflow_dont
, /* complain_on_overflow */
1059 _bfd_mips_elf_generic_reloc
, /* special_function */
1060 "R_MIPS_64", /* name */
1061 FALSE
, /* partial_inplace */
1063 MINUS_ONE
, /* dst_mask */
1064 FALSE
), /* pcrel_offset */
1066 /* Displacement in the global offset table. */
1067 HOWTO (R_MIPS_GOT_DISP
, /* type */
1069 2, /* size (0 = byte, 1 = short, 2 = long) */
1071 FALSE
, /* pc_relative */
1073 complain_overflow_signed
, /* complain_on_overflow */
1074 _bfd_mips_elf_generic_reloc
, /* special_function */
1075 "R_MIPS_GOT_DISP", /* name */
1076 FALSE
, /* partial_inplace */
1078 0x0000ffff, /* dst_mask */
1079 FALSE
), /* pcrel_offset */
1081 /* Displacement to page pointer in the global offset table. */
1082 HOWTO (R_MIPS_GOT_PAGE
, /* type */
1084 2, /* size (0 = byte, 1 = short, 2 = long) */
1086 FALSE
, /* pc_relative */
1088 complain_overflow_signed
, /* complain_on_overflow */
1089 _bfd_mips_elf_generic_reloc
, /* special_function */
1090 "R_MIPS_GOT_PAGE", /* name */
1091 FALSE
, /* partial_inplace */
1093 0x0000ffff, /* dst_mask */
1094 FALSE
), /* pcrel_offset */
1096 /* Offset from page pointer in the global offset table. */
1097 HOWTO (R_MIPS_GOT_OFST
, /* type */
1099 2, /* size (0 = byte, 1 = short, 2 = long) */
1101 FALSE
, /* pc_relative */
1103 complain_overflow_signed
, /* complain_on_overflow */
1104 _bfd_mips_elf_generic_reloc
, /* special_function */
1105 "R_MIPS_GOT_OFST", /* name */
1106 FALSE
, /* partial_inplace */
1108 0x0000ffff, /* dst_mask */
1109 FALSE
), /* pcrel_offset */
1111 /* High 16 bits of displacement in global offset table. */
1112 HOWTO (R_MIPS_GOT_HI16
, /* type */
1114 2, /* size (0 = byte, 1 = short, 2 = long) */
1116 FALSE
, /* pc_relative */
1118 complain_overflow_dont
, /* complain_on_overflow */
1119 _bfd_mips_elf_generic_reloc
, /* special_function */
1120 "R_MIPS_GOT_HI16", /* name */
1121 FALSE
, /* partial_inplace */
1123 0x0000ffff, /* dst_mask */
1124 FALSE
), /* pcrel_offset */
1126 /* Low 16 bits of displacement in global offset table. */
1127 HOWTO (R_MIPS_GOT_LO16
, /* type */
1129 2, /* size (0 = byte, 1 = short, 2 = long) */
1131 FALSE
, /* pc_relative */
1133 complain_overflow_dont
, /* complain_on_overflow */
1134 _bfd_mips_elf_generic_reloc
, /* special_function */
1135 "R_MIPS_GOT_LO16", /* name */
1136 FALSE
, /* partial_inplace */
1138 0x0000ffff, /* dst_mask */
1139 FALSE
), /* pcrel_offset */
1141 /* 64 bit subtraction. */
1142 HOWTO (R_MIPS_SUB
, /* type */
1144 4, /* size (0 = byte, 1 = short, 2 = long) */
1146 FALSE
, /* pc_relative */
1148 complain_overflow_dont
, /* complain_on_overflow */
1149 _bfd_mips_elf_generic_reloc
, /* special_function */
1150 "R_MIPS_SUB", /* name */
1151 FALSE
, /* partial_inplace */
1153 MINUS_ONE
, /* dst_mask */
1154 FALSE
), /* pcrel_offset */
1156 /* Insert the addend as an instruction. */
1157 /* FIXME: Not handled correctly. */
1158 HOWTO (R_MIPS_INSERT_A
, /* type */
1160 2, /* size (0 = byte, 1 = short, 2 = long) */
1162 FALSE
, /* pc_relative */
1164 complain_overflow_dont
, /* complain_on_overflow */
1165 _bfd_mips_elf_generic_reloc
, /* special_function */
1166 "R_MIPS_INSERT_A", /* name */
1167 FALSE
, /* partial_inplace */
1169 0xffffffff, /* dst_mask */
1170 FALSE
), /* pcrel_offset */
1172 /* Insert the addend as an instruction, and change all relocations
1173 to refer to the old instruction at the address. */
1174 /* FIXME: Not handled correctly. */
1175 HOWTO (R_MIPS_INSERT_B
, /* type */
1177 2, /* size (0 = byte, 1 = short, 2 = long) */
1179 FALSE
, /* pc_relative */
1181 complain_overflow_dont
, /* complain_on_overflow */
1182 _bfd_mips_elf_generic_reloc
, /* special_function */
1183 "R_MIPS_INSERT_B", /* name */
1184 FALSE
, /* partial_inplace */
1186 0xffffffff, /* dst_mask */
1187 FALSE
), /* pcrel_offset */
1189 /* Delete a 32 bit instruction. */
1190 /* FIXME: Not handled correctly. */
1191 HOWTO (R_MIPS_DELETE
, /* type */
1193 2, /* size (0 = byte, 1 = short, 2 = long) */
1195 FALSE
, /* pc_relative */
1197 complain_overflow_dont
, /* complain_on_overflow */
1198 _bfd_mips_elf_generic_reloc
, /* special_function */
1199 "R_MIPS_DELETE", /* name */
1200 FALSE
, /* partial_inplace */
1202 0xffffffff, /* dst_mask */
1203 FALSE
), /* pcrel_offset */
1205 /* Get the higher value of a 64 bit addend. */
1206 HOWTO (R_MIPS_HIGHER
, /* type */
1208 2, /* size (0 = byte, 1 = short, 2 = long) */
1210 FALSE
, /* pc_relative */
1212 complain_overflow_dont
, /* complain_on_overflow */
1213 _bfd_mips_elf_generic_reloc
, /* special_function */
1214 "R_MIPS_HIGHER", /* name */
1215 FALSE
, /* partial_inplace */
1217 0x0000ffff, /* dst_mask */
1218 FALSE
), /* pcrel_offset */
1220 /* Get the highest value of a 64 bit addend. */
1221 HOWTO (R_MIPS_HIGHEST
, /* type */
1223 2, /* size (0 = byte, 1 = short, 2 = long) */
1225 FALSE
, /* pc_relative */
1227 complain_overflow_dont
, /* complain_on_overflow */
1228 _bfd_mips_elf_generic_reloc
, /* special_function */
1229 "R_MIPS_HIGHEST", /* name */
1230 FALSE
, /* partial_inplace */
1232 0x0000ffff, /* dst_mask */
1233 FALSE
), /* pcrel_offset */
1235 /* High 16 bits of displacement in global offset table. */
1236 HOWTO (R_MIPS_CALL_HI16
, /* type */
1238 2, /* size (0 = byte, 1 = short, 2 = long) */
1240 FALSE
, /* pc_relative */
1242 complain_overflow_dont
, /* complain_on_overflow */
1243 _bfd_mips_elf_generic_reloc
, /* special_function */
1244 "R_MIPS_CALL_HI16", /* name */
1245 FALSE
, /* partial_inplace */
1247 0x0000ffff, /* dst_mask */
1248 FALSE
), /* pcrel_offset */
1250 /* Low 16 bits of displacement in global offset table. */
1251 HOWTO (R_MIPS_CALL_LO16
, /* type */
1253 2, /* size (0 = byte, 1 = short, 2 = long) */
1255 FALSE
, /* pc_relative */
1257 complain_overflow_dont
, /* complain_on_overflow */
1258 _bfd_mips_elf_generic_reloc
, /* special_function */
1259 "R_MIPS_CALL_LO16", /* name */
1260 FALSE
, /* partial_inplace */
1262 0x0000ffff, /* dst_mask */
1263 FALSE
), /* pcrel_offset */
1265 /* Section displacement, used by an associated event location section. */
1266 HOWTO (R_MIPS_SCN_DISP
, /* type */
1268 2, /* size (0 = byte, 1 = short, 2 = long) */
1270 FALSE
, /* pc_relative */
1272 complain_overflow_dont
, /* complain_on_overflow */
1273 _bfd_mips_elf_generic_reloc
, /* special_function */
1274 "R_MIPS_SCN_DISP", /* name */
1275 FALSE
, /* partial_inplace */
1277 0xffffffff, /* dst_mask */
1278 FALSE
), /* pcrel_offset */
1280 HOWTO (R_MIPS_REL16
, /* type */
1282 1, /* size (0 = byte, 1 = short, 2 = long) */
1284 FALSE
, /* pc_relative */
1286 complain_overflow_signed
, /* complain_on_overflow */
1287 _bfd_mips_elf_generic_reloc
, /* special_function */
1288 "R_MIPS_REL16", /* name */
1289 FALSE
, /* partial_inplace */
1291 0xffff, /* dst_mask */
1292 FALSE
), /* pcrel_offset */
1294 /* These two are obsolete. */
1295 EMPTY_HOWTO (R_MIPS_ADD_IMMEDIATE
),
1296 EMPTY_HOWTO (R_MIPS_PJUMP
),
1298 /* Similiar to R_MIPS_REL32, but used for relocations in a GOT section.
1299 It must be used for multigot GOT's (and only there). */
1300 HOWTO (R_MIPS_RELGOT
, /* type */
1302 2, /* size (0 = byte, 1 = short, 2 = long) */
1304 FALSE
, /* pc_relative */
1306 complain_overflow_dont
, /* complain_on_overflow */
1307 _bfd_mips_elf_generic_reloc
, /* special_function */
1308 "R_MIPS_RELGOT", /* name */
1309 FALSE
, /* partial_inplace */
1311 0xffffffff, /* dst_mask */
1312 FALSE
), /* pcrel_offset */
1314 /* Protected jump conversion. This is an optimization hint. No
1315 relocation is required for correctness. */
1316 HOWTO (R_MIPS_JALR
, /* type */
1318 2, /* size (0 = byte, 1 = short, 2 = long) */
1320 FALSE
, /* pc_relative */
1322 complain_overflow_dont
, /* complain_on_overflow */
1323 _bfd_mips_elf_generic_reloc
, /* special_function */
1324 "R_MIPS_JALR", /* name */
1325 FALSE
, /* partial_inplace */
1327 0x00000000, /* dst_mask */
1328 FALSE
), /* pcrel_offset */
1330 /* TLS relocations. */
1331 EMPTY_HOWTO (R_MIPS_TLS_DTPMOD32
),
1332 EMPTY_HOWTO (R_MIPS_TLS_DTPREL32
),
1333 EMPTY_HOWTO (R_MIPS_TLS_DTPMOD64
),
1335 HOWTO (R_MIPS_TLS_DTPREL64
, /* type */
1337 4, /* size (0 = byte, 1 = short, 2 = long) */
1339 FALSE
, /* pc_relative */
1341 complain_overflow_dont
, /* complain_on_overflow */
1342 _bfd_mips_elf_generic_reloc
, /* special_function */
1343 "R_MIPS_TLS_DTPREL64", /* name */
1344 TRUE
, /* partial_inplace */
1345 MINUS_ONE
, /* src_mask */
1346 MINUS_ONE
, /* dst_mask */
1347 FALSE
), /* pcrel_offset */
1349 /* TLS general dynamic variable reference. */
1350 HOWTO (R_MIPS_TLS_GD
, /* type */
1352 2, /* size (0 = byte, 1 = short, 2 = long) */
1354 FALSE
, /* pc_relative */
1356 complain_overflow_signed
, /* complain_on_overflow */
1357 _bfd_mips_elf_generic_reloc
, /* special_function */
1358 "R_MIPS_TLS_GD", /* name */
1359 TRUE
, /* partial_inplace */
1360 0x0000ffff, /* src_mask */
1361 0x0000ffff, /* dst_mask */
1362 FALSE
), /* pcrel_offset */
1364 /* TLS local dynamic variable reference. */
1365 HOWTO (R_MIPS_TLS_LDM
, /* type */
1367 2, /* size (0 = byte, 1 = short, 2 = long) */
1369 FALSE
, /* pc_relative */
1371 complain_overflow_signed
, /* complain_on_overflow */
1372 _bfd_mips_elf_generic_reloc
, /* special_function */
1373 "R_MIPS_TLS_LDM", /* name */
1374 TRUE
, /* partial_inplace */
1375 0x0000ffff, /* src_mask */
1376 0x0000ffff, /* dst_mask */
1377 FALSE
), /* pcrel_offset */
1379 /* TLS local dynamic offset. */
1380 HOWTO (R_MIPS_TLS_DTPREL_HI16
, /* type */
1382 2, /* size (0 = byte, 1 = short, 2 = long) */
1384 FALSE
, /* pc_relative */
1386 complain_overflow_signed
, /* complain_on_overflow */
1387 _bfd_mips_elf_generic_reloc
, /* special_function */
1388 "R_MIPS_TLS_DTPREL_HI16", /* name */
1389 TRUE
, /* partial_inplace */
1390 0x0000ffff, /* src_mask */
1391 0x0000ffff, /* dst_mask */
1392 FALSE
), /* pcrel_offset */
1394 /* TLS local dynamic offset. */
1395 HOWTO (R_MIPS_TLS_DTPREL_LO16
, /* type */
1397 2, /* size (0 = byte, 1 = short, 2 = long) */
1399 FALSE
, /* pc_relative */
1401 complain_overflow_signed
, /* complain_on_overflow */
1402 _bfd_mips_elf_generic_reloc
, /* special_function */
1403 "R_MIPS_TLS_DTPREL_LO16", /* name */
1404 TRUE
, /* partial_inplace */
1405 0x0000ffff, /* src_mask */
1406 0x0000ffff, /* dst_mask */
1407 FALSE
), /* pcrel_offset */
1409 /* TLS thread pointer offset. */
1410 HOWTO (R_MIPS_TLS_GOTTPREL
, /* type */
1412 2, /* size (0 = byte, 1 = short, 2 = long) */
1414 FALSE
, /* pc_relative */
1416 complain_overflow_signed
, /* complain_on_overflow */
1417 _bfd_mips_elf_generic_reloc
, /* special_function */
1418 "R_MIPS_TLS_GOTTPREL", /* name */
1419 TRUE
, /* partial_inplace */
1420 0x0000ffff, /* src_mask */
1421 0x0000ffff, /* dst_mask */
1422 FALSE
), /* pcrel_offset */
1424 EMPTY_HOWTO (R_MIPS_TLS_TPREL32
),
1425 EMPTY_HOWTO (R_MIPS_TLS_TPREL64
),
1427 /* TLS thread pointer offset. */
1428 HOWTO (R_MIPS_TLS_TPREL_HI16
, /* type */
1430 2, /* size (0 = byte, 1 = short, 2 = long) */
1432 FALSE
, /* pc_relative */
1434 complain_overflow_signed
, /* complain_on_overflow */
1435 _bfd_mips_elf_generic_reloc
, /* special_function */
1436 "R_MIPS_TLS_TPREL_HI16", /* name */
1437 TRUE
, /* partial_inplace */
1438 0x0000ffff, /* src_mask */
1439 0x0000ffff, /* dst_mask */
1440 FALSE
), /* pcrel_offset */
1442 /* TLS thread pointer offset. */
1443 HOWTO (R_MIPS_TLS_TPREL_LO16
, /* type */
1445 2, /* size (0 = byte, 1 = short, 2 = long) */
1447 FALSE
, /* pc_relative */
1449 complain_overflow_signed
, /* complain_on_overflow */
1450 _bfd_mips_elf_generic_reloc
, /* special_function */
1451 "R_MIPS_TLS_TPREL_LO16", /* name */
1452 TRUE
, /* partial_inplace */
1453 0x0000ffff, /* src_mask */
1454 0x0000ffff, /* dst_mask */
1455 FALSE
), /* pcrel_offset */
1457 /* 32 bit relocation with no addend. */
1458 HOWTO (R_MIPS_GLOB_DAT
, /* type */
1460 2, /* size (0 = byte, 1 = short, 2 = long) */
1462 FALSE
, /* pc_relative */
1464 complain_overflow_dont
, /* complain_on_overflow */
1465 _bfd_mips_elf_generic_reloc
, /* special_function */
1466 "R_MIPS_GLOB_DAT", /* name */
1467 FALSE
, /* partial_inplace */
1469 0xffffffff, /* dst_mask */
1470 FALSE
), /* pcrel_offset */
1473 static reloc_howto_type mips16_elf64_howto_table_rel
[] =
1475 /* The reloc used for the mips16 jump instruction. */
1476 HOWTO (R_MIPS16_26
, /* type */
1478 2, /* size (0 = byte, 1 = short, 2 = long) */
1480 FALSE
, /* pc_relative */
1482 complain_overflow_dont
, /* complain_on_overflow */
1483 /* This needs complex overflow
1484 detection, because the upper four
1485 bits must match the PC. */
1486 _bfd_mips_elf_generic_reloc
, /* special_function */
1487 "R_MIPS16_26", /* name */
1488 TRUE
, /* partial_inplace */
1489 0x3ffffff, /* src_mask */
1490 0x3ffffff, /* dst_mask */
1491 FALSE
), /* pcrel_offset */
1493 /* The reloc used for the mips16 gprel instruction. */
1494 HOWTO (R_MIPS16_GPREL
, /* type */
1496 2, /* size (0 = byte, 1 = short, 2 = long) */
1498 FALSE
, /* pc_relative */
1500 complain_overflow_signed
, /* complain_on_overflow */
1501 mips16_gprel_reloc
, /* special_function */
1502 "R_MIPS16_GPREL", /* name */
1503 TRUE
, /* partial_inplace */
1504 0x0000ffff, /* src_mask */
1505 0x0000ffff, /* dst_mask */
1506 FALSE
), /* pcrel_offset */
1508 /* A MIPS16 reference to the global offset table. */
1509 HOWTO (R_MIPS16_GOT16
, /* type */
1511 2, /* size (0 = byte, 1 = short, 2 = long) */
1513 FALSE
, /* pc_relative */
1515 complain_overflow_dont
, /* complain_on_overflow */
1516 _bfd_mips_elf_got16_reloc
, /* special_function */
1517 "R_MIPS16_GOT16", /* name */
1518 TRUE
, /* partial_inplace */
1519 0x0000ffff, /* src_mask */
1520 0x0000ffff, /* dst_mask */
1521 FALSE
), /* pcrel_offset */
1523 /* A MIPS16 call through the global offset table. */
1524 HOWTO (R_MIPS16_CALL16
, /* type */
1526 2, /* size (0 = byte, 1 = short, 2 = long) */
1528 FALSE
, /* pc_relative */
1530 complain_overflow_dont
, /* complain_on_overflow */
1531 _bfd_mips_elf_generic_reloc
, /* special_function */
1532 "R_MIPS16_CALL16", /* name */
1533 TRUE
, /* partial_inplace */
1534 0x0000ffff, /* src_mask */
1535 0x0000ffff, /* dst_mask */
1536 FALSE
), /* pcrel_offset */
1538 /* MIPS16 high 16 bits of symbol value. */
1539 HOWTO (R_MIPS16_HI16
, /* type */
1540 16, /* rightshift */
1541 2, /* size (0 = byte, 1 = short, 2 = long) */
1543 FALSE
, /* pc_relative */
1545 complain_overflow_dont
, /* complain_on_overflow */
1546 _bfd_mips_elf_hi16_reloc
, /* special_function */
1547 "R_MIPS16_HI16", /* name */
1548 TRUE
, /* partial_inplace */
1549 0x0000ffff, /* src_mask */
1550 0x0000ffff, /* dst_mask */
1551 FALSE
), /* pcrel_offset */
1553 /* MIPS16 low 16 bits of symbol value. */
1554 HOWTO (R_MIPS16_LO16
, /* type */
1556 2, /* size (0 = byte, 1 = short, 2 = long) */
1558 FALSE
, /* pc_relative */
1560 complain_overflow_dont
, /* complain_on_overflow */
1561 _bfd_mips_elf_lo16_reloc
, /* special_function */
1562 "R_MIPS16_LO16", /* name */
1563 TRUE
, /* partial_inplace */
1564 0x0000ffff, /* src_mask */
1565 0x0000ffff, /* dst_mask */
1566 FALSE
), /* pcrel_offset */
1569 static reloc_howto_type mips16_elf64_howto_table_rela
[] =
1571 /* The reloc used for the mips16 jump instruction. */
1572 HOWTO (R_MIPS16_26
, /* type */
1574 2, /* size (0 = byte, 1 = short, 2 = long) */
1576 FALSE
, /* pc_relative */
1578 complain_overflow_dont
, /* complain_on_overflow */
1579 /* This needs complex overflow
1580 detection, because the upper four
1581 bits must match the PC. */
1582 _bfd_mips_elf_generic_reloc
, /* special_function */
1583 "R_MIPS16_26", /* name */
1584 FALSE
, /* partial_inplace */
1585 0x3ffffff, /* src_mask */
1586 0x3ffffff, /* dst_mask */
1587 FALSE
), /* pcrel_offset */
1589 /* The reloc used for the mips16 gprel instruction. */
1590 HOWTO (R_MIPS16_GPREL
, /* type */
1592 2, /* size (0 = byte, 1 = short, 2 = long) */
1594 FALSE
, /* pc_relative */
1596 complain_overflow_signed
, /* complain_on_overflow */
1597 mips16_gprel_reloc
, /* special_function */
1598 "R_MIPS16_GPREL", /* name */
1599 FALSE
, /* partial_inplace */
1600 0x0000ffff, /* src_mask */
1601 0x0000ffff, /* dst_mask */
1602 FALSE
), /* pcrel_offset */
1604 /* A MIPS16 reference to the global offset table. */
1605 HOWTO (R_MIPS16_GOT16
, /* type */
1607 2, /* size (0 = byte, 1 = short, 2 = long) */
1609 FALSE
, /* pc_relative */
1611 complain_overflow_dont
, /* complain_on_overflow */
1612 _bfd_mips_elf_got16_reloc
, /* special_function */
1613 "R_MIPS16_GOT16", /* name */
1614 FALSE
, /* partial_inplace */
1615 0x0000ffff, /* src_mask */
1616 0x0000ffff, /* dst_mask */
1617 FALSE
), /* pcrel_offset */
1619 /* A MIPS16 call through the global offset table. */
1620 HOWTO (R_MIPS16_CALL16
, /* type */
1622 2, /* size (0 = byte, 1 = short, 2 = long) */
1624 FALSE
, /* pc_relative */
1626 complain_overflow_dont
, /* complain_on_overflow */
1627 _bfd_mips_elf_generic_reloc
, /* special_function */
1628 "R_MIPS16_CALL16", /* name */
1629 FALSE
, /* partial_inplace */
1630 0x0000ffff, /* src_mask */
1631 0x0000ffff, /* dst_mask */
1632 FALSE
), /* pcrel_offset */
1634 /* MIPS16 high 16 bits of symbol value. */
1635 HOWTO (R_MIPS16_HI16
, /* type */
1636 16, /* rightshift */
1637 2, /* size (0 = byte, 1 = short, 2 = long) */
1639 FALSE
, /* pc_relative */
1641 complain_overflow_dont
, /* complain_on_overflow */
1642 _bfd_mips_elf_hi16_reloc
, /* special_function */
1643 "R_MIPS16_HI16", /* name */
1644 FALSE
, /* partial_inplace */
1645 0x0000ffff, /* src_mask */
1646 0x0000ffff, /* dst_mask */
1647 FALSE
), /* pcrel_offset */
1649 /* MIPS16 low 16 bits of symbol value. */
1650 HOWTO (R_MIPS16_LO16
, /* type */
1652 2, /* size (0 = byte, 1 = short, 2 = long) */
1654 FALSE
, /* pc_relative */
1656 complain_overflow_dont
, /* complain_on_overflow */
1657 _bfd_mips_elf_lo16_reloc
, /* special_function */
1658 "R_MIPS16_LO16", /* name */
1659 FALSE
, /* partial_inplace */
1660 0x0000ffff, /* src_mask */
1661 0x0000ffff, /* dst_mask */
1662 FALSE
), /* pcrel_offset */
1665 /* GNU extension to record C++ vtable hierarchy */
1666 static reloc_howto_type elf_mips_gnu_vtinherit_howto
=
1667 HOWTO (R_MIPS_GNU_VTINHERIT
, /* type */
1669 2, /* size (0 = byte, 1 = short, 2 = long) */
1671 FALSE
, /* pc_relative */
1673 complain_overflow_dont
, /* complain_on_overflow */
1674 NULL
, /* special_function */
1675 "R_MIPS_GNU_VTINHERIT", /* name */
1676 FALSE
, /* partial_inplace */
1679 FALSE
); /* pcrel_offset */
1681 /* GNU extension to record C++ vtable member usage */
1682 static reloc_howto_type elf_mips_gnu_vtentry_howto
=
1683 HOWTO (R_MIPS_GNU_VTENTRY
, /* type */
1685 2, /* size (0 = byte, 1 = short, 2 = long) */
1687 FALSE
, /* pc_relative */
1689 complain_overflow_dont
, /* complain_on_overflow */
1690 _bfd_elf_rel_vtable_reloc_fn
, /* special_function */
1691 "R_MIPS_GNU_VTENTRY", /* name */
1692 FALSE
, /* partial_inplace */
1695 FALSE
); /* pcrel_offset */
1697 /* 16 bit offset for pc-relative branches. */
1698 static reloc_howto_type elf_mips_gnu_rel16_s2
=
1699 HOWTO (R_MIPS_GNU_REL16_S2
, /* type */
1701 2, /* size (0 = byte, 1 = short, 2 = long) */
1703 TRUE
, /* pc_relative */
1705 complain_overflow_signed
, /* complain_on_overflow */
1706 _bfd_mips_elf_generic_reloc
, /* special_function */
1707 "R_MIPS_GNU_REL16_S2", /* name */
1708 TRUE
, /* partial_inplace */
1709 0x0000ffff, /* src_mask */
1710 0x0000ffff, /* dst_mask */
1711 TRUE
); /* pcrel_offset */
1713 /* 16 bit offset for pc-relative branches. */
1714 static reloc_howto_type elf_mips_gnu_rela16_s2
=
1715 HOWTO (R_MIPS_GNU_REL16_S2
, /* type */
1717 2, /* size (0 = byte, 1 = short, 2 = long) */
1719 TRUE
, /* pc_relative */
1721 complain_overflow_signed
, /* complain_on_overflow */
1722 _bfd_mips_elf_generic_reloc
, /* special_function */
1723 "R_MIPS_GNU_REL16_S2", /* name */
1724 FALSE
, /* partial_inplace */
1726 0x0000ffff, /* dst_mask */
1727 TRUE
); /* pcrel_offset */
1729 /* Originally a VxWorks extension, but now used for other systems too. */
1730 static reloc_howto_type elf_mips_copy_howto
=
1731 HOWTO (R_MIPS_COPY
, /* type */
1733 0, /* this one is variable size */
1735 FALSE
, /* pc_relative */
1737 complain_overflow_bitfield
, /* complain_on_overflow */
1738 bfd_elf_generic_reloc
, /* special_function */
1739 "R_MIPS_COPY", /* name */
1740 FALSE
, /* partial_inplace */
1743 FALSE
); /* pcrel_offset */
1745 /* Originally a VxWorks extension, but now used for other systems too. */
1746 static reloc_howto_type elf_mips_jump_slot_howto
=
1747 HOWTO (R_MIPS_JUMP_SLOT
, /* type */
1749 4, /* size (0 = byte, 1 = short, 2 = long) */
1751 FALSE
, /* pc_relative */
1753 complain_overflow_bitfield
, /* complain_on_overflow */
1754 bfd_elf_generic_reloc
, /* special_function */
1755 "R_MIPS_JUMP_SLOT", /* name */
1756 FALSE
, /* partial_inplace */
1759 FALSE
); /* pcrel_offset */
1761 /* Swap in a MIPS 64-bit Rel reloc. */
1764 mips_elf64_swap_reloc_in (bfd
*abfd
, const Elf64_Mips_External_Rel
*src
,
1765 Elf64_Mips_Internal_Rela
*dst
)
1767 dst
->r_offset
= H_GET_64 (abfd
, src
->r_offset
);
1768 dst
->r_sym
= H_GET_32 (abfd
, src
->r_sym
);
1769 dst
->r_ssym
= H_GET_8 (abfd
, src
->r_ssym
);
1770 dst
->r_type3
= H_GET_8 (abfd
, src
->r_type3
);
1771 dst
->r_type2
= H_GET_8 (abfd
, src
->r_type2
);
1772 dst
->r_type
= H_GET_8 (abfd
, src
->r_type
);
1776 /* Swap in a MIPS 64-bit Rela reloc. */
1779 mips_elf64_swap_reloca_in (bfd
*abfd
, const Elf64_Mips_External_Rela
*src
,
1780 Elf64_Mips_Internal_Rela
*dst
)
1782 dst
->r_offset
= H_GET_64 (abfd
, src
->r_offset
);
1783 dst
->r_sym
= H_GET_32 (abfd
, src
->r_sym
);
1784 dst
->r_ssym
= H_GET_8 (abfd
, src
->r_ssym
);
1785 dst
->r_type3
= H_GET_8 (abfd
, src
->r_type3
);
1786 dst
->r_type2
= H_GET_8 (abfd
, src
->r_type2
);
1787 dst
->r_type
= H_GET_8 (abfd
, src
->r_type
);
1788 dst
->r_addend
= H_GET_S64 (abfd
, src
->r_addend
);
1791 /* Swap out a MIPS 64-bit Rel reloc. */
1794 mips_elf64_swap_reloc_out (bfd
*abfd
, const Elf64_Mips_Internal_Rela
*src
,
1795 Elf64_Mips_External_Rel
*dst
)
1797 H_PUT_64 (abfd
, src
->r_offset
, dst
->r_offset
);
1798 H_PUT_32 (abfd
, src
->r_sym
, dst
->r_sym
);
1799 H_PUT_8 (abfd
, src
->r_ssym
, dst
->r_ssym
);
1800 H_PUT_8 (abfd
, src
->r_type3
, dst
->r_type3
);
1801 H_PUT_8 (abfd
, src
->r_type2
, dst
->r_type2
);
1802 H_PUT_8 (abfd
, src
->r_type
, dst
->r_type
);
1805 /* Swap out a MIPS 64-bit Rela reloc. */
1808 mips_elf64_swap_reloca_out (bfd
*abfd
, const Elf64_Mips_Internal_Rela
*src
,
1809 Elf64_Mips_External_Rela
*dst
)
1811 H_PUT_64 (abfd
, src
->r_offset
, dst
->r_offset
);
1812 H_PUT_32 (abfd
, src
->r_sym
, dst
->r_sym
);
1813 H_PUT_8 (abfd
, src
->r_ssym
, dst
->r_ssym
);
1814 H_PUT_8 (abfd
, src
->r_type3
, dst
->r_type3
);
1815 H_PUT_8 (abfd
, src
->r_type2
, dst
->r_type2
);
1816 H_PUT_8 (abfd
, src
->r_type
, dst
->r_type
);
1817 H_PUT_S64 (abfd
, src
->r_addend
, dst
->r_addend
);
1820 /* Swap in a MIPS 64-bit Rel reloc. */
1823 mips_elf64_be_swap_reloc_in (bfd
*abfd
, const bfd_byte
*src
,
1824 Elf_Internal_Rela
*dst
)
1826 Elf64_Mips_Internal_Rela mirel
;
1828 mips_elf64_swap_reloc_in (abfd
,
1829 (const Elf64_Mips_External_Rel
*) src
,
1832 dst
[0].r_offset
= mirel
.r_offset
;
1833 dst
[0].r_info
= ELF64_R_INFO (mirel
.r_sym
, mirel
.r_type
);
1834 dst
[0].r_addend
= 0;
1835 dst
[1].r_offset
= mirel
.r_offset
;
1836 dst
[1].r_info
= ELF64_R_INFO (mirel
.r_ssym
, mirel
.r_type2
);
1837 dst
[1].r_addend
= 0;
1838 dst
[2].r_offset
= mirel
.r_offset
;
1839 dst
[2].r_info
= ELF64_R_INFO (STN_UNDEF
, mirel
.r_type3
);
1840 dst
[2].r_addend
= 0;
1843 /* Swap in a MIPS 64-bit Rela reloc. */
1846 mips_elf64_be_swap_reloca_in (bfd
*abfd
, const bfd_byte
*src
,
1847 Elf_Internal_Rela
*dst
)
1849 Elf64_Mips_Internal_Rela mirela
;
1851 mips_elf64_swap_reloca_in (abfd
,
1852 (const Elf64_Mips_External_Rela
*) src
,
1855 dst
[0].r_offset
= mirela
.r_offset
;
1856 dst
[0].r_info
= ELF64_R_INFO (mirela
.r_sym
, mirela
.r_type
);
1857 dst
[0].r_addend
= mirela
.r_addend
;
1858 dst
[1].r_offset
= mirela
.r_offset
;
1859 dst
[1].r_info
= ELF64_R_INFO (mirela
.r_ssym
, mirela
.r_type2
);
1860 dst
[1].r_addend
= 0;
1861 dst
[2].r_offset
= mirela
.r_offset
;
1862 dst
[2].r_info
= ELF64_R_INFO (STN_UNDEF
, mirela
.r_type3
);
1863 dst
[2].r_addend
= 0;
1866 /* Swap out a MIPS 64-bit Rel reloc. */
1869 mips_elf64_be_swap_reloc_out (bfd
*abfd
, const Elf_Internal_Rela
*src
,
1872 Elf64_Mips_Internal_Rela mirel
;
1874 mirel
.r_offset
= src
[0].r_offset
;
1875 BFD_ASSERT(src
[0].r_offset
== src
[1].r_offset
);
1877 mirel
.r_type
= ELF64_MIPS_R_TYPE (src
[0].r_info
);
1878 mirel
.r_sym
= ELF64_R_SYM (src
[0].r_info
);
1879 mirel
.r_type2
= ELF64_MIPS_R_TYPE (src
[1].r_info
);
1880 mirel
.r_ssym
= ELF64_MIPS_R_SSYM (src
[1].r_info
);
1881 mirel
.r_type3
= ELF64_MIPS_R_TYPE (src
[2].r_info
);
1883 mips_elf64_swap_reloc_out (abfd
, &mirel
,
1884 (Elf64_Mips_External_Rel
*) dst
);
1887 /* Swap out a MIPS 64-bit Rela reloc. */
1890 mips_elf64_be_swap_reloca_out (bfd
*abfd
, const Elf_Internal_Rela
*src
,
1893 Elf64_Mips_Internal_Rela mirela
;
1895 mirela
.r_offset
= src
[0].r_offset
;
1896 BFD_ASSERT(src
[0].r_offset
== src
[1].r_offset
);
1897 BFD_ASSERT(src
[0].r_offset
== src
[2].r_offset
);
1899 mirela
.r_type
= ELF64_MIPS_R_TYPE (src
[0].r_info
);
1900 mirela
.r_sym
= ELF64_R_SYM (src
[0].r_info
);
1901 mirela
.r_addend
= src
[0].r_addend
;
1902 BFD_ASSERT(src
[1].r_addend
== 0);
1903 BFD_ASSERT(src
[2].r_addend
== 0);
1905 mirela
.r_type2
= ELF64_MIPS_R_TYPE (src
[1].r_info
);
1906 mirela
.r_ssym
= ELF64_MIPS_R_SSYM (src
[1].r_info
);
1907 mirela
.r_type3
= ELF64_MIPS_R_TYPE (src
[2].r_info
);
1909 mips_elf64_swap_reloca_out (abfd
, &mirela
,
1910 (Elf64_Mips_External_Rela
*) dst
);
1913 /* Set the GP value for OUTPUT_BFD. Returns FALSE if this is a
1914 dangerous relocation. */
1917 mips_elf64_assign_gp (bfd
*output_bfd
, bfd_vma
*pgp
)
1923 /* If we've already figured out what GP will be, just return it. */
1924 *pgp
= _bfd_get_gp_value (output_bfd
);
1928 count
= bfd_get_symcount (output_bfd
);
1929 sym
= bfd_get_outsymbols (output_bfd
);
1931 /* The linker script will have created a symbol named `_gp' with the
1932 appropriate value. */
1937 for (i
= 0; i
< count
; i
++, sym
++)
1939 register const char *name
;
1941 name
= bfd_asymbol_name (*sym
);
1942 if (*name
== '_' && strcmp (name
, "_gp") == 0)
1944 *pgp
= bfd_asymbol_value (*sym
);
1945 _bfd_set_gp_value (output_bfd
, *pgp
);
1953 /* Only get the error once. */
1955 _bfd_set_gp_value (output_bfd
, *pgp
);
1962 /* We have to figure out the gp value, so that we can adjust the
1963 symbol value correctly. We look up the symbol _gp in the output
1964 BFD. If we can't find it, we're stuck. We cache it in the ELF
1965 target data. We don't need to adjust the symbol value for an
1966 external symbol if we are producing relocatable output. */
1968 static bfd_reloc_status_type
1969 mips_elf64_final_gp (bfd
*output_bfd
, asymbol
*symbol
, bfd_boolean relocatable
,
1970 char **error_message
, bfd_vma
*pgp
)
1972 if (bfd_is_und_section (symbol
->section
)
1976 return bfd_reloc_undefined
;
1979 *pgp
= _bfd_get_gp_value (output_bfd
);
1982 || (symbol
->flags
& BSF_SECTION_SYM
) != 0))
1986 /* Make up a value. */
1987 *pgp
= symbol
->section
->output_section
->vma
/*+ 0x4000*/;
1988 _bfd_set_gp_value (output_bfd
, *pgp
);
1990 else if (!mips_elf64_assign_gp (output_bfd
, pgp
))
1993 (char *) _("GP relative relocation when _gp not defined");
1994 return bfd_reloc_dangerous
;
1998 return bfd_reloc_ok
;
2001 /* Do a R_MIPS_GPREL16 relocation. This is a 16 bit value which must
2002 become the offset from the gp register. */
2004 static bfd_reloc_status_type
2005 mips_elf64_gprel16_reloc (bfd
*abfd
, arelent
*reloc_entry
, asymbol
*symbol
,
2006 void *data
, asection
*input_section
, bfd
*output_bfd
,
2007 char **error_message
)
2009 bfd_boolean relocatable
;
2010 bfd_reloc_status_type ret
;
2013 /* If we're relocating, and this is an external symbol, we don't want
2014 to change anything. */
2015 if (output_bfd
!= NULL
2016 && (symbol
->flags
& BSF_SECTION_SYM
) == 0
2017 && (symbol
->flags
& BSF_LOCAL
) != 0)
2019 reloc_entry
->address
+= input_section
->output_offset
;
2020 return bfd_reloc_ok
;
2023 if (output_bfd
!= NULL
)
2027 relocatable
= FALSE
;
2028 output_bfd
= symbol
->section
->output_section
->owner
;
2031 ret
= mips_elf64_final_gp (output_bfd
, symbol
, relocatable
, error_message
,
2033 if (ret
!= bfd_reloc_ok
)
2036 return _bfd_mips_elf_gprel16_with_gp (abfd
, symbol
, reloc_entry
,
2037 input_section
, relocatable
,
2041 /* Do a R_MIPS_LITERAL relocation. */
2043 static bfd_reloc_status_type
2044 mips_elf64_literal_reloc (bfd
*abfd
, arelent
*reloc_entry
, asymbol
*symbol
,
2045 void *data
, asection
*input_section
, bfd
*output_bfd
,
2046 char **error_message
)
2048 bfd_boolean relocatable
;
2049 bfd_reloc_status_type ret
;
2052 /* R_MIPS_LITERAL relocations are defined for local symbols only. */
2053 if (output_bfd
!= NULL
2054 && (symbol
->flags
& BSF_SECTION_SYM
) == 0
2055 && (symbol
->flags
& BSF_LOCAL
) != 0)
2057 *error_message
= (char *)
2058 _("literal relocation occurs for an external symbol");
2059 return bfd_reloc_outofrange
;
2062 /* FIXME: The entries in the .lit8 and .lit4 sections should be merged. */
2063 if (output_bfd
!= NULL
)
2067 relocatable
= FALSE
;
2068 output_bfd
= symbol
->section
->output_section
->owner
;
2071 ret
= mips_elf64_final_gp (output_bfd
, symbol
, relocatable
, error_message
,
2073 if (ret
!= bfd_reloc_ok
)
2076 return _bfd_mips_elf_gprel16_with_gp (abfd
, symbol
, reloc_entry
,
2077 input_section
, relocatable
,
2081 /* Do a R_MIPS_GPREL32 relocation. This is a 32 bit value which must
2082 become the offset from the gp register. */
2084 static bfd_reloc_status_type
2085 mips_elf64_gprel32_reloc (bfd
*abfd
, arelent
*reloc_entry
, asymbol
*symbol
,
2086 void *data
, asection
*input_section
, bfd
*output_bfd
,
2087 char **error_message
)
2089 bfd_boolean relocatable
;
2090 bfd_reloc_status_type ret
;
2095 /* R_MIPS_GPREL32 relocations are defined for local symbols only. */
2096 if (output_bfd
!= NULL
2097 && (symbol
->flags
& BSF_SECTION_SYM
) == 0
2098 && (symbol
->flags
& BSF_LOCAL
) != 0)
2100 *error_message
= (char *)
2101 _("32bits gp relative relocation occurs for an external symbol");
2102 return bfd_reloc_outofrange
;
2105 if (output_bfd
!= NULL
)
2109 relocatable
= FALSE
;
2110 output_bfd
= symbol
->section
->output_section
->owner
;
2113 ret
= mips_elf64_final_gp (output_bfd
, symbol
, relocatable
,
2114 error_message
, &gp
);
2115 if (ret
!= bfd_reloc_ok
)
2118 if (bfd_is_com_section (symbol
->section
))
2121 relocation
= symbol
->value
;
2123 relocation
+= symbol
->section
->output_section
->vma
;
2124 relocation
+= symbol
->section
->output_offset
;
2126 if (reloc_entry
->address
> bfd_get_section_limit (abfd
, input_section
))
2127 return bfd_reloc_outofrange
;
2129 /* Set val to the offset into the section or symbol. */
2130 val
= reloc_entry
->addend
;
2132 if (reloc_entry
->howto
->partial_inplace
)
2133 val
+= bfd_get_32 (abfd
, (bfd_byte
*) data
+ reloc_entry
->address
);
2135 /* Adjust val for the final section location and GP value. If we
2136 are producing relocatable output, we don't want to do this for
2137 an external symbol. */
2139 || (symbol
->flags
& BSF_SECTION_SYM
) != 0)
2140 val
+= relocation
- gp
;
2142 if (reloc_entry
->howto
->partial_inplace
)
2143 bfd_put_32 (abfd
, val
, (bfd_byte
*) data
+ reloc_entry
->address
);
2145 reloc_entry
->addend
= val
;
2148 reloc_entry
->address
+= input_section
->output_offset
;
2150 return bfd_reloc_ok
;
2153 /* Do a R_MIPS_SHIFT6 relocation. The MSB of the shift is stored at bit 2,
2154 the rest is at bits 6-10. The bitpos already got right by the howto. */
2156 static bfd_reloc_status_type
2157 mips_elf64_shift6_reloc (bfd
*abfd
, arelent
*reloc_entry
, asymbol
*symbol
,
2158 void *data
, asection
*input_section
, bfd
*output_bfd
,
2159 char **error_message
)
2161 if (reloc_entry
->howto
->partial_inplace
)
2163 reloc_entry
->addend
= ((reloc_entry
->addend
& 0x00007c0)
2164 | (reloc_entry
->addend
& 0x00000800) >> 9);
2167 return _bfd_mips_elf_generic_reloc (abfd
, reloc_entry
, symbol
, data
,
2168 input_section
, output_bfd
,
2172 /* Handle a mips16 GP relative reloc. */
2174 static bfd_reloc_status_type
2175 mips16_gprel_reloc (bfd
*abfd
, arelent
*reloc_entry
, asymbol
*symbol
,
2176 void *data
, asection
*input_section
, bfd
*output_bfd
,
2177 char **error_message
)
2179 bfd_boolean relocatable
;
2180 bfd_reloc_status_type ret
;
2184 /* If we're relocating, and this is an external symbol, we don't want
2185 to change anything. */
2186 if (output_bfd
!= NULL
2187 && (symbol
->flags
& BSF_SECTION_SYM
) == 0
2188 && (symbol
->flags
& BSF_LOCAL
) != 0)
2190 reloc_entry
->address
+= input_section
->output_offset
;
2191 return bfd_reloc_ok
;
2194 if (output_bfd
!= NULL
)
2198 relocatable
= FALSE
;
2199 output_bfd
= symbol
->section
->output_section
->owner
;
2202 ret
= mips_elf64_final_gp (output_bfd
, symbol
, relocatable
, error_message
,
2204 if (ret
!= bfd_reloc_ok
)
2207 location
= (bfd_byte
*) data
+ reloc_entry
->address
;
2208 _bfd_mips16_elf_reloc_unshuffle (abfd
, reloc_entry
->howto
->type
, FALSE
,
2210 ret
= _bfd_mips_elf_gprel16_with_gp (abfd
, symbol
, reloc_entry
,
2211 input_section
, relocatable
,
2213 _bfd_mips16_elf_reloc_shuffle (abfd
, reloc_entry
->howto
->type
, !relocatable
,
2219 /* A mapping from BFD reloc types to MIPS ELF reloc types. */
2221 struct elf_reloc_map
{
2222 bfd_reloc_code_real_type bfd_val
;
2223 enum elf_mips_reloc_type elf_val
;
2226 static const struct elf_reloc_map mips_reloc_map
[] =
2228 { BFD_RELOC_NONE
, R_MIPS_NONE
},
2229 { BFD_RELOC_16
, R_MIPS_16
},
2230 { BFD_RELOC_32
, R_MIPS_32
},
2231 /* There is no BFD reloc for R_MIPS_REL32. */
2232 { BFD_RELOC_64
, R_MIPS_64
},
2233 { BFD_RELOC_CTOR
, R_MIPS_64
},
2234 { BFD_RELOC_16_PCREL_S2
, R_MIPS_PC16
},
2235 { BFD_RELOC_HI16_S
, R_MIPS_HI16
},
2236 { BFD_RELOC_LO16
, R_MIPS_LO16
},
2237 { BFD_RELOC_GPREL16
, R_MIPS_GPREL16
},
2238 { BFD_RELOC_GPREL32
, R_MIPS_GPREL32
},
2239 { BFD_RELOC_MIPS_JMP
, R_MIPS_26
},
2240 { BFD_RELOC_MIPS_LITERAL
, R_MIPS_LITERAL
},
2241 { BFD_RELOC_MIPS_GOT16
, R_MIPS_GOT16
},
2242 { BFD_RELOC_MIPS_CALL16
, R_MIPS_CALL16
},
2243 { BFD_RELOC_MIPS_SHIFT5
, R_MIPS_SHIFT5
},
2244 { BFD_RELOC_MIPS_SHIFT6
, R_MIPS_SHIFT6
},
2245 { BFD_RELOC_MIPS_GOT_DISP
, R_MIPS_GOT_DISP
},
2246 { BFD_RELOC_MIPS_GOT_PAGE
, R_MIPS_GOT_PAGE
},
2247 { BFD_RELOC_MIPS_GOT_OFST
, R_MIPS_GOT_OFST
},
2248 { BFD_RELOC_MIPS_GOT_HI16
, R_MIPS_GOT_HI16
},
2249 { BFD_RELOC_MIPS_GOT_LO16
, R_MIPS_GOT_LO16
},
2250 { BFD_RELOC_MIPS_SUB
, R_MIPS_SUB
},
2251 { BFD_RELOC_MIPS_INSERT_A
, R_MIPS_INSERT_A
},
2252 { BFD_RELOC_MIPS_INSERT_B
, R_MIPS_INSERT_B
},
2253 { BFD_RELOC_MIPS_DELETE
, R_MIPS_DELETE
},
2254 { BFD_RELOC_MIPS_HIGHEST
, R_MIPS_HIGHEST
},
2255 { BFD_RELOC_MIPS_HIGHER
, R_MIPS_HIGHER
},
2256 { BFD_RELOC_MIPS_CALL_HI16
, R_MIPS_CALL_HI16
},
2257 { BFD_RELOC_MIPS_CALL_LO16
, R_MIPS_CALL_LO16
},
2258 { BFD_RELOC_MIPS_SCN_DISP
, R_MIPS_SCN_DISP
},
2259 { BFD_RELOC_MIPS_REL16
, R_MIPS_REL16
},
2260 /* Use of R_MIPS_ADD_IMMEDIATE and R_MIPS_PJUMP is deprecated. */
2261 { BFD_RELOC_MIPS_RELGOT
, R_MIPS_RELGOT
},
2262 { BFD_RELOC_MIPS_JALR
, R_MIPS_JALR
},
2263 { BFD_RELOC_MIPS_TLS_DTPMOD32
, R_MIPS_TLS_DTPMOD32
},
2264 { BFD_RELOC_MIPS_TLS_DTPREL32
, R_MIPS_TLS_DTPREL32
},
2265 { BFD_RELOC_MIPS_TLS_DTPMOD64
, R_MIPS_TLS_DTPMOD64
},
2266 { BFD_RELOC_MIPS_TLS_DTPREL64
, R_MIPS_TLS_DTPREL64
},
2267 { BFD_RELOC_MIPS_TLS_GD
, R_MIPS_TLS_GD
},
2268 { BFD_RELOC_MIPS_TLS_LDM
, R_MIPS_TLS_LDM
},
2269 { BFD_RELOC_MIPS_TLS_DTPREL_HI16
, R_MIPS_TLS_DTPREL_HI16
},
2270 { BFD_RELOC_MIPS_TLS_DTPREL_LO16
, R_MIPS_TLS_DTPREL_LO16
},
2271 { BFD_RELOC_MIPS_TLS_GOTTPREL
, R_MIPS_TLS_GOTTPREL
},
2272 { BFD_RELOC_MIPS_TLS_TPREL32
, R_MIPS_TLS_TPREL32
},
2273 { BFD_RELOC_MIPS_TLS_TPREL64
, R_MIPS_TLS_TPREL64
},
2274 { BFD_RELOC_MIPS_TLS_TPREL_HI16
, R_MIPS_TLS_TPREL_HI16
},
2275 { BFD_RELOC_MIPS_TLS_TPREL_LO16
, R_MIPS_TLS_TPREL_LO16
}
2278 static const struct elf_reloc_map mips16_reloc_map
[] =
2280 { BFD_RELOC_MIPS16_JMP
, R_MIPS16_26
- R_MIPS16_min
},
2281 { BFD_RELOC_MIPS16_GPREL
, R_MIPS16_GPREL
- R_MIPS16_min
},
2282 { BFD_RELOC_MIPS16_GOT16
, R_MIPS16_GOT16
- R_MIPS16_min
},
2283 { BFD_RELOC_MIPS16_CALL16
, R_MIPS16_CALL16
- R_MIPS16_min
},
2284 { BFD_RELOC_MIPS16_HI16_S
, R_MIPS16_HI16
- R_MIPS16_min
},
2285 { BFD_RELOC_MIPS16_LO16
, R_MIPS16_LO16
- R_MIPS16_min
},
2288 /* Given a BFD reloc type, return a howto structure. */
2290 static reloc_howto_type
*
2291 bfd_elf64_bfd_reloc_type_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
2292 bfd_reloc_code_real_type code
)
2295 /* FIXME: We default to RELA here instead of choosing the right
2296 relocation variant. */
2297 reloc_howto_type
*howto_table
= mips_elf64_howto_table_rela
;
2298 reloc_howto_type
*howto16_table
= mips16_elf64_howto_table_rela
;
2300 for (i
= 0; i
< sizeof (mips_reloc_map
) / sizeof (struct elf_reloc_map
);
2303 if (mips_reloc_map
[i
].bfd_val
== code
)
2304 return &howto_table
[(int) mips_reloc_map
[i
].elf_val
];
2307 for (i
= 0; i
< sizeof (mips16_reloc_map
) / sizeof (struct elf_reloc_map
);
2310 if (mips16_reloc_map
[i
].bfd_val
== code
)
2311 return &howto16_table
[(int) mips16_reloc_map
[i
].elf_val
];
2316 case BFD_RELOC_VTABLE_INHERIT
:
2317 return &elf_mips_gnu_vtinherit_howto
;
2318 case BFD_RELOC_VTABLE_ENTRY
:
2319 return &elf_mips_gnu_vtentry_howto
;
2320 case BFD_RELOC_MIPS_COPY
:
2321 return &elf_mips_copy_howto
;
2322 case BFD_RELOC_MIPS_JUMP_SLOT
:
2323 return &elf_mips_jump_slot_howto
;
2325 bfd_set_error (bfd_error_bad_value
);
2330 static reloc_howto_type
*
2331 bfd_elf64_bfd_reloc_name_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
2337 i
< (sizeof (mips_elf64_howto_table_rela
)
2338 / sizeof (mips_elf64_howto_table_rela
[0])); i
++)
2339 if (mips_elf64_howto_table_rela
[i
].name
!= NULL
2340 && strcasecmp (mips_elf64_howto_table_rela
[i
].name
, r_name
) == 0)
2341 return &mips_elf64_howto_table_rela
[i
];
2344 i
< (sizeof (mips16_elf64_howto_table_rela
)
2345 / sizeof (mips16_elf64_howto_table_rela
[0]));
2347 if (mips16_elf64_howto_table_rela
[i
].name
!= NULL
2348 && strcasecmp (mips16_elf64_howto_table_rela
[i
].name
, r_name
) == 0)
2349 return &mips16_elf64_howto_table_rela
[i
];
2351 if (strcasecmp (elf_mips_gnu_vtinherit_howto
.name
, r_name
) == 0)
2352 return &elf_mips_gnu_vtinherit_howto
;
2353 if (strcasecmp (elf_mips_gnu_vtentry_howto
.name
, r_name
) == 0)
2354 return &elf_mips_gnu_vtentry_howto
;
2355 if (strcasecmp (elf_mips_gnu_rel16_s2
.name
, r_name
) == 0)
2356 return &elf_mips_gnu_rel16_s2
;
2357 if (strcasecmp (elf_mips_gnu_rela16_s2
.name
, r_name
) == 0)
2358 return &elf_mips_gnu_rela16_s2
;
2359 if (strcasecmp (elf_mips_copy_howto
.name
, r_name
) == 0)
2360 return &elf_mips_copy_howto
;
2361 if (strcasecmp (elf_mips_jump_slot_howto
.name
, r_name
) == 0)
2362 return &elf_mips_jump_slot_howto
;
2367 /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure. */
2369 static reloc_howto_type
*
2370 mips_elf64_rtype_to_howto (unsigned int r_type
, bfd_boolean rela_p
)
2374 case R_MIPS_GNU_VTINHERIT
:
2375 return &elf_mips_gnu_vtinherit_howto
;
2376 case R_MIPS_GNU_VTENTRY
:
2377 return &elf_mips_gnu_vtentry_howto
;
2378 case R_MIPS_GNU_REL16_S2
:
2380 return &elf_mips_gnu_rela16_s2
;
2382 return &elf_mips_gnu_rel16_s2
;
2384 return &elf_mips_copy_howto
;
2385 case R_MIPS_JUMP_SLOT
:
2386 return &elf_mips_jump_slot_howto
;
2388 if (r_type
>= R_MIPS16_min
&& r_type
< R_MIPS16_max
)
2391 return &mips16_elf64_howto_table_rela
[r_type
- R_MIPS16_min
];
2393 return &mips16_elf64_howto_table_rel
[r_type
- R_MIPS16_min
];
2395 BFD_ASSERT (r_type
< (unsigned int) R_MIPS_max
);
2397 return &mips_elf64_howto_table_rela
[r_type
];
2399 return &mips_elf64_howto_table_rel
[r_type
];
2404 /* Prevent relocation handling by bfd for MIPS ELF64. */
2407 mips_elf64_info_to_howto_rel (bfd
*abfd ATTRIBUTE_UNUSED
,
2408 arelent
*cache_ptr ATTRIBUTE_UNUSED
,
2409 Elf_Internal_Rela
*dst ATTRIBUTE_UNUSED
)
2415 mips_elf64_info_to_howto_rela (bfd
*abfd ATTRIBUTE_UNUSED
,
2416 arelent
*cache_ptr ATTRIBUTE_UNUSED
,
2417 Elf_Internal_Rela
*dst ATTRIBUTE_UNUSED
)
2422 /* Since each entry in an SHT_REL or SHT_RELA section can represent up
2423 to three relocs, we must tell the user to allocate more space. */
2426 mips_elf64_get_reloc_upper_bound (bfd
*abfd ATTRIBUTE_UNUSED
, asection
*sec
)
2428 return (sec
->reloc_count
* 3 + 1) * sizeof (arelent
*);
2432 mips_elf64_get_dynamic_reloc_upper_bound (bfd
*abfd
)
2434 return _bfd_elf_get_dynamic_reloc_upper_bound (abfd
) * 3;
2437 /* We must also copy more relocations than the corresponding functions
2438 in elf.c would, so the two following functions are slightly
2439 modified from elf.c, that multiply the external relocation count by
2440 3 to obtain the internal relocation count. */
2443 mips_elf64_canonicalize_reloc (bfd
*abfd
, sec_ptr section
,
2444 arelent
**relptr
, asymbol
**symbols
)
2448 const struct elf_backend_data
*bed
= get_elf_backend_data (abfd
);
2450 if (! bed
->s
->slurp_reloc_table (abfd
, section
, symbols
, FALSE
))
2453 tblptr
= section
->relocation
;
2454 for (i
= 0; i
< section
->reloc_count
* 3; i
++)
2455 *relptr
++ = tblptr
++;
2459 return section
->reloc_count
* 3;
2463 mips_elf64_canonicalize_dynamic_reloc (bfd
*abfd
, arelent
**storage
,
2466 bfd_boolean (*slurp_relocs
) (bfd
*, asection
*, asymbol
**, bfd_boolean
);
2470 if (elf_dynsymtab (abfd
) == 0)
2472 bfd_set_error (bfd_error_invalid_operation
);
2476 slurp_relocs
= get_elf_backend_data (abfd
)->s
->slurp_reloc_table
;
2478 for (s
= abfd
->sections
; s
!= NULL
; s
= s
->next
)
2480 if (elf_section_data (s
)->this_hdr
.sh_link
== elf_dynsymtab (abfd
)
2481 && (elf_section_data (s
)->this_hdr
.sh_type
== SHT_REL
2482 || elf_section_data (s
)->this_hdr
.sh_type
== SHT_RELA
))
2487 if (! (*slurp_relocs
) (abfd
, s
, syms
, TRUE
))
2489 count
= s
->size
/ elf_section_data (s
)->this_hdr
.sh_entsize
* 3;
2491 for (i
= 0; i
< count
; i
++)
2502 /* Read the relocations from one reloc section. This is mostly copied
2503 from elfcode.h, except for the changes to expand one external
2504 relocation to 3 internal ones. We must unfortunately set
2505 reloc_count to the number of external relocations, because a lot of
2506 generic code seems to depend on this. */
2509 mips_elf64_slurp_one_reloc_table (bfd
*abfd
, asection
*asect
,
2510 Elf_Internal_Shdr
*rel_hdr
,
2511 bfd_size_type reloc_count
,
2512 arelent
*relents
, asymbol
**symbols
,
2513 bfd_boolean dynamic
)
2516 bfd_byte
*native_relocs
;
2522 allocated
= bfd_malloc (rel_hdr
->sh_size
);
2523 if (allocated
== NULL
)
2526 if (bfd_seek (abfd
, rel_hdr
->sh_offset
, SEEK_SET
) != 0
2527 || (bfd_bread (allocated
, rel_hdr
->sh_size
, abfd
)
2528 != rel_hdr
->sh_size
))
2531 native_relocs
= allocated
;
2533 entsize
= rel_hdr
->sh_entsize
;
2534 BFD_ASSERT (entsize
== sizeof (Elf64_Mips_External_Rel
)
2535 || entsize
== sizeof (Elf64_Mips_External_Rela
));
2537 if (entsize
== sizeof (Elf64_Mips_External_Rel
))
2542 for (i
= 0, relent
= relents
;
2544 i
++, native_relocs
+= entsize
)
2546 Elf64_Mips_Internal_Rela rela
;
2547 bfd_boolean used_sym
, used_ssym
;
2550 if (entsize
== sizeof (Elf64_Mips_External_Rela
))
2551 mips_elf64_swap_reloca_in (abfd
,
2552 (Elf64_Mips_External_Rela
*) native_relocs
,
2555 mips_elf64_swap_reloc_in (abfd
,
2556 (Elf64_Mips_External_Rel
*) native_relocs
,
2559 /* Each entry represents exactly three actual relocations. */
2563 for (ir
= 0; ir
< 3; ir
++)
2565 enum elf_mips_reloc_type type
;
2572 type
= (enum elf_mips_reloc_type
) rela
.r_type
;
2575 type
= (enum elf_mips_reloc_type
) rela
.r_type2
;
2578 type
= (enum elf_mips_reloc_type
) rela
.r_type3
;
2582 /* Some types require symbols, whereas some do not. */
2586 case R_MIPS_LITERAL
:
2587 case R_MIPS_INSERT_A
:
2588 case R_MIPS_INSERT_B
:
2590 relent
->sym_ptr_ptr
= bfd_abs_section_ptr
->symbol_ptr_ptr
;
2596 if (rela
.r_sym
== 0)
2597 relent
->sym_ptr_ptr
= bfd_abs_section_ptr
->symbol_ptr_ptr
;
2602 ps
= symbols
+ rela
.r_sym
- 1;
2604 if ((s
->flags
& BSF_SECTION_SYM
) == 0)
2605 relent
->sym_ptr_ptr
= ps
;
2607 relent
->sym_ptr_ptr
= s
->section
->symbol_ptr_ptr
;
2612 else if (! used_ssym
)
2614 switch (rela
.r_ssym
)
2617 relent
->sym_ptr_ptr
=
2618 bfd_abs_section_ptr
->symbol_ptr_ptr
;
2624 /* FIXME: I think these need to be handled using
2625 special howto structures. */
2637 relent
->sym_ptr_ptr
= bfd_abs_section_ptr
->symbol_ptr_ptr
;
2642 /* The address of an ELF reloc is section relative for an
2643 object file, and absolute for an executable file or
2644 shared library. The address of a BFD reloc is always
2645 section relative. */
2646 if ((abfd
->flags
& (EXEC_P
| DYNAMIC
)) == 0 || dynamic
)
2647 relent
->address
= rela
.r_offset
;
2649 relent
->address
= rela
.r_offset
- asect
->vma
;
2651 relent
->addend
= rela
.r_addend
;
2653 relent
->howto
= mips_elf64_rtype_to_howto (type
, rela_p
);
2659 asect
->reloc_count
+= (relent
- relents
) / 3;
2661 if (allocated
!= NULL
)
2667 if (allocated
!= NULL
)
2672 /* Read the relocations. On Irix 6, there can be two reloc sections
2673 associated with a single data section. This is copied from
2674 elfcode.h as well, with changes as small as accounting for 3
2675 internal relocs per external reloc and resetting reloc_count to
2676 zero before processing the relocs of a section. */
2679 mips_elf64_slurp_reloc_table (bfd
*abfd
, asection
*asect
,
2680 asymbol
**symbols
, bfd_boolean dynamic
)
2682 struct bfd_elf_section_data
* const d
= elf_section_data (asect
);
2683 Elf_Internal_Shdr
*rel_hdr
;
2684 Elf_Internal_Shdr
*rel_hdr2
;
2685 bfd_size_type reloc_count
;
2686 bfd_size_type reloc_count2
;
2690 if (asect
->relocation
!= NULL
)
2695 if ((asect
->flags
& SEC_RELOC
) == 0
2696 || asect
->reloc_count
== 0)
2699 rel_hdr
= &d
->rel_hdr
;
2700 reloc_count
= NUM_SHDR_ENTRIES (rel_hdr
);
2701 rel_hdr2
= d
->rel_hdr2
;
2702 reloc_count2
= (rel_hdr2
? NUM_SHDR_ENTRIES (rel_hdr2
) : 0);
2704 BFD_ASSERT (asect
->reloc_count
== reloc_count
+ reloc_count2
);
2705 BFD_ASSERT (asect
->rel_filepos
== rel_hdr
->sh_offset
2706 || (rel_hdr2
&& asect
->rel_filepos
== rel_hdr2
->sh_offset
));
2711 /* Note that ASECT->RELOC_COUNT tends not to be accurate in this
2712 case because relocations against this section may use the
2713 dynamic symbol table, and in that case bfd_section_from_shdr
2714 in elf.c does not update the RELOC_COUNT. */
2715 if (asect
->size
== 0)
2718 rel_hdr
= &d
->this_hdr
;
2719 reloc_count
= NUM_SHDR_ENTRIES (rel_hdr
);
2724 /* Allocate space for 3 arelent structures for each Rel structure. */
2725 amt
= (reloc_count
+ reloc_count2
) * 3 * sizeof (arelent
);
2726 relents
= bfd_alloc (abfd
, amt
);
2727 if (relents
== NULL
)
2730 /* The slurp_one_reloc_table routine increments reloc_count. */
2731 asect
->reloc_count
= 0;
2733 if (! mips_elf64_slurp_one_reloc_table (abfd
, asect
,
2734 rel_hdr
, reloc_count
,
2738 if (d
->rel_hdr2
!= NULL
)
2740 if (! mips_elf64_slurp_one_reloc_table (abfd
, asect
,
2741 rel_hdr2
, reloc_count2
,
2742 relents
+ reloc_count
* 3,
2747 asect
->relocation
= relents
;
2751 /* Write out the relocations. */
2754 mips_elf64_write_relocs (bfd
*abfd
, asection
*sec
, void *data
)
2756 bfd_boolean
*failedp
= data
;
2758 Elf_Internal_Shdr
*rel_hdr
;
2761 /* If we have already failed, don't do anything. */
2765 if ((sec
->flags
& SEC_RELOC
) == 0)
2768 /* The linker backend writes the relocs out itself, and sets the
2769 reloc_count field to zero to inhibit writing them here. Also,
2770 sometimes the SEC_RELOC flag gets set even when there aren't any
2772 if (sec
->reloc_count
== 0)
2775 /* We can combine up to three relocs that refer to the same address
2776 if the latter relocs have no associated symbol. */
2778 for (idx
= 0; idx
< sec
->reloc_count
; idx
++)
2785 addr
= sec
->orelocation
[idx
]->address
;
2786 for (i
= 0; i
< 2; i
++)
2790 if (idx
+ 1 >= sec
->reloc_count
)
2792 r
= sec
->orelocation
[idx
+ 1];
2793 if (r
->address
!= addr
2794 || ! bfd_is_abs_section ((*r
->sym_ptr_ptr
)->section
)
2795 || (*r
->sym_ptr_ptr
)->value
!= 0)
2798 /* We can merge the reloc at IDX + 1 with the reloc at IDX. */
2804 rel_hdr
= &elf_section_data (sec
)->rel_hdr
;
2806 /* Do the actual relocation. */
2808 if (rel_hdr
->sh_entsize
== sizeof(Elf64_Mips_External_Rel
))
2809 mips_elf64_write_rel (abfd
, sec
, rel_hdr
, &count
, data
);
2810 else if (rel_hdr
->sh_entsize
== sizeof(Elf64_Mips_External_Rela
))
2811 mips_elf64_write_rela (abfd
, sec
, rel_hdr
, &count
, data
);
2817 mips_elf64_write_rel (bfd
*abfd
, asection
*sec
,
2818 Elf_Internal_Shdr
*rel_hdr
,
2819 int *count
, void *data
)
2821 bfd_boolean
*failedp
= data
;
2822 Elf64_Mips_External_Rel
*ext_rel
;
2824 asymbol
*last_sym
= 0;
2825 int last_sym_idx
= 0;
2827 rel_hdr
->sh_size
= rel_hdr
->sh_entsize
* *count
;
2828 rel_hdr
->contents
= bfd_alloc (abfd
, rel_hdr
->sh_size
);
2829 if (rel_hdr
->contents
== NULL
)
2835 ext_rel
= (Elf64_Mips_External_Rel
*) rel_hdr
->contents
;
2836 for (idx
= 0; idx
< sec
->reloc_count
; idx
++, ext_rel
++)
2839 Elf64_Mips_Internal_Rela int_rel
;
2844 ptr
= sec
->orelocation
[idx
];
2846 /* The address of an ELF reloc is section relative for an object
2847 file, and absolute for an executable file or shared library.
2848 The address of a BFD reloc is always section relative. */
2849 if ((abfd
->flags
& (EXEC_P
| DYNAMIC
)) == 0)
2850 int_rel
.r_offset
= ptr
->address
;
2852 int_rel
.r_offset
= ptr
->address
+ sec
->vma
;
2854 sym
= *ptr
->sym_ptr_ptr
;
2855 if (sym
== last_sym
)
2857 else if (bfd_is_abs_section (sym
->section
) && sym
->value
== 0)
2862 n
= _bfd_elf_symbol_from_bfd_symbol (abfd
, &sym
);
2872 int_rel
.r_ssym
= RSS_UNDEF
;
2874 if ((*ptr
->sym_ptr_ptr
)->the_bfd
->xvec
!= abfd
->xvec
2875 && ! _bfd_elf_validate_reloc (abfd
, ptr
))
2881 int_rel
.r_type
= ptr
->howto
->type
;
2882 int_rel
.r_type2
= (int) R_MIPS_NONE
;
2883 int_rel
.r_type3
= (int) R_MIPS_NONE
;
2885 for (i
= 0; i
< 2; i
++)
2889 if (idx
+ 1 >= sec
->reloc_count
)
2891 r
= sec
->orelocation
[idx
+ 1];
2892 if (r
->address
!= ptr
->address
2893 || ! bfd_is_abs_section ((*r
->sym_ptr_ptr
)->section
)
2894 || (*r
->sym_ptr_ptr
)->value
!= 0)
2897 /* We can merge the reloc at IDX + 1 with the reloc at IDX. */
2900 int_rel
.r_type2
= r
->howto
->type
;
2902 int_rel
.r_type3
= r
->howto
->type
;
2907 mips_elf64_swap_reloc_out (abfd
, &int_rel
, ext_rel
);
2910 BFD_ASSERT (ext_rel
- (Elf64_Mips_External_Rel
*) rel_hdr
->contents
2915 mips_elf64_write_rela (bfd
*abfd
, asection
*sec
,
2916 Elf_Internal_Shdr
*rela_hdr
,
2917 int *count
, void *data
)
2919 bfd_boolean
*failedp
= data
;
2920 Elf64_Mips_External_Rela
*ext_rela
;
2922 asymbol
*last_sym
= 0;
2923 int last_sym_idx
= 0;
2925 rela_hdr
->sh_size
= rela_hdr
->sh_entsize
* *count
;
2926 rela_hdr
->contents
= bfd_alloc (abfd
, rela_hdr
->sh_size
);
2927 if (rela_hdr
->contents
== NULL
)
2933 ext_rela
= (Elf64_Mips_External_Rela
*) rela_hdr
->contents
;
2934 for (idx
= 0; idx
< sec
->reloc_count
; idx
++, ext_rela
++)
2937 Elf64_Mips_Internal_Rela int_rela
;
2942 ptr
= sec
->orelocation
[idx
];
2944 /* The address of an ELF reloc is section relative for an object
2945 file, and absolute for an executable file or shared library.
2946 The address of a BFD reloc is always section relative. */
2947 if ((abfd
->flags
& (EXEC_P
| DYNAMIC
)) == 0)
2948 int_rela
.r_offset
= ptr
->address
;
2950 int_rela
.r_offset
= ptr
->address
+ sec
->vma
;
2952 sym
= *ptr
->sym_ptr_ptr
;
2953 if (sym
== last_sym
)
2955 else if (bfd_is_abs_section (sym
->section
) && sym
->value
== 0)
2960 n
= _bfd_elf_symbol_from_bfd_symbol (abfd
, &sym
);
2970 int_rela
.r_addend
= ptr
->addend
;
2971 int_rela
.r_ssym
= RSS_UNDEF
;
2973 if ((*ptr
->sym_ptr_ptr
)->the_bfd
->xvec
!= abfd
->xvec
2974 && ! _bfd_elf_validate_reloc (abfd
, ptr
))
2980 int_rela
.r_type
= ptr
->howto
->type
;
2981 int_rela
.r_type2
= (int) R_MIPS_NONE
;
2982 int_rela
.r_type3
= (int) R_MIPS_NONE
;
2984 for (i
= 0; i
< 2; i
++)
2988 if (idx
+ 1 >= sec
->reloc_count
)
2990 r
= sec
->orelocation
[idx
+ 1];
2991 if (r
->address
!= ptr
->address
2992 || ! bfd_is_abs_section ((*r
->sym_ptr_ptr
)->section
)
2993 || (*r
->sym_ptr_ptr
)->value
!= 0)
2996 /* We can merge the reloc at IDX + 1 with the reloc at IDX. */
2999 int_rela
.r_type2
= r
->howto
->type
;
3001 int_rela
.r_type3
= r
->howto
->type
;
3006 mips_elf64_swap_reloca_out (abfd
, &int_rela
, ext_rela
);
3009 BFD_ASSERT (ext_rela
- (Elf64_Mips_External_Rela
*) rela_hdr
->contents
3013 /* Set the right machine number for a MIPS ELF file. */
3016 mips_elf64_object_p (bfd
*abfd
)
3020 /* Irix 6 is broken. Object file symbol tables are not always
3021 sorted correctly such that local symbols precede global symbols,
3022 and the sh_info field in the symbol table is not always right. */
3023 if (elf64_mips_irix_compat (abfd
) != ict_none
)
3024 elf_bad_symtab (abfd
) = TRUE
;
3026 mach
= _bfd_elf_mips_mach (elf_elfheader (abfd
)->e_flags
);
3027 bfd_default_set_arch_mach (abfd
, bfd_arch_mips
, mach
);
3031 /* MIPS ELF local labels start with "$L". */
3033 mips_elf64_is_local_label_name (bfd
*abfd
, const char *name
)
3035 if (name
[0] == '$' && name
[1] == 'L')
3038 /* We accept the generic ELF local label syntax as well. */
3039 return _bfd_elf_is_local_label_name (abfd
, name
);
3042 /* Depending on the target vector we generate some version of Irix
3043 executables or "normal" MIPS ELF ABI executables. */
3044 static irix_compat_t
3045 elf64_mips_irix_compat (bfd
*abfd
)
3047 if ((abfd
->xvec
== &bfd_elf64_bigmips_vec
)
3048 || (abfd
->xvec
== &bfd_elf64_littlemips_vec
))
3054 /* Support for core dump NOTE sections. */
3056 elf64_mips_grok_prstatus (bfd
*abfd
, Elf_Internal_Note
*note
)
3061 switch (note
->descsz
)
3066 case 480: /* Linux/MIPS - N64 kernel */
3068 elf_tdata (abfd
)->core_signal
= bfd_get_16 (abfd
, note
->descdata
+ 12);
3071 elf_tdata (abfd
)->core_pid
= bfd_get_32 (abfd
, note
->descdata
+ 32);
3080 /* Make a ".reg/999" section. */
3081 return _bfd_elfcore_make_pseudosection (abfd
, ".reg",
3082 size
, note
->descpos
+ offset
);
3086 elf64_mips_grok_psinfo (bfd
*abfd
, Elf_Internal_Note
*note
)
3088 switch (note
->descsz
)
3093 case 136: /* Linux/MIPS - N64 kernel elf_prpsinfo */
3094 elf_tdata (abfd
)->core_program
3095 = _bfd_elfcore_strndup (abfd
, note
->descdata
+ 40, 16);
3096 elf_tdata (abfd
)->core_command
3097 = _bfd_elfcore_strndup (abfd
, note
->descdata
+ 56, 80);
3100 /* Note that for some reason, a spurious space is tacked
3101 onto the end of the args in some (at least one anyway)
3102 implementations, so strip it off if it exists. */
3105 char *command
= elf_tdata (abfd
)->core_command
;
3106 int n
= strlen (command
);
3108 if (0 < n
&& command
[n
- 1] == ' ')
3109 command
[n
- 1] = '\0';
3115 /* ECOFF swapping routines. These are used when dealing with the
3116 .mdebug section, which is in the ECOFF debugging format. */
3117 static const struct ecoff_debug_swap mips_elf64_ecoff_debug_swap
=
3119 /* Symbol table magic number. */
3121 /* Alignment of debugging information. E.g., 4. */
3123 /* Sizes of external symbolic information. */
3124 sizeof (struct hdr_ext
),
3125 sizeof (struct dnr_ext
),
3126 sizeof (struct pdr_ext
),
3127 sizeof (struct sym_ext
),
3128 sizeof (struct opt_ext
),
3129 sizeof (struct fdr_ext
),
3130 sizeof (struct rfd_ext
),
3131 sizeof (struct ext_ext
),
3132 /* Functions to swap in external symbolic data. */
3141 _bfd_ecoff_swap_tir_in
,
3142 _bfd_ecoff_swap_rndx_in
,
3143 /* Functions to swap out external symbolic data. */
3152 _bfd_ecoff_swap_tir_out
,
3153 _bfd_ecoff_swap_rndx_out
,
3154 /* Function to read in symbolic data. */
3155 _bfd_mips_elf_read_ecoff_info
3158 /* Relocations in the 64 bit MIPS ELF ABI are more complex than in
3159 standard ELF. This structure is used to redirect the relocation
3160 handling routines. */
3162 const struct elf_size_info mips_elf64_size_info
=
3164 sizeof (Elf64_External_Ehdr
),
3165 sizeof (Elf64_External_Phdr
),
3166 sizeof (Elf64_External_Shdr
),
3167 sizeof (Elf64_Mips_External_Rel
),
3168 sizeof (Elf64_Mips_External_Rela
),
3169 sizeof (Elf64_External_Sym
),
3170 sizeof (Elf64_External_Dyn
),
3171 sizeof (Elf_External_Note
),
3172 4, /* hash-table entry size */
3173 3, /* internal relocations per external relocations */
3175 3, /* log_file_align */
3178 bfd_elf64_write_out_phdrs
,
3179 bfd_elf64_write_shdrs_and_ehdr
,
3180 bfd_elf64_checksum_contents
,
3181 mips_elf64_write_relocs
,
3182 bfd_elf64_swap_symbol_in
,
3183 bfd_elf64_swap_symbol_out
,
3184 mips_elf64_slurp_reloc_table
,
3185 bfd_elf64_slurp_symbol_table
,
3186 bfd_elf64_swap_dyn_in
,
3187 bfd_elf64_swap_dyn_out
,
3188 mips_elf64_be_swap_reloc_in
,
3189 mips_elf64_be_swap_reloc_out
,
3190 mips_elf64_be_swap_reloca_in
,
3191 mips_elf64_be_swap_reloca_out
3194 #define ELF_ARCH bfd_arch_mips
3195 #define ELF_MACHINE_CODE EM_MIPS
3197 #define elf_backend_collect TRUE
3198 #define elf_backend_type_change_ok TRUE
3199 #define elf_backend_can_gc_sections TRUE
3200 #define elf_info_to_howto mips_elf64_info_to_howto_rela
3201 #define elf_info_to_howto_rel mips_elf64_info_to_howto_rel
3202 #define elf_backend_object_p mips_elf64_object_p
3203 #define elf_backend_symbol_processing _bfd_mips_elf_symbol_processing
3204 #define elf_backend_section_processing _bfd_mips_elf_section_processing
3205 #define elf_backend_section_from_shdr _bfd_mips_elf_section_from_shdr
3206 #define elf_backend_fake_sections _bfd_mips_elf_fake_sections
3207 #define elf_backend_section_from_bfd_section \
3208 _bfd_mips_elf_section_from_bfd_section
3209 #define elf_backend_add_symbol_hook _bfd_mips_elf_add_symbol_hook
3210 #define elf_backend_link_output_symbol_hook \
3211 _bfd_mips_elf_link_output_symbol_hook
3212 #define elf_backend_create_dynamic_sections \
3213 _bfd_mips_elf_create_dynamic_sections
3214 #define elf_backend_check_relocs _bfd_mips_elf_check_relocs
3215 #define elf_backend_merge_symbol_attribute \
3216 _bfd_mips_elf_merge_symbol_attribute
3217 #define elf_backend_get_target_dtag _bfd_mips_elf_get_target_dtag
3218 #define elf_backend_adjust_dynamic_symbol \
3219 _bfd_mips_elf_adjust_dynamic_symbol
3220 #define elf_backend_always_size_sections \
3221 _bfd_mips_elf_always_size_sections
3222 #define elf_backend_size_dynamic_sections \
3223 _bfd_mips_elf_size_dynamic_sections
3224 #define elf_backend_init_index_section _bfd_elf_init_1_index_section
3225 #define elf_backend_relocate_section _bfd_mips_elf_relocate_section
3226 #define elf_backend_finish_dynamic_symbol \
3227 _bfd_mips_elf_finish_dynamic_symbol
3228 #define elf_backend_finish_dynamic_sections \
3229 _bfd_mips_elf_finish_dynamic_sections
3230 #define elf_backend_final_write_processing \
3231 _bfd_mips_elf_final_write_processing
3232 #define elf_backend_additional_program_headers \
3233 _bfd_mips_elf_additional_program_headers
3234 #define elf_backend_modify_segment_map _bfd_mips_elf_modify_segment_map
3235 #define elf_backend_gc_mark_hook _bfd_mips_elf_gc_mark_hook
3236 #define elf_backend_gc_sweep_hook _bfd_mips_elf_gc_sweep_hook
3237 #define elf_backend_copy_indirect_symbol \
3238 _bfd_mips_elf_copy_indirect_symbol
3239 #define elf_backend_ignore_discarded_relocs \
3240 _bfd_mips_elf_ignore_discarded_relocs
3241 #define elf_backend_mips_irix_compat elf64_mips_irix_compat
3242 #define elf_backend_mips_rtype_to_howto mips_elf64_rtype_to_howto
3243 #define elf_backend_ecoff_debug_swap &mips_elf64_ecoff_debug_swap
3244 #define elf_backend_size_info mips_elf64_size_info
3246 #define elf_backend_grok_prstatus elf64_mips_grok_prstatus
3247 #define elf_backend_grok_psinfo elf64_mips_grok_psinfo
3249 #define elf_backend_got_header_size (4 * MIPS_RESERVED_GOTNO)
3251 /* MIPS ELF64 can use a mixture of REL and RELA, but some Relocations
3252 work better/work only in RELA, so we default to this. */
3253 #define elf_backend_may_use_rel_p 1
3254 #define elf_backend_may_use_rela_p 1
3255 #define elf_backend_default_use_rela_p 1
3256 #define elf_backend_rela_plts_and_copies_p 0
3257 #define elf_backend_plt_readonly 1
3258 #define elf_backend_plt_sym_val _bfd_mips_elf_plt_sym_val
3260 #define elf_backend_sign_extend_vma TRUE
3262 #define elf_backend_write_section _bfd_mips_elf_write_section
3264 #define bfd_elf64_bfd_is_local_label_name \
3265 mips_elf64_is_local_label_name
3266 #define bfd_elf64_find_nearest_line _bfd_mips_elf_find_nearest_line
3267 #define bfd_elf64_find_inliner_info _bfd_mips_elf_find_inliner_info
3268 #define bfd_elf64_new_section_hook _bfd_mips_elf_new_section_hook
3269 #define bfd_elf64_set_section_contents _bfd_mips_elf_set_section_contents
3270 #define bfd_elf64_bfd_get_relocated_section_contents \
3271 _bfd_elf_mips_get_relocated_section_contents
3272 #define bfd_elf64_mkobject _bfd_mips_elf_mkobject
3273 #define bfd_elf64_bfd_link_hash_table_create \
3274 _bfd_mips_elf_link_hash_table_create
3275 #define bfd_elf64_bfd_final_link _bfd_mips_elf_final_link
3276 #define bfd_elf64_bfd_merge_private_bfd_data \
3277 _bfd_mips_elf_merge_private_bfd_data
3278 #define bfd_elf64_bfd_set_private_flags _bfd_mips_elf_set_private_flags
3279 #define bfd_elf64_bfd_print_private_bfd_data \
3280 _bfd_mips_elf_print_private_bfd_data
3282 #define bfd_elf64_get_reloc_upper_bound mips_elf64_get_reloc_upper_bound
3283 #define bfd_elf64_canonicalize_reloc mips_elf64_canonicalize_reloc
3284 #define bfd_elf64_get_dynamic_reloc_upper_bound mips_elf64_get_dynamic_reloc_upper_bound
3285 #define bfd_elf64_canonicalize_dynamic_reloc mips_elf64_canonicalize_dynamic_reloc
3286 #define bfd_elf64_bfd_relax_section _bfd_mips_relax_section
3288 /* MIPS ELF64 archive functions. */
3289 #define bfd_elf64_archive_functions
3290 extern bfd_boolean bfd_elf64_archive_slurp_armap
3292 extern bfd_boolean bfd_elf64_archive_write_armap
3293 (bfd
*, unsigned int, struct orl
*, unsigned int, int);
3294 #define bfd_elf64_archive_slurp_extended_name_table \
3295 _bfd_archive_coff_slurp_extended_name_table
3296 #define bfd_elf64_archive_construct_extended_name_table \
3297 _bfd_archive_coff_construct_extended_name_table
3298 #define bfd_elf64_archive_truncate_arname \
3299 _bfd_archive_coff_truncate_arname
3300 #define bfd_elf64_archive_read_ar_hdr _bfd_archive_coff_read_ar_hdr
3301 #define bfd_elf64_archive_openr_next_archived_file \
3302 _bfd_archive_coff_openr_next_archived_file
3303 #define bfd_elf64_archive_get_elt_at_index \
3304 _bfd_archive_coff_get_elt_at_index
3305 #define bfd_elf64_archive_generic_stat_arch_elt \
3306 _bfd_archive_coff_generic_stat_arch_elt
3307 #define bfd_elf64_archive_update_armap_timestamp \
3308 _bfd_archive_coff_update_armap_timestamp
3310 /* The SGI style (n)64 NewABI. */
3311 #define TARGET_LITTLE_SYM bfd_elf64_littlemips_vec
3312 #define TARGET_LITTLE_NAME "elf64-littlemips"
3313 #define TARGET_BIG_SYM bfd_elf64_bigmips_vec
3314 #define TARGET_BIG_NAME "elf64-bigmips"
3316 #define ELF_MAXPAGESIZE 0x10000
3317 #define ELF_COMMONPAGESIZE 0x1000
3319 #include "elf64-target.h"
3321 /* The SYSV-style 'traditional' (n)64 NewABI. */
3322 #undef TARGET_LITTLE_SYM
3323 #undef TARGET_LITTLE_NAME
3324 #undef TARGET_BIG_SYM
3325 #undef TARGET_BIG_NAME
3327 #undef ELF_MAXPAGESIZE
3328 #undef ELF_COMMONPAGESIZE
3330 #define TARGET_LITTLE_SYM bfd_elf64_tradlittlemips_vec
3331 #define TARGET_LITTLE_NAME "elf64-tradlittlemips"
3332 #define TARGET_BIG_SYM bfd_elf64_tradbigmips_vec
3333 #define TARGET_BIG_NAME "elf64-tradbigmips"
3335 #define ELF_MAXPAGESIZE 0x10000
3336 #define ELF_COMMONPAGESIZE 0x1000
3337 #define elf64_bed elf64_tradbed
3339 /* Include the target file again for this target. */
3340 #include "elf64-target.h"