elf64-mips.c revision 1.10 1 /* MIPS-specific support for 64-bit ELF
2 Copyright (C) 1996-2022 Free Software Foundation, Inc.
3 Ian Lance Taylor, Cygnus Support
4 Linker support added by Mark Mitchell, CodeSourcery, LLC.
5 <mark (at) codesourcery.com>
6
7 This file is part of BFD, the Binary File Descriptor library.
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
22 MA 02110-1301, USA. */
23
24
25 /* This file supports the 64-bit MIPS ELF ABI.
26
27 The MIPS 64-bit ELF ABI uses an unusual reloc format. This file
28 overrides the usual ELF reloc handling, and handles reading and
29 writing the relocations here. */
30
31 /* TODO: Many things are unsupported, even if there is some code for it
32 . (which was mostly stolen from elf32-mips.c and slightly adapted).
33 .
34 . - Relocation handling for REL relocs is wrong in many cases and
35 . generally untested.
36 . - Relocation handling for RELA relocs related to GOT support are
37 . also likely to be wrong.
38 . - Support for MIPS16 is untested.
39 . - Combined relocs with RSS_* entries are unsupported.
40 . - The whole GOT handling for NewABI is missing, some parts of
41 . the OldABI version is still lying around and should be removed.
42 */
43
44 #include "sysdep.h"
45 #include "bfd.h"
46 #include "libbfd.h"
47 #include "aout/ar.h"
48 #include "bfdlink.h"
49 #include "genlink.h"
50 #include "elf-bfd.h"
51 #include "elfxx-mips.h"
52 #include "elf/mips.h"
53
54 /* Get the ECOFF swapping routines. The 64-bit ABI is not supposed to
55 use ECOFF. However, we support it anyhow for an easier changeover. */
56 #include "coff/sym.h"
57 #include "coff/symconst.h"
58 #include "coff/internal.h"
59 #include "coff/ecoff.h"
60 /* The 64 bit versions of the mdebug data structures are in alpha.h. */
61 #include "coff/alpha.h"
62 #define ECOFF_SIGNED_64
63 #include "ecoffswap.h"
64
65 static void mips_elf64_swap_reloc_in
66 (bfd *, const Elf64_Mips_External_Rel *, Elf64_Mips_Internal_Rela *);
67 static void mips_elf64_swap_reloca_in
68 (bfd *, const Elf64_Mips_External_Rela *, Elf64_Mips_Internal_Rela *);
69 static void mips_elf64_swap_reloc_out
70 (bfd *, const Elf64_Mips_Internal_Rela *, Elf64_Mips_External_Rel *);
71 static void mips_elf64_swap_reloca_out
72 (bfd *, const Elf64_Mips_Internal_Rela *, Elf64_Mips_External_Rela *);
73 static void mips_elf64_be_swap_reloc_in
74 (bfd *, const bfd_byte *, Elf_Internal_Rela *);
75 static void mips_elf64_be_swap_reloc_out
76 (bfd *, const Elf_Internal_Rela *, bfd_byte *);
77 static void mips_elf64_be_swap_reloca_in
78 (bfd *, const bfd_byte *, Elf_Internal_Rela *);
79 static void mips_elf64_be_swap_reloca_out
80 (bfd *, const Elf_Internal_Rela *, bfd_byte *);
81 static reloc_howto_type *bfd_elf64_bfd_reloc_type_lookup
82 (bfd *, bfd_reloc_code_real_type);
83 static bool mips_elf64_info_to_howto_rela
84 (bfd *, arelent *, Elf_Internal_Rela *);
85 static long mips_elf64_get_dynamic_reloc_upper_bound
86 (bfd *);
87 static bool mips_elf64_slurp_one_reloc_table
88 (bfd *, asection *, Elf_Internal_Shdr *, bfd_size_type, arelent *,
89 asymbol **, bool);
90 static bool mips_elf64_slurp_reloc_table
91 (bfd *, asection *, asymbol **, bool);
92 static void mips_elf64_write_relocs
93 (bfd *, asection *, void *);
94 static void mips_elf64_write_rel
95 (bfd *, asection *, Elf_Internal_Shdr *, int *, void *);
96 static void mips_elf64_write_rela
97 (bfd *, asection *, Elf_Internal_Shdr *, int *, void *);
98 static bfd_reloc_status_type mips_elf64_gprel16_reloc
99 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
100 static bfd_reloc_status_type mips_elf64_literal_reloc
101 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
102 static bfd_reloc_status_type mips_elf64_gprel32_reloc
103 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
104 static bfd_reloc_status_type mips_elf64_shift6_reloc
105 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
106 static bfd_reloc_status_type mips16_gprel_reloc
107 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
108 static bool mips_elf64_assign_gp
109 (bfd *, bfd_vma *);
110 static bfd_reloc_status_type mips_elf64_final_gp
111 (bfd *, asymbol *, bool, char **, bfd_vma *);
112 static bool mips_elf64_object_p
113 (bfd *);
114 static irix_compat_t elf64_mips_irix_compat
115 (bfd *);
116 static bool elf64_mips_grok_prstatus
117 (bfd *, Elf_Internal_Note *);
118 static bool elf64_mips_grok_psinfo
119 (bfd *, Elf_Internal_Note *);
120
121 extern const bfd_target mips_elf64_be_vec;
122 extern const bfd_target mips_elf64_le_vec;
123
124 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
125 from smaller values. Start with zero, widen, *then* decrement. */
126 #define MINUS_ONE (((bfd_vma)0) - 1)
127
128 /* The number of local .got entries we reserve. */
129 #define MIPS_RESERVED_GOTNO (2)
130
131 /* The relocation table used for SHT_REL sections. */
133
134 static reloc_howto_type mips_elf64_howto_table_rel[] =
135 {
136 /* No relocation. */
137 HOWTO (R_MIPS_NONE, /* type */
138 0, /* rightshift */
139 0, /* size */
140 0, /* bitsize */
141 false, /* pc_relative */
142 0, /* bitpos */
143 complain_overflow_dont, /* complain_on_overflow */
144 _bfd_mips_elf_generic_reloc, /* special_function */
145 "R_MIPS_NONE", /* name */
146 false, /* partial_inplace */
147 0, /* src_mask */
148 0, /* dst_mask */
149 false), /* pcrel_offset */
150
151 /* 16 bit relocation. */
152 HOWTO (R_MIPS_16, /* type */
153 0, /* rightshift */
154 4, /* size */
155 16, /* bitsize */
156 false, /* pc_relative */
157 0, /* bitpos */
158 complain_overflow_signed, /* complain_on_overflow */
159 _bfd_mips_elf_generic_reloc, /* special_function */
160 "R_MIPS_16", /* name */
161 true, /* partial_inplace */
162 0x0000ffff, /* src_mask */
163 0x0000ffff, /* dst_mask */
164 false), /* pcrel_offset */
165
166 /* 32 bit relocation. */
167 HOWTO (R_MIPS_32, /* type */
168 0, /* rightshift */
169 4, /* size */
170 32, /* bitsize */
171 false, /* pc_relative */
172 0, /* bitpos */
173 complain_overflow_dont, /* complain_on_overflow */
174 _bfd_mips_elf_generic_reloc, /* special_function */
175 "R_MIPS_32", /* name */
176 true, /* partial_inplace */
177 0xffffffff, /* src_mask */
178 0xffffffff, /* dst_mask */
179 false), /* pcrel_offset */
180
181 /* 32 bit symbol relative relocation. */
182 HOWTO (R_MIPS_REL32, /* type */
183 0, /* rightshift */
184 4, /* size */
185 32, /* bitsize */
186 false, /* pc_relative */
187 0, /* bitpos */
188 complain_overflow_dont, /* complain_on_overflow */
189 _bfd_mips_elf_generic_reloc, /* special_function */
190 "R_MIPS_REL32", /* name */
191 true, /* partial_inplace */
192 0xffffffff, /* src_mask */
193 0xffffffff, /* dst_mask */
194 false), /* pcrel_offset */
195
196 /* 26 bit jump address. */
197 HOWTO (R_MIPS_26, /* type */
198 2, /* rightshift */
199 4, /* size */
200 26, /* bitsize */
201 false, /* pc_relative */
202 0, /* bitpos */
203 complain_overflow_dont, /* complain_on_overflow */
204 /* This needs complex overflow
205 detection, because the upper 36
206 bits must match the PC + 4. */
207 _bfd_mips_elf_generic_reloc, /* special_function */
208 "R_MIPS_26", /* name */
209 true, /* partial_inplace */
210 0x03ffffff, /* src_mask */
211 0x03ffffff, /* dst_mask */
212 false), /* pcrel_offset */
213
214 /* R_MIPS_HI16 and R_MIPS_LO16 are unsupported for NewABI REL.
215 However, the native IRIX6 tools use them, so we try our best. */
216
217 /* High 16 bits of symbol value. */
218 HOWTO (R_MIPS_HI16, /* type */
219 16, /* rightshift */
220 4, /* size */
221 16, /* bitsize */
222 false, /* pc_relative */
223 0, /* bitpos */
224 complain_overflow_dont, /* complain_on_overflow */
225 _bfd_mips_elf_hi16_reloc, /* special_function */
226 "R_MIPS_HI16", /* name */
227 true, /* partial_inplace */
228 0x0000ffff, /* src_mask */
229 0x0000ffff, /* dst_mask */
230 false), /* pcrel_offset */
231
232 /* Low 16 bits of symbol value. */
233 HOWTO (R_MIPS_LO16, /* type */
234 0, /* rightshift */
235 4, /* size */
236 16, /* bitsize */
237 false, /* pc_relative */
238 0, /* bitpos */
239 complain_overflow_dont, /* complain_on_overflow */
240 _bfd_mips_elf_lo16_reloc, /* special_function */
241 "R_MIPS_LO16", /* name */
242 true, /* partial_inplace */
243 0x0000ffff, /* src_mask */
244 0x0000ffff, /* dst_mask */
245 false), /* pcrel_offset */
246
247 /* GP relative reference. */
248 HOWTO (R_MIPS_GPREL16, /* type */
249 0, /* rightshift */
250 4, /* size */
251 16, /* bitsize */
252 false, /* pc_relative */
253 0, /* bitpos */
254 complain_overflow_signed, /* complain_on_overflow */
255 mips_elf64_gprel16_reloc, /* special_function */
256 "R_MIPS_GPREL16", /* name */
257 true, /* partial_inplace */
258 0x0000ffff, /* src_mask */
259 0x0000ffff, /* dst_mask */
260 false), /* pcrel_offset */
261
262 /* Reference to literal section. */
263 HOWTO (R_MIPS_LITERAL, /* type */
264 0, /* rightshift */
265 4, /* size */
266 16, /* bitsize */
267 false, /* pc_relative */
268 0, /* bitpos */
269 complain_overflow_signed, /* complain_on_overflow */
270 mips_elf64_literal_reloc, /* special_function */
271 "R_MIPS_LITERAL", /* name */
272 true, /* partial_inplace */
273 0x0000ffff, /* src_mask */
274 0x0000ffff, /* dst_mask */
275 false), /* pcrel_offset */
276
277 /* Reference to global offset table. */
278 HOWTO (R_MIPS_GOT16, /* type */
279 0, /* rightshift */
280 4, /* size */
281 16, /* bitsize */
282 false, /* pc_relative */
283 0, /* bitpos */
284 complain_overflow_signed, /* complain_on_overflow */
285 _bfd_mips_elf_got16_reloc, /* special_function */
286 "R_MIPS_GOT16", /* name */
287 true, /* partial_inplace */
288 0x0000ffff, /* src_mask */
289 0x0000ffff, /* dst_mask */
290 false), /* pcrel_offset */
291
292 /* 16 bit PC relative reference. Note that the ABI document has a typo
293 and claims R_MIPS_PC16 to be not rightshifted, rendering it useless.
294 We do the right thing here. */
295 HOWTO (R_MIPS_PC16, /* type */
296 2, /* rightshift */
297 4, /* size */
298 16, /* bitsize */
299 true, /* pc_relative */
300 0, /* bitpos */
301 complain_overflow_signed, /* complain_on_overflow */
302 _bfd_mips_elf_generic_reloc, /* special_function */
303 "R_MIPS_PC16", /* name */
304 true, /* partial_inplace */
305 0x0000ffff, /* src_mask */
306 0x0000ffff, /* dst_mask */
307 true), /* pcrel_offset */
308
309 /* 16 bit call through global offset table. */
310 HOWTO (R_MIPS_CALL16, /* type */
311 0, /* rightshift */
312 4, /* size */
313 16, /* bitsize */
314 false, /* pc_relative */
315 0, /* bitpos */
316 complain_overflow_signed, /* complain_on_overflow */
317 _bfd_mips_elf_generic_reloc, /* special_function */
318 "R_MIPS_CALL16", /* name */
319 true, /* partial_inplace */
320 0x0000ffff, /* src_mask */
321 0x0000ffff, /* dst_mask */
322 false), /* pcrel_offset */
323
324 /* 32 bit GP relative reference. */
325 HOWTO (R_MIPS_GPREL32, /* type */
326 0, /* rightshift */
327 4, /* size */
328 32, /* bitsize */
329 false, /* pc_relative */
330 0, /* bitpos */
331 complain_overflow_dont, /* complain_on_overflow */
332 mips_elf64_gprel32_reloc, /* special_function */
333 "R_MIPS_GPREL32", /* name */
334 true, /* partial_inplace */
335 0xffffffff, /* src_mask */
336 0xffffffff, /* dst_mask */
337 false), /* pcrel_offset */
338
339 EMPTY_HOWTO (13),
340 EMPTY_HOWTO (14),
341 EMPTY_HOWTO (15),
342
343 /* A 5 bit shift field. */
344 HOWTO (R_MIPS_SHIFT5, /* type */
345 0, /* rightshift */
346 4, /* size */
347 5, /* bitsize */
348 false, /* pc_relative */
349 6, /* bitpos */
350 complain_overflow_bitfield, /* complain_on_overflow */
351 _bfd_mips_elf_generic_reloc, /* special_function */
352 "R_MIPS_SHIFT5", /* name */
353 true, /* partial_inplace */
354 0x000007c0, /* src_mask */
355 0x000007c0, /* dst_mask */
356 false), /* pcrel_offset */
357
358 /* A 6 bit shift field. */
359 HOWTO (R_MIPS_SHIFT6, /* type */
360 0, /* rightshift */
361 4, /* size */
362 6, /* bitsize */
363 false, /* pc_relative */
364 6, /* bitpos */
365 complain_overflow_bitfield, /* complain_on_overflow */
366 mips_elf64_shift6_reloc, /* special_function */
367 "R_MIPS_SHIFT6", /* name */
368 true, /* partial_inplace */
369 0x000007c4, /* src_mask */
370 0x000007c4, /* dst_mask */
371 false), /* pcrel_offset */
372
373 /* 64 bit relocation. */
374 HOWTO (R_MIPS_64, /* type */
375 0, /* rightshift */
376 8, /* size */
377 64, /* bitsize */
378 false, /* pc_relative */
379 0, /* bitpos */
380 complain_overflow_dont, /* complain_on_overflow */
381 _bfd_mips_elf_generic_reloc, /* special_function */
382 "R_MIPS_64", /* name */
383 true, /* partial_inplace */
384 MINUS_ONE, /* src_mask */
385 MINUS_ONE, /* dst_mask */
386 false), /* pcrel_offset */
387
388 /* Displacement in the global offset table. */
389 HOWTO (R_MIPS_GOT_DISP, /* type */
390 0, /* rightshift */
391 4, /* size */
392 16, /* bitsize */
393 false, /* pc_relative */
394 0, /* bitpos */
395 complain_overflow_signed, /* complain_on_overflow */
396 _bfd_mips_elf_generic_reloc, /* special_function */
397 "R_MIPS_GOT_DISP", /* name */
398 true, /* partial_inplace */
399 0x0000ffff, /* src_mask */
400 0x0000ffff, /* dst_mask */
401 false), /* pcrel_offset */
402
403 /* Displacement to page pointer in the global offset table. */
404 HOWTO (R_MIPS_GOT_PAGE, /* type */
405 0, /* rightshift */
406 4, /* size */
407 16, /* bitsize */
408 false, /* pc_relative */
409 0, /* bitpos */
410 complain_overflow_signed, /* complain_on_overflow */
411 _bfd_mips_elf_generic_reloc, /* special_function */
412 "R_MIPS_GOT_PAGE", /* name */
413 true, /* partial_inplace */
414 0x0000ffff, /* src_mask */
415 0x0000ffff, /* dst_mask */
416 false), /* pcrel_offset */
417
418 /* Offset from page pointer in the global offset table. */
419 HOWTO (R_MIPS_GOT_OFST, /* type */
420 0, /* rightshift */
421 4, /* size */
422 16, /* bitsize */
423 false, /* pc_relative */
424 0, /* bitpos */
425 complain_overflow_signed, /* complain_on_overflow */
426 _bfd_mips_elf_generic_reloc, /* special_function */
427 "R_MIPS_GOT_OFST", /* name */
428 true, /* partial_inplace */
429 0x0000ffff, /* src_mask */
430 0x0000ffff, /* dst_mask */
431 false), /* pcrel_offset */
432
433 /* High 16 bits of displacement in global offset table. */
434 HOWTO (R_MIPS_GOT_HI16, /* type */
435 0, /* rightshift */
436 4, /* size */
437 16, /* bitsize */
438 false, /* pc_relative */
439 0, /* bitpos */
440 complain_overflow_dont, /* complain_on_overflow */
441 _bfd_mips_elf_generic_reloc, /* special_function */
442 "R_MIPS_GOT_HI16", /* name */
443 true, /* partial_inplace */
444 0x0000ffff, /* src_mask */
445 0x0000ffff, /* dst_mask */
446 false), /* pcrel_offset */
447
448 /* Low 16 bits of displacement in global offset table. */
449 HOWTO (R_MIPS_GOT_LO16, /* type */
450 0, /* rightshift */
451 4, /* size */
452 16, /* bitsize */
453 false, /* pc_relative */
454 0, /* bitpos */
455 complain_overflow_dont, /* complain_on_overflow */
456 _bfd_mips_elf_generic_reloc, /* special_function */
457 "R_MIPS_GOT_LO16", /* name */
458 true, /* partial_inplace */
459 0x0000ffff, /* src_mask */
460 0x0000ffff, /* dst_mask */
461 false), /* pcrel_offset */
462
463 /* 64 bit subtraction. */
464 HOWTO (R_MIPS_SUB, /* type */
465 0, /* rightshift */
466 8, /* size */
467 64, /* bitsize */
468 false, /* pc_relative */
469 0, /* bitpos */
470 complain_overflow_dont, /* complain_on_overflow */
471 _bfd_mips_elf_generic_reloc, /* special_function */
472 "R_MIPS_SUB", /* name */
473 true, /* partial_inplace */
474 MINUS_ONE, /* src_mask */
475 MINUS_ONE, /* dst_mask */
476 false), /* pcrel_offset */
477
478 /* Insert the addend as an instruction. */
479 /* FIXME: Not handled correctly. */
480 HOWTO (R_MIPS_INSERT_A, /* type */
481 0, /* rightshift */
482 4, /* size */
483 32, /* bitsize */
484 false, /* pc_relative */
485 0, /* bitpos */
486 complain_overflow_dont, /* complain_on_overflow */
487 _bfd_mips_elf_generic_reloc, /* special_function */
488 "R_MIPS_INSERT_A", /* name */
489 true, /* partial_inplace */
490 0xffffffff, /* src_mask */
491 0xffffffff, /* dst_mask */
492 false), /* pcrel_offset */
493
494 /* Insert the addend as an instruction, and change all relocations
495 to refer to the old instruction at the address. */
496 /* FIXME: Not handled correctly. */
497 HOWTO (R_MIPS_INSERT_B, /* type */
498 0, /* rightshift */
499 4, /* size */
500 32, /* bitsize */
501 false, /* pc_relative */
502 0, /* bitpos */
503 complain_overflow_dont, /* complain_on_overflow */
504 _bfd_mips_elf_generic_reloc, /* special_function */
505 "R_MIPS_INSERT_B", /* name */
506 true, /* partial_inplace */
507 0xffffffff, /* src_mask */
508 0xffffffff, /* dst_mask */
509 false), /* pcrel_offset */
510
511 /* Delete a 32 bit instruction. */
512 /* FIXME: Not handled correctly. */
513 HOWTO (R_MIPS_DELETE, /* type */
514 0, /* rightshift */
515 4, /* size */
516 32, /* bitsize */
517 false, /* pc_relative */
518 0, /* bitpos */
519 complain_overflow_dont, /* complain_on_overflow */
520 _bfd_mips_elf_generic_reloc, /* special_function */
521 "R_MIPS_DELETE", /* name */
522 true, /* partial_inplace */
523 0xffffffff, /* src_mask */
524 0xffffffff, /* dst_mask */
525 false), /* pcrel_offset */
526
527 /* The MIPS ELF64 ABI Draft wants us to support these for REL relocations.
528 We don't, because
529 a) It means building the addend from a R_MIPS_HIGHEST/R_MIPS_HIGHER/
530 R_MIPS_HI16/R_MIPS_LO16 sequence with varying ordering, using
531 fallable heuristics.
532 b) No other NewABI toolchain actually emits such relocations. */
533 EMPTY_HOWTO (R_MIPS_HIGHER),
534 EMPTY_HOWTO (R_MIPS_HIGHEST),
535
536 /* High 16 bits of displacement in global offset table. */
537 HOWTO (R_MIPS_CALL_HI16, /* type */
538 0, /* rightshift */
539 4, /* size */
540 16, /* bitsize */
541 false, /* pc_relative */
542 0, /* bitpos */
543 complain_overflow_dont, /* complain_on_overflow */
544 _bfd_mips_elf_generic_reloc, /* special_function */
545 "R_MIPS_CALL_HI16", /* name */
546 true, /* partial_inplace */
547 0x0000ffff, /* src_mask */
548 0x0000ffff, /* dst_mask */
549 false), /* pcrel_offset */
550
551 /* Low 16 bits of displacement in global offset table. */
552 HOWTO (R_MIPS_CALL_LO16, /* type */
553 0, /* rightshift */
554 4, /* size */
555 16, /* bitsize */
556 false, /* pc_relative */
557 0, /* bitpos */
558 complain_overflow_dont, /* complain_on_overflow */
559 _bfd_mips_elf_generic_reloc, /* special_function */
560 "R_MIPS_CALL_LO16", /* name */
561 true, /* partial_inplace */
562 0x0000ffff, /* src_mask */
563 0x0000ffff, /* dst_mask */
564 false), /* pcrel_offset */
565
566 /* Section displacement, used by an associated event location section. */
567 HOWTO (R_MIPS_SCN_DISP, /* type */
568 0, /* rightshift */
569 4, /* size */
570 32, /* bitsize */
571 false, /* pc_relative */
572 0, /* bitpos */
573 complain_overflow_dont, /* complain_on_overflow */
574 _bfd_mips_elf_generic_reloc, /* special_function */
575 "R_MIPS_SCN_DISP", /* name */
576 true, /* partial_inplace */
577 0xffffffff, /* src_mask */
578 0xffffffff, /* dst_mask */
579 false), /* pcrel_offset */
580
581 HOWTO (R_MIPS_REL16, /* type */
582 0, /* rightshift */
583 2, /* size */
584 16, /* bitsize */
585 false, /* pc_relative */
586 0, /* bitpos */
587 complain_overflow_signed, /* complain_on_overflow */
588 _bfd_mips_elf_generic_reloc, /* special_function */
589 "R_MIPS_REL16", /* name */
590 true, /* partial_inplace */
591 0xffff, /* src_mask */
592 0xffff, /* dst_mask */
593 false), /* pcrel_offset */
594
595 /* These two are obsolete. */
596 EMPTY_HOWTO (R_MIPS_ADD_IMMEDIATE),
597 EMPTY_HOWTO (R_MIPS_PJUMP),
598
599 /* Similiar to R_MIPS_REL32, but used for relocations in a GOT section.
600 It must be used for multigot GOT's (and only there). */
601 HOWTO (R_MIPS_RELGOT, /* type */
602 0, /* rightshift */
603 4, /* size */
604 32, /* bitsize */
605 false, /* pc_relative */
606 0, /* bitpos */
607 complain_overflow_dont, /* complain_on_overflow */
608 _bfd_mips_elf_generic_reloc, /* special_function */
609 "R_MIPS_RELGOT", /* name */
610 true, /* partial_inplace */
611 0xffffffff, /* src_mask */
612 0xffffffff, /* dst_mask */
613 false), /* pcrel_offset */
614
615 /* Protected jump conversion. This is an optimization hint. No
616 relocation is required for correctness. */
617 HOWTO (R_MIPS_JALR, /* type */
618 0, /* rightshift */
619 4, /* size */
620 32, /* bitsize */
621 false, /* pc_relative */
622 0, /* bitpos */
623 complain_overflow_dont, /* complain_on_overflow */
624 _bfd_mips_elf_generic_reloc, /* special_function */
625 "R_MIPS_JALR", /* name */
626 false, /* partial_inplace */
627 0, /* src_mask */
628 0x00000000, /* dst_mask */
629 false), /* pcrel_offset */
630
631 /* TLS relocations. */
632 EMPTY_HOWTO (R_MIPS_TLS_DTPMOD32),
633 EMPTY_HOWTO (R_MIPS_TLS_DTPREL32),
634
635 HOWTO (R_MIPS_TLS_DTPMOD64, /* type */
636 0, /* rightshift */
637 8, /* size */
638 64, /* bitsize */
639 false, /* pc_relative */
640 0, /* bitpos */
641 complain_overflow_dont, /* complain_on_overflow */
642 _bfd_mips_elf_generic_reloc, /* special_function */
643 "R_MIPS_TLS_DTPMOD64", /* name */
644 true, /* partial_inplace */
645 MINUS_ONE, /* src_mask */
646 MINUS_ONE, /* dst_mask */
647 false), /* pcrel_offset */
648
649 HOWTO (R_MIPS_TLS_DTPREL64, /* type */
650 0, /* rightshift */
651 8, /* size */
652 64, /* bitsize */
653 false, /* pc_relative */
654 0, /* bitpos */
655 complain_overflow_dont, /* complain_on_overflow */
656 _bfd_mips_elf_generic_reloc, /* special_function */
657 "R_MIPS_TLS_DTPREL64", /* name */
658 true, /* partial_inplace */
659 MINUS_ONE, /* src_mask */
660 MINUS_ONE, /* dst_mask */
661 false), /* pcrel_offset */
662
663 /* TLS general dynamic variable reference. */
664 HOWTO (R_MIPS_TLS_GD, /* type */
665 0, /* rightshift */
666 4, /* size */
667 16, /* bitsize */
668 false, /* pc_relative */
669 0, /* bitpos */
670 complain_overflow_signed, /* complain_on_overflow */
671 _bfd_mips_elf_generic_reloc, /* special_function */
672 "R_MIPS_TLS_GD", /* name */
673 true, /* partial_inplace */
674 0x0000ffff, /* src_mask */
675 0x0000ffff, /* dst_mask */
676 false), /* pcrel_offset */
677
678 /* TLS local dynamic variable reference. */
679 HOWTO (R_MIPS_TLS_LDM, /* type */
680 0, /* rightshift */
681 4, /* size */
682 16, /* bitsize */
683 false, /* pc_relative */
684 0, /* bitpos */
685 complain_overflow_signed, /* complain_on_overflow */
686 _bfd_mips_elf_generic_reloc, /* special_function */
687 "R_MIPS_TLS_LDM", /* name */
688 true, /* partial_inplace */
689 0x0000ffff, /* src_mask */
690 0x0000ffff, /* dst_mask */
691 false), /* pcrel_offset */
692
693 /* TLS local dynamic offset. */
694 HOWTO (R_MIPS_TLS_DTPREL_HI16, /* type */
695 0, /* rightshift */
696 4, /* size */
697 16, /* bitsize */
698 false, /* pc_relative */
699 0, /* bitpos */
700 complain_overflow_signed, /* complain_on_overflow */
701 _bfd_mips_elf_generic_reloc, /* special_function */
702 "R_MIPS_TLS_DTPREL_HI16", /* name */
703 true, /* partial_inplace */
704 0x0000ffff, /* src_mask */
705 0x0000ffff, /* dst_mask */
706 false), /* pcrel_offset */
707
708 /* TLS local dynamic offset. */
709 HOWTO (R_MIPS_TLS_DTPREL_LO16, /* type */
710 0, /* rightshift */
711 4, /* size */
712 16, /* bitsize */
713 false, /* pc_relative */
714 0, /* bitpos */
715 complain_overflow_signed, /* complain_on_overflow */
716 _bfd_mips_elf_generic_reloc, /* special_function */
717 "R_MIPS_TLS_DTPREL_LO16", /* name */
718 true, /* partial_inplace */
719 0x0000ffff, /* src_mask */
720 0x0000ffff, /* dst_mask */
721 false), /* pcrel_offset */
722
723 /* TLS thread pointer offset. */
724 HOWTO (R_MIPS_TLS_GOTTPREL, /* type */
725 0, /* rightshift */
726 4, /* size */
727 16, /* bitsize */
728 false, /* pc_relative */
729 0, /* bitpos */
730 complain_overflow_signed, /* complain_on_overflow */
731 _bfd_mips_elf_generic_reloc, /* special_function */
732 "R_MIPS_TLS_GOTTPREL", /* name */
733 true, /* partial_inplace */
734 0x0000ffff, /* src_mask */
735 0x0000ffff, /* dst_mask */
736 false), /* pcrel_offset */
737
738 /* TLS IE dynamic relocations. */
739 EMPTY_HOWTO (R_MIPS_TLS_TPREL32),
740
741 HOWTO (R_MIPS_TLS_TPREL64, /* type */
742 0, /* rightshift */
743 8, /* size */
744 64, /* bitsize */
745 false, /* pc_relative */
746 0, /* bitpos */
747 complain_overflow_dont, /* complain_on_overflow */
748 _bfd_mips_elf_generic_reloc, /* special_function */
749 "R_MIPS_TLS_TPREL64", /* name */
750 true, /* partial_inplace */
751 MINUS_ONE, /* src_mask */
752 MINUS_ONE, /* dst_mask */
753 false), /* pcrel_offset */
754
755 /* TLS thread pointer offset. */
756 HOWTO (R_MIPS_TLS_TPREL_HI16, /* type */
757 0, /* rightshift */
758 4, /* size */
759 16, /* bitsize */
760 false, /* pc_relative */
761 0, /* bitpos */
762 complain_overflow_signed, /* complain_on_overflow */
763 _bfd_mips_elf_generic_reloc, /* special_function */
764 "R_MIPS_TLS_TPREL_HI16", /* name */
765 true, /* partial_inplace */
766 0x0000ffff, /* src_mask */
767 0x0000ffff, /* dst_mask */
768 false), /* pcrel_offset */
769
770 /* TLS thread pointer offset. */
771 HOWTO (R_MIPS_TLS_TPREL_LO16, /* type */
772 0, /* rightshift */
773 4, /* size */
774 16, /* bitsize */
775 false, /* pc_relative */
776 0, /* bitpos */
777 complain_overflow_signed, /* complain_on_overflow */
778 _bfd_mips_elf_generic_reloc, /* special_function */
779 "R_MIPS_TLS_TPREL_LO16", /* name */
780 true, /* partial_inplace */
781 0x0000ffff, /* src_mask */
782 0x0000ffff, /* dst_mask */
783 false), /* pcrel_offset */
784
785 /* 32 bit relocation with no addend. */
786 HOWTO (R_MIPS_GLOB_DAT, /* type */
787 0, /* rightshift */
788 4, /* size */
789 32, /* bitsize */
790 false, /* pc_relative */
791 0, /* bitpos */
792 complain_overflow_dont, /* complain_on_overflow */
793 _bfd_mips_elf_generic_reloc, /* special_function */
794 "R_MIPS_GLOB_DAT", /* name */
795 false, /* partial_inplace */
796 0x0, /* src_mask */
797 0xffffffff, /* dst_mask */
798 false), /* pcrel_offset */
799
800 EMPTY_HOWTO (52),
801 EMPTY_HOWTO (53),
802 EMPTY_HOWTO (54),
803 EMPTY_HOWTO (55),
804 EMPTY_HOWTO (56),
805 EMPTY_HOWTO (57),
806 EMPTY_HOWTO (58),
807 EMPTY_HOWTO (59),
808
809 HOWTO (R_MIPS_PC21_S2, /* type */
810 2, /* rightshift */
811 4, /* size */
812 21, /* bitsize */
813 true, /* pc_relative */
814 0, /* bitpos */
815 complain_overflow_signed, /* complain_on_overflow */
816 _bfd_mips_elf_generic_reloc, /* special_function */
817 "R_MIPS_PC21_S2", /* name */
818 true, /* partial_inplace */
819 0x001fffff, /* src_mask */
820 0x001fffff, /* dst_mask */
821 true), /* pcrel_offset */
822
823 HOWTO (R_MIPS_PC26_S2, /* type */
824 2, /* rightshift */
825 4, /* size */
826 26, /* bitsize */
827 true, /* pc_relative */
828 0, /* bitpos */
829 complain_overflow_signed, /* complain_on_overflow */
830 _bfd_mips_elf_generic_reloc, /* special_function */
831 "R_MIPS_PC26_S2", /* name */
832 true, /* partial_inplace */
833 0x03ffffff, /* src_mask */
834 0x03ffffff, /* dst_mask */
835 true), /* pcrel_offset */
836
837 HOWTO (R_MIPS_PC18_S3, /* type */
838 3, /* rightshift */
839 4, /* size */
840 18, /* bitsize */
841 true, /* pc_relative */
842 0, /* bitpos */
843 complain_overflow_signed, /* complain_on_overflow */
844 _bfd_mips_elf_generic_reloc, /* special_function */
845 "R_MIPS_PC18_S3", /* name */
846 true, /* partial_inplace */
847 0x0003ffff, /* src_mask */
848 0x0003ffff, /* dst_mask */
849 true), /* pcrel_offset */
850
851 HOWTO (R_MIPS_PC19_S2, /* type */
852 2, /* rightshift */
853 4, /* size */
854 19, /* bitsize */
855 true, /* pc_relative */
856 0, /* bitpos */
857 complain_overflow_signed, /* complain_on_overflow */
858 _bfd_mips_elf_generic_reloc, /* special_function */
859 "R_MIPS_PC19_S2", /* name */
860 true, /* partial_inplace */
861 0x0007ffff, /* src_mask */
862 0x0007ffff, /* dst_mask */
863 true), /* pcrel_offset */
864
865 HOWTO (R_MIPS_PCHI16, /* type */
866 16, /* rightshift */
867 4, /* size */
868 16, /* bitsize */
869 true, /* pc_relative */
870 0, /* bitpos */
871 complain_overflow_signed, /* complain_on_overflow */
872 _bfd_mips_elf_generic_reloc, /* special_function */
873 "R_MIPS_PCHI16", /* name */
874 true, /* partial_inplace */
875 0x0000ffff, /* src_mask */
876 0x0000ffff, /* dst_mask */
877 true), /* pcrel_offset */
878
879 HOWTO (R_MIPS_PCLO16, /* type */
880 0, /* rightshift */
881 4, /* size */
882 16, /* bitsize */
883 true, /* pc_relative */
884 0, /* bitpos */
885 complain_overflow_dont, /* complain_on_overflow */
886 _bfd_mips_elf_generic_reloc, /* special_function */
887 "R_MIPS_PCLO16", /* name */
888 true, /* partial_inplace */
889 0x0000ffff, /* src_mask */
890 0x0000ffff, /* dst_mask */
891 true), /* pcrel_offset */
892
893 };
894
895 /* The relocation table used for SHT_RELA sections. */
896
897 static reloc_howto_type mips_elf64_howto_table_rela[] =
898 {
899 /* No relocation. */
900 HOWTO (R_MIPS_NONE, /* type */
901 0, /* rightshift */
902 0, /* size */
903 0, /* bitsize */
904 false, /* pc_relative */
905 0, /* bitpos */
906 complain_overflow_dont, /* complain_on_overflow */
907 _bfd_mips_elf_generic_reloc, /* special_function */
908 "R_MIPS_NONE", /* name */
909 false, /* partial_inplace */
910 0, /* src_mask */
911 0, /* dst_mask */
912 false), /* pcrel_offset */
913
914 /* 16 bit relocation. */
915 HOWTO (R_MIPS_16, /* type */
916 0, /* rightshift */
917 4, /* size */
918 16, /* bitsize */
919 false, /* pc_relative */
920 0, /* bitpos */
921 complain_overflow_signed, /* complain_on_overflow */
922 _bfd_mips_elf_generic_reloc, /* special_function */
923 "R_MIPS_16", /* name */
924 false, /* partial_inplace */
925 0, /* src_mask */
926 0x0000ffff, /* dst_mask */
927 false), /* pcrel_offset */
928
929 /* 32 bit relocation. */
930 HOWTO (R_MIPS_32, /* type */
931 0, /* rightshift */
932 4, /* size */
933 32, /* bitsize */
934 false, /* pc_relative */
935 0, /* bitpos */
936 complain_overflow_dont, /* complain_on_overflow */
937 _bfd_mips_elf_generic_reloc, /* special_function */
938 "R_MIPS_32", /* name */
939 false, /* partial_inplace */
940 0, /* src_mask */
941 0xffffffff, /* dst_mask */
942 false), /* pcrel_offset */
943
944 /* 32 bit symbol relative relocation. */
945 HOWTO (R_MIPS_REL32, /* type */
946 0, /* rightshift */
947 4, /* size */
948 32, /* bitsize */
949 false, /* pc_relative */
950 0, /* bitpos */
951 complain_overflow_dont, /* complain_on_overflow */
952 _bfd_mips_elf_generic_reloc, /* special_function */
953 "R_MIPS_REL32", /* name */
954 false, /* partial_inplace */
955 0, /* src_mask */
956 0xffffffff, /* dst_mask */
957 false), /* pcrel_offset */
958
959 /* 26 bit jump address. */
960 HOWTO (R_MIPS_26, /* type */
961 2, /* rightshift */
962 4, /* size */
963 26, /* bitsize */
964 false, /* pc_relative */
965 0, /* bitpos */
966 complain_overflow_dont, /* complain_on_overflow */
967 /* This needs complex overflow
968 detection, because the upper 36
969 bits must match the PC + 4. */
970 _bfd_mips_elf_generic_reloc, /* special_function */
971 "R_MIPS_26", /* name */
972 false, /* partial_inplace */
973 0, /* src_mask */
974 0x03ffffff, /* dst_mask */
975 false), /* pcrel_offset */
976
977 /* High 16 bits of symbol value. */
978 HOWTO (R_MIPS_HI16, /* type */
979 0, /* rightshift */
980 4, /* size */
981 16, /* bitsize */
982 false, /* pc_relative */
983 0, /* bitpos */
984 complain_overflow_dont, /* complain_on_overflow */
985 _bfd_mips_elf_generic_reloc, /* special_function */
986 "R_MIPS_HI16", /* name */
987 false, /* partial_inplace */
988 0, /* src_mask */
989 0x0000ffff, /* dst_mask */
990 false), /* pcrel_offset */
991
992 /* Low 16 bits of symbol value. */
993 HOWTO (R_MIPS_LO16, /* type */
994 0, /* rightshift */
995 4, /* size */
996 16, /* bitsize */
997 false, /* pc_relative */
998 0, /* bitpos */
999 complain_overflow_dont, /* complain_on_overflow */
1000 _bfd_mips_elf_generic_reloc, /* special_function */
1001 "R_MIPS_LO16", /* name */
1002 false, /* partial_inplace */
1003 0, /* src_mask */
1004 0x0000ffff, /* dst_mask */
1005 false), /* pcrel_offset */
1006
1007 /* GP relative reference. */
1008 HOWTO (R_MIPS_GPREL16, /* type */
1009 0, /* rightshift */
1010 4, /* size */
1011 16, /* bitsize */
1012 false, /* pc_relative */
1013 0, /* bitpos */
1014 complain_overflow_signed, /* complain_on_overflow */
1015 mips_elf64_gprel16_reloc, /* special_function */
1016 "R_MIPS_GPREL16", /* name */
1017 false, /* partial_inplace */
1018 0, /* src_mask */
1019 0x0000ffff, /* dst_mask */
1020 false), /* pcrel_offset */
1021
1022 /* Reference to literal section. */
1023 HOWTO (R_MIPS_LITERAL, /* type */
1024 0, /* rightshift */
1025 4, /* size */
1026 16, /* bitsize */
1027 false, /* pc_relative */
1028 0, /* bitpos */
1029 complain_overflow_signed, /* complain_on_overflow */
1030 mips_elf64_literal_reloc, /* special_function */
1031 "R_MIPS_LITERAL", /* name */
1032 false, /* partial_inplace */
1033 0, /* src_mask */
1034 0x0000ffff, /* dst_mask */
1035 false), /* pcrel_offset */
1036
1037 /* Reference to global offset table. */
1038 HOWTO (R_MIPS_GOT16, /* type */
1039 0, /* rightshift */
1040 4, /* size */
1041 16, /* bitsize */
1042 false, /* pc_relative */
1043 0, /* bitpos */
1044 complain_overflow_signed, /* complain_on_overflow */
1045 _bfd_mips_elf_generic_reloc, /* special_function */
1046 "R_MIPS_GOT16", /* name */
1047 false, /* partial_inplace */
1048 0, /* src_mask */
1049 0x0000ffff, /* dst_mask */
1050 false), /* pcrel_offset */
1051
1052 /* 16 bit PC relative reference. Note that the ABI document has a typo
1053 and claims R_MIPS_PC16 to be not rightshifted, rendering it useless.
1054 We do the right thing here. */
1055 HOWTO (R_MIPS_PC16, /* type */
1056 2, /* rightshift */
1057 4, /* size */
1058 16, /* bitsize */
1059 true, /* pc_relative */
1060 0, /* bitpos */
1061 complain_overflow_signed, /* complain_on_overflow */
1062 _bfd_mips_elf_generic_reloc, /* special_function */
1063 "R_MIPS_PC16", /* name */
1064 false, /* partial_inplace */
1065 0, /* src_mask */
1066 0x0000ffff, /* dst_mask */
1067 true), /* pcrel_offset */
1068
1069 /* 16 bit call through global offset table. */
1070 HOWTO (R_MIPS_CALL16, /* type */
1071 0, /* rightshift */
1072 4, /* size */
1073 16, /* bitsize */
1074 false, /* pc_relative */
1075 0, /* bitpos */
1076 complain_overflow_signed, /* complain_on_overflow */
1077 _bfd_mips_elf_generic_reloc, /* special_function */
1078 "R_MIPS_CALL16", /* name */
1079 false, /* partial_inplace */
1080 0, /* src_mask */
1081 0x0000ffff, /* dst_mask */
1082 false), /* pcrel_offset */
1083
1084 /* 32 bit GP relative reference. */
1085 HOWTO (R_MIPS_GPREL32, /* type */
1086 0, /* rightshift */
1087 4, /* size */
1088 32, /* bitsize */
1089 false, /* pc_relative */
1090 0, /* bitpos */
1091 complain_overflow_dont, /* complain_on_overflow */
1092 mips_elf64_gprel32_reloc, /* special_function */
1093 "R_MIPS_GPREL32", /* name */
1094 false, /* partial_inplace */
1095 0, /* src_mask */
1096 0xffffffff, /* dst_mask */
1097 false), /* pcrel_offset */
1098
1099 EMPTY_HOWTO (13),
1100 EMPTY_HOWTO (14),
1101 EMPTY_HOWTO (15),
1102
1103 /* A 5 bit shift field. */
1104 HOWTO (R_MIPS_SHIFT5, /* type */
1105 0, /* rightshift */
1106 4, /* size */
1107 5, /* bitsize */
1108 false, /* pc_relative */
1109 6, /* bitpos */
1110 complain_overflow_bitfield, /* complain_on_overflow */
1111 _bfd_mips_elf_generic_reloc, /* special_function */
1112 "R_MIPS_SHIFT5", /* name */
1113 false, /* partial_inplace */
1114 0, /* src_mask */
1115 0x000007c0, /* dst_mask */
1116 false), /* pcrel_offset */
1117
1118 /* A 6 bit shift field. */
1119 HOWTO (R_MIPS_SHIFT6, /* type */
1120 0, /* rightshift */
1121 4, /* size */
1122 6, /* bitsize */
1123 false, /* pc_relative */
1124 6, /* bitpos */
1125 complain_overflow_bitfield, /* complain_on_overflow */
1126 mips_elf64_shift6_reloc, /* special_function */
1127 "R_MIPS_SHIFT6", /* name */
1128 false, /* partial_inplace */
1129 0, /* src_mask */
1130 0x000007c4, /* dst_mask */
1131 false), /* pcrel_offset */
1132
1133 /* 64 bit relocation. */
1134 HOWTO (R_MIPS_64, /* type */
1135 0, /* rightshift */
1136 8, /* size */
1137 64, /* bitsize */
1138 false, /* pc_relative */
1139 0, /* bitpos */
1140 complain_overflow_dont, /* complain_on_overflow */
1141 _bfd_mips_elf_generic_reloc, /* special_function */
1142 "R_MIPS_64", /* name */
1143 false, /* partial_inplace */
1144 0, /* src_mask */
1145 MINUS_ONE, /* dst_mask */
1146 false), /* pcrel_offset */
1147
1148 /* Displacement in the global offset table. */
1149 HOWTO (R_MIPS_GOT_DISP, /* type */
1150 0, /* rightshift */
1151 4, /* size */
1152 16, /* bitsize */
1153 false, /* pc_relative */
1154 0, /* bitpos */
1155 complain_overflow_signed, /* complain_on_overflow */
1156 _bfd_mips_elf_generic_reloc, /* special_function */
1157 "R_MIPS_GOT_DISP", /* name */
1158 false, /* partial_inplace */
1159 0, /* src_mask */
1160 0x0000ffff, /* dst_mask */
1161 false), /* pcrel_offset */
1162
1163 /* Displacement to page pointer in the global offset table. */
1164 HOWTO (R_MIPS_GOT_PAGE, /* type */
1165 0, /* rightshift */
1166 4, /* size */
1167 16, /* bitsize */
1168 false, /* pc_relative */
1169 0, /* bitpos */
1170 complain_overflow_signed, /* complain_on_overflow */
1171 _bfd_mips_elf_generic_reloc, /* special_function */
1172 "R_MIPS_GOT_PAGE", /* name */
1173 false, /* partial_inplace */
1174 0, /* src_mask */
1175 0x0000ffff, /* dst_mask */
1176 false), /* pcrel_offset */
1177
1178 /* Offset from page pointer in the global offset table. */
1179 HOWTO (R_MIPS_GOT_OFST, /* type */
1180 0, /* rightshift */
1181 4, /* size */
1182 16, /* bitsize */
1183 false, /* pc_relative */
1184 0, /* bitpos */
1185 complain_overflow_signed, /* complain_on_overflow */
1186 _bfd_mips_elf_generic_reloc, /* special_function */
1187 "R_MIPS_GOT_OFST", /* name */
1188 false, /* partial_inplace */
1189 0, /* src_mask */
1190 0x0000ffff, /* dst_mask */
1191 false), /* pcrel_offset */
1192
1193 /* High 16 bits of displacement in global offset table. */
1194 HOWTO (R_MIPS_GOT_HI16, /* type */
1195 0, /* rightshift */
1196 4, /* size */
1197 16, /* bitsize */
1198 false, /* pc_relative */
1199 0, /* bitpos */
1200 complain_overflow_dont, /* complain_on_overflow */
1201 _bfd_mips_elf_generic_reloc, /* special_function */
1202 "R_MIPS_GOT_HI16", /* name */
1203 false, /* partial_inplace */
1204 0, /* src_mask */
1205 0x0000ffff, /* dst_mask */
1206 false), /* pcrel_offset */
1207
1208 /* Low 16 bits of displacement in global offset table. */
1209 HOWTO (R_MIPS_GOT_LO16, /* type */
1210 0, /* rightshift */
1211 4, /* size */
1212 16, /* bitsize */
1213 false, /* pc_relative */
1214 0, /* bitpos */
1215 complain_overflow_dont, /* complain_on_overflow */
1216 _bfd_mips_elf_generic_reloc, /* special_function */
1217 "R_MIPS_GOT_LO16", /* name */
1218 false, /* partial_inplace */
1219 0, /* src_mask */
1220 0x0000ffff, /* dst_mask */
1221 false), /* pcrel_offset */
1222
1223 /* 64 bit subtraction. */
1224 HOWTO (R_MIPS_SUB, /* type */
1225 0, /* rightshift */
1226 8, /* size */
1227 64, /* bitsize */
1228 false, /* pc_relative */
1229 0, /* bitpos */
1230 complain_overflow_dont, /* complain_on_overflow */
1231 _bfd_mips_elf_generic_reloc, /* special_function */
1232 "R_MIPS_SUB", /* name */
1233 false, /* partial_inplace */
1234 0, /* src_mask */
1235 MINUS_ONE, /* dst_mask */
1236 false), /* pcrel_offset */
1237
1238 /* Insert the addend as an instruction. */
1239 /* FIXME: Not handled correctly. */
1240 HOWTO (R_MIPS_INSERT_A, /* type */
1241 0, /* rightshift */
1242 4, /* size */
1243 32, /* bitsize */
1244 false, /* pc_relative */
1245 0, /* bitpos */
1246 complain_overflow_dont, /* complain_on_overflow */
1247 _bfd_mips_elf_generic_reloc, /* special_function */
1248 "R_MIPS_INSERT_A", /* name */
1249 false, /* partial_inplace */
1250 0, /* src_mask */
1251 0xffffffff, /* dst_mask */
1252 false), /* pcrel_offset */
1253
1254 /* Insert the addend as an instruction, and change all relocations
1255 to refer to the old instruction at the address. */
1256 /* FIXME: Not handled correctly. */
1257 HOWTO (R_MIPS_INSERT_B, /* type */
1258 0, /* rightshift */
1259 4, /* size */
1260 32, /* bitsize */
1261 false, /* pc_relative */
1262 0, /* bitpos */
1263 complain_overflow_dont, /* complain_on_overflow */
1264 _bfd_mips_elf_generic_reloc, /* special_function */
1265 "R_MIPS_INSERT_B", /* name */
1266 false, /* partial_inplace */
1267 0, /* src_mask */
1268 0xffffffff, /* dst_mask */
1269 false), /* pcrel_offset */
1270
1271 /* Delete a 32 bit instruction. */
1272 /* FIXME: Not handled correctly. */
1273 HOWTO (R_MIPS_DELETE, /* type */
1274 0, /* rightshift */
1275 4, /* size */
1276 32, /* bitsize */
1277 false, /* pc_relative */
1278 0, /* bitpos */
1279 complain_overflow_dont, /* complain_on_overflow */
1280 _bfd_mips_elf_generic_reloc, /* special_function */
1281 "R_MIPS_DELETE", /* name */
1282 false, /* partial_inplace */
1283 0, /* src_mask */
1284 0xffffffff, /* dst_mask */
1285 false), /* pcrel_offset */
1286
1287 /* Get the higher value of a 64 bit addend. */
1288 HOWTO (R_MIPS_HIGHER, /* type */
1289 0, /* rightshift */
1290 4, /* size */
1291 16, /* bitsize */
1292 false, /* pc_relative */
1293 0, /* bitpos */
1294 complain_overflow_dont, /* complain_on_overflow */
1295 _bfd_mips_elf_generic_reloc, /* special_function */
1296 "R_MIPS_HIGHER", /* name */
1297 false, /* partial_inplace */
1298 0, /* src_mask */
1299 0x0000ffff, /* dst_mask */
1300 false), /* pcrel_offset */
1301
1302 /* Get the highest value of a 64 bit addend. */
1303 HOWTO (R_MIPS_HIGHEST, /* type */
1304 0, /* rightshift */
1305 4, /* size */
1306 16, /* bitsize */
1307 false, /* pc_relative */
1308 0, /* bitpos */
1309 complain_overflow_dont, /* complain_on_overflow */
1310 _bfd_mips_elf_generic_reloc, /* special_function */
1311 "R_MIPS_HIGHEST", /* name */
1312 false, /* partial_inplace */
1313 0, /* src_mask */
1314 0x0000ffff, /* dst_mask */
1315 false), /* pcrel_offset */
1316
1317 /* High 16 bits of displacement in global offset table. */
1318 HOWTO (R_MIPS_CALL_HI16, /* type */
1319 0, /* rightshift */
1320 4, /* size */
1321 16, /* bitsize */
1322 false, /* pc_relative */
1323 0, /* bitpos */
1324 complain_overflow_dont, /* complain_on_overflow */
1325 _bfd_mips_elf_generic_reloc, /* special_function */
1326 "R_MIPS_CALL_HI16", /* name */
1327 false, /* partial_inplace */
1328 0, /* src_mask */
1329 0x0000ffff, /* dst_mask */
1330 false), /* pcrel_offset */
1331
1332 /* Low 16 bits of displacement in global offset table. */
1333 HOWTO (R_MIPS_CALL_LO16, /* type */
1334 0, /* rightshift */
1335 4, /* size */
1336 16, /* bitsize */
1337 false, /* pc_relative */
1338 0, /* bitpos */
1339 complain_overflow_dont, /* complain_on_overflow */
1340 _bfd_mips_elf_generic_reloc, /* special_function */
1341 "R_MIPS_CALL_LO16", /* name */
1342 false, /* partial_inplace */
1343 0, /* src_mask */
1344 0x0000ffff, /* dst_mask */
1345 false), /* pcrel_offset */
1346
1347 /* Section displacement, used by an associated event location section. */
1348 HOWTO (R_MIPS_SCN_DISP, /* type */
1349 0, /* rightshift */
1350 4, /* size */
1351 32, /* bitsize */
1352 false, /* pc_relative */
1353 0, /* bitpos */
1354 complain_overflow_dont, /* complain_on_overflow */
1355 _bfd_mips_elf_generic_reloc, /* special_function */
1356 "R_MIPS_SCN_DISP", /* name */
1357 false, /* partial_inplace */
1358 0, /* src_mask */
1359 0xffffffff, /* dst_mask */
1360 false), /* pcrel_offset */
1361
1362 HOWTO (R_MIPS_REL16, /* type */
1363 0, /* rightshift */
1364 2, /* size */
1365 16, /* bitsize */
1366 false, /* pc_relative */
1367 0, /* bitpos */
1368 complain_overflow_signed, /* complain_on_overflow */
1369 _bfd_mips_elf_generic_reloc, /* special_function */
1370 "R_MIPS_REL16", /* name */
1371 false, /* partial_inplace */
1372 0, /* src_mask */
1373 0xffff, /* dst_mask */
1374 false), /* pcrel_offset */
1375
1376 /* These two are obsolete. */
1377 EMPTY_HOWTO (R_MIPS_ADD_IMMEDIATE),
1378 EMPTY_HOWTO (R_MIPS_PJUMP),
1379
1380 /* Similiar to R_MIPS_REL32, but used for relocations in a GOT section.
1381 It must be used for multigot GOT's (and only there). */
1382 HOWTO (R_MIPS_RELGOT, /* type */
1383 0, /* rightshift */
1384 4, /* size */
1385 32, /* bitsize */
1386 false, /* pc_relative */
1387 0, /* bitpos */
1388 complain_overflow_dont, /* complain_on_overflow */
1389 _bfd_mips_elf_generic_reloc, /* special_function */
1390 "R_MIPS_RELGOT", /* name */
1391 false, /* partial_inplace */
1392 0, /* src_mask */
1393 0xffffffff, /* dst_mask */
1394 false), /* pcrel_offset */
1395
1396 /* Protected jump conversion. This is an optimization hint. No
1397 relocation is required for correctness. */
1398 HOWTO (R_MIPS_JALR, /* type */
1399 0, /* rightshift */
1400 4, /* size */
1401 32, /* bitsize */
1402 false, /* pc_relative */
1403 0, /* bitpos */
1404 complain_overflow_dont, /* complain_on_overflow */
1405 _bfd_mips_elf_generic_reloc, /* special_function */
1406 "R_MIPS_JALR", /* name */
1407 false, /* partial_inplace */
1408 0, /* src_mask */
1409 0x00000000, /* dst_mask */
1410 false), /* pcrel_offset */
1411
1412 /* TLS relocations. */
1413 EMPTY_HOWTO (R_MIPS_TLS_DTPMOD32),
1414 EMPTY_HOWTO (R_MIPS_TLS_DTPREL32),
1415
1416 HOWTO (R_MIPS_TLS_DTPMOD64, /* type */
1417 0, /* rightshift */
1418 8, /* size */
1419 64, /* bitsize */
1420 false, /* pc_relative */
1421 0, /* bitpos */
1422 complain_overflow_dont, /* complain_on_overflow */
1423 _bfd_mips_elf_generic_reloc, /* special_function */
1424 "R_MIPS_TLS_DTPMOD64", /* name */
1425 false, /* partial_inplace */
1426 0, /* src_mask */
1427 MINUS_ONE, /* dst_mask */
1428 false), /* pcrel_offset */
1429
1430 HOWTO (R_MIPS_TLS_DTPREL64, /* type */
1431 0, /* rightshift */
1432 8, /* size */
1433 64, /* bitsize */
1434 false, /* pc_relative */
1435 0, /* bitpos */
1436 complain_overflow_dont, /* complain_on_overflow */
1437 _bfd_mips_elf_generic_reloc, /* special_function */
1438 "R_MIPS_TLS_DTPREL64", /* name */
1439 false, /* partial_inplace */
1440 0, /* src_mask */
1441 MINUS_ONE, /* dst_mask */
1442 false), /* pcrel_offset */
1443
1444 /* TLS general dynamic variable reference. */
1445 HOWTO (R_MIPS_TLS_GD, /* type */
1446 0, /* rightshift */
1447 4, /* size */
1448 16, /* bitsize */
1449 false, /* pc_relative */
1450 0, /* bitpos */
1451 complain_overflow_signed, /* complain_on_overflow */
1452 _bfd_mips_elf_generic_reloc, /* special_function */
1453 "R_MIPS_TLS_GD", /* name */
1454 false, /* partial_inplace */
1455 0, /* src_mask */
1456 0x0000ffff, /* dst_mask */
1457 false), /* pcrel_offset */
1458
1459 /* TLS local dynamic variable reference. */
1460 HOWTO (R_MIPS_TLS_LDM, /* type */
1461 0, /* rightshift */
1462 4, /* size */
1463 16, /* bitsize */
1464 false, /* pc_relative */
1465 0, /* bitpos */
1466 complain_overflow_signed, /* complain_on_overflow */
1467 _bfd_mips_elf_generic_reloc, /* special_function */
1468 "R_MIPS_TLS_LDM", /* name */
1469 false, /* partial_inplace */
1470 0, /* src_mask */
1471 0x0000ffff, /* dst_mask */
1472 false), /* pcrel_offset */
1473
1474 /* TLS local dynamic offset. */
1475 HOWTO (R_MIPS_TLS_DTPREL_HI16, /* type */
1476 0, /* rightshift */
1477 4, /* size */
1478 16, /* bitsize */
1479 false, /* pc_relative */
1480 0, /* bitpos */
1481 complain_overflow_signed, /* complain_on_overflow */
1482 _bfd_mips_elf_generic_reloc, /* special_function */
1483 "R_MIPS_TLS_DTPREL_HI16", /* name */
1484 false, /* partial_inplace */
1485 0, /* src_mask */
1486 0x0000ffff, /* dst_mask */
1487 false), /* pcrel_offset */
1488
1489 /* TLS local dynamic offset. */
1490 HOWTO (R_MIPS_TLS_DTPREL_LO16, /* type */
1491 0, /* rightshift */
1492 4, /* size */
1493 16, /* bitsize */
1494 false, /* pc_relative */
1495 0, /* bitpos */
1496 complain_overflow_signed, /* complain_on_overflow */
1497 _bfd_mips_elf_generic_reloc, /* special_function */
1498 "R_MIPS_TLS_DTPREL_LO16", /* name */
1499 false, /* partial_inplace */
1500 0, /* src_mask */
1501 0x0000ffff, /* dst_mask */
1502 false), /* pcrel_offset */
1503
1504 /* TLS thread pointer offset. */
1505 HOWTO (R_MIPS_TLS_GOTTPREL, /* type */
1506 0, /* rightshift */
1507 4, /* size */
1508 16, /* bitsize */
1509 false, /* pc_relative */
1510 0, /* bitpos */
1511 complain_overflow_signed, /* complain_on_overflow */
1512 _bfd_mips_elf_generic_reloc, /* special_function */
1513 "R_MIPS_TLS_GOTTPREL", /* name */
1514 false, /* partial_inplace */
1515 0, /* src_mask */
1516 0x0000ffff, /* dst_mask */
1517 false), /* pcrel_offset */
1518
1519 /* TLS IE dynamic relocations. */
1520 EMPTY_HOWTO (R_MIPS_TLS_TPREL32),
1521
1522 HOWTO (R_MIPS_TLS_TPREL64, /* type */
1523 0, /* rightshift */
1524 8, /* size */
1525 64, /* bitsize */
1526 false, /* pc_relative */
1527 0, /* bitpos */
1528 complain_overflow_dont, /* complain_on_overflow */
1529 _bfd_mips_elf_generic_reloc, /* special_function */
1530 "R_MIPS_TLS_TPREL64", /* name */
1531 false, /* partial_inplace */
1532 0, /* src_mask */
1533 MINUS_ONE, /* dst_mask */
1534 false), /* pcrel_offset */
1535
1536 /* TLS thread pointer offset. */
1537 HOWTO (R_MIPS_TLS_TPREL_HI16, /* type */
1538 0, /* rightshift */
1539 4, /* size */
1540 16, /* bitsize */
1541 false, /* pc_relative */
1542 0, /* bitpos */
1543 complain_overflow_signed, /* complain_on_overflow */
1544 _bfd_mips_elf_generic_reloc, /* special_function */
1545 "R_MIPS_TLS_TPREL_HI16", /* name */
1546 false, /* partial_inplace */
1547 0, /* src_mask */
1548 0x0000ffff, /* dst_mask */
1549 false), /* pcrel_offset */
1550
1551 /* TLS thread pointer offset. */
1552 HOWTO (R_MIPS_TLS_TPREL_LO16, /* type */
1553 0, /* rightshift */
1554 4, /* size */
1555 16, /* bitsize */
1556 false, /* pc_relative */
1557 0, /* bitpos */
1558 complain_overflow_signed, /* complain_on_overflow */
1559 _bfd_mips_elf_generic_reloc, /* special_function */
1560 "R_MIPS_TLS_TPREL_LO16", /* name */
1561 false, /* partial_inplace */
1562 0, /* src_mask */
1563 0x0000ffff, /* dst_mask */
1564 false), /* pcrel_offset */
1565
1566 /* 32 bit relocation with no addend. */
1567 HOWTO (R_MIPS_GLOB_DAT, /* type */
1568 0, /* rightshift */
1569 4, /* size */
1570 32, /* bitsize */
1571 false, /* pc_relative */
1572 0, /* bitpos */
1573 complain_overflow_dont, /* complain_on_overflow */
1574 _bfd_mips_elf_generic_reloc, /* special_function */
1575 "R_MIPS_GLOB_DAT", /* name */
1576 false, /* partial_inplace */
1577 0x0, /* src_mask */
1578 0xffffffff, /* dst_mask */
1579 false), /* pcrel_offset */
1580
1581 EMPTY_HOWTO (52),
1582 EMPTY_HOWTO (53),
1583 EMPTY_HOWTO (54),
1584 EMPTY_HOWTO (55),
1585 EMPTY_HOWTO (56),
1586 EMPTY_HOWTO (57),
1587 EMPTY_HOWTO (58),
1588 EMPTY_HOWTO (59),
1589
1590 HOWTO (R_MIPS_PC21_S2, /* type */
1591 2, /* rightshift */
1592 4, /* size */
1593 21, /* bitsize */
1594 true, /* pc_relative */
1595 0, /* bitpos */
1596 complain_overflow_signed, /* complain_on_overflow */
1597 _bfd_mips_elf_generic_reloc, /* special_function */
1598 "R_MIPS_PC21_S2", /* name */
1599 false, /* partial_inplace */
1600 0, /* src_mask */
1601 0x001fffff, /* dst_mask */
1602 true), /* pcrel_offset */
1603
1604 HOWTO (R_MIPS_PC26_S2, /* type */
1605 2, /* rightshift */
1606 4, /* size */
1607 26, /* bitsize */
1608 true, /* pc_relative */
1609 0, /* bitpos */
1610 complain_overflow_signed, /* complain_on_overflow */
1611 _bfd_mips_elf_generic_reloc, /* special_function */
1612 "R_MIPS_PC26_S2", /* name */
1613 false, /* partial_inplace */
1614 0, /* src_mask */
1615 0x03ffffff, /* dst_mask */
1616 true), /* pcrel_offset */
1617
1618 HOWTO (R_MIPS_PC18_S3, /* type */
1619 3, /* rightshift */
1620 4, /* size */
1621 18, /* bitsize */
1622 true, /* pc_relative */
1623 0, /* bitpos */
1624 complain_overflow_signed, /* complain_on_overflow */
1625 _bfd_mips_elf_generic_reloc, /* special_function */
1626 "R_MIPS_PC18_S3", /* name */
1627 false, /* partial_inplace */
1628 0, /* src_mask */
1629 0x0003ffff, /* dst_mask */
1630 true), /* pcrel_offset */
1631
1632 HOWTO (R_MIPS_PC19_S2, /* type */
1633 2, /* rightshift */
1634 4, /* size */
1635 19, /* bitsize */
1636 true, /* pc_relative */
1637 0, /* bitpos */
1638 complain_overflow_signed, /* complain_on_overflow */
1639 _bfd_mips_elf_generic_reloc, /* special_function */
1640 "R_MIPS_PC19_S2", /* name */
1641 false, /* partial_inplace */
1642 0, /* src_mask */
1643 0x0007ffff, /* dst_mask */
1644 true), /* pcrel_offset */
1645
1646 HOWTO (R_MIPS_PCHI16, /* type */
1647 16, /* rightshift */
1648 4, /* size */
1649 16, /* bitsize */
1650 true, /* pc_relative */
1651 0, /* bitpos */
1652 complain_overflow_signed, /* complain_on_overflow */
1653 _bfd_mips_elf_generic_reloc, /* special_function */
1654 "R_MIPS_PCHI16", /* name */
1655 false, /* partial_inplace */
1656 0, /* src_mask */
1657 0x0000ffff, /* dst_mask */
1658 true), /* pcrel_offset */
1659
1660 HOWTO (R_MIPS_PCLO16, /* type */
1661 0, /* rightshift */
1662 4, /* size */
1663 16, /* bitsize */
1664 true, /* pc_relative */
1665 0, /* bitpos */
1666 complain_overflow_dont, /* complain_on_overflow */
1667 _bfd_mips_elf_generic_reloc, /* special_function */
1668 "R_MIPS_PCLO16", /* name */
1669 false, /* partial_inplace */
1670 0, /* src_mask */
1671 0x0000ffff, /* dst_mask */
1672 true), /* pcrel_offset */
1673
1674 };
1675
1676 static reloc_howto_type mips16_elf64_howto_table_rel[] =
1677 {
1678 /* The reloc used for the mips16 jump instruction. */
1679 HOWTO (R_MIPS16_26, /* type */
1680 2, /* rightshift */
1681 4, /* size */
1682 26, /* bitsize */
1683 false, /* pc_relative */
1684 0, /* bitpos */
1685 complain_overflow_dont, /* complain_on_overflow */
1686 /* This needs complex overflow
1687 detection, because the upper four
1688 bits must match the PC. */
1689 _bfd_mips_elf_generic_reloc, /* special_function */
1690 "R_MIPS16_26", /* name */
1691 true, /* partial_inplace */
1692 0x3ffffff, /* src_mask */
1693 0x3ffffff, /* dst_mask */
1694 false), /* pcrel_offset */
1695
1696 /* The reloc used for the mips16 gprel instruction. */
1697 HOWTO (R_MIPS16_GPREL, /* type */
1698 0, /* rightshift */
1699 4, /* size */
1700 16, /* bitsize */
1701 false, /* pc_relative */
1702 0, /* bitpos */
1703 complain_overflow_signed, /* complain_on_overflow */
1704 mips16_gprel_reloc, /* special_function */
1705 "R_MIPS16_GPREL", /* name */
1706 true, /* partial_inplace */
1707 0x0000ffff, /* src_mask */
1708 0x0000ffff, /* dst_mask */
1709 false), /* pcrel_offset */
1710
1711 /* A MIPS16 reference to the global offset table. */
1712 HOWTO (R_MIPS16_GOT16, /* type */
1713 0, /* rightshift */
1714 4, /* size */
1715 16, /* bitsize */
1716 false, /* pc_relative */
1717 0, /* bitpos */
1718 complain_overflow_dont, /* complain_on_overflow */
1719 _bfd_mips_elf_got16_reloc, /* special_function */
1720 "R_MIPS16_GOT16", /* name */
1721 true, /* partial_inplace */
1722 0x0000ffff, /* src_mask */
1723 0x0000ffff, /* dst_mask */
1724 false), /* pcrel_offset */
1725
1726 /* A MIPS16 call through the global offset table. */
1727 HOWTO (R_MIPS16_CALL16, /* type */
1728 0, /* rightshift */
1729 4, /* size */
1730 16, /* bitsize */
1731 false, /* pc_relative */
1732 0, /* bitpos */
1733 complain_overflow_dont, /* complain_on_overflow */
1734 _bfd_mips_elf_generic_reloc, /* special_function */
1735 "R_MIPS16_CALL16", /* name */
1736 true, /* partial_inplace */
1737 0x0000ffff, /* src_mask */
1738 0x0000ffff, /* dst_mask */
1739 false), /* pcrel_offset */
1740
1741 /* MIPS16 high 16 bits of symbol value. */
1742 HOWTO (R_MIPS16_HI16, /* type */
1743 16, /* rightshift */
1744 4, /* size */
1745 16, /* bitsize */
1746 false, /* pc_relative */
1747 0, /* bitpos */
1748 complain_overflow_dont, /* complain_on_overflow */
1749 _bfd_mips_elf_hi16_reloc, /* special_function */
1750 "R_MIPS16_HI16", /* name */
1751 true, /* partial_inplace */
1752 0x0000ffff, /* src_mask */
1753 0x0000ffff, /* dst_mask */
1754 false), /* pcrel_offset */
1755
1756 /* MIPS16 low 16 bits of symbol value. */
1757 HOWTO (R_MIPS16_LO16, /* type */
1758 0, /* rightshift */
1759 4, /* size */
1760 16, /* bitsize */
1761 false, /* pc_relative */
1762 0, /* bitpos */
1763 complain_overflow_dont, /* complain_on_overflow */
1764 _bfd_mips_elf_lo16_reloc, /* special_function */
1765 "R_MIPS16_LO16", /* name */
1766 true, /* partial_inplace */
1767 0x0000ffff, /* src_mask */
1768 0x0000ffff, /* dst_mask */
1769 false), /* pcrel_offset */
1770
1771 /* MIPS16 TLS general dynamic variable reference. */
1772 HOWTO (R_MIPS16_TLS_GD, /* type */
1773 0, /* rightshift */
1774 4, /* size */
1775 16, /* bitsize */
1776 false, /* pc_relative */
1777 0, /* bitpos */
1778 complain_overflow_signed, /* complain_on_overflow */
1779 _bfd_mips_elf_generic_reloc, /* special_function */
1780 "R_MIPS16_TLS_GD", /* name */
1781 true, /* partial_inplace */
1782 0x0000ffff, /* src_mask */
1783 0x0000ffff, /* dst_mask */
1784 false), /* pcrel_offset */
1785
1786 /* MIPS16 TLS local dynamic variable reference. */
1787 HOWTO (R_MIPS16_TLS_LDM, /* type */
1788 0, /* rightshift */
1789 4, /* size */
1790 16, /* bitsize */
1791 false, /* pc_relative */
1792 0, /* bitpos */
1793 complain_overflow_signed, /* complain_on_overflow */
1794 _bfd_mips_elf_generic_reloc, /* special_function */
1795 "R_MIPS16_TLS_LDM", /* name */
1796 true, /* partial_inplace */
1797 0x0000ffff, /* src_mask */
1798 0x0000ffff, /* dst_mask */
1799 false), /* pcrel_offset */
1800
1801 /* MIPS16 TLS local dynamic offset. */
1802 HOWTO (R_MIPS16_TLS_DTPREL_HI16, /* type */
1803 0, /* rightshift */
1804 4, /* size */
1805 16, /* bitsize */
1806 false, /* pc_relative */
1807 0, /* bitpos */
1808 complain_overflow_signed, /* complain_on_overflow */
1809 _bfd_mips_elf_generic_reloc, /* special_function */
1810 "R_MIPS16_TLS_DTPREL_HI16", /* name */
1811 true, /* partial_inplace */
1812 0x0000ffff, /* src_mask */
1813 0x0000ffff, /* dst_mask */
1814 false), /* pcrel_offset */
1815
1816 /* MIPS16 TLS local dynamic offset. */
1817 HOWTO (R_MIPS16_TLS_DTPREL_LO16, /* type */
1818 0, /* rightshift */
1819 4, /* size */
1820 16, /* bitsize */
1821 false, /* pc_relative */
1822 0, /* bitpos */
1823 complain_overflow_signed, /* complain_on_overflow */
1824 _bfd_mips_elf_generic_reloc, /* special_function */
1825 "R_MIPS16_TLS_DTPREL_LO16", /* name */
1826 true, /* partial_inplace */
1827 0x0000ffff, /* src_mask */
1828 0x0000ffff, /* dst_mask */
1829 false), /* pcrel_offset */
1830
1831 /* MIPS16 TLS thread pointer offset. */
1832 HOWTO (R_MIPS16_TLS_GOTTPREL, /* type */
1833 0, /* rightshift */
1834 4, /* size */
1835 16, /* bitsize */
1836 false, /* pc_relative */
1837 0, /* bitpos */
1838 complain_overflow_signed, /* complain_on_overflow */
1839 _bfd_mips_elf_generic_reloc, /* special_function */
1840 "R_MIPS16_TLS_GOTTPREL", /* name */
1841 true, /* partial_inplace */
1842 0x0000ffff, /* src_mask */
1843 0x0000ffff, /* dst_mask */
1844 false), /* pcrel_offset */
1845
1846 /* MIPS16 TLS thread pointer offset. */
1847 HOWTO (R_MIPS16_TLS_TPREL_HI16, /* type */
1848 0, /* rightshift */
1849 4, /* size */
1850 16, /* bitsize */
1851 false, /* pc_relative */
1852 0, /* bitpos */
1853 complain_overflow_signed, /* complain_on_overflow */
1854 _bfd_mips_elf_generic_reloc, /* special_function */
1855 "R_MIPS16_TLS_TPREL_HI16", /* name */
1856 true, /* partial_inplace */
1857 0x0000ffff, /* src_mask */
1858 0x0000ffff, /* dst_mask */
1859 false), /* pcrel_offset */
1860
1861 /* MIPS16 TLS thread pointer offset. */
1862 HOWTO (R_MIPS16_TLS_TPREL_LO16, /* type */
1863 0, /* rightshift */
1864 4, /* size */
1865 16, /* bitsize */
1866 false, /* pc_relative */
1867 0, /* bitpos */
1868 complain_overflow_signed, /* complain_on_overflow */
1869 _bfd_mips_elf_generic_reloc, /* special_function */
1870 "R_MIPS16_TLS_TPREL_LO16", /* name */
1871 true, /* partial_inplace */
1872 0x0000ffff, /* src_mask */
1873 0x0000ffff, /* dst_mask */
1874 false), /* pcrel_offset */
1875
1876 /* MIPS16 16-bit PC-relative branch offset. */
1877 HOWTO (R_MIPS16_PC16_S1, /* type */
1878 1, /* rightshift */
1879 4, /* size */
1880 16, /* bitsize */
1881 true, /* pc_relative */
1882 0, /* bitpos */
1883 complain_overflow_signed, /* complain_on_overflow */
1884 _bfd_mips_elf_generic_reloc, /* special_function */
1885 "R_MIPS16_PC16_S1", /* name */
1886 true, /* partial_inplace */
1887 0x0000ffff, /* src_mask */
1888 0x0000ffff, /* dst_mask */
1889 true), /* pcrel_offset */
1890 };
1891
1892 static reloc_howto_type mips16_elf64_howto_table_rela[] =
1893 {
1894 /* The reloc used for the mips16 jump instruction. */
1895 HOWTO (R_MIPS16_26, /* type */
1896 2, /* rightshift */
1897 4, /* size */
1898 26, /* bitsize */
1899 false, /* pc_relative */
1900 0, /* bitpos */
1901 complain_overflow_dont, /* complain_on_overflow */
1902 /* This needs complex overflow
1903 detection, because the upper four
1904 bits must match the PC. */
1905 _bfd_mips_elf_generic_reloc, /* special_function */
1906 "R_MIPS16_26", /* name */
1907 false, /* partial_inplace */
1908 0, /* src_mask */
1909 0x3ffffff, /* dst_mask */
1910 false), /* pcrel_offset */
1911
1912 /* The reloc used for the mips16 gprel instruction. */
1913 HOWTO (R_MIPS16_GPREL, /* type */
1914 0, /* rightshift */
1915 4, /* size */
1916 16, /* bitsize */
1917 false, /* pc_relative */
1918 0, /* bitpos */
1919 complain_overflow_signed, /* complain_on_overflow */
1920 mips16_gprel_reloc, /* special_function */
1921 "R_MIPS16_GPREL", /* name */
1922 false, /* partial_inplace */
1923 0, /* src_mask */
1924 0x0000ffff, /* dst_mask */
1925 false), /* pcrel_offset */
1926
1927 /* A MIPS16 reference to the global offset table. */
1928 HOWTO (R_MIPS16_GOT16, /* type */
1929 0, /* rightshift */
1930 4, /* size */
1931 16, /* bitsize */
1932 false, /* pc_relative */
1933 0, /* bitpos */
1934 complain_overflow_dont, /* complain_on_overflow */
1935 _bfd_mips_elf_got16_reloc, /* special_function */
1936 "R_MIPS16_GOT16", /* name */
1937 false, /* partial_inplace */
1938 0, /* src_mask */
1939 0x0000ffff, /* dst_mask */
1940 false), /* pcrel_offset */
1941
1942 /* A MIPS16 call through the global offset table. */
1943 HOWTO (R_MIPS16_CALL16, /* type */
1944 0, /* rightshift */
1945 4, /* size */
1946 16, /* bitsize */
1947 false, /* pc_relative */
1948 0, /* bitpos */
1949 complain_overflow_dont, /* complain_on_overflow */
1950 _bfd_mips_elf_generic_reloc, /* special_function */
1951 "R_MIPS16_CALL16", /* name */
1952 false, /* partial_inplace */
1953 0, /* src_mask */
1954 0x0000ffff, /* dst_mask */
1955 false), /* pcrel_offset */
1956
1957 /* MIPS16 high 16 bits of symbol value. */
1958 HOWTO (R_MIPS16_HI16, /* type */
1959 16, /* rightshift */
1960 4, /* size */
1961 16, /* bitsize */
1962 false, /* pc_relative */
1963 0, /* bitpos */
1964 complain_overflow_dont, /* complain_on_overflow */
1965 _bfd_mips_elf_hi16_reloc, /* special_function */
1966 "R_MIPS16_HI16", /* name */
1967 false, /* partial_inplace */
1968 0, /* src_mask */
1969 0x0000ffff, /* dst_mask */
1970 false), /* pcrel_offset */
1971
1972 /* MIPS16 low 16 bits of symbol value. */
1973 HOWTO (R_MIPS16_LO16, /* type */
1974 0, /* rightshift */
1975 4, /* size */
1976 16, /* bitsize */
1977 false, /* pc_relative */
1978 0, /* bitpos */
1979 complain_overflow_dont, /* complain_on_overflow */
1980 _bfd_mips_elf_lo16_reloc, /* special_function */
1981 "R_MIPS16_LO16", /* name */
1982 false, /* partial_inplace */
1983 0, /* src_mask */
1984 0x0000ffff, /* dst_mask */
1985 false), /* pcrel_offset */
1986
1987 /* MIPS16 TLS general dynamic variable reference. */
1988 HOWTO (R_MIPS16_TLS_GD, /* type */
1989 0, /* rightshift */
1990 4, /* size */
1991 16, /* bitsize */
1992 false, /* pc_relative */
1993 0, /* bitpos */
1994 complain_overflow_signed, /* complain_on_overflow */
1995 _bfd_mips_elf_generic_reloc, /* special_function */
1996 "R_MIPS16_TLS_GD", /* name */
1997 false, /* partial_inplace */
1998 0, /* src_mask */
1999 0x0000ffff, /* dst_mask */
2000 false), /* pcrel_offset */
2001
2002 /* MIPS16 TLS local dynamic variable reference. */
2003 HOWTO (R_MIPS16_TLS_LDM, /* type */
2004 0, /* rightshift */
2005 4, /* size */
2006 16, /* bitsize */
2007 false, /* pc_relative */
2008 0, /* bitpos */
2009 complain_overflow_signed, /* complain_on_overflow */
2010 _bfd_mips_elf_generic_reloc, /* special_function */
2011 "R_MIPS16_TLS_LDM", /* name */
2012 false, /* partial_inplace */
2013 0, /* src_mask */
2014 0x0000ffff, /* dst_mask */
2015 false), /* pcrel_offset */
2016
2017 /* MIPS16 TLS local dynamic offset. */
2018 HOWTO (R_MIPS16_TLS_DTPREL_HI16, /* type */
2019 0, /* rightshift */
2020 4, /* size */
2021 16, /* bitsize */
2022 false, /* pc_relative */
2023 0, /* bitpos */
2024 complain_overflow_signed, /* complain_on_overflow */
2025 _bfd_mips_elf_generic_reloc, /* special_function */
2026 "R_MIPS16_TLS_DTPREL_HI16", /* name */
2027 false, /* partial_inplace */
2028 0, /* src_mask */
2029 0x0000ffff, /* dst_mask */
2030 false), /* pcrel_offset */
2031
2032 /* MIPS16 TLS local dynamic offset. */
2033 HOWTO (R_MIPS16_TLS_DTPREL_LO16, /* type */
2034 0, /* rightshift */
2035 4, /* size */
2036 16, /* bitsize */
2037 false, /* pc_relative */
2038 0, /* bitpos */
2039 complain_overflow_signed, /* complain_on_overflow */
2040 _bfd_mips_elf_generic_reloc, /* special_function */
2041 "R_MIPS16_TLS_DTPREL_LO16", /* name */
2042 false, /* partial_inplace */
2043 0, /* src_mask */
2044 0x0000ffff, /* dst_mask */
2045 false), /* pcrel_offset */
2046
2047 /* MIPS16 TLS thread pointer offset. */
2048 HOWTO (R_MIPS16_TLS_GOTTPREL, /* type */
2049 0, /* rightshift */
2050 4, /* size */
2051 16, /* bitsize */
2052 false, /* pc_relative */
2053 0, /* bitpos */
2054 complain_overflow_signed, /* complain_on_overflow */
2055 _bfd_mips_elf_generic_reloc, /* special_function */
2056 "R_MIPS16_TLS_GOTTPREL", /* name */
2057 false, /* partial_inplace */
2058 0, /* src_mask */
2059 0x0000ffff, /* dst_mask */
2060 false), /* pcrel_offset */
2061
2062 /* MIPS16 TLS thread pointer offset. */
2063 HOWTO (R_MIPS16_TLS_TPREL_HI16, /* type */
2064 0, /* rightshift */
2065 4, /* size */
2066 16, /* bitsize */
2067 false, /* pc_relative */
2068 0, /* bitpos */
2069 complain_overflow_signed, /* complain_on_overflow */
2070 _bfd_mips_elf_generic_reloc, /* special_function */
2071 "R_MIPS16_TLS_TPREL_HI16", /* name */
2072 false, /* partial_inplace */
2073 0, /* src_mask */
2074 0x0000ffff, /* dst_mask */
2075 false), /* pcrel_offset */
2076
2077 /* MIPS16 TLS thread pointer offset. */
2078 HOWTO (R_MIPS16_TLS_TPREL_LO16, /* type */
2079 0, /* rightshift */
2080 4, /* size */
2081 16, /* bitsize */
2082 false, /* pc_relative */
2083 0, /* bitpos */
2084 complain_overflow_signed, /* complain_on_overflow */
2085 _bfd_mips_elf_generic_reloc, /* special_function */
2086 "R_MIPS16_TLS_TPREL_LO16", /* name */
2087 false, /* partial_inplace */
2088 0, /* src_mask */
2089 0x0000ffff, /* dst_mask */
2090 false), /* pcrel_offset */
2091
2092 /* MIPS16 16-bit PC-relative branch offset. */
2093 HOWTO (R_MIPS16_PC16_S1, /* type */
2094 1, /* rightshift */
2095 4, /* size */
2096 16, /* bitsize */
2097 true, /* pc_relative */
2098 0, /* bitpos */
2099 complain_overflow_signed, /* complain_on_overflow */
2100 _bfd_mips_elf_generic_reloc, /* special_function */
2101 "R_MIPS16_PC16_S1", /* name */
2102 false, /* partial_inplace */
2103 0, /* src_mask */
2104 0x0000ffff, /* dst_mask */
2105 true), /* pcrel_offset */
2106 };
2107
2108 static reloc_howto_type micromips_elf64_howto_table_rel[] =
2109 {
2110 EMPTY_HOWTO (130),
2111 EMPTY_HOWTO (131),
2112 EMPTY_HOWTO (132),
2113
2114 /* 26 bit jump address. */
2115 HOWTO (R_MICROMIPS_26_S1, /* type */
2116 1, /* rightshift */
2117 4, /* size */
2118 26, /* bitsize */
2119 false, /* pc_relative */
2120 0, /* bitpos */
2121 complain_overflow_dont, /* complain_on_overflow */
2122 /* This needs complex overflow
2123 detection, because the upper four
2124 bits must match the PC. */
2125 _bfd_mips_elf_generic_reloc, /* special_function */
2126 "R_MICROMIPS_26_S1", /* name */
2127 true, /* partial_inplace */
2128 0x3ffffff, /* src_mask */
2129 0x3ffffff, /* dst_mask */
2130 false), /* pcrel_offset */
2131
2132 /* High 16 bits of symbol value. */
2133 HOWTO (R_MICROMIPS_HI16, /* type */
2134 16, /* rightshift */
2135 4, /* size */
2136 16, /* bitsize */
2137 false, /* pc_relative */
2138 0, /* bitpos */
2139 complain_overflow_dont, /* complain_on_overflow */
2140 _bfd_mips_elf_hi16_reloc, /* special_function */
2141 "R_MICROMIPS_HI16", /* name */
2142 true, /* partial_inplace */
2143 0x0000ffff, /* src_mask */
2144 0x0000ffff, /* dst_mask */
2145 false), /* pcrel_offset */
2146
2147 /* Low 16 bits of symbol value. */
2148 HOWTO (R_MICROMIPS_LO16, /* type */
2149 0, /* rightshift */
2150 4, /* size */
2151 16, /* bitsize */
2152 false, /* pc_relative */
2153 0, /* bitpos */
2154 complain_overflow_dont, /* complain_on_overflow */
2155 _bfd_mips_elf_lo16_reloc, /* special_function */
2156 "R_MICROMIPS_LO16", /* name */
2157 true, /* partial_inplace */
2158 0x0000ffff, /* src_mask */
2159 0x0000ffff, /* dst_mask */
2160 false), /* pcrel_offset */
2161
2162 /* GP relative reference. */
2163 HOWTO (R_MICROMIPS_GPREL16, /* type */
2164 0, /* rightshift */
2165 4, /* size */
2166 16, /* bitsize */
2167 false, /* pc_relative */
2168 0, /* bitpos */
2169 complain_overflow_signed, /* complain_on_overflow */
2170 _bfd_mips_elf32_gprel16_reloc, /* special_function */
2171 "R_MICROMIPS_GPREL16", /* name */
2172 true, /* partial_inplace */
2173 0x0000ffff, /* src_mask */
2174 0x0000ffff, /* dst_mask */
2175 false), /* pcrel_offset */
2176
2177 /* Reference to literal section. */
2178 HOWTO (R_MICROMIPS_LITERAL, /* type */
2179 0, /* rightshift */
2180 4, /* size */
2181 16, /* bitsize */
2182 false, /* pc_relative */
2183 0, /* bitpos */
2184 complain_overflow_signed, /* complain_on_overflow */
2185 _bfd_mips_elf32_gprel16_reloc, /* special_function */
2186 "R_MICROMIPS_LITERAL", /* name */
2187 true, /* partial_inplace */
2188 0x0000ffff, /* src_mask */
2189 0x0000ffff, /* dst_mask */
2190 false), /* pcrel_offset */
2191
2192 /* Reference to global offset table. */
2193 HOWTO (R_MICROMIPS_GOT16, /* type */
2194 0, /* rightshift */
2195 4, /* size */
2196 16, /* bitsize */
2197 false, /* pc_relative */
2198 0, /* bitpos */
2199 complain_overflow_signed, /* complain_on_overflow */
2200 _bfd_mips_elf_got16_reloc, /* special_function */
2201 "R_MICROMIPS_GOT16", /* name */
2202 true, /* partial_inplace */
2203 0x0000ffff, /* src_mask */
2204 0x0000ffff, /* dst_mask */
2205 false), /* pcrel_offset */
2206
2207 /* This is for microMIPS branches. */
2208 HOWTO (R_MICROMIPS_PC7_S1, /* type */
2209 1, /* rightshift */
2210 2, /* size */
2211 7, /* bitsize */
2212 true, /* pc_relative */
2213 0, /* bitpos */
2214 complain_overflow_signed, /* complain_on_overflow */
2215 _bfd_mips_elf_generic_reloc, /* special_function */
2216 "R_MICROMIPS_PC7_S1", /* name */
2217 true, /* partial_inplace */
2218 0x0000007f, /* src_mask */
2219 0x0000007f, /* dst_mask */
2220 true), /* pcrel_offset */
2221
2222 HOWTO (R_MICROMIPS_PC10_S1, /* type */
2223 1, /* rightshift */
2224 2, /* size */
2225 10, /* bitsize */
2226 true, /* pc_relative */
2227 0, /* bitpos */
2228 complain_overflow_signed, /* complain_on_overflow */
2229 _bfd_mips_elf_generic_reloc, /* special_function */
2230 "R_MICROMIPS_PC10_S1", /* name */
2231 true, /* partial_inplace */
2232 0x000003ff, /* src_mask */
2233 0x000003ff, /* dst_mask */
2234 true), /* pcrel_offset */
2235
2236 HOWTO (R_MICROMIPS_PC16_S1, /* type */
2237 1, /* rightshift */
2238 4, /* size */
2239 16, /* bitsize */
2240 true, /* pc_relative */
2241 0, /* bitpos */
2242 complain_overflow_signed, /* complain_on_overflow */
2243 _bfd_mips_elf_generic_reloc, /* special_function */
2244 "R_MICROMIPS_PC16_S1", /* name */
2245 true, /* partial_inplace */
2246 0x0000ffff, /* src_mask */
2247 0x0000ffff, /* dst_mask */
2248 true), /* pcrel_offset */
2249
2250 /* 16 bit call through global offset table. */
2251 HOWTO (R_MICROMIPS_CALL16, /* type */
2252 0, /* rightshift */
2253 4, /* size */
2254 16, /* bitsize */
2255 false, /* pc_relative */
2256 0, /* bitpos */
2257 complain_overflow_signed, /* complain_on_overflow */
2258 _bfd_mips_elf_generic_reloc, /* special_function */
2259 "R_MICROMIPS_CALL16", /* name */
2260 true, /* partial_inplace */
2261 0x0000ffff, /* src_mask */
2262 0x0000ffff, /* dst_mask */
2263 false), /* pcrel_offset */
2264
2265 EMPTY_HOWTO (143),
2266 EMPTY_HOWTO (144),
2267
2268 /* Displacement in the global offset table. */
2269 HOWTO (R_MICROMIPS_GOT_DISP, /* type */
2270 0, /* rightshift */
2271 4, /* size */
2272 16, /* bitsize */
2273 false, /* pc_relative */
2274 0, /* bitpos */
2275 complain_overflow_signed, /* complain_on_overflow */
2276 _bfd_mips_elf_generic_reloc, /* special_function */
2277 "R_MICROMIPS_GOT_DISP",/* name */
2278 true, /* partial_inplace */
2279 0x0000ffff, /* src_mask */
2280 0x0000ffff, /* dst_mask */
2281 false), /* pcrel_offset */
2282
2283 /* Displacement to page pointer in the global offset table. */
2284 HOWTO (R_MICROMIPS_GOT_PAGE, /* type */
2285 0, /* rightshift */
2286 4, /* size */
2287 16, /* bitsize */
2288 false, /* pc_relative */
2289 0, /* bitpos */
2290 complain_overflow_signed, /* complain_on_overflow */
2291 _bfd_mips_elf_generic_reloc, /* special_function */
2292 "R_MICROMIPS_GOT_PAGE",/* name */
2293 true, /* partial_inplace */
2294 0x0000ffff, /* src_mask */
2295 0x0000ffff, /* dst_mask */
2296 false), /* pcrel_offset */
2297
2298 /* Offset from page pointer in the global offset table. */
2299 HOWTO (R_MICROMIPS_GOT_OFST, /* type */
2300 0, /* rightshift */
2301 4, /* size */
2302 16, /* bitsize */
2303 false, /* pc_relative */
2304 0, /* bitpos */
2305 complain_overflow_signed, /* complain_on_overflow */
2306 _bfd_mips_elf_generic_reloc, /* special_function */
2307 "R_MICROMIPS_GOT_OFST",/* name */
2308 true, /* partial_inplace */
2309 0x0000ffff, /* src_mask */
2310 0x0000ffff, /* dst_mask */
2311 false), /* pcrel_offset */
2312
2313 /* High 16 bits of displacement in global offset table. */
2314 HOWTO (R_MICROMIPS_GOT_HI16, /* type */
2315 0, /* rightshift */
2316 4, /* size */
2317 16, /* bitsize */
2318 false, /* pc_relative */
2319 0, /* bitpos */
2320 complain_overflow_dont, /* complain_on_overflow */
2321 _bfd_mips_elf_generic_reloc, /* special_function */
2322 "R_MICROMIPS_GOT_HI16",/* name */
2323 true, /* partial_inplace */
2324 0x0000ffff, /* src_mask */
2325 0x0000ffff, /* dst_mask */
2326 false), /* pcrel_offset */
2327
2328 /* Low 16 bits of displacement in global offset table. */
2329 HOWTO (R_MICROMIPS_GOT_LO16, /* type */
2330 0, /* rightshift */
2331 4, /* size */
2332 16, /* bitsize */
2333 false, /* pc_relative */
2334 0, /* bitpos */
2335 complain_overflow_dont, /* complain_on_overflow */
2336 _bfd_mips_elf_generic_reloc, /* special_function */
2337 "R_MICROMIPS_GOT_LO16",/* name */
2338 true, /* partial_inplace */
2339 0x0000ffff, /* src_mask */
2340 0x0000ffff, /* dst_mask */
2341 false), /* pcrel_offset */
2342
2343 /* 64 bit subtraction. Used in the N32 ABI. */
2344 HOWTO (R_MICROMIPS_SUB, /* type */
2345 0, /* rightshift */
2346 8, /* size */
2347 64, /* bitsize */
2348 false, /* pc_relative */
2349 0, /* bitpos */
2350 complain_overflow_dont, /* complain_on_overflow */
2351 _bfd_mips_elf_generic_reloc, /* special_function */
2352 "R_MICROMIPS_SUB", /* name */
2353 true, /* partial_inplace */
2354 MINUS_ONE, /* src_mask */
2355 MINUS_ONE, /* dst_mask */
2356 false), /* pcrel_offset */
2357
2358 /* We don't support these for REL relocations, because it means building
2359 the addend from a R_MICROMIPS_HIGHEST/R_MICROMIPS_HIGHER/
2360 R_MICROMIPS_HI16/R_MICROMIPS_LO16 sequence with varying ordering,
2361 using fallable heuristics. */
2362 EMPTY_HOWTO (R_MICROMIPS_HIGHER),
2363 EMPTY_HOWTO (R_MICROMIPS_HIGHEST),
2364
2365 /* High 16 bits of displacement in global offset table. */
2366 HOWTO (R_MICROMIPS_CALL_HI16, /* type */
2367 0, /* rightshift */
2368 4, /* size */
2369 16, /* bitsize */
2370 false, /* pc_relative */
2371 0, /* bitpos */
2372 complain_overflow_dont, /* complain_on_overflow */
2373 _bfd_mips_elf_generic_reloc, /* special_function */
2374 "R_MICROMIPS_CALL_HI16",/* name */
2375 true, /* partial_inplace */
2376 0x0000ffff, /* src_mask */
2377 0x0000ffff, /* dst_mask */
2378 false), /* pcrel_offset */
2379
2380 /* Low 16 bits of displacement in global offset table. */
2381 HOWTO (R_MICROMIPS_CALL_LO16, /* type */
2382 0, /* rightshift */
2383 4, /* size */
2384 16, /* bitsize */
2385 false, /* pc_relative */
2386 0, /* bitpos */
2387 complain_overflow_dont, /* complain_on_overflow */
2388 _bfd_mips_elf_generic_reloc, /* special_function */
2389 "R_MICROMIPS_CALL_LO16",/* name */
2390 true, /* partial_inplace */
2391 0x0000ffff, /* src_mask */
2392 0x0000ffff, /* dst_mask */
2393 false), /* pcrel_offset */
2394
2395 /* Section displacement. */
2396 HOWTO (R_MICROMIPS_SCN_DISP, /* type */
2397 0, /* rightshift */
2398 4, /* size */
2399 32, /* bitsize */
2400 false, /* pc_relative */
2401 0, /* bitpos */
2402 complain_overflow_dont, /* complain_on_overflow */
2403 _bfd_mips_elf_generic_reloc, /* special_function */
2404 "R_MICROMIPS_SCN_DISP", /* name */
2405 true, /* partial_inplace */
2406 0xffffffff, /* src_mask */
2407 0xffffffff, /* dst_mask */
2408 false), /* pcrel_offset */
2409
2410 /* Protected jump conversion. This is an optimization hint. No
2411 relocation is required for correctness. */
2412 HOWTO (R_MICROMIPS_JALR, /* type */
2413 0, /* rightshift */
2414 4, /* size */
2415 32, /* bitsize */
2416 false, /* pc_relative */
2417 0, /* bitpos */
2418 complain_overflow_dont, /* complain_on_overflow */
2419 _bfd_mips_elf_generic_reloc, /* special_function */
2420 "R_MICROMIPS_JALR", /* name */
2421 false, /* partial_inplace */
2422 0, /* src_mask */
2423 0x00000000, /* dst_mask */
2424 false), /* pcrel_offset */
2425
2426 /* Low 16 bits of symbol value. Note that the high 16 bits of symbol values
2427 must be zero. This is used for relaxation. */
2428 HOWTO (R_MICROMIPS_HI0_LO16, /* type */
2429 0, /* rightshift */
2430 4, /* size */
2431 16, /* bitsize */
2432 false, /* pc_relative */
2433 0, /* bitpos */
2434 complain_overflow_dont, /* complain_on_overflow */
2435 _bfd_mips_elf_generic_reloc, /* special_function */
2436 "R_MICROMIPS_HI0_LO16",/* name */
2437 true, /* partial_inplace */
2438 0x0000ffff, /* src_mask */
2439 0x0000ffff, /* dst_mask */
2440 false), /* pcrel_offset */
2441
2442 EMPTY_HOWTO (158),
2443 EMPTY_HOWTO (159),
2444 EMPTY_HOWTO (160),
2445 EMPTY_HOWTO (161),
2446
2447 /* TLS general dynamic variable reference. */
2448 HOWTO (R_MICROMIPS_TLS_GD, /* type */
2449 0, /* rightshift */
2450 4, /* size */
2451 16, /* bitsize */
2452 false, /* pc_relative */
2453 0, /* bitpos */
2454 complain_overflow_signed, /* complain_on_overflow */
2455 _bfd_mips_elf_generic_reloc, /* special_function */
2456 "R_MICROMIPS_TLS_GD", /* name */
2457 true, /* partial_inplace */
2458 0x0000ffff, /* src_mask */
2459 0x0000ffff, /* dst_mask */
2460 false), /* pcrel_offset */
2461
2462 /* TLS local dynamic variable reference. */
2463 HOWTO (R_MICROMIPS_TLS_LDM, /* type */
2464 0, /* rightshift */
2465 4, /* size */
2466 16, /* bitsize */
2467 false, /* pc_relative */
2468 0, /* bitpos */
2469 complain_overflow_signed, /* complain_on_overflow */
2470 _bfd_mips_elf_generic_reloc, /* special_function */
2471 "R_MICROMIPS_TLS_LDM", /* name */
2472 true, /* partial_inplace */
2473 0x0000ffff, /* src_mask */
2474 0x0000ffff, /* dst_mask */
2475 false), /* pcrel_offset */
2476
2477 /* TLS local dynamic offset. */
2478 HOWTO (R_MICROMIPS_TLS_DTPREL_HI16, /* type */
2479 0, /* rightshift */
2480 4, /* size */
2481 16, /* bitsize */
2482 false, /* pc_relative */
2483 0, /* bitpos */
2484 complain_overflow_signed, /* complain_on_overflow */
2485 _bfd_mips_elf_generic_reloc, /* special_function */
2486 "R_MICROMIPS_TLS_DTPREL_HI16", /* name */
2487 true, /* partial_inplace */
2488 0x0000ffff, /* src_mask */
2489 0x0000ffff, /* dst_mask */
2490 false), /* pcrel_offset */
2491
2492 /* TLS local dynamic offset. */
2493 HOWTO (R_MICROMIPS_TLS_DTPREL_LO16, /* type */
2494 0, /* rightshift */
2495 4, /* size */
2496 16, /* bitsize */
2497 false, /* pc_relative */
2498 0, /* bitpos */
2499 complain_overflow_signed, /* complain_on_overflow */
2500 _bfd_mips_elf_generic_reloc, /* special_function */
2501 "R_MICROMIPS_TLS_DTPREL_LO16", /* name */
2502 true, /* partial_inplace */
2503 0x0000ffff, /* src_mask */
2504 0x0000ffff, /* dst_mask */
2505 false), /* pcrel_offset */
2506
2507 /* TLS thread pointer offset. */
2508 HOWTO (R_MICROMIPS_TLS_GOTTPREL, /* type */
2509 0, /* rightshift */
2510 4, /* size */
2511 16, /* bitsize */
2512 false, /* pc_relative */
2513 0, /* bitpos */
2514 complain_overflow_signed, /* complain_on_overflow */
2515 _bfd_mips_elf_generic_reloc, /* special_function */
2516 "R_MICROMIPS_TLS_GOTTPREL", /* name */
2517 true, /* partial_inplace */
2518 0x0000ffff, /* src_mask */
2519 0x0000ffff, /* dst_mask */
2520 false), /* pcrel_offset */
2521
2522 EMPTY_HOWTO (167),
2523 EMPTY_HOWTO (168),
2524
2525 /* TLS thread pointer offset. */
2526 HOWTO (R_MICROMIPS_TLS_TPREL_HI16, /* type */
2527 0, /* rightshift */
2528 4, /* size */
2529 16, /* bitsize */
2530 false, /* pc_relative */
2531 0, /* bitpos */
2532 complain_overflow_signed, /* complain_on_overflow */
2533 _bfd_mips_elf_generic_reloc, /* special_function */
2534 "R_MICROMIPS_TLS_TPREL_HI16", /* name */
2535 true, /* partial_inplace */
2536 0x0000ffff, /* src_mask */
2537 0x0000ffff, /* dst_mask */
2538 false), /* pcrel_offset */
2539
2540 /* TLS thread pointer offset. */
2541 HOWTO (R_MICROMIPS_TLS_TPREL_LO16, /* type */
2542 0, /* rightshift */
2543 4, /* size */
2544 16, /* bitsize */
2545 false, /* pc_relative */
2546 0, /* bitpos */
2547 complain_overflow_signed, /* complain_on_overflow */
2548 _bfd_mips_elf_generic_reloc, /* special_function */
2549 "R_MICROMIPS_TLS_TPREL_LO16", /* name */
2550 true, /* partial_inplace */
2551 0x0000ffff, /* src_mask */
2552 0x0000ffff, /* dst_mask */
2553 false), /* pcrel_offset */
2554
2555 EMPTY_HOWTO (171),
2556
2557 /* GP- and PC-relative relocations. */
2558 HOWTO (R_MICROMIPS_GPREL7_S2, /* type */
2559 2, /* rightshift */
2560 2, /* size */
2561 7, /* bitsize */
2562 false, /* pc_relative */
2563 0, /* bitpos */
2564 complain_overflow_signed, /* complain_on_overflow */
2565 _bfd_mips_elf32_gprel16_reloc, /* special_function */
2566 "R_MICROMIPS_GPREL7_S2", /* name */
2567 true, /* partial_inplace */
2568 0x0000007f, /* src_mask */
2569 0x0000007f, /* dst_mask */
2570 false), /* pcrel_offset */
2571
2572 HOWTO (R_MICROMIPS_PC23_S2, /* type */
2573 2, /* rightshift */
2574 4, /* size */
2575 23, /* bitsize */
2576 true, /* pc_relative */
2577 0, /* bitpos */
2578 complain_overflow_signed, /* complain_on_overflow */
2579 _bfd_mips_elf_generic_reloc, /* special_function */
2580 "R_MICROMIPS_PC23_S2", /* name */
2581 true, /* partial_inplace */
2582 0x007fffff, /* src_mask */
2583 0x007fffff, /* dst_mask */
2584 true), /* pcrel_offset */
2585 };
2586
2587 static reloc_howto_type micromips_elf64_howto_table_rela[] =
2588 {
2589 EMPTY_HOWTO (130),
2590 EMPTY_HOWTO (131),
2591 EMPTY_HOWTO (132),
2592
2593 /* 26 bit jump address. */
2594 HOWTO (R_MICROMIPS_26_S1, /* type */
2595 1, /* rightshift */
2596 4, /* size */
2597 26, /* bitsize */
2598 false, /* pc_relative */
2599 0, /* bitpos */
2600 complain_overflow_dont, /* complain_on_overflow */
2601 /* This needs complex overflow
2602 detection, because the upper four
2603 bits must match the PC. */
2604 _bfd_mips_elf_generic_reloc, /* special_function */
2605 "R_MICROMIPS_26_S1", /* name */
2606 false, /* partial_inplace */
2607 0, /* src_mask */
2608 0x3ffffff, /* dst_mask */
2609 false), /* pcrel_offset */
2610
2611 /* High 16 bits of symbol value. */
2612 HOWTO (R_MICROMIPS_HI16, /* type */
2613 16, /* rightshift */
2614 4, /* size */
2615 16, /* bitsize */
2616 false, /* pc_relative */
2617 0, /* bitpos */
2618 complain_overflow_dont, /* complain_on_overflow */
2619 _bfd_mips_elf_hi16_reloc, /* special_function */
2620 "R_MICROMIPS_HI16", /* name */
2621 false, /* partial_inplace */
2622 0, /* src_mask */
2623 0x0000ffff, /* dst_mask */
2624 false), /* pcrel_offset */
2625
2626 /* Low 16 bits of symbol value. */
2627 HOWTO (R_MICROMIPS_LO16, /* type */
2628 0, /* rightshift */
2629 4, /* size */
2630 16, /* bitsize */
2631 false, /* pc_relative */
2632 0, /* bitpos */
2633 complain_overflow_dont, /* complain_on_overflow */
2634 _bfd_mips_elf_lo16_reloc, /* special_function */
2635 "R_MICROMIPS_LO16", /* name */
2636 false, /* partial_inplace */
2637 0, /* src_mask */
2638 0x0000ffff, /* dst_mask */
2639 false), /* pcrel_offset */
2640
2641 /* GP relative reference. */
2642 HOWTO (R_MICROMIPS_GPREL16, /* type */
2643 0, /* rightshift */
2644 4, /* size */
2645 16, /* bitsize */
2646 false, /* pc_relative */
2647 0, /* bitpos */
2648 complain_overflow_signed, /* complain_on_overflow */
2649 _bfd_mips_elf32_gprel16_reloc, /* special_function */
2650 "R_MICROMIPS_GPREL16", /* name */
2651 false, /* partial_inplace */
2652 0, /* src_mask */
2653 0x0000ffff, /* dst_mask */
2654 false), /* pcrel_offset */
2655
2656 /* Reference to literal section. */
2657 HOWTO (R_MICROMIPS_LITERAL, /* type */
2658 0, /* rightshift */
2659 4, /* size */
2660 16, /* bitsize */
2661 false, /* pc_relative */
2662 0, /* bitpos */
2663 complain_overflow_signed, /* complain_on_overflow */
2664 _bfd_mips_elf32_gprel16_reloc, /* special_function */
2665 "R_MICROMIPS_LITERAL", /* name */
2666 false, /* partial_inplace */
2667 0, /* src_mask */
2668 0x0000ffff, /* dst_mask */
2669 false), /* pcrel_offset */
2670
2671 /* Reference to global offset table. */
2672 HOWTO (R_MICROMIPS_GOT16, /* type */
2673 0, /* rightshift */
2674 4, /* size */
2675 16, /* bitsize */
2676 false, /* pc_relative */
2677 0, /* bitpos */
2678 complain_overflow_signed, /* complain_on_overflow */
2679 _bfd_mips_elf_got16_reloc, /* special_function */
2680 "R_MICROMIPS_GOT16", /* name */
2681 false, /* partial_inplace */
2682 0, /* src_mask */
2683 0x0000ffff, /* dst_mask */
2684 false), /* pcrel_offset */
2685
2686 /* This is for microMIPS branches. */
2687 HOWTO (R_MICROMIPS_PC7_S1, /* type */
2688 1, /* rightshift */
2689 2, /* size */
2690 7, /* bitsize */
2691 true, /* pc_relative */
2692 0, /* bitpos */
2693 complain_overflow_signed, /* complain_on_overflow */
2694 _bfd_mips_elf_generic_reloc, /* special_function */
2695 "R_MICROMIPS_PC7_S1", /* name */
2696 false, /* partial_inplace */
2697 0, /* src_mask */
2698 0x0000007f, /* dst_mask */
2699 true), /* pcrel_offset */
2700
2701 HOWTO (R_MICROMIPS_PC10_S1, /* type */
2702 1, /* rightshift */
2703 2, /* size */
2704 10, /* bitsize */
2705 true, /* pc_relative */
2706 0, /* bitpos */
2707 complain_overflow_signed, /* complain_on_overflow */
2708 _bfd_mips_elf_generic_reloc, /* special_function */
2709 "R_MICROMIPS_PC10_S1", /* name */
2710 false, /* partial_inplace */
2711 0, /* src_mask */
2712 0x000003ff, /* dst_mask */
2713 true), /* pcrel_offset */
2714
2715 HOWTO (R_MICROMIPS_PC16_S1, /* type */
2716 1, /* rightshift */
2717 4, /* size */
2718 16, /* bitsize */
2719 true, /* pc_relative */
2720 0, /* bitpos */
2721 complain_overflow_signed, /* complain_on_overflow */
2722 _bfd_mips_elf_generic_reloc, /* special_function */
2723 "R_MICROMIPS_PC16_S1", /* name */
2724 false, /* partial_inplace */
2725 0, /* src_mask */
2726 0x0000ffff, /* dst_mask */
2727 true), /* pcrel_offset */
2728
2729 /* 16 bit call through global offset table. */
2730 HOWTO (R_MICROMIPS_CALL16, /* type */
2731 0, /* rightshift */
2732 4, /* size */
2733 16, /* bitsize */
2734 false, /* pc_relative */
2735 0, /* bitpos */
2736 complain_overflow_signed, /* complain_on_overflow */
2737 _bfd_mips_elf_generic_reloc, /* special_function */
2738 "R_MICROMIPS_CALL16", /* name */
2739 false, /* partial_inplace */
2740 0, /* src_mask */
2741 0x0000ffff, /* dst_mask */
2742 false), /* pcrel_offset */
2743
2744 EMPTY_HOWTO (143),
2745 EMPTY_HOWTO (144),
2746
2747 /* Displacement in the global offset table. */
2748 HOWTO (R_MICROMIPS_GOT_DISP, /* type */
2749 0, /* rightshift */
2750 4, /* size */
2751 16, /* bitsize */
2752 false, /* pc_relative */
2753 0, /* bitpos */
2754 complain_overflow_signed, /* complain_on_overflow */
2755 _bfd_mips_elf_generic_reloc, /* special_function */
2756 "R_MICROMIPS_GOT_DISP",/* name */
2757 false, /* partial_inplace */
2758 0, /* src_mask */
2759 0x0000ffff, /* dst_mask */
2760 false), /* pcrel_offset */
2761
2762 /* Displacement to page pointer in the global offset table. */
2763 HOWTO (R_MICROMIPS_GOT_PAGE, /* type */
2764 0, /* rightshift */
2765 4, /* size */
2766 16, /* bitsize */
2767 false, /* pc_relative */
2768 0, /* bitpos */
2769 complain_overflow_signed, /* complain_on_overflow */
2770 _bfd_mips_elf_generic_reloc, /* special_function */
2771 "R_MICROMIPS_GOT_PAGE",/* name */
2772 false, /* partial_inplace */
2773 0, /* src_mask */
2774 0x0000ffff, /* dst_mask */
2775 false), /* pcrel_offset */
2776
2777 /* Offset from page pointer in the global offset table. */
2778 HOWTO (R_MICROMIPS_GOT_OFST, /* type */
2779 0, /* rightshift */
2780 4, /* size */
2781 16, /* bitsize */
2782 false, /* pc_relative */
2783 0, /* bitpos */
2784 complain_overflow_signed, /* complain_on_overflow */
2785 _bfd_mips_elf_generic_reloc, /* special_function */
2786 "R_MICROMIPS_GOT_OFST",/* name */
2787 false, /* partial_inplace */
2788 0, /* src_mask */
2789 0x0000ffff, /* dst_mask */
2790 false), /* pcrel_offset */
2791
2792 /* High 16 bits of displacement in global offset table. */
2793 HOWTO (R_MICROMIPS_GOT_HI16, /* type */
2794 0, /* rightshift */
2795 4, /* size */
2796 16, /* bitsize */
2797 false, /* pc_relative */
2798 0, /* bitpos */
2799 complain_overflow_dont, /* complain_on_overflow */
2800 _bfd_mips_elf_generic_reloc, /* special_function */
2801 "R_MICROMIPS_GOT_HI16",/* name */
2802 false, /* partial_inplace */
2803 0, /* src_mask */
2804 0x0000ffff, /* dst_mask */
2805 false), /* pcrel_offset */
2806
2807 /* Low 16 bits of displacement in global offset table. */
2808 HOWTO (R_MICROMIPS_GOT_LO16, /* type */
2809 0, /* rightshift */
2810 4, /* size */
2811 16, /* bitsize */
2812 false, /* pc_relative */
2813 0, /* bitpos */
2814 complain_overflow_dont, /* complain_on_overflow */
2815 _bfd_mips_elf_generic_reloc, /* special_function */
2816 "R_MICROMIPS_GOT_LO16",/* name */
2817 false, /* partial_inplace */
2818 0, /* src_mask */
2819 0x0000ffff, /* dst_mask */
2820 false), /* pcrel_offset */
2821
2822 /* 64 bit subtraction. Used in the N32 ABI. */
2823 HOWTO (R_MICROMIPS_SUB, /* type */
2824 0, /* rightshift */
2825 8, /* size */
2826 64, /* bitsize */
2827 false, /* pc_relative */
2828 0, /* bitpos */
2829 complain_overflow_dont, /* complain_on_overflow */
2830 _bfd_mips_elf_generic_reloc, /* special_function */
2831 "R_MICROMIPS_SUB", /* name */
2832 false, /* partial_inplace */
2833 0, /* src_mask */
2834 MINUS_ONE, /* dst_mask */
2835 false), /* pcrel_offset */
2836
2837 /* Get the higher value of a 64 bit addend. */
2838 HOWTO (R_MICROMIPS_HIGHER, /* type */
2839 0, /* rightshift */
2840 4, /* size */
2841 16, /* bitsize */
2842 false, /* pc_relative */
2843 0, /* bitpos */
2844 complain_overflow_dont, /* complain_on_overflow */
2845 _bfd_mips_elf_generic_reloc, /* special_function */
2846 "R_MICROMIPS_HIGHER", /* name */
2847 false, /* partial_inplace */
2848 0, /* src_mask */
2849 0x0000ffff, /* dst_mask */
2850 false), /* pcrel_offset */
2851
2852 /* Get the highest value of a 64 bit addend. */
2853 HOWTO (R_MICROMIPS_HIGHEST, /* type */
2854 0, /* rightshift */
2855 4, /* size */
2856 16, /* bitsize */
2857 false, /* pc_relative */
2858 0, /* bitpos */
2859 complain_overflow_dont, /* complain_on_overflow */
2860 _bfd_mips_elf_generic_reloc, /* special_function */
2861 "R_MICROMIPS_HIGHEST", /* name */
2862 false, /* partial_inplace */
2863 0, /* src_mask */
2864 0x0000ffff, /* dst_mask */
2865 false), /* pcrel_offset */
2866
2867 /* High 16 bits of displacement in global offset table. */
2868 HOWTO (R_MICROMIPS_CALL_HI16, /* type */
2869 0, /* rightshift */
2870 4, /* size */
2871 16, /* bitsize */
2872 false, /* pc_relative */
2873 0, /* bitpos */
2874 complain_overflow_dont, /* complain_on_overflow */
2875 _bfd_mips_elf_generic_reloc, /* special_function */
2876 "R_MICROMIPS_CALL_HI16",/* name */
2877 false, /* partial_inplace */
2878 0, /* src_mask */
2879 0x0000ffff, /* dst_mask */
2880 false), /* pcrel_offset */
2881
2882 /* Low 16 bits of displacement in global offset table. */
2883 HOWTO (R_MICROMIPS_CALL_LO16, /* type */
2884 0, /* rightshift */
2885 4, /* size */
2886 16, /* bitsize */
2887 false, /* pc_relative */
2888 0, /* bitpos */
2889 complain_overflow_dont, /* complain_on_overflow */
2890 _bfd_mips_elf_generic_reloc, /* special_function */
2891 "R_MICROMIPS_CALL_LO16",/* name */
2892 false, /* partial_inplace */
2893 0, /* src_mask */
2894 0x0000ffff, /* dst_mask */
2895 false), /* pcrel_offset */
2896
2897 /* Section displacement. */
2898 HOWTO (R_MICROMIPS_SCN_DISP, /* type */
2899 0, /* rightshift */
2900 4, /* size */
2901 32, /* bitsize */
2902 false, /* pc_relative */
2903 0, /* bitpos */
2904 complain_overflow_dont, /* complain_on_overflow */
2905 _bfd_mips_elf_generic_reloc, /* special_function */
2906 "R_MICROMIPS_SCN_DISP", /* name */
2907 false, /* partial_inplace */
2908 0, /* src_mask */
2909 0xffffffff, /* dst_mask */
2910 false), /* pcrel_offset */
2911
2912 /* Protected jump conversion. This is an optimization hint. No
2913 relocation is required for correctness. */
2914 HOWTO (R_MICROMIPS_JALR, /* type */
2915 0, /* rightshift */
2916 4, /* size */
2917 32, /* bitsize */
2918 false, /* pc_relative */
2919 0, /* bitpos */
2920 complain_overflow_dont, /* complain_on_overflow */
2921 _bfd_mips_elf_generic_reloc, /* special_function */
2922 "R_MICROMIPS_JALR", /* name */
2923 false, /* partial_inplace */
2924 0, /* src_mask */
2925 0x00000000, /* dst_mask */
2926 false), /* pcrel_offset */
2927
2928 /* Low 16 bits of symbol value. Note that the high 16 bits of symbol values
2929 must be zero. This is used for relaxation. */
2930 HOWTO (R_MICROMIPS_HI0_LO16, /* type */
2931 0, /* rightshift */
2932 4, /* size */
2933 16, /* bitsize */
2934 false, /* pc_relative */
2935 0, /* bitpos */
2936 complain_overflow_dont, /* complain_on_overflow */
2937 _bfd_mips_elf_generic_reloc, /* special_function */
2938 "R_MICROMIPS_HI0_LO16",/* name */
2939 false, /* partial_inplace */
2940 0, /* src_mask */
2941 0x0000ffff, /* dst_mask */
2942 false), /* pcrel_offset */
2943
2944 EMPTY_HOWTO (158),
2945 EMPTY_HOWTO (159),
2946 EMPTY_HOWTO (160),
2947 EMPTY_HOWTO (161),
2948
2949 /* TLS general dynamic variable reference. */
2950 HOWTO (R_MICROMIPS_TLS_GD, /* type */
2951 0, /* rightshift */
2952 4, /* size */
2953 16, /* bitsize */
2954 false, /* pc_relative */
2955 0, /* bitpos */
2956 complain_overflow_signed, /* complain_on_overflow */
2957 _bfd_mips_elf_generic_reloc, /* special_function */
2958 "R_MICROMIPS_TLS_GD", /* name */
2959 false, /* partial_inplace */
2960 0, /* src_mask */
2961 0x0000ffff, /* dst_mask */
2962 false), /* pcrel_offset */
2963
2964 /* TLS local dynamic variable reference. */
2965 HOWTO (R_MICROMIPS_TLS_LDM, /* type */
2966 0, /* rightshift */
2967 4, /* size */
2968 16, /* bitsize */
2969 false, /* pc_relative */
2970 0, /* bitpos */
2971 complain_overflow_signed, /* complain_on_overflow */
2972 _bfd_mips_elf_generic_reloc, /* special_function */
2973 "R_MICROMIPS_TLS_LDM", /* name */
2974 false, /* partial_inplace */
2975 0, /* src_mask */
2976 0x0000ffff, /* dst_mask */
2977 false), /* pcrel_offset */
2978
2979 /* TLS local dynamic offset. */
2980 HOWTO (R_MICROMIPS_TLS_DTPREL_HI16, /* type */
2981 0, /* rightshift */
2982 4, /* size */
2983 16, /* bitsize */
2984 false, /* pc_relative */
2985 0, /* bitpos */
2986 complain_overflow_signed, /* complain_on_overflow */
2987 _bfd_mips_elf_generic_reloc, /* special_function */
2988 "R_MICROMIPS_TLS_DTPREL_HI16", /* name */
2989 false, /* partial_inplace */
2990 0, /* src_mask */
2991 0x0000ffff, /* dst_mask */
2992 false), /* pcrel_offset */
2993
2994 /* TLS local dynamic offset. */
2995 HOWTO (R_MICROMIPS_TLS_DTPREL_LO16, /* type */
2996 0, /* rightshift */
2997 4, /* size */
2998 16, /* bitsize */
2999 false, /* pc_relative */
3000 0, /* bitpos */
3001 complain_overflow_signed, /* complain_on_overflow */
3002 _bfd_mips_elf_generic_reloc, /* special_function */
3003 "R_MICROMIPS_TLS_DTPREL_LO16", /* name */
3004 false, /* partial_inplace */
3005 0, /* src_mask */
3006 0x0000ffff, /* dst_mask */
3007 false), /* pcrel_offset */
3008
3009 /* TLS thread pointer offset. */
3010 HOWTO (R_MICROMIPS_TLS_GOTTPREL, /* type */
3011 0, /* rightshift */
3012 4, /* size */
3013 16, /* bitsize */
3014 false, /* pc_relative */
3015 0, /* bitpos */
3016 complain_overflow_signed, /* complain_on_overflow */
3017 _bfd_mips_elf_generic_reloc, /* special_function */
3018 "R_MICROMIPS_TLS_GOTTPREL", /* name */
3019 false, /* partial_inplace */
3020 0, /* src_mask */
3021 0x0000ffff, /* dst_mask */
3022 false), /* pcrel_offset */
3023
3024 EMPTY_HOWTO (167),
3025 EMPTY_HOWTO (168),
3026
3027 /* TLS thread pointer offset. */
3028 HOWTO (R_MICROMIPS_TLS_TPREL_HI16, /* type */
3029 0, /* rightshift */
3030 4, /* size */
3031 16, /* bitsize */
3032 false, /* pc_relative */
3033 0, /* bitpos */
3034 complain_overflow_signed, /* complain_on_overflow */
3035 _bfd_mips_elf_generic_reloc, /* special_function */
3036 "R_MICROMIPS_TLS_TPREL_HI16", /* name */
3037 false, /* partial_inplace */
3038 0, /* src_mask */
3039 0x0000ffff, /* dst_mask */
3040 false), /* pcrel_offset */
3041
3042 /* TLS thread pointer offset. */
3043 HOWTO (R_MICROMIPS_TLS_TPREL_LO16, /* type */
3044 0, /* rightshift */
3045 4, /* size */
3046 16, /* bitsize */
3047 false, /* pc_relative */
3048 0, /* bitpos */
3049 complain_overflow_signed, /* complain_on_overflow */
3050 _bfd_mips_elf_generic_reloc, /* special_function */
3051 "R_MICROMIPS_TLS_TPREL_LO16", /* name */
3052 false, /* partial_inplace */
3053 0, /* src_mask */
3054 0x0000ffff, /* dst_mask */
3055 false), /* pcrel_offset */
3056
3057 EMPTY_HOWTO (171),
3058
3059 /* GP- and PC-relative relocations. */
3060 HOWTO (R_MICROMIPS_GPREL7_S2, /* type */
3061 2, /* rightshift */
3062 2, /* size */
3063 7, /* bitsize */
3064 false, /* pc_relative */
3065 0, /* bitpos */
3066 complain_overflow_signed, /* complain_on_overflow */
3067 _bfd_mips_elf32_gprel16_reloc, /* special_function */
3068 "R_MICROMIPS_GPREL7_S2", /* name */
3069 false, /* partial_inplace */
3070 0, /* src_mask */
3071 0x0000007f, /* dst_mask */
3072 false), /* pcrel_offset */
3073
3074 HOWTO (R_MICROMIPS_PC23_S2, /* type */
3075 2, /* rightshift */
3076 4, /* size */
3077 23, /* bitsize */
3078 true, /* pc_relative */
3079 0, /* bitpos */
3080 complain_overflow_signed, /* complain_on_overflow */
3081 _bfd_mips_elf_generic_reloc, /* special_function */
3082 "R_MICROMIPS_PC23_S2", /* name */
3083 false, /* partial_inplace */
3084 0, /* src_mask */
3085 0x007fffff, /* dst_mask */
3086 true), /* pcrel_offset */
3087 };
3088
3089 /* GNU extension to record C++ vtable hierarchy */
3090 static reloc_howto_type elf_mips_gnu_vtinherit_howto =
3091 HOWTO (R_MIPS_GNU_VTINHERIT, /* type */
3092 0, /* rightshift */
3093 4, /* size */
3094 0, /* bitsize */
3095 false, /* pc_relative */
3096 0, /* bitpos */
3097 complain_overflow_dont, /* complain_on_overflow */
3098 NULL, /* special_function */
3099 "R_MIPS_GNU_VTINHERIT", /* name */
3100 false, /* partial_inplace */
3101 0, /* src_mask */
3102 0, /* dst_mask */
3103 false); /* pcrel_offset */
3104
3105 /* GNU extension to record C++ vtable member usage */
3106 static reloc_howto_type elf_mips_gnu_vtentry_howto =
3107 HOWTO (R_MIPS_GNU_VTENTRY, /* type */
3108 0, /* rightshift */
3109 4, /* size */
3110 0, /* bitsize */
3111 false, /* pc_relative */
3112 0, /* bitpos */
3113 complain_overflow_dont, /* complain_on_overflow */
3114 _bfd_elf_rel_vtable_reloc_fn, /* special_function */
3115 "R_MIPS_GNU_VTENTRY", /* name */
3116 false, /* partial_inplace */
3117 0, /* src_mask */
3118 0, /* dst_mask */
3119 false); /* pcrel_offset */
3120
3121 /* 16 bit offset for pc-relative branches. */
3123 static reloc_howto_type elf_mips_gnu_rel16_s2 =
3124 HOWTO (R_MIPS_GNU_REL16_S2, /* type */
3125 2, /* rightshift */
3126 4, /* size */
3127 16, /* bitsize */
3128 true, /* pc_relative */
3129 0, /* bitpos */
3130 complain_overflow_signed, /* complain_on_overflow */
3131 _bfd_mips_elf_generic_reloc, /* special_function */
3132 "R_MIPS_GNU_REL16_S2", /* name */
3133 true, /* partial_inplace */
3134 0x0000ffff, /* src_mask */
3135 0x0000ffff, /* dst_mask */
3136 true); /* pcrel_offset */
3137
3138 /* 16 bit offset for pc-relative branches. */
3139 static reloc_howto_type elf_mips_gnu_rela16_s2 =
3140 HOWTO (R_MIPS_GNU_REL16_S2, /* type */
3141 2, /* rightshift */
3142 4, /* size */
3143 16, /* bitsize */
3144 true, /* pc_relative */
3145 0, /* bitpos */
3146 complain_overflow_signed, /* complain_on_overflow */
3147 _bfd_mips_elf_generic_reloc, /* special_function */
3148 "R_MIPS_GNU_REL16_S2", /* name */
3149 false, /* partial_inplace */
3150 0, /* src_mask */
3151 0x0000ffff, /* dst_mask */
3152 true); /* pcrel_offset */
3153
3154 /* 32 bit pc-relative. Used for compact EH tables. */
3155 static reloc_howto_type elf_mips_gnu_pcrel32 =
3156 HOWTO (R_MIPS_PC32, /* type */
3157 0, /* rightshift */
3158 4, /* size */
3159 32, /* bitsize */
3160 true, /* pc_relative */
3161 0, /* bitpos */
3162 complain_overflow_signed, /* complain_on_overflow */
3163 _bfd_mips_elf_generic_reloc, /* special_function */
3164 "R_MIPS_PC32", /* name */
3165 true, /* partial_inplace */
3166 0xffffffff, /* src_mask */
3167 0xffffffff, /* dst_mask */
3168 true); /* pcrel_offset */
3169
3170
3171 /* Originally a VxWorks extension, but now used for other systems too. */
3173 static reloc_howto_type elf_mips_copy_howto =
3174 HOWTO (R_MIPS_COPY, /* type */
3175 0, /* rightshift */
3176 0, /* this one is variable size */
3177 0, /* bitsize */
3178 false, /* pc_relative */
3179 0, /* bitpos */
3180 complain_overflow_bitfield, /* complain_on_overflow */
3181 _bfd_mips_elf_generic_reloc, /* special_function */
3182 "R_MIPS_COPY", /* name */
3183 false, /* partial_inplace */
3184 0x0, /* src_mask */
3185 0x0, /* dst_mask */
3186 false); /* pcrel_offset */
3187
3188 /* Originally a VxWorks extension, but now used for other systems too. */
3189 static reloc_howto_type elf_mips_jump_slot_howto =
3190 HOWTO (R_MIPS_JUMP_SLOT, /* type */
3191 0, /* rightshift */
3192 8, /* size */
3193 64, /* bitsize */
3194 false, /* pc_relative */
3195 0, /* bitpos */
3196 complain_overflow_bitfield, /* complain_on_overflow */
3197 _bfd_mips_elf_generic_reloc, /* special_function */
3198 "R_MIPS_JUMP_SLOT", /* name */
3199 false, /* partial_inplace */
3200 0x0, /* src_mask */
3201 0x0, /* dst_mask */
3202 false); /* pcrel_offset */
3203
3204 /* Used in EH tables. */
3205 static reloc_howto_type elf_mips_eh_howto =
3206 HOWTO (R_MIPS_EH, /* type */
3207 0, /* rightshift */
3208 4, /* size */
3209 32, /* bitsize */
3210 false, /* pc_relative */
3211 0, /* bitpos */
3212 complain_overflow_signed, /* complain_on_overflow */
3213 _bfd_mips_elf_generic_reloc, /* special_function */
3214 "R_MIPS_EH", /* name */
3215 true, /* partial_inplace */
3216 0xffffffff, /* src_mask */
3217 0xffffffff, /* dst_mask */
3218 false); /* pcrel_offset */
3219
3220
3221 /* Swap in a MIPS 64-bit Rel reloc. */
3223
3224 static void
3225 mips_elf64_swap_reloc_in (bfd *abfd, const Elf64_Mips_External_Rel *src,
3226 Elf64_Mips_Internal_Rela *dst)
3227 {
3228 dst->r_offset = H_GET_64 (abfd, src->r_offset);
3229 dst->r_sym = H_GET_32 (abfd, src->r_sym);
3230 dst->r_ssym = H_GET_8 (abfd, src->r_ssym);
3231 dst->r_type3 = H_GET_8 (abfd, src->r_type3);
3232 dst->r_type2 = H_GET_8 (abfd, src->r_type2);
3233 dst->r_type = H_GET_8 (abfd, src->r_type);
3234 dst->r_addend = 0;
3235 }
3236
3237 /* Swap in a MIPS 64-bit Rela reloc. */
3238
3239 static void
3240 mips_elf64_swap_reloca_in (bfd *abfd, const Elf64_Mips_External_Rela *src,
3241 Elf64_Mips_Internal_Rela *dst)
3242 {
3243 dst->r_offset = H_GET_64 (abfd, src->r_offset);
3244 dst->r_sym = H_GET_32 (abfd, src->r_sym);
3245 dst->r_ssym = H_GET_8 (abfd, src->r_ssym);
3246 dst->r_type3 = H_GET_8 (abfd, src->r_type3);
3247 dst->r_type2 = H_GET_8 (abfd, src->r_type2);
3248 dst->r_type = H_GET_8 (abfd, src->r_type);
3249 dst->r_addend = H_GET_S64 (abfd, src->r_addend);
3250 }
3251
3252 /* Swap out a MIPS 64-bit Rel reloc. */
3253
3254 static void
3255 mips_elf64_swap_reloc_out (bfd *abfd, const Elf64_Mips_Internal_Rela *src,
3256 Elf64_Mips_External_Rel *dst)
3257 {
3258 H_PUT_64 (abfd, src->r_offset, dst->r_offset);
3259 H_PUT_32 (abfd, src->r_sym, dst->r_sym);
3260 H_PUT_8 (abfd, src->r_ssym, dst->r_ssym);
3261 H_PUT_8 (abfd, src->r_type3, dst->r_type3);
3262 H_PUT_8 (abfd, src->r_type2, dst->r_type2);
3263 H_PUT_8 (abfd, src->r_type, dst->r_type);
3264 }
3265
3266 /* Swap out a MIPS 64-bit Rela reloc. */
3267
3268 static void
3269 mips_elf64_swap_reloca_out (bfd *abfd, const Elf64_Mips_Internal_Rela *src,
3270 Elf64_Mips_External_Rela *dst)
3271 {
3272 H_PUT_64 (abfd, src->r_offset, dst->r_offset);
3273 H_PUT_32 (abfd, src->r_sym, dst->r_sym);
3274 H_PUT_8 (abfd, src->r_ssym, dst->r_ssym);
3275 H_PUT_8 (abfd, src->r_type3, dst->r_type3);
3276 H_PUT_8 (abfd, src->r_type2, dst->r_type2);
3277 H_PUT_8 (abfd, src->r_type, dst->r_type);
3278 H_PUT_S64 (abfd, src->r_addend, dst->r_addend);
3279 }
3280
3281 /* Swap in a MIPS 64-bit Rel reloc. */
3282
3283 static void
3284 mips_elf64_be_swap_reloc_in (bfd *abfd, const bfd_byte *src,
3285 Elf_Internal_Rela *dst)
3286 {
3287 Elf64_Mips_Internal_Rela mirel;
3288
3289 mips_elf64_swap_reloc_in (abfd,
3290 (const Elf64_Mips_External_Rel *) src,
3291 &mirel);
3292
3293 dst[0].r_offset = mirel.r_offset;
3294 dst[0].r_info = ELF64_R_INFO (mirel.r_sym, mirel.r_type);
3295 dst[0].r_addend = 0;
3296 dst[1].r_offset = mirel.r_offset;
3297 dst[1].r_info = ELF64_R_INFO (mirel.r_ssym, mirel.r_type2);
3298 dst[1].r_addend = 0;
3299 dst[2].r_offset = mirel.r_offset;
3300 dst[2].r_info = ELF64_R_INFO (STN_UNDEF, mirel.r_type3);
3301 dst[2].r_addend = 0;
3302 }
3303
3304 /* Swap in a MIPS 64-bit Rela reloc. */
3305
3306 static void
3307 mips_elf64_be_swap_reloca_in (bfd *abfd, const bfd_byte *src,
3308 Elf_Internal_Rela *dst)
3309 {
3310 Elf64_Mips_Internal_Rela mirela;
3311
3312 mips_elf64_swap_reloca_in (abfd,
3313 (const Elf64_Mips_External_Rela *) src,
3314 &mirela);
3315
3316 dst[0].r_offset = mirela.r_offset;
3317 dst[0].r_info = ELF64_R_INFO (mirela.r_sym, mirela.r_type);
3318 dst[0].r_addend = mirela.r_addend;
3319 dst[1].r_offset = mirela.r_offset;
3320 dst[1].r_info = ELF64_R_INFO (mirela.r_ssym, mirela.r_type2);
3321 dst[1].r_addend = 0;
3322 dst[2].r_offset = mirela.r_offset;
3323 dst[2].r_info = ELF64_R_INFO (STN_UNDEF, mirela.r_type3);
3324 dst[2].r_addend = 0;
3325 }
3326
3327 /* Swap out a MIPS 64-bit Rel reloc. */
3328
3329 static void
3330 mips_elf64_be_swap_reloc_out (bfd *abfd, const Elf_Internal_Rela *src,
3331 bfd_byte *dst)
3332 {
3333 Elf64_Mips_Internal_Rela mirel;
3334
3335 mirel.r_offset = src[0].r_offset;
3336 BFD_ASSERT(src[0].r_offset == src[1].r_offset);
3337 BFD_ASSERT(src[0].r_offset == src[2].r_offset);
3338
3339 mirel.r_type = ELF64_MIPS_R_TYPE (src[0].r_info);
3340 mirel.r_sym = ELF64_R_SYM (src[0].r_info);
3341 mirel.r_type2 = ELF64_MIPS_R_TYPE (src[1].r_info);
3342 mirel.r_ssym = ELF64_MIPS_R_SSYM (src[1].r_info);
3343 mirel.r_type3 = ELF64_MIPS_R_TYPE (src[2].r_info);
3344
3345 mips_elf64_swap_reloc_out (abfd, &mirel,
3346 (Elf64_Mips_External_Rel *) dst);
3347 }
3348
3349 /* Swap out a MIPS 64-bit Rela reloc. */
3350
3351 static void
3352 mips_elf64_be_swap_reloca_out (bfd *abfd, const Elf_Internal_Rela *src,
3353 bfd_byte *dst)
3354 {
3355 Elf64_Mips_Internal_Rela mirela;
3356
3357 mirela.r_offset = src[0].r_offset;
3358 BFD_ASSERT(src[0].r_offset == src[1].r_offset);
3359 BFD_ASSERT(src[0].r_offset == src[2].r_offset);
3360
3361 mirela.r_type = ELF64_MIPS_R_TYPE (src[0].r_info);
3362 mirela.r_sym = ELF64_R_SYM (src[0].r_info);
3363 mirela.r_addend = src[0].r_addend;
3364 BFD_ASSERT(src[1].r_addend == 0);
3365 BFD_ASSERT(src[2].r_addend == 0);
3366
3367 mirela.r_type2 = ELF64_MIPS_R_TYPE (src[1].r_info);
3368 mirela.r_ssym = ELF64_MIPS_R_SSYM (src[1].r_info);
3369 mirela.r_type3 = ELF64_MIPS_R_TYPE (src[2].r_info);
3370
3371 mips_elf64_swap_reloca_out (abfd, &mirela,
3372 (Elf64_Mips_External_Rela *) dst);
3373 }
3374
3375 /* Set the GP value for OUTPUT_BFD. Returns FALSE if this is a
3377 dangerous relocation. */
3378
3379 static bool
3380 mips_elf64_assign_gp (bfd *output_bfd, bfd_vma *pgp)
3381 {
3382 unsigned int count;
3383 asymbol **sym;
3384 unsigned int i;
3385
3386 /* If we've already figured out what GP will be, just return it. */
3387 *pgp = _bfd_get_gp_value (output_bfd);
3388 if (*pgp)
3389 return true;
3390
3391 count = bfd_get_symcount (output_bfd);
3392 sym = bfd_get_outsymbols (output_bfd);
3393
3394 /* The linker script will have created a symbol named `_gp' with the
3395 appropriate value. */
3396 if (sym == NULL)
3397 i = count;
3398 else
3399 {
3400 for (i = 0; i < count; i++, sym++)
3401 {
3402 register const char *name;
3403
3404 name = bfd_asymbol_name (*sym);
3405 if (*name == '_' && strcmp (name, "_gp") == 0)
3406 {
3407 *pgp = bfd_asymbol_value (*sym);
3408 _bfd_set_gp_value (output_bfd, *pgp);
3409 break;
3410 }
3411 }
3412 }
3413
3414 if (i >= count)
3415 {
3416 /* Only get the error once. */
3417 *pgp = 4;
3418 _bfd_set_gp_value (output_bfd, *pgp);
3419 return false;
3420 }
3421
3422 return true;
3423 }
3424
3425 /* We have to figure out the gp value, so that we can adjust the
3426 symbol value correctly. We look up the symbol _gp in the output
3427 BFD. If we can't find it, we're stuck. We cache it in the ELF
3428 target data. We don't need to adjust the symbol value for an
3429 external symbol if we are producing relocatable output. */
3430
3431 static bfd_reloc_status_type
3432 mips_elf64_final_gp (bfd *output_bfd, asymbol *symbol, bool relocatable,
3433 char **error_message, bfd_vma *pgp)
3434 {
3435 if (output_bfd == NULL)
3436 {
3437 *pgp = 0;
3438 return bfd_reloc_undefined;
3439 }
3440
3441 *pgp = _bfd_get_gp_value (output_bfd);
3442 if (*pgp == 0
3443 && (! relocatable
3444 || (symbol->flags & BSF_SECTION_SYM) != 0))
3445 {
3446 if (relocatable)
3447 {
3448 /* Make up a value. */
3449 *pgp = symbol->section->output_section->vma /*+ 0x4000*/;
3450 _bfd_set_gp_value (output_bfd, *pgp);
3451 }
3452 else if (!mips_elf64_assign_gp (output_bfd, pgp))
3453 {
3454 *error_message =
3455 (char *) _("GP relative relocation when _gp not defined");
3456 return bfd_reloc_dangerous;
3457 }
3458 }
3459
3460 return bfd_reloc_ok;
3461 }
3462
3463 /* Do a R_MIPS_GPREL16 relocation. This is a 16 bit value which must
3464 become the offset from the gp register. */
3465
3466 static bfd_reloc_status_type
3467 mips_elf64_gprel16_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
3468 void *data, asection *input_section, bfd *output_bfd,
3469 char **error_message)
3470 {
3471 bool relocatable;
3472 bfd_reloc_status_type ret;
3473 bfd_vma gp;
3474
3475 /* If we're relocating, and this is an external symbol, we don't want
3476 to change anything. */
3477 if (output_bfd != NULL
3478 && (symbol->flags & BSF_SECTION_SYM) == 0
3479 && (symbol->flags & BSF_LOCAL) != 0)
3480 {
3481 reloc_entry->address += input_section->output_offset;
3482 return bfd_reloc_ok;
3483 }
3484
3485 if (output_bfd != NULL)
3486 relocatable = true;
3487 else
3488 {
3489 relocatable = false;
3490 output_bfd = input_section->output_section->owner;
3491 }
3492
3493 ret = mips_elf64_final_gp (output_bfd, symbol, relocatable, error_message,
3494 &gp);
3495 if (ret != bfd_reloc_ok)
3496 return ret;
3497
3498 return _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
3499 input_section, relocatable,
3500 data, gp);
3501 }
3502
3503 /* Do a R_MIPS_LITERAL relocation. */
3504
3505 static bfd_reloc_status_type
3506 mips_elf64_literal_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
3507 void *data, asection *input_section, bfd *output_bfd,
3508 char **error_message)
3509 {
3510 bool relocatable;
3511 bfd_reloc_status_type ret;
3512 bfd_vma gp;
3513
3514 /* R_MIPS_LITERAL relocations are defined for local symbols only. */
3515 if (output_bfd != NULL
3516 && (symbol->flags & BSF_SECTION_SYM) == 0
3517 && (symbol->flags & BSF_LOCAL) != 0)
3518 {
3519 *error_message = (char *)
3520 _("literal relocation occurs for an external symbol");
3521 return bfd_reloc_outofrange;
3522 }
3523
3524 /* FIXME: The entries in the .lit8 and .lit4 sections should be merged. */
3525 if (output_bfd != NULL)
3526 relocatable = true;
3527 else
3528 {
3529 relocatable = false;
3530 output_bfd = input_section->output_section->owner;
3531 }
3532
3533 ret = mips_elf64_final_gp (output_bfd, symbol, relocatable, error_message,
3534 &gp);
3535 if (ret != bfd_reloc_ok)
3536 return ret;
3537
3538 return _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
3539 input_section, relocatable,
3540 data, gp);
3541 }
3542
3543 /* Do a R_MIPS_GPREL32 relocation. This is a 32 bit value which must
3544 become the offset from the gp register. */
3545
3546 static bfd_reloc_status_type
3547 mips_elf64_gprel32_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
3548 void *data, asection *input_section, bfd *output_bfd,
3549 char **error_message)
3550 {
3551 bool relocatable;
3552 bfd_reloc_status_type ret;
3553 bfd_vma gp;
3554 bfd_vma relocation;
3555 bfd_vma val;
3556
3557 /* R_MIPS_GPREL32 relocations are defined for local symbols only. */
3558 if (output_bfd != NULL
3559 && (symbol->flags & BSF_SECTION_SYM) == 0
3560 && (symbol->flags & BSF_LOCAL) != 0)
3561 {
3562 *error_message = (char *)
3563 _("32bits gp relative relocation occurs for an external symbol");
3564 return bfd_reloc_outofrange;
3565 }
3566
3567 if (output_bfd != NULL)
3568 relocatable = true;
3569 else
3570 {
3571 relocatable = false;
3572 output_bfd = input_section->output_section->owner;
3573 }
3574
3575 ret = mips_elf64_final_gp (output_bfd, symbol, relocatable,
3576 error_message, &gp);
3577 if (ret != bfd_reloc_ok)
3578 return ret;
3579
3580 if (bfd_is_com_section (symbol->section))
3581 relocation = 0;
3582 else
3583 relocation = symbol->value;
3584
3585 relocation += symbol->section->output_section->vma;
3586 relocation += symbol->section->output_offset;
3587
3588 if (!_bfd_mips_reloc_offset_in_range (abfd, input_section, reloc_entry,
3589 check_inplace))
3590 return bfd_reloc_outofrange;
3591
3592 /* Set val to the offset into the section or symbol. */
3593 val = reloc_entry->addend;
3594
3595 if (reloc_entry->howto->partial_inplace)
3596 val += bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
3597
3598 /* Adjust val for the final section location and GP value. If we
3599 are producing relocatable output, we don't want to do this for
3600 an external symbol. */
3601 if (! relocatable
3602 || (symbol->flags & BSF_SECTION_SYM) != 0)
3603 val += relocation - gp;
3604
3605 if (reloc_entry->howto->partial_inplace)
3606 bfd_put_32 (abfd, val, (bfd_byte *) data + reloc_entry->address);
3607 else
3608 reloc_entry->addend = val;
3609
3610 if (relocatable)
3611 reloc_entry->address += input_section->output_offset;
3612
3613 return bfd_reloc_ok;
3614 }
3615
3616 /* Do a R_MIPS_SHIFT6 relocation. The MSB of the shift is stored at bit 2,
3617 the rest is at bits 6-10. The bitpos already got right by the howto. */
3618
3619 static bfd_reloc_status_type
3620 mips_elf64_shift6_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
3621 void *data, asection *input_section, bfd *output_bfd,
3622 char **error_message)
3623 {
3624 if (reloc_entry->howto->partial_inplace)
3625 {
3626 reloc_entry->addend = ((reloc_entry->addend & 0x00007c0)
3627 | (reloc_entry->addend & 0x00000800) >> 9);
3628 }
3629
3630 return _bfd_mips_elf_generic_reloc (abfd, reloc_entry, symbol, data,
3631 input_section, output_bfd,
3632 error_message);
3633 }
3634
3635 /* Handle a mips16 GP relative reloc. */
3636
3637 static bfd_reloc_status_type
3638 mips16_gprel_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
3639 void *data, asection *input_section, bfd *output_bfd,
3640 char **error_message)
3641 {
3642 bool relocatable;
3643 bfd_reloc_status_type ret;
3644 bfd_byte *location;
3645 bfd_vma gp;
3646
3647 /* If we're relocating, and this is an external symbol, we don't want
3648 to change anything. */
3649 if (output_bfd != NULL
3650 && (symbol->flags & BSF_SECTION_SYM) == 0
3651 && (symbol->flags & BSF_LOCAL) != 0)
3652 {
3653 reloc_entry->address += input_section->output_offset;
3654 return bfd_reloc_ok;
3655 }
3656
3657 if (output_bfd != NULL)
3658 relocatable = true;
3659 else
3660 {
3661 relocatable = false;
3662 output_bfd = input_section->output_section->owner;
3663 }
3664
3665 ret = mips_elf64_final_gp (output_bfd, symbol, relocatable, error_message,
3666 &gp);
3667 if (ret != bfd_reloc_ok)
3668 return ret;
3669
3670 if (!_bfd_mips_reloc_offset_in_range (abfd, input_section, reloc_entry,
3671 check_shuffle))
3672 return bfd_reloc_outofrange;
3673
3674 location = (bfd_byte *) data + reloc_entry->address;
3675 _bfd_mips_elf_reloc_unshuffle (abfd, reloc_entry->howto->type, false,
3676 location);
3677 ret = _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
3678 input_section, relocatable,
3679 data, gp);
3680 _bfd_mips_elf_reloc_shuffle (abfd, reloc_entry->howto->type, !relocatable,
3681 location);
3682
3683 return ret;
3684 }
3685
3686 /* A mapping from BFD reloc types to MIPS ELF reloc types. */
3688
3689 struct elf_reloc_map {
3690 bfd_reloc_code_real_type bfd_val;
3691 enum elf_mips_reloc_type elf_val;
3692 };
3693
3694 static const struct elf_reloc_map mips_reloc_map[] =
3695 {
3696 { BFD_RELOC_NONE, R_MIPS_NONE },
3697 { BFD_RELOC_MIPS_16, R_MIPS_16 },
3698 { BFD_RELOC_16, R_MIPS_REL16 },
3699 { BFD_RELOC_32, R_MIPS_32 },
3700 /* There is no BFD reloc for R_MIPS_REL32. */
3701 { BFD_RELOC_64, R_MIPS_64 },
3702 { BFD_RELOC_CTOR, R_MIPS_64 },
3703 { BFD_RELOC_16_PCREL_S2, R_MIPS_PC16 },
3704 { BFD_RELOC_HI16_S, R_MIPS_HI16 },
3705 { BFD_RELOC_LO16, R_MIPS_LO16 },
3706 { BFD_RELOC_GPREL16, R_MIPS_GPREL16 },
3707 { BFD_RELOC_GPREL32, R_MIPS_GPREL32 },
3708 { BFD_RELOC_MIPS_JMP, R_MIPS_26 },
3709 { BFD_RELOC_MIPS_LITERAL, R_MIPS_LITERAL },
3710 { BFD_RELOC_MIPS_GOT16, R_MIPS_GOT16 },
3711 { BFD_RELOC_MIPS_CALL16, R_MIPS_CALL16 },
3712 { BFD_RELOC_MIPS_SHIFT5, R_MIPS_SHIFT5 },
3713 { BFD_RELOC_MIPS_SHIFT6, R_MIPS_SHIFT6 },
3714 { BFD_RELOC_MIPS_GOT_DISP, R_MIPS_GOT_DISP },
3715 { BFD_RELOC_MIPS_GOT_PAGE, R_MIPS_GOT_PAGE },
3716 { BFD_RELOC_MIPS_GOT_OFST, R_MIPS_GOT_OFST },
3717 { BFD_RELOC_MIPS_GOT_HI16, R_MIPS_GOT_HI16 },
3718 { BFD_RELOC_MIPS_GOT_LO16, R_MIPS_GOT_LO16 },
3719 { BFD_RELOC_MIPS_SUB, R_MIPS_SUB },
3720 { BFD_RELOC_MIPS_INSERT_A, R_MIPS_INSERT_A },
3721 { BFD_RELOC_MIPS_INSERT_B, R_MIPS_INSERT_B },
3722 { BFD_RELOC_MIPS_DELETE, R_MIPS_DELETE },
3723 { BFD_RELOC_MIPS_HIGHEST, R_MIPS_HIGHEST },
3724 { BFD_RELOC_MIPS_HIGHER, R_MIPS_HIGHER },
3725 { BFD_RELOC_MIPS_CALL_HI16, R_MIPS_CALL_HI16 },
3726 { BFD_RELOC_MIPS_CALL_LO16, R_MIPS_CALL_LO16 },
3727 { BFD_RELOC_MIPS_SCN_DISP, R_MIPS_SCN_DISP },
3728 /* Use of R_MIPS_ADD_IMMEDIATE and R_MIPS_PJUMP is deprecated. */
3729 { BFD_RELOC_MIPS_RELGOT, R_MIPS_RELGOT },
3730 { BFD_RELOC_MIPS_JALR, R_MIPS_JALR },
3731 { BFD_RELOC_MIPS_TLS_DTPMOD32, R_MIPS_TLS_DTPMOD32 },
3732 { BFD_RELOC_MIPS_TLS_DTPREL32, R_MIPS_TLS_DTPREL32 },
3733 { BFD_RELOC_MIPS_TLS_DTPMOD64, R_MIPS_TLS_DTPMOD64 },
3734 { BFD_RELOC_MIPS_TLS_DTPREL64, R_MIPS_TLS_DTPREL64 },
3735 { BFD_RELOC_MIPS_TLS_GD, R_MIPS_TLS_GD },
3736 { BFD_RELOC_MIPS_TLS_LDM, R_MIPS_TLS_LDM },
3737 { BFD_RELOC_MIPS_TLS_DTPREL_HI16, R_MIPS_TLS_DTPREL_HI16 },
3738 { BFD_RELOC_MIPS_TLS_DTPREL_LO16, R_MIPS_TLS_DTPREL_LO16 },
3739 { BFD_RELOC_MIPS_TLS_GOTTPREL, R_MIPS_TLS_GOTTPREL },
3740 { BFD_RELOC_MIPS_TLS_TPREL32, R_MIPS_TLS_TPREL32 },
3741 { BFD_RELOC_MIPS_TLS_TPREL64, R_MIPS_TLS_TPREL64 },
3742 { BFD_RELOC_MIPS_TLS_TPREL_HI16, R_MIPS_TLS_TPREL_HI16 },
3743 { BFD_RELOC_MIPS_TLS_TPREL_LO16, R_MIPS_TLS_TPREL_LO16 },
3744 { BFD_RELOC_MIPS_21_PCREL_S2, R_MIPS_PC21_S2 },
3745 { BFD_RELOC_MIPS_26_PCREL_S2, R_MIPS_PC26_S2 },
3746 { BFD_RELOC_MIPS_18_PCREL_S3, R_MIPS_PC18_S3 },
3747 { BFD_RELOC_MIPS_19_PCREL_S2, R_MIPS_PC19_S2 },
3748 { BFD_RELOC_HI16_S_PCREL, R_MIPS_PCHI16 },
3749 { BFD_RELOC_LO16_PCREL, R_MIPS_PCLO16 }
3750 };
3751
3752 static const struct elf_reloc_map mips16_reloc_map[] =
3753 {
3754 { BFD_RELOC_MIPS16_JMP, R_MIPS16_26 - R_MIPS16_min },
3755 { BFD_RELOC_MIPS16_GPREL, R_MIPS16_GPREL - R_MIPS16_min },
3756 { BFD_RELOC_MIPS16_GOT16, R_MIPS16_GOT16 - R_MIPS16_min },
3757 { BFD_RELOC_MIPS16_CALL16, R_MIPS16_CALL16 - R_MIPS16_min },
3758 { BFD_RELOC_MIPS16_HI16_S, R_MIPS16_HI16 - R_MIPS16_min },
3759 { BFD_RELOC_MIPS16_LO16, R_MIPS16_LO16 - R_MIPS16_min },
3760 { BFD_RELOC_MIPS16_TLS_GD, R_MIPS16_TLS_GD - R_MIPS16_min },
3761 { BFD_RELOC_MIPS16_TLS_LDM, R_MIPS16_TLS_LDM - R_MIPS16_min },
3762 { BFD_RELOC_MIPS16_TLS_DTPREL_HI16,
3763 R_MIPS16_TLS_DTPREL_HI16 - R_MIPS16_min },
3764 { BFD_RELOC_MIPS16_TLS_DTPREL_LO16,
3765 R_MIPS16_TLS_DTPREL_LO16 - R_MIPS16_min },
3766 { BFD_RELOC_MIPS16_TLS_GOTTPREL, R_MIPS16_TLS_GOTTPREL - R_MIPS16_min },
3767 { BFD_RELOC_MIPS16_TLS_TPREL_HI16, R_MIPS16_TLS_TPREL_HI16 - R_MIPS16_min },
3768 { BFD_RELOC_MIPS16_TLS_TPREL_LO16, R_MIPS16_TLS_TPREL_LO16 - R_MIPS16_min },
3769 { BFD_RELOC_MIPS16_16_PCREL_S1, R_MIPS16_PC16_S1 - R_MIPS16_min }
3770 };
3771
3772 static const struct elf_reloc_map micromips_reloc_map[] =
3773 {
3774 { BFD_RELOC_MICROMIPS_JMP, R_MICROMIPS_26_S1 - R_MICROMIPS_min },
3775 { BFD_RELOC_MICROMIPS_HI16_S, R_MICROMIPS_HI16 - R_MICROMIPS_min },
3776 { BFD_RELOC_MICROMIPS_LO16, R_MICROMIPS_LO16 - R_MICROMIPS_min },
3777 { BFD_RELOC_MICROMIPS_GPREL16, R_MICROMIPS_GPREL16 - R_MICROMIPS_min },
3778 { BFD_RELOC_MICROMIPS_LITERAL, R_MICROMIPS_LITERAL - R_MICROMIPS_min },
3779 { BFD_RELOC_MICROMIPS_GOT16, R_MICROMIPS_GOT16 - R_MICROMIPS_min },
3780 { BFD_RELOC_MICROMIPS_7_PCREL_S1, R_MICROMIPS_PC7_S1 - R_MICROMIPS_min },
3781 { BFD_RELOC_MICROMIPS_10_PCREL_S1, R_MICROMIPS_PC10_S1 - R_MICROMIPS_min },
3782 { BFD_RELOC_MICROMIPS_16_PCREL_S1, R_MICROMIPS_PC16_S1 - R_MICROMIPS_min },
3783 { BFD_RELOC_MICROMIPS_CALL16, R_MICROMIPS_CALL16 - R_MICROMIPS_min },
3784 { BFD_RELOC_MICROMIPS_GOT_DISP, R_MICROMIPS_GOT_DISP - R_MICROMIPS_min },
3785 { BFD_RELOC_MICROMIPS_GOT_PAGE, R_MICROMIPS_GOT_PAGE - R_MICROMIPS_min },
3786 { BFD_RELOC_MICROMIPS_GOT_OFST, R_MICROMIPS_GOT_OFST - R_MICROMIPS_min },
3787 { BFD_RELOC_MICROMIPS_GOT_HI16, R_MICROMIPS_GOT_HI16 - R_MICROMIPS_min },
3788 { BFD_RELOC_MICROMIPS_GOT_LO16, R_MICROMIPS_GOT_LO16 - R_MICROMIPS_min },
3789 { BFD_RELOC_MICROMIPS_SUB, R_MICROMIPS_SUB - R_MICROMIPS_min },
3790 { BFD_RELOC_MICROMIPS_HIGHER, R_MICROMIPS_HIGHER - R_MICROMIPS_min },
3791 { BFD_RELOC_MICROMIPS_HIGHEST, R_MICROMIPS_HIGHEST - R_MICROMIPS_min },
3792 { BFD_RELOC_MICROMIPS_CALL_HI16, R_MICROMIPS_CALL_HI16 - R_MICROMIPS_min },
3793 { BFD_RELOC_MICROMIPS_CALL_LO16, R_MICROMIPS_CALL_LO16 - R_MICROMIPS_min },
3794 { BFD_RELOC_MICROMIPS_SCN_DISP, R_MICROMIPS_SCN_DISP - R_MICROMIPS_min },
3795 { BFD_RELOC_MICROMIPS_JALR, R_MICROMIPS_JALR - R_MICROMIPS_min },
3796 /* There is no BFD reloc for R_MICROMIPS_HI0_LO16. */
3797 { BFD_RELOC_MICROMIPS_TLS_GD, R_MICROMIPS_TLS_GD - R_MICROMIPS_min },
3798 { BFD_RELOC_MICROMIPS_TLS_LDM, R_MICROMIPS_TLS_LDM - R_MICROMIPS_min },
3799 { BFD_RELOC_MICROMIPS_TLS_DTPREL_HI16,
3800 R_MICROMIPS_TLS_DTPREL_HI16 - R_MICROMIPS_min },
3801 { BFD_RELOC_MICROMIPS_TLS_DTPREL_LO16,
3802 R_MICROMIPS_TLS_DTPREL_LO16 - R_MICROMIPS_min },
3803 { BFD_RELOC_MICROMIPS_TLS_GOTTPREL,
3804 R_MICROMIPS_TLS_GOTTPREL - R_MICROMIPS_min },
3805 { BFD_RELOC_MICROMIPS_TLS_TPREL_HI16,
3806 R_MICROMIPS_TLS_TPREL_HI16 - R_MICROMIPS_min },
3807 { BFD_RELOC_MICROMIPS_TLS_TPREL_LO16,
3808 R_MICROMIPS_TLS_TPREL_LO16 - R_MICROMIPS_min },
3809 /* There is no BFD reloc for R_MICROMIPS_GPREL7_S2. */
3810 /* There is no BFD reloc for R_MICROMIPS_PC23_S2. */
3811 };
3812 /* Given a BFD reloc type, return a howto structure. */
3813
3814 static reloc_howto_type *
3815 bfd_elf64_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
3816 bfd_reloc_code_real_type code)
3817 {
3818 unsigned int i;
3819 /* FIXME: We default to RELA here instead of choosing the right
3820 relocation variant. */
3821 reloc_howto_type *howto_table = mips_elf64_howto_table_rela;
3822 reloc_howto_type *howto16_table = mips16_elf64_howto_table_rela;
3823 reloc_howto_type *howto_micromips_table = micromips_elf64_howto_table_rela;
3824
3825 for (i = 0; i < sizeof (mips_reloc_map) / sizeof (struct elf_reloc_map);
3826 i++)
3827 {
3828 if (mips_reloc_map[i].bfd_val == code)
3829 return &howto_table[(int) mips_reloc_map[i].elf_val];
3830 }
3831
3832 for (i = 0; i < sizeof (mips16_reloc_map) / sizeof (struct elf_reloc_map);
3833 i++)
3834 {
3835 if (mips16_reloc_map[i].bfd_val == code)
3836 return &howto16_table[(int) mips16_reloc_map[i].elf_val];
3837 }
3838
3839 for (i = 0; i < sizeof (micromips_reloc_map) / sizeof (struct elf_reloc_map);
3840 i++)
3841 {
3842 if (micromips_reloc_map[i].bfd_val == code)
3843 return &howto_micromips_table[(int) micromips_reloc_map[i].elf_val];
3844 }
3845
3846 switch (code)
3847 {
3848 case BFD_RELOC_VTABLE_INHERIT:
3849 return &elf_mips_gnu_vtinherit_howto;
3850 case BFD_RELOC_VTABLE_ENTRY:
3851 return &elf_mips_gnu_vtentry_howto;
3852 case BFD_RELOC_32_PCREL:
3853 return &elf_mips_gnu_pcrel32;
3854 case BFD_RELOC_MIPS_EH:
3855 return &elf_mips_eh_howto;
3856 case BFD_RELOC_MIPS_COPY:
3857 return &elf_mips_copy_howto;
3858 case BFD_RELOC_MIPS_JUMP_SLOT:
3859 return &elf_mips_jump_slot_howto;
3860 default:
3861 bfd_set_error (bfd_error_bad_value);
3862 return NULL;
3863 }
3864 }
3865
3866 static reloc_howto_type *
3867 bfd_elf64_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
3868 const char *r_name)
3869 {
3870 unsigned int i;
3871
3872 for (i = 0;
3873 i < (sizeof (mips_elf64_howto_table_rela)
3874 / sizeof (mips_elf64_howto_table_rela[0])); i++)
3875 if (mips_elf64_howto_table_rela[i].name != NULL
3876 && strcasecmp (mips_elf64_howto_table_rela[i].name, r_name) == 0)
3877 return &mips_elf64_howto_table_rela[i];
3878
3879 for (i = 0;
3880 i < (sizeof (mips16_elf64_howto_table_rela)
3881 / sizeof (mips16_elf64_howto_table_rela[0]));
3882 i++)
3883 if (mips16_elf64_howto_table_rela[i].name != NULL
3884 && strcasecmp (mips16_elf64_howto_table_rela[i].name, r_name) == 0)
3885 return &mips16_elf64_howto_table_rela[i];
3886
3887 for (i = 0;
3888 i < (sizeof (micromips_elf64_howto_table_rela)
3889 / sizeof (micromips_elf64_howto_table_rela[0]));
3890 i++)
3891 if (micromips_elf64_howto_table_rela[i].name != NULL
3892 && strcasecmp (micromips_elf64_howto_table_rela[i].name, r_name) == 0)
3893 return µmips_elf64_howto_table_rela[i];
3894
3895 if (strcasecmp (elf_mips_gnu_vtinherit_howto.name, r_name) == 0)
3896 return &elf_mips_gnu_vtinherit_howto;
3897 if (strcasecmp (elf_mips_gnu_vtentry_howto.name, r_name) == 0)
3898 return &elf_mips_gnu_vtentry_howto;
3899 if (strcasecmp (elf_mips_gnu_rel16_s2.name, r_name) == 0)
3900 return &elf_mips_gnu_rel16_s2;
3901 if (strcasecmp (elf_mips_gnu_rela16_s2.name, r_name) == 0)
3902 return &elf_mips_gnu_rela16_s2;
3903 if (strcasecmp (elf_mips_gnu_pcrel32.name, r_name) == 0)
3904 return &elf_mips_gnu_pcrel32;
3905 if (strcasecmp (elf_mips_eh_howto.name, r_name) == 0)
3906 return &elf_mips_eh_howto;
3907 if (strcasecmp (elf_mips_copy_howto.name, r_name) == 0)
3908 return &elf_mips_copy_howto;
3909 if (strcasecmp (elf_mips_jump_slot_howto.name, r_name) == 0)
3910 return &elf_mips_jump_slot_howto;
3911
3912 return NULL;
3913 }
3914
3915 /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure. */
3916
3917 static reloc_howto_type *
3918 mips_elf64_rtype_to_howto (bfd *abfd, unsigned int r_type, bool rela_p)
3919 {
3920 reloc_howto_type *howto = NULL;
3921
3922 switch (r_type)
3923 {
3924 case R_MIPS_GNU_VTINHERIT:
3925 return &elf_mips_gnu_vtinherit_howto;
3926 case R_MIPS_GNU_VTENTRY:
3927 return &elf_mips_gnu_vtentry_howto;
3928 case R_MIPS_GNU_REL16_S2:
3929 if (rela_p)
3930 return &elf_mips_gnu_rela16_s2;
3931 else
3932 return &elf_mips_gnu_rel16_s2;
3933 case R_MIPS_PC32:
3934 return &elf_mips_gnu_pcrel32;
3935 case R_MIPS_EH:
3936 return &elf_mips_eh_howto;
3937 case R_MIPS_COPY:
3938 return &elf_mips_copy_howto;
3939 case R_MIPS_JUMP_SLOT:
3940 return &elf_mips_jump_slot_howto;
3941 default:
3942 if (r_type >= R_MICROMIPS_min && r_type < R_MICROMIPS_max)
3943 {
3944 if (rela_p)
3945 howto
3946 = µmips_elf64_howto_table_rela[r_type - R_MICROMIPS_min];
3947 else
3948 howto
3949 = µmips_elf64_howto_table_rel[r_type - R_MICROMIPS_min];
3950 }
3951 if (r_type >= R_MIPS16_min && r_type < R_MIPS16_max)
3952 {
3953 if (rela_p)
3954 howto = &mips16_elf64_howto_table_rela[r_type - R_MIPS16_min];
3955 else
3956 howto = &mips16_elf64_howto_table_rel[r_type - R_MIPS16_min];
3957 }
3958 if (r_type < R_MIPS_max)
3959 {
3960 if (rela_p)
3961 howto = &mips_elf64_howto_table_rela[r_type];
3962 else
3963 howto = &mips_elf64_howto_table_rel[r_type];
3964 }
3965 if (howto != NULL && howto->name != NULL)
3966 return howto;
3967
3968 _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
3969 abfd, r_type);
3970 bfd_set_error (bfd_error_bad_value);
3971 return NULL;
3972 }
3973 }
3974
3975 /* Prevent relocation handling by bfd for MIPS ELF64. */
3976
3977 static bool
3978 mips_elf64_info_to_howto_rela (bfd *abfd,
3979 arelent *cache_ptr ATTRIBUTE_UNUSED,
3980 Elf_Internal_Rela *dst)
3981 {
3982 unsigned int r_type = ELF32_R_TYPE (dst->r_info);
3983 /* xgettext:c-format */
3984 _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
3985 abfd, r_type);
3986 bfd_set_error (bfd_error_bad_value);
3987 return false;
3988 }
3989
3990 /* Since each entry in an SHT_REL or SHT_RELA section can represent up
3991 to three relocs, we must tell the user to allocate more space. */
3992
3993 static long
3994 mips_elf64_get_dynamic_reloc_upper_bound (bfd *abfd)
3995 {
3996 return _bfd_elf_get_dynamic_reloc_upper_bound (abfd) * 3;
3997 }
3998
3999 /* Read the relocations from one reloc section. This is mostly copied
4000 from elfcode.h, except for the changes to expand one external
4001 relocation to 3 internal ones. To reduce processing effort we
4002 could discard those R_MIPS_NONE relocations that occupy the second
4003 and the third entry of a triplet, as `mips_elf64_write_rel' and
4004 `mips_elf64_write_rela' recreate them in output automagically,
4005 however that would also remove them from `objdump -r' output,
4006 breaking a long-established tradition and likely confusing people. */
4007
4008 static bool
4009 mips_elf64_slurp_one_reloc_table (bfd *abfd, asection *asect,
4010 Elf_Internal_Shdr *rel_hdr,
4011 bfd_size_type reloc_count,
4012 arelent *relents, asymbol **symbols,
4013 bool dynamic)
4014 {
4015 void *allocated;
4016 bfd_byte *native_relocs;
4017 unsigned int symcount;
4018 arelent *relent;
4019 bfd_vma i;
4020 int entsize;
4021 bool rela_p;
4022
4023 if (bfd_seek (abfd, rel_hdr->sh_offset, SEEK_SET) != 0)
4024 return false;
4025 allocated = _bfd_malloc_and_read (abfd, rel_hdr->sh_size, rel_hdr->sh_size);
4026 if (allocated == NULL)
4027 return false;
4028
4029 native_relocs = allocated;
4030
4031 entsize = rel_hdr->sh_entsize;
4032 BFD_ASSERT (entsize == sizeof (Elf64_Mips_External_Rel)
4033 || entsize == sizeof (Elf64_Mips_External_Rela));
4034
4035 if (entsize == sizeof (Elf64_Mips_External_Rel))
4036 rela_p = false;
4037 else
4038 rela_p = true;
4039
4040 if (dynamic)
4041 symcount = bfd_get_dynamic_symcount (abfd);
4042 else
4043 symcount = bfd_get_symcount (abfd);
4044
4045 for (i = 0, relent = relents;
4046 i < reloc_count;
4047 i++, native_relocs += entsize)
4048 {
4049 Elf64_Mips_Internal_Rela rela;
4050 bool used_sym, used_ssym;
4051 int ir;
4052
4053 if (entsize == sizeof (Elf64_Mips_External_Rela))
4054 mips_elf64_swap_reloca_in (abfd,
4055 (Elf64_Mips_External_Rela *) native_relocs,
4056 &rela);
4057 else
4058 mips_elf64_swap_reloc_in (abfd,
4059 (Elf64_Mips_External_Rel *) native_relocs,
4060 &rela);
4061
4062 /* Each entry represents exactly three actual relocations. */
4063
4064 used_sym = false;
4065 used_ssym = false;
4066 for (ir = 0; ir < 3; ir++)
4067 {
4068 enum elf_mips_reloc_type type;
4069
4070 switch (ir)
4071 {
4072 default:
4073 abort ();
4074 case 0:
4075 type = (enum elf_mips_reloc_type) rela.r_type;
4076 break;
4077 case 1:
4078 type = (enum elf_mips_reloc_type) rela.r_type2;
4079 break;
4080 case 2:
4081 type = (enum elf_mips_reloc_type) rela.r_type3;
4082 break;
4083 }
4084
4085 /* Some types require symbols, whereas some do not. */
4086 relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
4087 switch (type)
4088 {
4089 case R_MIPS_NONE:
4090 case R_MIPS_LITERAL:
4091 case R_MIPS_INSERT_A:
4092 case R_MIPS_INSERT_B:
4093 case R_MIPS_DELETE:
4094 break;
4095
4096 default:
4097 if (! used_sym)
4098 {
4099 if (rela.r_sym == STN_UNDEF)
4100 ;
4101 else if (rela.r_sym > symcount)
4102 {
4103 _bfd_error_handler
4104 /* xgettext:c-format */
4105 (_("%pB(%pA): relocation %" PRIu64
4106 " has invalid symbol index %ld"),
4107 abfd, asect, (uint64_t) i, rela.r_sym);
4108 bfd_set_error (bfd_error_bad_value);
4109 }
4110 else
4111 {
4112 asymbol **ps, *s;
4113
4114 ps = symbols + rela.r_sym - 1;
4115 s = *ps;
4116 if ((s->flags & BSF_SECTION_SYM) == 0)
4117 relent->sym_ptr_ptr = ps;
4118 else
4119 relent->sym_ptr_ptr = s->section->symbol_ptr_ptr;
4120 }
4121
4122 used_sym = true;
4123 }
4124 else if (! used_ssym)
4125 {
4126 switch (rela.r_ssym)
4127 {
4128 case RSS_UNDEF:
4129 break;
4130
4131 case RSS_GP:
4132 case RSS_GP0:
4133 case RSS_LOC:
4134 /* FIXME: I think these need to be handled using
4135 special howto structures. */
4136 BFD_ASSERT (0);
4137 break;
4138
4139 default:
4140 BFD_ASSERT (0);
4141 break;
4142 }
4143
4144 used_ssym = true;
4145 }
4146 break;
4147 }
4148
4149 /* The address of an ELF reloc is section relative for an
4150 object file, and absolute for an executable file or
4151 shared library. The address of a BFD reloc is always
4152 section relative. */
4153 if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0 || dynamic)
4154 relent->address = rela.r_offset;
4155 else
4156 relent->address = rela.r_offset - asect->vma;
4157
4158 relent->addend = rela.r_addend;
4159
4160 relent->howto = mips_elf64_rtype_to_howto (abfd, type, rela_p);
4161 if (relent->howto == NULL)
4162 goto error_return;
4163
4164 ++relent;
4165 }
4166 }
4167
4168 free (allocated);
4169 return true;
4170
4171 error_return:
4172 free (allocated);
4173 return false;
4174 }
4175
4176 /* Read the relocations. On Irix 6, there can be two reloc sections
4177 associated with a single data section. This is copied from
4178 elfcode.h as well, with changes as small as accounting for 3
4179 internal relocs per external reloc. */
4180
4181 static bool
4182 mips_elf64_slurp_reloc_table (bfd *abfd, asection *asect,
4183 asymbol **symbols, bool dynamic)
4184 {
4185 struct bfd_elf_section_data * const d = elf_section_data (asect);
4186 Elf_Internal_Shdr *rel_hdr;
4187 Elf_Internal_Shdr *rel_hdr2;
4188 bfd_size_type reloc_count;
4189 bfd_size_type reloc_count2;
4190 arelent *relents;
4191 bfd_size_type amt;
4192
4193 if (asect->relocation != NULL)
4194 return true;
4195
4196 if (! dynamic)
4197 {
4198 if ((asect->flags & SEC_RELOC) == 0
4199 || asect->reloc_count == 0)
4200 return true;
4201
4202 rel_hdr = d->rel.hdr;
4203 reloc_count = rel_hdr ? NUM_SHDR_ENTRIES (rel_hdr) : 0;
4204 rel_hdr2 = d->rela.hdr;
4205 reloc_count2 = (rel_hdr2 ? NUM_SHDR_ENTRIES (rel_hdr2) : 0);
4206
4207 BFD_ASSERT (asect->reloc_count == 3 * (reloc_count + reloc_count2));
4208 BFD_ASSERT ((rel_hdr && asect->rel_filepos == rel_hdr->sh_offset)
4209 || (rel_hdr2 && asect->rel_filepos == rel_hdr2->sh_offset));
4210
4211 }
4212 else
4213 {
4214 /* Note that ASECT->RELOC_COUNT tends not to be accurate in this
4215 case because relocations against this section may use the
4216 dynamic symbol table, and in that case bfd_section_from_shdr
4217 in elf.c does not update the RELOC_COUNT. */
4218 if (asect->size == 0)
4219 return true;
4220
4221 rel_hdr = &d->this_hdr;
4222 reloc_count = NUM_SHDR_ENTRIES (rel_hdr);
4223 rel_hdr2 = NULL;
4224 reloc_count2 = 0;
4225 }
4226
4227 /* Allocate space for 3 arelent structures for each Rel structure. */
4228 amt = (reloc_count + reloc_count2) * 3 * sizeof (arelent);
4229 relents = bfd_alloc (abfd, amt);
4230 if (relents == NULL)
4231 return false;
4232
4233 if (rel_hdr != NULL
4234 && ! mips_elf64_slurp_one_reloc_table (abfd, asect,
4235 rel_hdr, reloc_count,
4236 relents,
4237 symbols, dynamic))
4238 return false;
4239 if (rel_hdr2 != NULL
4240 && ! mips_elf64_slurp_one_reloc_table (abfd, asect,
4241 rel_hdr2, reloc_count2,
4242 relents + reloc_count * 3,
4243 symbols, dynamic))
4244 return false;
4245
4246 asect->relocation = relents;
4247 return true;
4248 }
4249
4250 /* Write out the relocations. */
4251
4252 static void
4253 mips_elf64_write_relocs (bfd *abfd, asection *sec, void *data)
4254 {
4255 bool *failedp = data;
4256 int count;
4257 Elf_Internal_Shdr *rel_hdr;
4258 unsigned int idx;
4259
4260 /* If we have already failed, don't do anything. */
4261 if (*failedp)
4262 return;
4263
4264 if ((sec->flags & SEC_RELOC) == 0)
4265 return;
4266
4267 /* The linker backend writes the relocs out itself, and sets the
4268 reloc_count field to zero to inhibit writing them here. Also,
4269 sometimes the SEC_RELOC flag gets set even when there aren't any
4270 relocs. */
4271 if (sec->reloc_count == 0)
4272 return;
4273
4274 /* We can combine up to three relocs that refer to the same address
4275 if the latter relocs have no associated symbol. */
4276 count = 0;
4277 for (idx = 0; idx < sec->reloc_count; idx++)
4278 {
4279 bfd_vma addr;
4280 unsigned int i;
4281
4282 ++count;
4283
4284 addr = sec->orelocation[idx]->address;
4285 for (i = 0; i < 2; i++)
4286 {
4287 arelent *r;
4288
4289 if (idx + 1 >= sec->reloc_count)
4290 break;
4291 r = sec->orelocation[idx + 1];
4292 if (r->address != addr
4293 || ! bfd_is_abs_section ((*r->sym_ptr_ptr)->section)
4294 || (*r->sym_ptr_ptr)->value != 0)
4295 break;
4296
4297 /* We can merge the reloc at IDX + 1 with the reloc at IDX. */
4298
4299 ++idx;
4300 }
4301 }
4302
4303 rel_hdr = _bfd_elf_single_rel_hdr (sec);
4304
4305 /* Do the actual relocation. */
4306
4307 if (rel_hdr->sh_entsize == sizeof(Elf64_Mips_External_Rel))
4308 mips_elf64_write_rel (abfd, sec, rel_hdr, &count, data);
4309 else if (rel_hdr->sh_entsize == sizeof(Elf64_Mips_External_Rela))
4310 mips_elf64_write_rela (abfd, sec, rel_hdr, &count, data);
4311 else
4312 BFD_ASSERT (0);
4313 }
4314
4315 static void
4316 mips_elf64_write_rel (bfd *abfd, asection *sec,
4317 Elf_Internal_Shdr *rel_hdr,
4318 int *count, void *data)
4319 {
4320 bool *failedp = data;
4321 Elf64_Mips_External_Rel *ext_rel;
4322 unsigned int idx;
4323 asymbol *last_sym = 0;
4324 int last_sym_idx = 0;
4325
4326 rel_hdr->sh_size = rel_hdr->sh_entsize * *count;
4327 rel_hdr->contents = bfd_alloc (abfd, rel_hdr->sh_size);
4328 if (rel_hdr->contents == NULL)
4329 {
4330 *failedp = true;
4331 return;
4332 }
4333
4334 ext_rel = (Elf64_Mips_External_Rel *) rel_hdr->contents;
4335 for (idx = 0; idx < sec->reloc_count; idx++, ext_rel++)
4336 {
4337 arelent *ptr;
4338 Elf64_Mips_Internal_Rela int_rel;
4339 asymbol *sym;
4340 int n;
4341 unsigned int i;
4342
4343 ptr = sec->orelocation[idx];
4344
4345 /* The address of an ELF reloc is section relative for an object
4346 file, and absolute for an executable file or shared library.
4347 The address of a BFD reloc is always section relative. */
4348 if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0)
4349 int_rel.r_offset = ptr->address;
4350 else
4351 int_rel.r_offset = ptr->address + sec->vma;
4352
4353 sym = *ptr->sym_ptr_ptr;
4354 if (sym == last_sym)
4355 n = last_sym_idx;
4356 else if (bfd_is_abs_section (sym->section) && sym->value == 0)
4357 n = STN_UNDEF;
4358 else
4359 {
4360 last_sym = sym;
4361 n = _bfd_elf_symbol_from_bfd_symbol (abfd, &sym);
4362 if (n < 0)
4363 {
4364 *failedp = true;
4365 return;
4366 }
4367 last_sym_idx = n;
4368 }
4369
4370 int_rel.r_sym = n;
4371 int_rel.r_ssym = RSS_UNDEF;
4372
4373 if ((*ptr->sym_ptr_ptr)->the_bfd != NULL
4374 && (*ptr->sym_ptr_ptr)->the_bfd->xvec != abfd->xvec
4375 && ! _bfd_elf_validate_reloc (abfd, ptr))
4376 {
4377 *failedp = true;
4378 return;
4379 }
4380
4381 int_rel.r_type = ptr->howto->type;
4382 int_rel.r_type2 = (int) R_MIPS_NONE;
4383 int_rel.r_type3 = (int) R_MIPS_NONE;
4384
4385 for (i = 0; i < 2; i++)
4386 {
4387 arelent *r;
4388
4389 if (idx + 1 >= sec->reloc_count)
4390 break;
4391 r = sec->orelocation[idx + 1];
4392 if (r->address != ptr->address
4393 || ! bfd_is_abs_section ((*r->sym_ptr_ptr)->section)
4394 || (*r->sym_ptr_ptr)->value != 0)
4395 break;
4396
4397 /* We can merge the reloc at IDX + 1 with the reloc at IDX. */
4398
4399 if (i == 0)
4400 int_rel.r_type2 = r->howto->type;
4401 else
4402 int_rel.r_type3 = r->howto->type;
4403
4404 ++idx;
4405 }
4406
4407 mips_elf64_swap_reloc_out (abfd, &int_rel, ext_rel);
4408 }
4409
4410 BFD_ASSERT (ext_rel - (Elf64_Mips_External_Rel *) rel_hdr->contents
4411 == *count);
4412 }
4413
4414 static void
4415 mips_elf64_write_rela (bfd *abfd, asection *sec,
4416 Elf_Internal_Shdr *rela_hdr,
4417 int *count, void *data)
4418 {
4419 bool *failedp = data;
4420 Elf64_Mips_External_Rela *ext_rela;
4421 unsigned int idx;
4422 asymbol *last_sym = 0;
4423 int last_sym_idx = 0;
4424
4425 rela_hdr->sh_size = rela_hdr->sh_entsize * *count;
4426 rela_hdr->contents = bfd_alloc (abfd, rela_hdr->sh_size);
4427 if (rela_hdr->contents == NULL)
4428 {
4429 *failedp = true;
4430 return;
4431 }
4432
4433 ext_rela = (Elf64_Mips_External_Rela *) rela_hdr->contents;
4434 for (idx = 0; idx < sec->reloc_count; idx++, ext_rela++)
4435 {
4436 arelent *ptr;
4437 Elf64_Mips_Internal_Rela int_rela;
4438 asymbol *sym;
4439 int n;
4440 unsigned int i;
4441
4442 ptr = sec->orelocation[idx];
4443
4444 /* The address of an ELF reloc is section relative for an object
4445 file, and absolute for an executable file or shared library.
4446 The address of a BFD reloc is always section relative. */
4447 if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0)
4448 int_rela.r_offset = ptr->address;
4449 else
4450 int_rela.r_offset = ptr->address + sec->vma;
4451
4452 sym = *ptr->sym_ptr_ptr;
4453 if (sym == last_sym)
4454 n = last_sym_idx;
4455 else if (bfd_is_abs_section (sym->section) && sym->value == 0)
4456 n = STN_UNDEF;
4457 else
4458 {
4459 last_sym = sym;
4460 n = _bfd_elf_symbol_from_bfd_symbol (abfd, &sym);
4461 if (n < 0)
4462 {
4463 *failedp = true;
4464 return;
4465 }
4466 last_sym_idx = n;
4467 }
4468
4469 int_rela.r_sym = n;
4470 int_rela.r_addend = ptr->addend;
4471 int_rela.r_ssym = RSS_UNDEF;
4472
4473 if ((*ptr->sym_ptr_ptr)->the_bfd != NULL
4474 && (*ptr->sym_ptr_ptr)->the_bfd->xvec != abfd->xvec
4475 && ! _bfd_elf_validate_reloc (abfd, ptr))
4476 {
4477 *failedp = true;
4478 return;
4479 }
4480
4481 int_rela.r_type = ptr->howto->type;
4482 int_rela.r_type2 = (int) R_MIPS_NONE;
4483 int_rela.r_type3 = (int) R_MIPS_NONE;
4484
4485 for (i = 0; i < 2; i++)
4486 {
4487 arelent *r;
4488
4489 if (idx + 1 >= sec->reloc_count)
4490 break;
4491 r = sec->orelocation[idx + 1];
4492 if (r->address != ptr->address
4493 || ! bfd_is_abs_section ((*r->sym_ptr_ptr)->section)
4494 || (*r->sym_ptr_ptr)->value != 0)
4495 break;
4496
4497 /* We can merge the reloc at IDX + 1 with the reloc at IDX. */
4498
4499 if (i == 0)
4500 int_rela.r_type2 = r->howto->type;
4501 else
4502 int_rela.r_type3 = r->howto->type;
4503
4504 ++idx;
4505 }
4506
4507 mips_elf64_swap_reloca_out (abfd, &int_rela, ext_rela);
4508 }
4509
4510 BFD_ASSERT (ext_rela - (Elf64_Mips_External_Rela *) rela_hdr->contents
4511 == *count);
4512 }
4513
4514 /* Set the right machine number for a MIPS ELF file. */
4516
4517 static bool
4518 mips_elf64_object_p (bfd *abfd)
4519 {
4520 unsigned long mach;
4521
4522 /* Irix 6 is broken. Object file symbol tables are not always
4523 sorted correctly such that local symbols precede global symbols,
4524 and the sh_info field in the symbol table is not always right. */
4525 if (elf64_mips_irix_compat (abfd) != ict_none)
4526 elf_bad_symtab (abfd) = true;
4527
4528 mach = _bfd_elf_mips_mach (elf_elfheader (abfd)->e_flags);
4529 bfd_default_set_arch_mach (abfd, bfd_arch_mips, mach);
4530 return true;
4531 }
4532
4533 /* Depending on the target vector we generate some version of Irix
4534 executables or "normal" MIPS ELF ABI executables. */
4535 static irix_compat_t
4536 elf64_mips_irix_compat (bfd *abfd)
4537 {
4538 if ((abfd->xvec == &mips_elf64_be_vec)
4539 || (abfd->xvec == &mips_elf64_le_vec))
4540 return ict_irix6;
4541 else
4542 return ict_none;
4543 }
4544
4545 /* Support for core dump NOTE sections. */
4547 static bool
4548 elf64_mips_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
4549 {
4550 int offset;
4551 unsigned int size;
4552
4553 switch (note->descsz)
4554 {
4555 default:
4556 return false;
4557
4558 case 480: /* Linux/MIPS - N64 kernel */
4559 /* pr_cursig */
4560 elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
4561
4562 /* pr_pid */
4563 elf_tdata (abfd)->core->lwpid = bfd_get_32 (abfd, note->descdata + 32);
4564
4565 /* pr_reg */
4566 offset = 112;
4567 size = 360;
4568
4569 break;
4570 }
4571
4572 /* Make a ".reg/999" section. */
4573 return _bfd_elfcore_make_pseudosection (abfd, ".reg",
4574 size, note->descpos + offset);
4575 }
4576
4577 static bool
4578 elf64_mips_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
4579 {
4580 switch (note->descsz)
4581 {
4582 default:
4583 return false;
4584
4585 case 136: /* Linux/MIPS - N64 kernel elf_prpsinfo */
4586 elf_tdata (abfd)->core->pid
4587 = bfd_get_32 (abfd, note->descdata + 24);
4588 elf_tdata (abfd)->core->program
4589 = _bfd_elfcore_strndup (abfd, note->descdata + 40, 16);
4590 elf_tdata (abfd)->core->command
4591 = _bfd_elfcore_strndup (abfd, note->descdata + 56, 80);
4592 }
4593
4594 /* Note that for some reason, a spurious space is tacked
4595 onto the end of the args in some (at least one anyway)
4596 implementations, so strip it off if it exists. */
4597
4598 {
4599 char *command = elf_tdata (abfd)->core->command;
4600 int n = strlen (command);
4601
4602 if (0 < n && command[n - 1] == ' ')
4603 command[n - 1] = '\0';
4604 }
4605
4606 return true;
4607 }
4608
4609 /* Write Linux core PRSTATUS note into core file. */
4610
4611 static char *
4612 elf64_mips_write_core_note (bfd *abfd, char *buf, int *bufsiz, int note_type,
4613 ...)
4614 {
4615 switch (note_type)
4616 {
4617 default:
4618 return NULL;
4619
4620 case NT_PRPSINFO:
4621 BFD_FAIL ();
4622 return NULL;
4623
4624 case NT_PRSTATUS:
4625 {
4626 char data[480];
4627 va_list ap;
4628 long pid;
4629 int cursig;
4630 const void *greg;
4631
4632 va_start (ap, note_type);
4633 memset (data, 0, 112);
4634 pid = va_arg (ap, long);
4635 bfd_put_32 (abfd, pid, data + 32);
4636 cursig = va_arg (ap, int);
4637 bfd_put_16 (abfd, cursig, data + 12);
4638 greg = va_arg (ap, const void *);
4639 memcpy (data + 112, greg, 360);
4640 memset (data + 472, 0, 8);
4641 va_end (ap);
4642 return elfcore_write_note (abfd, buf, bufsiz,
4643 "CORE", note_type, data, sizeof (data));
4644 }
4645 }
4646 }
4647
4648 /* ECOFF swapping routines. These are used when dealing with the
4650 .mdebug section, which is in the ECOFF debugging format. */
4651 static const struct ecoff_debug_swap mips_elf64_ecoff_debug_swap =
4652 {
4653 /* Symbol table magic number. */
4654 magicSym2,
4655 /* Alignment of debugging information. E.g., 4. */
4656 8,
4657 /* Sizes of external symbolic information. */
4658 sizeof (struct hdr_ext),
4659 sizeof (struct dnr_ext),
4660 sizeof (struct pdr_ext),
4661 sizeof (struct sym_ext),
4662 sizeof (struct opt_ext),
4663 sizeof (struct fdr_ext),
4664 sizeof (struct rfd_ext),
4665 sizeof (struct ext_ext),
4666 /* Functions to swap in external symbolic data. */
4667 ecoff_swap_hdr_in,
4668 ecoff_swap_dnr_in,
4669 ecoff_swap_pdr_in,
4670 ecoff_swap_sym_in,
4671 ecoff_swap_opt_in,
4672 ecoff_swap_fdr_in,
4673 ecoff_swap_rfd_in,
4674 ecoff_swap_ext_in,
4675 _bfd_ecoff_swap_tir_in,
4676 _bfd_ecoff_swap_rndx_in,
4677 /* Functions to swap out external symbolic data. */
4678 ecoff_swap_hdr_out,
4679 ecoff_swap_dnr_out,
4680 ecoff_swap_pdr_out,
4681 ecoff_swap_sym_out,
4682 ecoff_swap_opt_out,
4683 ecoff_swap_fdr_out,
4684 ecoff_swap_rfd_out,
4685 ecoff_swap_ext_out,
4686 _bfd_ecoff_swap_tir_out,
4687 _bfd_ecoff_swap_rndx_out,
4688 /* Function to read in symbolic data. */
4689 _bfd_mips_elf_read_ecoff_info
4690 };
4691
4692 /* Relocations in the 64 bit MIPS ELF ABI are more complex than in
4694 standard ELF. This structure is used to redirect the relocation
4695 handling routines. */
4696
4697 const struct elf_size_info mips_elf64_size_info =
4698 {
4699 sizeof (Elf64_External_Ehdr),
4700 sizeof (Elf64_External_Phdr),
4701 sizeof (Elf64_External_Shdr),
4702 sizeof (Elf64_Mips_External_Rel),
4703 sizeof (Elf64_Mips_External_Rela),
4704 sizeof (Elf64_External_Sym),
4705 sizeof (Elf64_External_Dyn),
4706 sizeof (Elf_External_Note),
4707 4, /* hash-table entry size */
4708 3, /* internal relocations per external relocations */
4709 64, /* arch_size */
4710 3, /* log_file_align */
4711 ELFCLASS64,
4712 EV_CURRENT,
4713 bfd_elf64_write_out_phdrs,
4714 bfd_elf64_write_shdrs_and_ehdr,
4715 bfd_elf64_checksum_contents,
4716 mips_elf64_write_relocs,
4717 bfd_elf64_swap_symbol_in,
4718 bfd_elf64_swap_symbol_out,
4719 mips_elf64_slurp_reloc_table,
4720 bfd_elf64_slurp_symbol_table,
4721 bfd_elf64_swap_dyn_in,
4722 bfd_elf64_swap_dyn_out,
4723 mips_elf64_be_swap_reloc_in,
4724 mips_elf64_be_swap_reloc_out,
4725 mips_elf64_be_swap_reloca_in,
4726 mips_elf64_be_swap_reloca_out
4727 };
4728
4729 #define ELF_ARCH bfd_arch_mips
4730 #define ELF_TARGET_ID MIPS_ELF_DATA
4731 #define ELF_MACHINE_CODE EM_MIPS
4732
4733 #define elf_backend_collect true
4734 #define elf_backend_type_change_ok true
4735 #define elf_backend_can_gc_sections true
4736 #define elf_backend_gc_mark_extra_sections \
4737 _bfd_mips_elf_gc_mark_extra_sections
4738 #define elf_info_to_howto mips_elf64_info_to_howto_rela
4739 #define elf_info_to_howto_rel mips_elf64_info_to_howto_rela
4740 #define elf_backend_object_p mips_elf64_object_p
4741 #define elf_backend_symbol_processing _bfd_mips_elf_symbol_processing
4742 #define elf_backend_section_processing _bfd_mips_elf_section_processing
4743 #define elf_backend_section_from_shdr _bfd_mips_elf_section_from_shdr
4744 #define elf_backend_fake_sections _bfd_mips_elf_fake_sections
4745 #define elf_backend_section_from_bfd_section \
4746 _bfd_mips_elf_section_from_bfd_section
4747 #define elf_backend_add_symbol_hook _bfd_mips_elf_add_symbol_hook
4748 #define elf_backend_link_output_symbol_hook \
4749 _bfd_mips_elf_link_output_symbol_hook
4750 #define elf_backend_create_dynamic_sections \
4751 _bfd_mips_elf_create_dynamic_sections
4752 #define elf_backend_check_relocs _bfd_mips_elf_check_relocs
4753 #define elf_backend_merge_symbol_attribute \
4754 _bfd_mips_elf_merge_symbol_attribute
4755 #define elf_backend_get_target_dtag _bfd_mips_elf_get_target_dtag
4756 #define elf_backend_adjust_dynamic_symbol \
4757 _bfd_mips_elf_adjust_dynamic_symbol
4758 #define elf_backend_always_size_sections \
4759 _bfd_mips_elf_always_size_sections
4760 #define elf_backend_size_dynamic_sections \
4761 _bfd_mips_elf_size_dynamic_sections
4762 #define elf_backend_init_index_section _bfd_elf_init_1_index_section
4763 #define elf_backend_relocate_section _bfd_mips_elf_relocate_section
4764 #define elf_backend_finish_dynamic_symbol \
4765 _bfd_mips_elf_finish_dynamic_symbol
4766 #define elf_backend_finish_dynamic_sections \
4767 _bfd_mips_elf_finish_dynamic_sections
4768 #define elf_backend_final_write_processing \
4769 _bfd_mips_elf_final_write_processing
4770 #define elf_backend_additional_program_headers \
4771 _bfd_mips_elf_additional_program_headers
4772 #define elf_backend_modify_segment_map _bfd_mips_elf_modify_segment_map
4773 #define elf_backend_gc_mark_hook _bfd_mips_elf_gc_mark_hook
4774 #define elf_backend_copy_indirect_symbol \
4775 _bfd_mips_elf_copy_indirect_symbol
4776 #define elf_backend_hide_symbol _bfd_mips_elf_hide_symbol
4777 #define elf_backend_ignore_discarded_relocs \
4778 _bfd_mips_elf_ignore_discarded_relocs
4779 #define elf_backend_mips_irix_compat elf64_mips_irix_compat
4780 #define elf_backend_mips_rtype_to_howto mips_elf64_rtype_to_howto
4781 #define elf_backend_ecoff_debug_swap &mips_elf64_ecoff_debug_swap
4782 #define elf_backend_size_info mips_elf64_size_info
4783
4784 #define elf_backend_grok_prstatus elf64_mips_grok_prstatus
4785 #define elf_backend_grok_psinfo elf64_mips_grok_psinfo
4786
4787 #define elf_backend_got_header_size (8 * MIPS_RESERVED_GOTNO)
4788 #define elf_backend_want_dynrelro 1
4789
4790 /* MIPS ELF64 can use a mixture of REL and RELA, but some Relocations
4791 work better/work only in RELA, so we default to this. */
4792 #define elf_backend_may_use_rel_p 1
4793 #define elf_backend_may_use_rela_p 1
4794 #define elf_backend_default_use_rela_p 1
4795 #define elf_backend_rela_plts_and_copies_p 0
4796 #define elf_backend_plt_readonly 1
4797 #define elf_backend_plt_sym_val _bfd_mips_elf_plt_sym_val
4798
4799 #define elf_backend_sign_extend_vma true
4800
4801 #define elf_backend_write_section _bfd_mips_elf_write_section
4802 #define elf_backend_sort_relocs_p _bfd_mips_elf_sort_relocs_p
4803
4804 /* We don't set bfd_elf64_bfd_is_local_label_name because the 32-bit
4805 MIPS-specific function only applies to IRIX5, which had no 64-bit
4806 ABI. */
4807 #define bfd_elf64_bfd_is_target_special_symbol \
4808 _bfd_mips_elf_is_target_special_symbol
4809 #define bfd_elf64_find_nearest_line _bfd_mips_elf_find_nearest_line
4810 #define bfd_elf64_find_nearest_line_with_alt \
4811 _bfd_mips_elf_find_nearest_line_with_alt
4812 #define bfd_elf64_find_inliner_info _bfd_mips_elf_find_inliner_info
4813 #define bfd_elf64_new_section_hook _bfd_mips_elf_new_section_hook
4814 #define bfd_elf64_set_section_contents _bfd_mips_elf_set_section_contents
4815 #define bfd_elf64_bfd_get_relocated_section_contents \
4816 _bfd_elf_mips_get_relocated_section_contents
4817 #define bfd_elf64_bfd_link_hash_table_create \
4818 _bfd_mips_elf_link_hash_table_create
4819 #define bfd_elf64_bfd_final_link _bfd_mips_elf_final_link
4820 #define bfd_elf64_bfd_merge_private_bfd_data \
4821 _bfd_mips_elf_merge_private_bfd_data
4822 #define bfd_elf64_bfd_set_private_flags _bfd_mips_elf_set_private_flags
4823 #define bfd_elf64_bfd_print_private_bfd_data \
4824 _bfd_mips_elf_print_private_bfd_data
4825
4826 #define bfd_elf64_get_dynamic_reloc_upper_bound mips_elf64_get_dynamic_reloc_upper_bound
4827 #define bfd_elf64_mkobject _bfd_mips_elf_mkobject
4828 #define bfd_elf64_close_and_cleanup _bfd_mips_elf_close_and_cleanup
4829
4830 /* The SGI style (n)64 NewABI. */
4831 #define TARGET_LITTLE_SYM mips_elf64_le_vec
4832 #define TARGET_LITTLE_NAME "elf64-littlemips"
4833 #define TARGET_BIG_SYM mips_elf64_be_vec
4834 #define TARGET_BIG_NAME "elf64-bigmips"
4835
4836 #define ELF_MAXPAGESIZE 0x10000
4837 #define ELF_COMMONPAGESIZE 0x1000
4838
4839 #include "elf64-target.h"
4840
4841 /* The SYSV-style 'traditional' (n)64 NewABI. */
4842 #undef TARGET_LITTLE_SYM
4843 #undef TARGET_LITTLE_NAME
4844 #undef TARGET_BIG_SYM
4845 #undef TARGET_BIG_NAME
4846
4847 #undef ELF_MAXPAGESIZE
4848 #undef ELF_COMMONPAGESIZE
4849
4850 #define TARGET_LITTLE_SYM mips_elf64_trad_le_vec
4851 #define TARGET_LITTLE_NAME "elf64-tradlittlemips"
4852 #define TARGET_BIG_SYM mips_elf64_trad_be_vec
4853 #define TARGET_BIG_NAME "elf64-tradbigmips"
4854
4855 #define ELF_MAXPAGESIZE 0x10000
4856 #define ELF_COMMONPAGESIZE 0x1000
4857 #define elf64_bed elf64_tradbed
4858
4859 #undef elf_backend_write_core_note
4860 #define elf_backend_write_core_note elf64_mips_write_core_note
4861
4862 /* Include the target file again for this target. */
4863 #include "elf64-target.h"
4864
4865
4866 /* FreeBSD support. */
4867
4868 #undef TARGET_LITTLE_SYM
4869 #undef TARGET_LITTLE_NAME
4870 #undef TARGET_BIG_SYM
4871 #undef TARGET_BIG_NAME
4872
4873 #define TARGET_LITTLE_SYM mips_elf64_tradfbsd_le_vec
4874 #define TARGET_LITTLE_NAME "elf64-tradlittlemips-freebsd"
4875 #define TARGET_BIG_SYM mips_elf64_tradfbsd_be_vec
4876 #define TARGET_BIG_NAME "elf64-tradbigmips-freebsd"
4877
4878 #undef ELF_OSABI
4879 #define ELF_OSABI ELFOSABI_FREEBSD
4880
4881 #undef elf64_bed
4882 #define elf64_bed elf64_fbsd_tradbed
4883
4884 #undef elf64_mips_write_core_note
4885
4886 #include "elf64-target.h"
4887