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