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