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