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