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