1 /* MIPS-specific support for 32-bit ELF
2 Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
3 2003 Free Software Foundation, Inc.
5 Most of the information added by Ian Lance Taylor, Cygnus Support,
7 N32/64 ABI support added by Mark Mitchell, CodeSourcery, LLC.
8 <mark@codesourcery.com>
9 Traditional MIPS targets support added by Koundinya.K, Dansk Data
10 Elektronik & Operations Research Group. <kk@ddeorg.soft.net>
12 This file is part of BFD, the Binary File Descriptor library.
14 This program is free software; you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by
16 the Free Software Foundation; either version 2 of the License, or
17 (at your option) any later version.
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details.
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, write to the Free Software
26 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
28 /* This file handles MIPS ELF targets. SGI Irix 5 uses a slightly
29 different MIPS ELF from other targets. This matters when linking.
30 This file supports both, switching at runtime. */
38 #include "elfxx-mips.h"
41 /* Get the ECOFF swapping routines. */
43 #include "coff/symconst.h"
44 #include "coff/internal.h"
45 #include "coff/ecoff.h"
46 #include "coff/mips.h"
47 #define ECOFF_SIGNED_32
48 #include "ecoffswap.h"
50 static bfd_reloc_status_type mips_elf_generic_reloc
51 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
52 static bfd_reloc_status_type mips_elf_hi16_reloc
53 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
54 static bfd_reloc_status_type mips_elf_lo16_reloc
55 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
56 static bfd_reloc_status_type mips_elf_got16_reloc
57 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
58 static bfd_boolean mips_elf_assign_gp
59 PARAMS ((bfd *, bfd_vma *));
60 static bfd_reloc_status_type mips_elf_final_gp
61 PARAMS ((bfd *, asymbol *, bfd_boolean, char **, bfd_vma *));
62 static bfd_reloc_status_type mips_elf_gprel16_reloc
63 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
64 static bfd_reloc_status_type mips_elf_literal_reloc
65 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
66 static bfd_reloc_status_type mips_elf_gprel32_reloc
67 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
68 static bfd_reloc_status_type gprel32_with_gp
69 PARAMS ((bfd *, asymbol *, arelent *, asection *, bfd_boolean, PTR,
71 static bfd_reloc_status_type mips_elf_shift6_reloc
72 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
73 static bfd_reloc_status_type mips16_jump_reloc
74 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
75 static bfd_reloc_status_type mips16_gprel_reloc
76 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
77 static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
78 PARAMS ((bfd *, bfd_reloc_code_real_type));
79 static reloc_howto_type *mips_elf_n32_rtype_to_howto
80 PARAMS ((unsigned int, bfd_boolean));
81 static void mips_info_to_howto_rel
82 PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
83 static void mips_info_to_howto_rela
84 PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
85 static bfd_boolean mips_elf_sym_is_global
86 PARAMS ((bfd *, asymbol *));
87 static bfd_boolean mips_elf_n32_object_p
89 static bfd_boolean elf32_mips_grok_prstatus
90 PARAMS ((bfd *, Elf_Internal_Note *));
91 static bfd_boolean elf32_mips_grok_psinfo
92 PARAMS ((bfd *, Elf_Internal_Note *));
93 static irix_compat_t elf_n32_mips_irix_compat
96 extern const bfd_target bfd_elf32_nbigmips_vec;
97 extern const bfd_target bfd_elf32_nlittlemips_vec;
99 static asection *prev_reloc_section = NULL;
100 static bfd_vma prev_reloc_address = -1;
101 static bfd_vma prev_reloc_addend = 0;
103 /* Nonzero if ABFD is using the N32 ABI. */
104 #define ABI_N32_P(abfd) \
105 ((elf_elfheader (abfd)->e_flags & EF_MIPS_ABI2) != 0)
107 /* Whether we are trying to be compatible with IRIX at all. */
108 #define SGI_COMPAT(abfd) \
109 (elf_n32_mips_irix_compat (abfd) != ict_none)
111 /* The number of local .got entries we reserve. */
112 #define MIPS_RESERVED_GOTNO (2)
114 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
115 from smaller values. Start with zero, widen, *then* decrement. */
116 #define MINUS_ONE (((bfd_vma)0) - 1)
118 /* The relocation table used for SHT_REL sections. */
120 static reloc_howto_type elf_mips_howto_table_rel[] =
123 HOWTO (R_MIPS_NONE, /* type */
125 0, /* size (0 = byte, 1 = short, 2 = long) */
127 FALSE, /* pc_relative */
129 complain_overflow_dont, /* complain_on_overflow */
130 mips_elf_generic_reloc, /* special_function */
131 "R_MIPS_NONE", /* name */
132 FALSE, /* partial_inplace */
135 FALSE), /* pcrel_offset */
137 /* 16 bit relocation. */
138 HOWTO (R_MIPS_16, /* type */
140 2, /* size (0 = byte, 1 = short, 2 = long) */
142 FALSE, /* pc_relative */
144 complain_overflow_signed, /* complain_on_overflow */
145 mips_elf_generic_reloc, /* special_function */
146 "R_MIPS_16", /* name */
147 TRUE, /* partial_inplace */
148 0x0000ffff, /* src_mask */
149 0x0000ffff, /* dst_mask */
150 FALSE), /* pcrel_offset */
152 /* 32 bit relocation. */
153 HOWTO (R_MIPS_32, /* type */
155 2, /* size (0 = byte, 1 = short, 2 = long) */
157 FALSE, /* pc_relative */
159 complain_overflow_dont, /* complain_on_overflow */
160 mips_elf_generic_reloc, /* special_function */
161 "R_MIPS_32", /* name */
162 TRUE, /* partial_inplace */
163 0xffffffff, /* src_mask */
164 0xffffffff, /* dst_mask */
165 FALSE), /* pcrel_offset */
167 /* 32 bit symbol relative relocation. */
168 HOWTO (R_MIPS_REL32, /* type */
170 2, /* size (0 = byte, 1 = short, 2 = long) */
172 FALSE, /* pc_relative */
174 complain_overflow_dont, /* complain_on_overflow */
175 mips_elf_generic_reloc, /* special_function */
176 "R_MIPS_REL32", /* name */
177 TRUE, /* partial_inplace */
178 0xffffffff, /* src_mask */
179 0xffffffff, /* dst_mask */
180 FALSE), /* pcrel_offset */
182 /* 26 bit jump address. */
183 HOWTO (R_MIPS_26, /* type */
185 2, /* size (0 = byte, 1 = short, 2 = long) */
187 FALSE, /* pc_relative */
189 complain_overflow_dont, /* complain_on_overflow */
190 /* This needs complex overflow
191 detection, because the upper four
192 bits must match the PC + 4. */
193 mips_elf_generic_reloc, /* special_function */
194 "R_MIPS_26", /* name */
195 TRUE, /* partial_inplace */
196 0x03ffffff, /* src_mask */
197 0x03ffffff, /* dst_mask */
198 FALSE), /* pcrel_offset */
200 /* R_MIPS_HI16 and R_MIPS_LO16 are unsupported for NewABI REL.
201 However, the native IRIX6 tools use them, so we try our best. */
203 /* High 16 bits of symbol value. */
204 HOWTO (R_MIPS_HI16, /* type */
206 2, /* size (0 = byte, 1 = short, 2 = long) */
208 FALSE, /* pc_relative */
210 complain_overflow_dont, /* complain_on_overflow */
211 mips_elf_hi16_reloc, /* special_function */
212 "R_MIPS_HI16", /* name */
213 TRUE, /* partial_inplace */
214 0x0000ffff, /* src_mask */
215 0x0000ffff, /* dst_mask */
216 FALSE), /* pcrel_offset */
218 /* Low 16 bits of symbol value. */
219 HOWTO (R_MIPS_LO16, /* type */
221 2, /* size (0 = byte, 1 = short, 2 = long) */
223 FALSE, /* pc_relative */
225 complain_overflow_dont, /* complain_on_overflow */
226 mips_elf_lo16_reloc, /* special_function */
227 "R_MIPS_LO16", /* name */
228 TRUE, /* partial_inplace */
229 0x0000ffff, /* src_mask */
230 0x0000ffff, /* dst_mask */
231 FALSE), /* pcrel_offset */
233 /* GP relative reference. */
234 HOWTO (R_MIPS_GPREL16, /* type */
236 2, /* size (0 = byte, 1 = short, 2 = long) */
238 FALSE, /* pc_relative */
240 complain_overflow_signed, /* complain_on_overflow */
241 mips_elf_gprel16_reloc, /* special_function */
242 "R_MIPS_GPREL16", /* name */
243 TRUE, /* partial_inplace */
244 0x0000ffff, /* src_mask */
245 0x0000ffff, /* dst_mask */
246 FALSE), /* pcrel_offset */
248 /* Reference to literal section. */
249 HOWTO (R_MIPS_LITERAL, /* type */
251 2, /* size (0 = byte, 1 = short, 2 = long) */
253 FALSE, /* pc_relative */
255 complain_overflow_signed, /* complain_on_overflow */
256 mips_elf_literal_reloc, /* special_function */
257 "R_MIPS_LITERAL", /* name */
258 TRUE, /* partial_inplace */
259 0x0000ffff, /* src_mask */
260 0x0000ffff, /* dst_mask */
261 FALSE), /* pcrel_offset */
263 /* Reference to global offset table. */
264 HOWTO (R_MIPS_GOT16, /* type */
266 2, /* size (0 = byte, 1 = short, 2 = long) */
268 FALSE, /* pc_relative */
270 complain_overflow_signed, /* complain_on_overflow */
271 mips_elf_got16_reloc, /* special_function */
272 "R_MIPS_GOT16", /* name */
273 TRUE, /* partial_inplace */
274 0x0000ffff, /* src_mask */
275 0x0000ffff, /* dst_mask */
276 FALSE), /* pcrel_offset */
278 /* 16 bit PC relative reference. */
279 HOWTO (R_MIPS_PC16, /* type */
281 2, /* size (0 = byte, 1 = short, 2 = long) */
283 TRUE, /* pc_relative */
285 complain_overflow_signed, /* complain_on_overflow */
286 mips_elf_generic_reloc, /* special_function */
287 "R_MIPS_PC16", /* name */
288 TRUE, /* partial_inplace */
289 0x0000ffff, /* src_mask */
290 0x0000ffff, /* dst_mask */
291 TRUE), /* pcrel_offset */
293 /* 16 bit call through global offset table. */
294 HOWTO (R_MIPS_CALL16, /* type */
296 2, /* size (0 = byte, 1 = short, 2 = long) */
298 FALSE, /* pc_relative */
300 complain_overflow_signed, /* complain_on_overflow */
301 mips_elf_generic_reloc, /* special_function */
302 "R_MIPS_CALL16", /* name */
303 TRUE, /* partial_inplace */
304 0x0000ffff, /* src_mask */
305 0x0000ffff, /* dst_mask */
306 FALSE), /* pcrel_offset */
308 /* 32 bit GP relative reference. */
309 HOWTO (R_MIPS_GPREL32, /* type */
311 2, /* size (0 = byte, 1 = short, 2 = long) */
313 FALSE, /* pc_relative */
315 complain_overflow_dont, /* complain_on_overflow */
316 mips_elf_gprel32_reloc, /* special_function */
317 "R_MIPS_GPREL32", /* name */
318 TRUE, /* partial_inplace */
319 0xffffffff, /* src_mask */
320 0xffffffff, /* dst_mask */
321 FALSE), /* pcrel_offset */
323 /* The remaining relocs are defined on Irix 5, although they are
324 not defined by the ABI. */
329 /* A 5 bit shift field. */
330 HOWTO (R_MIPS_SHIFT5, /* type */
332 2, /* size (0 = byte, 1 = short, 2 = long) */
334 FALSE, /* pc_relative */
336 complain_overflow_bitfield, /* complain_on_overflow */
337 mips_elf_generic_reloc, /* special_function */
338 "R_MIPS_SHIFT5", /* name */
339 TRUE, /* partial_inplace */
340 0x000007c0, /* src_mask */
341 0x000007c0, /* dst_mask */
342 FALSE), /* pcrel_offset */
344 /* A 6 bit shift field. */
345 HOWTO (R_MIPS_SHIFT6, /* type */
347 2, /* size (0 = byte, 1 = short, 2 = long) */
349 FALSE, /* pc_relative */
351 complain_overflow_bitfield, /* complain_on_overflow */
352 mips_elf_shift6_reloc, /* special_function */
353 "R_MIPS_SHIFT6", /* name */
354 TRUE, /* partial_inplace */
355 0x000007c4, /* src_mask */
356 0x000007c4, /* dst_mask */
357 FALSE), /* pcrel_offset */
359 /* A 64 bit relocation. */
360 HOWTO (R_MIPS_64, /* type */
362 4, /* size (0 = byte, 1 = short, 2 = long) */
364 FALSE, /* pc_relative */
366 complain_overflow_dont, /* complain_on_overflow */
367 mips_elf_generic_reloc, /* special_function */
368 "R_MIPS_64", /* name */
369 TRUE, /* partial_inplace */
370 MINUS_ONE, /* src_mask */
371 MINUS_ONE, /* dst_mask */
372 FALSE), /* pcrel_offset */
374 /* Displacement in the global offset table. */
375 HOWTO (R_MIPS_GOT_DISP, /* type */
377 2, /* size (0 = byte, 1 = short, 2 = long) */
379 FALSE, /* pc_relative */
381 complain_overflow_signed, /* complain_on_overflow */
382 mips_elf_generic_reloc, /* special_function */
383 "R_MIPS_GOT_DISP", /* name */
384 TRUE, /* partial_inplace */
385 0x0000ffff, /* src_mask */
386 0x0000ffff, /* dst_mask */
387 FALSE), /* pcrel_offset */
389 /* Displacement to page pointer in the global offset table. */
390 HOWTO (R_MIPS_GOT_PAGE, /* type */
392 2, /* size (0 = byte, 1 = short, 2 = long) */
394 FALSE, /* pc_relative */
396 complain_overflow_signed, /* complain_on_overflow */
397 mips_elf_generic_reloc, /* special_function */
398 "R_MIPS_GOT_PAGE", /* name */
399 TRUE, /* partial_inplace */
400 0x0000ffff, /* src_mask */
401 0x0000ffff, /* dst_mask */
402 FALSE), /* pcrel_offset */
404 /* Offset from page pointer in the global offset table. */
405 HOWTO (R_MIPS_GOT_OFST, /* type */
407 2, /* size (0 = byte, 1 = short, 2 = long) */
409 FALSE, /* pc_relative */
411 complain_overflow_signed, /* complain_on_overflow */
412 mips_elf_generic_reloc, /* special_function */
413 "R_MIPS_GOT_OFST", /* name */
414 TRUE, /* partial_inplace */
415 0x0000ffff, /* src_mask */
416 0x0000ffff, /* dst_mask */
417 FALSE), /* pcrel_offset */
419 /* High 16 bits of displacement in global offset table. */
420 HOWTO (R_MIPS_GOT_HI16, /* type */
422 2, /* size (0 = byte, 1 = short, 2 = long) */
424 FALSE, /* pc_relative */
426 complain_overflow_dont, /* complain_on_overflow */
427 mips_elf_generic_reloc, /* special_function */
428 "R_MIPS_GOT_HI16", /* name */
429 TRUE, /* partial_inplace */
430 0x0000ffff, /* src_mask */
431 0x0000ffff, /* dst_mask */
432 FALSE), /* pcrel_offset */
434 /* Low 16 bits of displacement in global offset table. */
435 HOWTO (R_MIPS_GOT_LO16, /* type */
437 2, /* size (0 = byte, 1 = short, 2 = long) */
439 FALSE, /* pc_relative */
441 complain_overflow_dont, /* complain_on_overflow */
442 mips_elf_generic_reloc, /* special_function */
443 "R_MIPS_GOT_LO16", /* name */
444 TRUE, /* partial_inplace */
445 0x0000ffff, /* src_mask */
446 0x0000ffff, /* dst_mask */
447 FALSE), /* pcrel_offset */
449 /* 64 bit subtraction. */
450 HOWTO (R_MIPS_SUB, /* type */
452 4, /* size (0 = byte, 1 = short, 2 = long) */
454 FALSE, /* pc_relative */
456 complain_overflow_dont, /* complain_on_overflow */
457 mips_elf_generic_reloc, /* special_function */
458 "R_MIPS_SUB", /* name */
459 TRUE, /* partial_inplace */
460 MINUS_ONE, /* src_mask */
461 MINUS_ONE, /* dst_mask */
462 FALSE), /* pcrel_offset */
464 /* Insert the addend as an instruction. */
465 /* FIXME: Not handled correctly. */
466 HOWTO (R_MIPS_INSERT_A, /* type */
468 2, /* size (0 = byte, 1 = short, 2 = long) */
470 FALSE, /* pc_relative */
472 complain_overflow_dont, /* complain_on_overflow */
473 mips_elf_generic_reloc, /* special_function */
474 "R_MIPS_INSERT_A", /* name */
475 TRUE, /* partial_inplace */
476 0xffffffff, /* src_mask */
477 0xffffffff, /* dst_mask */
478 FALSE), /* pcrel_offset */
480 /* Insert the addend as an instruction, and change all relocations
481 to refer to the old instruction at the address. */
482 /* FIXME: Not handled correctly. */
483 HOWTO (R_MIPS_INSERT_B, /* type */
485 2, /* size (0 = byte, 1 = short, 2 = long) */
487 FALSE, /* pc_relative */
489 complain_overflow_dont, /* complain_on_overflow */
490 mips_elf_generic_reloc, /* special_function */
491 "R_MIPS_INSERT_B", /* name */
492 TRUE, /* partial_inplace */
493 0xffffffff, /* src_mask */
494 0xffffffff, /* dst_mask */
495 FALSE), /* pcrel_offset */
497 /* Delete a 32 bit instruction. */
498 /* FIXME: Not handled correctly. */
499 HOWTO (R_MIPS_DELETE, /* type */
501 2, /* size (0 = byte, 1 = short, 2 = long) */
503 FALSE, /* pc_relative */
505 complain_overflow_dont, /* complain_on_overflow */
506 mips_elf_generic_reloc, /* special_function */
507 "R_MIPS_DELETE", /* name */
508 TRUE, /* partial_inplace */
509 0xffffffff, /* src_mask */
510 0xffffffff, /* dst_mask */
511 FALSE), /* pcrel_offset */
513 /* The MIPS ELF64 ABI Draft wants us to support these for REL relocations.
515 a) It means building the addend from a R_MIPS_HIGHEST/R_MIPS_HIGHER/
516 R_MIPS_HI16/R_MIPS_LO16 sequence with varying ordering, using
518 b) No other NEwABI toolchain actually emits such relocations. */
519 EMPTY_HOWTO (R_MIPS_HIGHER),
520 EMPTY_HOWTO (R_MIPS_HIGHEST),
522 /* High 16 bits of displacement in global offset table. */
523 HOWTO (R_MIPS_CALL_HI16, /* type */
525 2, /* size (0 = byte, 1 = short, 2 = long) */
527 FALSE, /* pc_relative */
529 complain_overflow_dont, /* complain_on_overflow */
530 mips_elf_generic_reloc, /* special_function */
531 "R_MIPS_CALL_HI16", /* name */
532 TRUE, /* partial_inplace */
533 0x0000ffff, /* src_mask */
534 0x0000ffff, /* dst_mask */
535 FALSE), /* pcrel_offset */
537 /* Low 16 bits of displacement in global offset table. */
538 HOWTO (R_MIPS_CALL_LO16, /* type */
540 2, /* size (0 = byte, 1 = short, 2 = long) */
542 FALSE, /* pc_relative */
544 complain_overflow_dont, /* complain_on_overflow */
545 mips_elf_generic_reloc, /* special_function */
546 "R_MIPS_CALL_LO16", /* name */
547 TRUE, /* partial_inplace */
548 0x0000ffff, /* src_mask */
549 0x0000ffff, /* dst_mask */
550 FALSE), /* pcrel_offset */
552 /* Section displacement. */
553 HOWTO (R_MIPS_SCN_DISP, /* type */
555 2, /* size (0 = byte, 1 = short, 2 = long) */
557 FALSE, /* pc_relative */
559 complain_overflow_dont, /* complain_on_overflow */
560 mips_elf_generic_reloc, /* special_function */
561 "R_MIPS_SCN_DISP", /* name */
562 TRUE, /* partial_inplace */
563 0xffffffff, /* src_mask */
564 0xffffffff, /* dst_mask */
565 FALSE), /* pcrel_offset */
567 HOWTO (R_MIPS_REL16, /* type */
569 1, /* size (0 = byte, 1 = short, 2 = long) */
571 FALSE, /* pc_relative */
573 complain_overflow_signed, /* complain_on_overflow */
574 mips_elf_generic_reloc, /* special_function */
575 "R_MIPS_REL16", /* name */
576 TRUE, /* partial_inplace */
577 0xffff, /* src_mask */
578 0xffff, /* dst_mask */
579 FALSE), /* pcrel_offset */
581 /* These two are obsolete. */
582 EMPTY_HOWTO (R_MIPS_ADD_IMMEDIATE),
583 EMPTY_HOWTO (R_MIPS_PJUMP),
585 /* Similiar to R_MIPS_REL32, but used for relocations in a GOT section.
586 It must be used for multigot GOT's (and only there). */
587 HOWTO (R_MIPS_RELGOT, /* type */
589 2, /* size (0 = byte, 1 = short, 2 = long) */
591 FALSE, /* pc_relative */
593 complain_overflow_dont, /* complain_on_overflow */
594 mips_elf_generic_reloc, /* special_function */
595 "R_MIPS_RELGOT", /* name */
596 TRUE, /* partial_inplace */
597 0xffffffff, /* src_mask */
598 0xffffffff, /* dst_mask */
599 FALSE), /* pcrel_offset */
601 /* Protected jump conversion. This is an optimization hint. No
602 relocation is required for correctness. */
603 HOWTO (R_MIPS_JALR, /* type */
605 2, /* size (0 = byte, 1 = short, 2 = long) */
607 FALSE, /* pc_relative */
609 complain_overflow_dont, /* complain_on_overflow */
610 mips_elf_generic_reloc, /* special_function */
611 "R_MIPS_JALR", /* name */
612 FALSE, /* partial_inplace */
613 0x00000000, /* src_mask */
614 0x00000000, /* dst_mask */
615 FALSE), /* pcrel_offset */
618 /* The relocation table used for SHT_RELA sections. */
620 static reloc_howto_type elf_mips_howto_table_rela[] =
623 HOWTO (R_MIPS_NONE, /* type */
625 0, /* size (0 = byte, 1 = short, 2 = long) */
627 FALSE, /* pc_relative */
629 complain_overflow_dont, /* complain_on_overflow */
630 mips_elf_generic_reloc, /* special_function */
631 "R_MIPS_NONE", /* name */
632 FALSE, /* partial_inplace */
635 FALSE), /* pcrel_offset */
637 /* 16 bit relocation. */
638 HOWTO (R_MIPS_16, /* type */
640 2, /* size (0 = byte, 1 = short, 2 = long) */
642 FALSE, /* pc_relative */
644 complain_overflow_signed, /* complain_on_overflow */
645 mips_elf_generic_reloc, /* special_function */
646 "R_MIPS_16", /* name */
647 FALSE, /* partial_inplace */
649 0x0000, /* dst_mask */
650 FALSE), /* pcrel_offset */
652 /* 32 bit relocation. */
653 HOWTO (R_MIPS_32, /* type */
655 2, /* size (0 = byte, 1 = short, 2 = long) */
657 FALSE, /* pc_relative */
659 complain_overflow_dont, /* complain_on_overflow */
660 mips_elf_generic_reloc, /* special_function */
661 "R_MIPS_32", /* name */
662 FALSE, /* partial_inplace */
664 0xffffffff, /* dst_mask */
665 FALSE), /* pcrel_offset */
667 /* 32 bit symbol relative relocation. */
668 HOWTO (R_MIPS_REL32, /* type */
670 2, /* size (0 = byte, 1 = short, 2 = long) */
672 FALSE, /* pc_relative */
674 complain_overflow_dont, /* complain_on_overflow */
675 mips_elf_generic_reloc, /* special_function */
676 "R_MIPS_REL32", /* name */
677 FALSE, /* partial_inplace */
679 0xffffffff, /* dst_mask */
680 FALSE), /* pcrel_offset */
682 /* 26 bit jump address. */
683 HOWTO (R_MIPS_26, /* type */
685 2, /* size (0 = byte, 1 = short, 2 = long) */
687 FALSE, /* pc_relative */
689 complain_overflow_dont, /* complain_on_overflow */
690 /* This needs complex overflow
691 detection, because the upper 36
692 bits must match the PC + 4. */
693 mips_elf_generic_reloc, /* special_function */
694 "R_MIPS_26", /* name */
695 FALSE, /* partial_inplace */
697 0x03ffffff, /* dst_mask */
698 FALSE), /* pcrel_offset */
700 /* High 16 bits of symbol value. */
701 HOWTO (R_MIPS_HI16, /* type */
703 2, /* size (0 = byte, 1 = short, 2 = long) */
705 FALSE, /* pc_relative */
707 complain_overflow_dont, /* complain_on_overflow */
708 mips_elf_generic_reloc, /* special_function */
709 "R_MIPS_HI16", /* name */
710 FALSE, /* partial_inplace */
712 0x0000ffff, /* dst_mask */
713 FALSE), /* pcrel_offset */
715 /* Low 16 bits of symbol value. */
716 HOWTO (R_MIPS_LO16, /* type */
718 2, /* size (0 = byte, 1 = short, 2 = long) */
720 FALSE, /* pc_relative */
722 complain_overflow_dont, /* complain_on_overflow */
723 mips_elf_generic_reloc, /* special_function */
724 "R_MIPS_LO16", /* name */
725 FALSE, /* partial_inplace */
727 0x0000ffff, /* dst_mask */
728 FALSE), /* pcrel_offset */
730 /* GP relative reference. */
731 HOWTO (R_MIPS_GPREL16, /* type */
733 2, /* size (0 = byte, 1 = short, 2 = long) */
735 FALSE, /* pc_relative */
737 complain_overflow_signed, /* complain_on_overflow */
738 mips_elf_gprel16_reloc, /* special_function */
739 "R_MIPS_GPREL16", /* name */
740 FALSE, /* partial_inplace */
742 0x0000ffff, /* dst_mask */
743 FALSE), /* pcrel_offset */
745 /* Reference to literal section. */
746 HOWTO (R_MIPS_LITERAL, /* type */
748 2, /* size (0 = byte, 1 = short, 2 = long) */
750 FALSE, /* pc_relative */
752 complain_overflow_signed, /* complain_on_overflow */
753 mips_elf_literal_reloc, /* special_function */
754 "R_MIPS_LITERAL", /* name */
755 FALSE, /* partial_inplace */
757 0x0000ffff, /* dst_mask */
758 FALSE), /* pcrel_offset */
760 /* Reference to global offset table. */
761 HOWTO (R_MIPS_GOT16, /* type */
763 2, /* size (0 = byte, 1 = short, 2 = long) */
765 FALSE, /* pc_relative */
767 complain_overflow_signed, /* complain_on_overflow */
768 mips_elf_got16_reloc, /* special_function */
769 "R_MIPS_GOT16", /* name */
770 FALSE, /* partial_inplace */
772 0x0000ffff, /* dst_mask */
773 FALSE), /* pcrel_offset */
775 /* 16 bit PC relative reference. */
776 HOWTO (R_MIPS_PC16, /* type */
778 2, /* size (0 = byte, 1 = short, 2 = long) */
780 TRUE, /* pc_relative */
782 complain_overflow_signed, /* complain_on_overflow */
783 mips_elf_generic_reloc, /* special_function */
784 "R_MIPS_PC16", /* name */
785 FALSE, /* partial_inplace */
787 0x0000ffff, /* dst_mask */
788 TRUE), /* pcrel_offset */
790 /* 16 bit call through global offset table. */
791 HOWTO (R_MIPS_CALL16, /* type */
793 2, /* size (0 = byte, 1 = short, 2 = long) */
795 FALSE, /* pc_relative */
797 complain_overflow_signed, /* complain_on_overflow */
798 mips_elf_generic_reloc, /* special_function */
799 "R_MIPS_CALL16", /* name */
800 FALSE, /* partial_inplace */
802 0x0000ffff, /* dst_mask */
803 FALSE), /* pcrel_offset */
805 /* 32 bit GP relative reference. */
806 HOWTO (R_MIPS_GPREL32, /* type */
808 2, /* size (0 = byte, 1 = short, 2 = long) */
810 FALSE, /* pc_relative */
812 complain_overflow_dont, /* complain_on_overflow */
813 mips_elf_gprel32_reloc, /* special_function */
814 "R_MIPS_GPREL32", /* name */
815 FALSE, /* partial_inplace */
817 0xffffffff, /* dst_mask */
818 FALSE), /* pcrel_offset */
824 /* A 5 bit shift field. */
825 HOWTO (R_MIPS_SHIFT5, /* type */
827 2, /* size (0 = byte, 1 = short, 2 = long) */
829 FALSE, /* pc_relative */
831 complain_overflow_bitfield, /* complain_on_overflow */
832 mips_elf_generic_reloc, /* special_function */
833 "R_MIPS_SHIFT5", /* name */
834 FALSE, /* partial_inplace */
836 0x000007c0, /* dst_mask */
837 FALSE), /* pcrel_offset */
839 /* A 6 bit shift field. */
840 HOWTO (R_MIPS_SHIFT6, /* type */
842 2, /* size (0 = byte, 1 = short, 2 = long) */
844 FALSE, /* pc_relative */
846 complain_overflow_bitfield, /* complain_on_overflow */
847 mips_elf_shift6_reloc, /* special_function */
848 "R_MIPS_SHIFT6", /* name */
849 FALSE, /* partial_inplace */
851 0x000007c4, /* dst_mask */
852 FALSE), /* pcrel_offset */
854 /* 64 bit relocation. */
855 HOWTO (R_MIPS_64, /* type */
857 4, /* size (0 = byte, 1 = short, 2 = long) */
859 FALSE, /* pc_relative */
861 complain_overflow_dont, /* complain_on_overflow */
862 mips_elf_generic_reloc, /* special_function */
863 "R_MIPS_64", /* name */
864 FALSE, /* partial_inplace */
866 MINUS_ONE, /* dst_mask */
867 FALSE), /* pcrel_offset */
869 /* Displacement in the global offset table. */
870 HOWTO (R_MIPS_GOT_DISP, /* type */
872 2, /* size (0 = byte, 1 = short, 2 = long) */
874 FALSE, /* pc_relative */
876 complain_overflow_signed, /* complain_on_overflow */
877 mips_elf_generic_reloc, /* special_function */
878 "R_MIPS_GOT_DISP", /* name */
879 FALSE, /* partial_inplace */
881 0x0000ffff, /* dst_mask */
882 FALSE), /* pcrel_offset */
884 /* Displacement to page pointer in the global offset table. */
885 HOWTO (R_MIPS_GOT_PAGE, /* type */
887 2, /* size (0 = byte, 1 = short, 2 = long) */
889 FALSE, /* pc_relative */
891 complain_overflow_signed, /* complain_on_overflow */
892 mips_elf_generic_reloc, /* special_function */
893 "R_MIPS_GOT_PAGE", /* name */
894 FALSE, /* partial_inplace */
896 0x0000ffff, /* dst_mask */
897 FALSE), /* pcrel_offset */
899 /* Offset from page pointer in the global offset table. */
900 HOWTO (R_MIPS_GOT_OFST, /* type */
902 2, /* size (0 = byte, 1 = short, 2 = long) */
904 FALSE, /* pc_relative */
906 complain_overflow_signed, /* complain_on_overflow */
907 mips_elf_generic_reloc, /* special_function */
908 "R_MIPS_GOT_OFST", /* name */
909 FALSE, /* partial_inplace */
911 0x0000ffff, /* dst_mask */
912 FALSE), /* pcrel_offset */
914 /* High 16 bits of displacement in global offset table. */
915 HOWTO (R_MIPS_GOT_HI16, /* type */
917 2, /* size (0 = byte, 1 = short, 2 = long) */
919 FALSE, /* pc_relative */
921 complain_overflow_dont, /* complain_on_overflow */
922 mips_elf_generic_reloc, /* special_function */
923 "R_MIPS_GOT_HI16", /* name */
924 FALSE, /* partial_inplace */
926 0x0000ffff, /* dst_mask */
927 FALSE), /* pcrel_offset */
929 /* Low 16 bits of displacement in global offset table. */
930 HOWTO (R_MIPS_GOT_LO16, /* type */
932 2, /* size (0 = byte, 1 = short, 2 = long) */
934 FALSE, /* pc_relative */
936 complain_overflow_dont, /* complain_on_overflow */
937 mips_elf_generic_reloc, /* special_function */
938 "R_MIPS_GOT_LO16", /* name */
939 FALSE, /* partial_inplace */
941 0x0000ffff, /* dst_mask */
942 FALSE), /* pcrel_offset */
944 /* 64 bit substraction. */
945 HOWTO (R_MIPS_SUB, /* type */
947 4, /* size (0 = byte, 1 = short, 2 = long) */
949 FALSE, /* pc_relative */
951 complain_overflow_dont, /* complain_on_overflow */
952 mips_elf_generic_reloc, /* special_function */
953 "R_MIPS_SUB", /* name */
954 FALSE, /* partial_inplace */
956 MINUS_ONE, /* dst_mask */
957 FALSE), /* pcrel_offset */
959 /* Insert the addend as an instruction. */
960 /* FIXME: Not handled correctly. */
961 HOWTO (R_MIPS_INSERT_A, /* type */
963 2, /* size (0 = byte, 1 = short, 2 = long) */
965 FALSE, /* pc_relative */
967 complain_overflow_dont, /* complain_on_overflow */
968 mips_elf_generic_reloc, /* special_function */
969 "R_MIPS_INSERT_A", /* name */
970 FALSE, /* partial_inplace */
972 0xffffffff, /* dst_mask */
973 FALSE), /* pcrel_offset */
975 /* Insert the addend as an instruction, and change all relocations
976 to refer to the old instruction at the address. */
977 /* FIXME: Not handled correctly. */
978 HOWTO (R_MIPS_INSERT_B, /* type */
980 2, /* size (0 = byte, 1 = short, 2 = long) */
982 FALSE, /* pc_relative */
984 complain_overflow_dont, /* complain_on_overflow */
985 mips_elf_generic_reloc, /* special_function */
986 "R_MIPS_INSERT_B", /* name */
987 FALSE, /* partial_inplace */
989 0xffffffff, /* dst_mask */
990 FALSE), /* pcrel_offset */
992 /* Delete a 32 bit instruction. */
993 /* FIXME: Not handled correctly. */
994 HOWTO (R_MIPS_DELETE, /* type */
996 2, /* size (0 = byte, 1 = short, 2 = long) */
998 FALSE, /* pc_relative */
1000 complain_overflow_dont, /* complain_on_overflow */
1001 mips_elf_generic_reloc, /* special_function */
1002 "R_MIPS_DELETE", /* name */
1003 FALSE, /* partial_inplace */
1005 0xffffffff, /* dst_mask */
1006 FALSE), /* pcrel_offset */
1008 /* Get the higher value of a 64 bit addend. */
1009 HOWTO (R_MIPS_HIGHER, /* type */
1011 2, /* size (0 = byte, 1 = short, 2 = long) */
1013 FALSE, /* pc_relative */
1015 complain_overflow_dont, /* complain_on_overflow */
1016 mips_elf_generic_reloc, /* special_function */
1017 "R_MIPS_HIGHER", /* name */
1018 FALSE, /* partial_inplace */
1020 0x0000ffff, /* dst_mask */
1021 FALSE), /* pcrel_offset */
1023 /* Get the highest value of a 64 bit addend. */
1024 HOWTO (R_MIPS_HIGHEST, /* type */
1026 2, /* size (0 = byte, 1 = short, 2 = long) */
1028 FALSE, /* pc_relative */
1030 complain_overflow_dont, /* complain_on_overflow */
1031 mips_elf_generic_reloc, /* special_function */
1032 "R_MIPS_HIGHEST", /* name */
1033 FALSE, /* partial_inplace */
1035 0x0000ffff, /* dst_mask */
1036 FALSE), /* pcrel_offset */
1038 /* High 16 bits of displacement in global offset table. */
1039 HOWTO (R_MIPS_CALL_HI16, /* type */
1041 2, /* size (0 = byte, 1 = short, 2 = long) */
1043 FALSE, /* pc_relative */
1045 complain_overflow_dont, /* complain_on_overflow */
1046 mips_elf_generic_reloc, /* special_function */
1047 "R_MIPS_CALL_HI16", /* name */
1048 FALSE, /* partial_inplace */
1050 0x0000ffff, /* dst_mask */
1051 FALSE), /* pcrel_offset */
1053 /* Low 16 bits of displacement in global offset table. */
1054 HOWTO (R_MIPS_CALL_LO16, /* type */
1056 2, /* size (0 = byte, 1 = short, 2 = long) */
1058 FALSE, /* pc_relative */
1060 complain_overflow_dont, /* complain_on_overflow */
1061 mips_elf_generic_reloc, /* special_function */
1062 "R_MIPS_CALL_LO16", /* name */
1063 FALSE, /* partial_inplace */
1065 0x0000ffff, /* dst_mask */
1066 FALSE), /* pcrel_offset */
1068 /* Section displacement, used by an associated event location section. */
1069 HOWTO (R_MIPS_SCN_DISP, /* type */
1071 2, /* size (0 = byte, 1 = short, 2 = long) */
1073 FALSE, /* pc_relative */
1075 complain_overflow_dont, /* complain_on_overflow */
1076 mips_elf_generic_reloc, /* special_function */
1077 "R_MIPS_SCN_DISP", /* name */
1078 FALSE, /* partial_inplace */
1080 0xffffffff, /* dst_mask */
1081 FALSE), /* pcrel_offset */
1083 /* 16 bit relocation. */
1084 HOWTO (R_MIPS_REL16, /* type */
1086 1, /* size (0 = byte, 1 = short, 2 = long) */
1088 FALSE, /* pc_relative */
1090 complain_overflow_signed, /* complain_on_overflow */
1091 mips_elf_generic_reloc, /* special_function */
1092 "R_MIPS_REL16", /* name */
1093 FALSE, /* partial_inplace */
1095 0xffff, /* dst_mask */
1096 FALSE), /* pcrel_offset */
1098 /* These two are obsolete. */
1099 EMPTY_HOWTO (R_MIPS_ADD_IMMEDIATE),
1100 EMPTY_HOWTO (R_MIPS_PJUMP),
1102 /* Similiar to R_MIPS_REL32, but used for relocations in a GOT section.
1103 It must be used for multigot GOT's (and only there). */
1104 HOWTO (R_MIPS_RELGOT, /* type */
1106 2, /* size (0 = byte, 1 = short, 2 = long) */
1108 FALSE, /* pc_relative */
1110 complain_overflow_dont, /* complain_on_overflow */
1111 mips_elf_generic_reloc, /* special_function */
1112 "R_MIPS_RELGOT", /* name */
1113 FALSE, /* partial_inplace */
1115 0xffffffff, /* dst_mask */
1116 FALSE), /* pcrel_offset */
1118 /* Protected jump conversion. This is an optimization hint. No
1119 relocation is required for correctness. */
1120 HOWTO (R_MIPS_JALR, /* type */
1122 2, /* size (0 = byte, 1 = short, 2 = long) */
1124 FALSE, /* pc_relative */
1126 complain_overflow_dont, /* complain_on_overflow */
1127 mips_elf_generic_reloc, /* special_function */
1128 "R_MIPS_JALR", /* name */
1129 FALSE, /* partial_inplace */
1131 0xffffffff, /* dst_mask */
1132 FALSE), /* pcrel_offset */
1135 /* The reloc used for the mips16 jump instruction. */
1136 static reloc_howto_type elf_mips16_jump_howto =
1137 HOWTO (R_MIPS16_26, /* type */
1139 2, /* size (0 = byte, 1 = short, 2 = long) */
1141 FALSE, /* pc_relative */
1143 complain_overflow_dont, /* complain_on_overflow */
1144 /* This needs complex overflow
1145 detection, because the upper four
1146 bits must match the PC. */
1147 mips16_jump_reloc, /* special_function */
1148 "R_MIPS16_26", /* name */
1149 TRUE, /* partial_inplace */
1150 0x3ffffff, /* src_mask */
1151 0x3ffffff, /* dst_mask */
1152 FALSE); /* pcrel_offset */
1154 /* The reloc used for the mips16 gprel instruction. */
1155 static reloc_howto_type elf_mips16_gprel_howto =
1156 HOWTO (R_MIPS16_GPREL, /* type */
1158 2, /* size (0 = byte, 1 = short, 2 = long) */
1160 FALSE, /* pc_relative */
1162 complain_overflow_signed, /* complain_on_overflow */
1163 mips16_gprel_reloc, /* special_function */
1164 "R_MIPS16_GPREL", /* name */
1165 TRUE, /* partial_inplace */
1166 0x07ff001f, /* src_mask */
1167 0x07ff001f, /* dst_mask */
1168 FALSE); /* pcrel_offset */
1170 /* GNU extension to record C++ vtable hierarchy */
1171 static reloc_howto_type elf_mips_gnu_vtinherit_howto =
1172 HOWTO (R_MIPS_GNU_VTINHERIT, /* type */
1174 2, /* size (0 = byte, 1 = short, 2 = long) */
1176 FALSE, /* pc_relative */
1178 complain_overflow_dont, /* complain_on_overflow */
1179 NULL, /* special_function */
1180 "R_MIPS_GNU_VTINHERIT", /* name */
1181 FALSE, /* partial_inplace */
1184 FALSE); /* pcrel_offset */
1186 /* GNU extension to record C++ vtable member usage */
1187 static reloc_howto_type elf_mips_gnu_vtentry_howto =
1188 HOWTO (R_MIPS_GNU_VTENTRY, /* type */
1190 2, /* size (0 = byte, 1 = short, 2 = long) */
1192 FALSE, /* pc_relative */
1194 complain_overflow_dont, /* complain_on_overflow */
1195 _bfd_elf_rel_vtable_reloc_fn, /* special_function */
1196 "R_MIPS_GNU_VTENTRY", /* name */
1197 FALSE, /* partial_inplace */
1200 FALSE); /* pcrel_offset */
1202 /* This is derived from bfd_elf_generic_reloc. NewABI allows us to have
1203 several relocations against the same address. The addend is derived
1204 from the addends of preceding relocations. If we don't need to
1205 do something special, we simply keep track of the addend. */
1207 #define GET_RELOC_ADDEND(obfd, sym, entry, sec) \
1209 /* If we're relocating, and this is an external symbol, we don't \
1210 want to change anything. */ \
1211 if ((obfd) != (bfd *) NULL \
1212 && ((sym)->flags & BSF_SECTION_SYM) == 0 \
1213 && (! (entry)->howto->partial_inplace \
1214 || (entry)->addend == 0)) \
1216 (entry)->address += (sec)->output_offset; \
1217 return bfd_reloc_ok; \
1220 /* The addend of combined relocs is remembered and left for \
1221 subsequent relocs. */ \
1222 if (prev_reloc_address != (entry)->address \
1223 || prev_reloc_section != (sec)) \
1225 prev_reloc_section = (sec); \
1226 prev_reloc_address = (entry)->address; \
1227 prev_reloc_addend = (entry)->addend; \
1230 (entry)->addend = prev_reloc_addend; \
1233 #define SET_RELOC_ADDEND(entry) \
1235 prev_reloc_addend = (entry)->addend; \
1238 static bfd_reloc_status_type
1239 mips_elf_generic_reloc (abfd, reloc_entry, symbol, data, input_section,
1240 output_bfd, error_message)
1241 bfd *abfd ATTRIBUTE_UNUSED;
1242 arelent *reloc_entry;
1244 PTR data ATTRIBUTE_UNUSED;
1245 asection *input_section;
1247 char **error_message ATTRIBUTE_UNUSED;
1249 GET_RELOC_ADDEND (output_bfd, symbol, reloc_entry, input_section)
1251 return bfd_reloc_continue;
1254 /* Do a R_MIPS_HI16 relocation. This has to be done in combination
1255 with a R_MIPS_LO16 reloc, because there is a carry from the LO16 to
1256 the HI16. Here we just save the information we need; we do the
1257 actual relocation when we see the LO16.
1259 MIPS ELF requires that the LO16 immediately follow the HI16. As a
1260 GNU extension, for non-pc-relative relocations, we permit an
1261 arbitrary number of HI16 relocs to be associated with a single LO16
1262 reloc. This extension permits gcc to output the HI and LO relocs
1265 This cannot be done for PC-relative relocations because both the HI16
1266 and LO16 parts of the relocations must be done relative to the LO16
1267 part, and there can be carry to or borrow from the HI16 part. */
1271 struct mips_hi16 *next;
1276 /* FIXME: This should not be a static variable. */
1278 static struct mips_hi16 *mips_hi16_list;
1280 static bfd_reloc_status_type
1281 mips_elf_hi16_reloc (abfd, reloc_entry, symbol, data, input_section,
1282 output_bfd, error_message)
1283 bfd *abfd ATTRIBUTE_UNUSED;
1284 arelent *reloc_entry;
1287 asection *input_section;
1289 char **error_message ATTRIBUTE_UNUSED;
1291 bfd_reloc_status_type ret;
1293 struct mips_hi16 *n;
1295 GET_RELOC_ADDEND (output_bfd, symbol, reloc_entry, input_section)
1299 if (bfd_is_und_section (symbol->section) && output_bfd == (bfd *) NULL)
1300 ret = bfd_reloc_undefined;
1302 if (bfd_is_com_section (symbol->section))
1305 relocation = symbol->value;
1307 relocation += symbol->section->output_section->vma;
1308 relocation += symbol->section->output_offset;
1309 relocation += reloc_entry->addend;
1311 if (reloc_entry->address > input_section->_cooked_size)
1312 return bfd_reloc_outofrange;
1314 /* Save the information, and let LO16 do the actual relocation. */
1315 n = (struct mips_hi16 *) bfd_malloc ((bfd_size_type) sizeof *n);
1317 return bfd_reloc_outofrange;
1318 n->addr = (bfd_byte *) data + reloc_entry->address;
1319 n->addend = relocation;
1320 n->next = mips_hi16_list;
1323 if (output_bfd != (bfd *) NULL)
1324 reloc_entry->address += input_section->output_offset;
1329 /* Do a R_MIPS_LO16 relocation. This is a straightforward 16 bit
1330 inplace relocation; this function exists in order to do the
1331 R_MIPS_HI16 relocation described above. */
1333 static bfd_reloc_status_type
1334 mips_elf_lo16_reloc (abfd, reloc_entry, symbol, data, input_section,
1335 output_bfd, error_message)
1337 arelent *reloc_entry;
1340 asection *input_section;
1342 char **error_message;
1344 if (mips_hi16_list != NULL)
1346 struct mips_hi16 *l;
1353 unsigned long vallo;
1354 struct mips_hi16 *next;
1356 /* Do the HI16 relocation. Note that we actually don't need
1357 to know anything about the LO16 itself, except where to
1358 find the low 16 bits of the addend needed by the LO16. */
1359 insn = bfd_get_32 (abfd, l->addr);
1360 vallo = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
1362 /* The low order 16 bits are always treated as a signed
1364 vallo = ((vallo & 0xffff) ^ 0x8000) - 0x8000;
1365 val = ((insn & 0xffff) << 16) + vallo;
1368 /* If PC-relative, we need to subtract out the address of the LO
1369 half of the HI/LO. (The actual relocation is relative
1370 to that instruction.) */
1371 if (reloc_entry->howto->pc_relative)
1372 val -= reloc_entry->address;
1374 /* At this point, "val" has the value of the combined HI/LO
1375 pair. If the low order 16 bits (which will be used for
1376 the LO16 insn) are negative, then we will need an
1377 adjustment for the high order 16 bits. */
1379 val = (val >> 16) & 0xffff;
1381 insn &= ~ (bfd_vma) 0xffff;
1383 bfd_put_32 (abfd, (bfd_vma) insn, l->addr);
1390 mips_hi16_list = NULL;
1393 /* Now do the LO16 reloc in the usual way. */
1394 return mips_elf_generic_reloc (abfd, reloc_entry, symbol, data,
1395 input_section, output_bfd, error_message);
1398 /* Do a R_MIPS_GOT16 reloc. This is a reloc against the global offset
1399 table used for PIC code. If the symbol is an external symbol, the
1400 instruction is modified to contain the offset of the appropriate
1401 entry in the global offset table. If the symbol is a section
1402 symbol, the next reloc is a R_MIPS_LO16 reloc. The two 16 bit
1403 addends are combined to form the real addend against the section
1404 symbol; the GOT16 is modified to contain the offset of an entry in
1405 the global offset table, and the LO16 is modified to offset it
1406 appropriately. Thus an offset larger than 16 bits requires a
1407 modified value in the global offset table.
1409 This implementation suffices for the assembler, but the linker does
1410 not yet know how to create global offset tables. */
1412 static bfd_reloc_status_type
1413 mips_elf_got16_reloc (abfd, reloc_entry, symbol, data, input_section,
1414 output_bfd, error_message)
1416 arelent *reloc_entry;
1419 asection *input_section;
1421 char **error_message;
1423 /* If we're relocating, and this is a local symbol, we can handle it
1425 if (output_bfd != (bfd *) NULL
1426 && (symbol->flags & BSF_SECTION_SYM) != 0)
1427 return mips_elf_hi16_reloc (abfd, reloc_entry, symbol, data,
1428 input_section, output_bfd, error_message);
1430 /* Otherwise we try to handle it as R_MIPS_GOT_DISP. */
1431 return mips_elf_generic_reloc (abfd, reloc_entry, symbol, data,
1432 input_section, output_bfd, error_message);
1435 /* Set the GP value for OUTPUT_BFD. Returns FALSE if this is a
1436 dangerous relocation. */
1439 mips_elf_assign_gp (output_bfd, pgp)
1447 /* If we've already figured out what GP will be, just return it. */
1448 *pgp = _bfd_get_gp_value (output_bfd);
1452 count = bfd_get_symcount (output_bfd);
1453 sym = bfd_get_outsymbols (output_bfd);
1455 /* The linker script will have created a symbol named `_gp' with the
1456 appropriate value. */
1457 if (sym == (asymbol **) NULL)
1461 for (i = 0; i < count; i++, sym++)
1463 register const char *name;
1465 name = bfd_asymbol_name (*sym);
1466 if (*name == '_' && strcmp (name, "_gp") == 0)
1468 *pgp = bfd_asymbol_value (*sym);
1469 _bfd_set_gp_value (output_bfd, *pgp);
1477 /* Only get the error once. */
1479 _bfd_set_gp_value (output_bfd, *pgp);
1486 /* We have to figure out the gp value, so that we can adjust the
1487 symbol value correctly. We look up the symbol _gp in the output
1488 BFD. If we can't find it, we're stuck. We cache it in the ELF
1489 target data. We don't need to adjust the symbol value for an
1490 external symbol if we are producing relocateable output. */
1492 static bfd_reloc_status_type
1493 mips_elf_final_gp (output_bfd, symbol, relocateable, error_message, pgp)
1496 bfd_boolean relocateable;
1497 char **error_message;
1500 if (bfd_is_und_section (symbol->section)
1504 return bfd_reloc_undefined;
1507 *pgp = _bfd_get_gp_value (output_bfd);
1510 || (symbol->flags & BSF_SECTION_SYM) != 0))
1514 /* Make up a value. */
1515 *pgp = symbol->section->output_section->vma /*+ 0x4000*/;
1516 _bfd_set_gp_value (output_bfd, *pgp);
1518 else if (!mips_elf_assign_gp (output_bfd, pgp))
1521 (char *) _("GP relative relocation when _gp not defined");
1522 return bfd_reloc_dangerous;
1526 return bfd_reloc_ok;
1529 /* Do a R_MIPS_GPREL16 relocation. This is a 16 bit value which must
1530 become the offset from the gp register. */
1532 static bfd_reloc_status_type
1533 mips_elf_gprel16_reloc (abfd, reloc_entry, symbol, data, input_section,
1534 output_bfd, error_message)
1535 bfd *abfd ATTRIBUTE_UNUSED;
1536 arelent *reloc_entry;
1538 PTR data ATTRIBUTE_UNUSED;
1539 asection *input_section;
1541 char **error_message ATTRIBUTE_UNUSED;
1543 bfd_boolean relocateable;
1544 bfd_reloc_status_type ret;
1547 GET_RELOC_ADDEND (output_bfd, symbol, reloc_entry, input_section)
1549 if (output_bfd != (bfd *) NULL)
1550 relocateable = TRUE;
1553 relocateable = FALSE;
1554 output_bfd = symbol->section->output_section->owner;
1557 ret = mips_elf_final_gp (output_bfd, symbol, relocateable, error_message,
1559 if (ret != bfd_reloc_ok)
1562 return _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
1563 input_section, relocateable,
1567 /* Do a R_MIPS_LITERAL relocation. */
1569 static bfd_reloc_status_type
1570 mips_elf_literal_reloc (abfd, reloc_entry, symbol, data, input_section,
1571 output_bfd, error_message)
1573 arelent *reloc_entry;
1576 asection *input_section;
1578 char **error_message;
1580 bfd_boolean relocateable;
1581 bfd_reloc_status_type ret;
1584 GET_RELOC_ADDEND (output_bfd, symbol, reloc_entry, input_section)
1586 /* FIXME: The entries in the .lit8 and .lit4 sections should be merged. */
1587 if (output_bfd != (bfd *) NULL)
1588 relocateable = TRUE;
1591 relocateable = FALSE;
1592 output_bfd = symbol->section->output_section->owner;
1595 ret = mips_elf_final_gp (output_bfd, symbol, relocateable, error_message,
1597 if (ret != bfd_reloc_ok)
1600 return _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
1601 input_section, relocateable,
1605 /* Do a R_MIPS_GPREL32 relocation. This is a 32 bit value which must
1606 become the offset from the gp register. */
1608 static bfd_reloc_status_type
1609 mips_elf_gprel32_reloc (abfd, reloc_entry, symbol, data, input_section,
1610 output_bfd, error_message)
1612 arelent *reloc_entry;
1615 asection *input_section;
1617 char **error_message;
1619 bfd_boolean relocateable;
1620 bfd_reloc_status_type ret;
1623 GET_RELOC_ADDEND (output_bfd, symbol, reloc_entry, input_section)
1625 /* R_MIPS_GPREL32 relocations are defined for local symbols only.
1626 We will only have an addend if this is a newly created reloc,
1627 not read from an ELF file. */
1628 if (output_bfd != (bfd *) NULL
1629 && (symbol->flags & BSF_SECTION_SYM) == 0
1630 && reloc_entry->addend == 0)
1632 *error_message = (char *)
1633 _("32bits gp relative relocation occurs for an external symbol");
1634 return bfd_reloc_outofrange;
1637 if (output_bfd != (bfd *) NULL)
1639 relocateable = TRUE;
1640 gp = _bfd_get_gp_value (output_bfd);
1644 relocateable = FALSE;
1645 output_bfd = symbol->section->output_section->owner;
1647 ret = mips_elf_final_gp (output_bfd, symbol, relocateable,
1648 error_message, &gp);
1649 if (ret != bfd_reloc_ok)
1653 return gprel32_with_gp (abfd, symbol, reloc_entry, input_section,
1654 relocateable, data, gp);
1657 static bfd_reloc_status_type
1658 gprel32_with_gp (abfd, symbol, reloc_entry, input_section, relocateable, data,
1662 arelent *reloc_entry;
1663 asection *input_section;
1664 bfd_boolean relocateable;
1671 if (bfd_is_com_section (symbol->section))
1674 relocation = symbol->value;
1676 relocation += symbol->section->output_section->vma;
1677 relocation += symbol->section->output_offset;
1679 if (reloc_entry->address > input_section->_cooked_size)
1680 return bfd_reloc_outofrange;
1682 if (reloc_entry->howto->src_mask == 0)
1685 val = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
1687 /* Set val to the offset into the section or symbol. */
1688 val += reloc_entry->addend;
1690 /* Adjust val for the final section location and GP value. If we
1691 are producing relocateable output, we don't want to do this for
1692 an external symbol. */
1694 || (symbol->flags & BSF_SECTION_SYM) != 0)
1695 val += relocation - gp;
1697 bfd_put_32 (abfd, (bfd_vma) val, (bfd_byte *) data + reloc_entry->address);
1700 reloc_entry->address += input_section->output_offset;
1702 return bfd_reloc_ok;
1705 /* Do a R_MIPS_SHIFT6 relocation. The MSB of the shift is stored at bit 2,
1706 the rest is at bits 6-10. The bitpos already got right by the howto. */
1708 static bfd_reloc_status_type
1709 mips_elf_shift6_reloc (abfd, reloc_entry, symbol, data, input_section,
1710 output_bfd, error_message)
1711 bfd *abfd ATTRIBUTE_UNUSED;
1712 arelent *reloc_entry;
1714 PTR data ATTRIBUTE_UNUSED;
1715 asection *input_section;
1717 char **error_message ATTRIBUTE_UNUSED;
1719 GET_RELOC_ADDEND (output_bfd, symbol, reloc_entry, input_section)
1721 reloc_entry->addend = (reloc_entry->addend & 0x00007c0)
1722 | (reloc_entry->addend & 0x00000800) >> 9;
1724 SET_RELOC_ADDEND (reloc_entry)
1726 return bfd_reloc_continue;
1729 /* Handle a mips16 jump. */
1731 static bfd_reloc_status_type
1732 mips16_jump_reloc (abfd, reloc_entry, symbol, data, input_section,
1733 output_bfd, error_message)
1734 bfd *abfd ATTRIBUTE_UNUSED;
1735 arelent *reloc_entry;
1737 PTR data ATTRIBUTE_UNUSED;
1738 asection *input_section;
1740 char **error_message ATTRIBUTE_UNUSED;
1742 static bfd_boolean warned = FALSE;
1744 GET_RELOC_ADDEND (output_bfd, symbol, reloc_entry, input_section)
1748 (*_bfd_error_handler)
1749 (_("Linking mips16 objects into %s format is not supported"),
1750 bfd_get_target (input_section->output_section->owner));
1753 return bfd_reloc_undefined;
1756 /* Handle a mips16 GP relative reloc. */
1758 static bfd_reloc_status_type
1759 mips16_gprel_reloc (abfd, reloc_entry, symbol, data, input_section,
1760 output_bfd, error_message)
1762 arelent *reloc_entry;
1765 asection *input_section;
1767 char **error_message;
1769 bfd_boolean relocateable;
1770 bfd_reloc_status_type ret;
1772 unsigned short extend, insn;
1773 unsigned long final;
1775 GET_RELOC_ADDEND (output_bfd, symbol, reloc_entry, input_section)
1777 if (output_bfd != NULL)
1778 relocateable = TRUE;
1781 relocateable = FALSE;
1782 output_bfd = symbol->section->output_section->owner;
1785 ret = mips_elf_final_gp (output_bfd, symbol, relocateable, error_message,
1787 if (ret != bfd_reloc_ok)
1790 if (reloc_entry->address > input_section->_cooked_size)
1791 return bfd_reloc_outofrange;
1793 /* Pick up the mips16 extend instruction and the real instruction. */
1794 extend = bfd_get_16 (abfd, (bfd_byte *) data + reloc_entry->address);
1795 insn = bfd_get_16 (abfd, (bfd_byte *) data + reloc_entry->address + 2);
1797 /* Stuff the current addend back as a 32 bit value, do the usual
1798 relocation, and then clean up. */
1800 (bfd_vma) (((extend & 0x1f) << 11)
1803 (bfd_byte *) data + reloc_entry->address);
1805 ret = _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
1806 input_section, relocateable, data, gp);
1808 final = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
1810 (bfd_vma) ((extend & 0xf800)
1811 | ((final >> 11) & 0x1f)
1813 (bfd_byte *) data + reloc_entry->address);
1815 (bfd_vma) ((insn & 0xffe0)
1817 (bfd_byte *) data + reloc_entry->address + 2);
1822 #undef GET_RELOC_ADDEND
1823 #undef SET_RELOC_ADDEND
1825 /* A mapping from BFD reloc types to MIPS ELF reloc types. */
1827 struct elf_reloc_map {
1828 bfd_reloc_code_real_type bfd_val;
1829 enum elf_mips_reloc_type elf_val;
1832 static const struct elf_reloc_map mips_reloc_map[] =
1834 { BFD_RELOC_NONE, R_MIPS_NONE },
1835 { BFD_RELOC_16, R_MIPS_16 },
1836 { BFD_RELOC_32, R_MIPS_32 },
1837 /* There is no BFD reloc for R_MIPS_REL32. */
1838 { BFD_RELOC_CTOR, R_MIPS_32 },
1839 { BFD_RELOC_64, R_MIPS_64 },
1840 { BFD_RELOC_16_PCREL, R_MIPS_PC16 },
1841 { BFD_RELOC_HI16_S, R_MIPS_HI16 },
1842 { BFD_RELOC_LO16, R_MIPS_LO16 },
1843 { BFD_RELOC_GPREL16, R_MIPS_GPREL16 },
1844 { BFD_RELOC_GPREL32, R_MIPS_GPREL32 },
1845 { BFD_RELOC_MIPS_JMP, R_MIPS_26 },
1846 { BFD_RELOC_MIPS_LITERAL, R_MIPS_LITERAL },
1847 { BFD_RELOC_MIPS_GOT16, R_MIPS_GOT16 },
1848 { BFD_RELOC_MIPS_CALL16, R_MIPS_CALL16 },
1849 { BFD_RELOC_MIPS_SHIFT5, R_MIPS_SHIFT5 },
1850 { BFD_RELOC_MIPS_SHIFT6, R_MIPS_SHIFT6 },
1851 { BFD_RELOC_MIPS_GOT_DISP, R_MIPS_GOT_DISP },
1852 { BFD_RELOC_MIPS_GOT_PAGE, R_MIPS_GOT_PAGE },
1853 { BFD_RELOC_MIPS_GOT_OFST, R_MIPS_GOT_OFST },
1854 { BFD_RELOC_MIPS_GOT_HI16, R_MIPS_GOT_HI16 },
1855 { BFD_RELOC_MIPS_GOT_LO16, R_MIPS_GOT_LO16 },
1856 { BFD_RELOC_MIPS_SUB, R_MIPS_SUB },
1857 { BFD_RELOC_MIPS_INSERT_A, R_MIPS_INSERT_A },
1858 { BFD_RELOC_MIPS_INSERT_B, R_MIPS_INSERT_B },
1859 { BFD_RELOC_MIPS_DELETE, R_MIPS_DELETE },
1860 { BFD_RELOC_MIPS_HIGHEST, R_MIPS_HIGHEST },
1861 { BFD_RELOC_MIPS_HIGHER, R_MIPS_HIGHER },
1862 { BFD_RELOC_MIPS_CALL_HI16, R_MIPS_CALL_HI16 },
1863 { BFD_RELOC_MIPS_CALL_LO16, R_MIPS_CALL_LO16 },
1864 { BFD_RELOC_MIPS_SCN_DISP, R_MIPS_SCN_DISP },
1865 { BFD_RELOC_MIPS_REL16, R_MIPS_REL16 },
1866 /* Use of R_MIPS_ADD_IMMEDIATE and R_MIPS_PJUMP is deprecated. */
1867 { BFD_RELOC_MIPS_RELGOT, R_MIPS_RELGOT },
1868 { BFD_RELOC_MIPS_JALR, R_MIPS_JALR }
1871 /* Given a BFD reloc type, return a howto structure. */
1873 static reloc_howto_type *
1874 bfd_elf32_bfd_reloc_type_lookup (abfd, code)
1875 bfd *abfd ATTRIBUTE_UNUSED;
1876 bfd_reloc_code_real_type code;
1879 /* FIXME: We default to RELA here instead of choosing the right
1880 relocation variant. */
1881 reloc_howto_type *howto_table = elf_mips_howto_table_rela;
1883 for (i = 0; i < sizeof (mips_reloc_map) / sizeof (struct elf_reloc_map);
1886 if (mips_reloc_map[i].bfd_val == code)
1887 return &howto_table[(int) mips_reloc_map[i].elf_val];
1892 case BFD_RELOC_MIPS16_JMP:
1893 return &elf_mips16_jump_howto;
1894 case BFD_RELOC_MIPS16_GPREL:
1895 return &elf_mips16_gprel_howto;
1896 case BFD_RELOC_VTABLE_INHERIT:
1897 return &elf_mips_gnu_vtinherit_howto;
1898 case BFD_RELOC_VTABLE_ENTRY:
1899 return &elf_mips_gnu_vtentry_howto;
1901 bfd_set_error (bfd_error_bad_value);
1906 /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure. */
1908 static reloc_howto_type *
1909 mips_elf_n32_rtype_to_howto (r_type, rela_p)
1910 unsigned int r_type;
1916 return &elf_mips16_jump_howto;
1917 case R_MIPS16_GPREL:
1918 return &elf_mips16_gprel_howto;
1919 case R_MIPS_GNU_VTINHERIT:
1920 return &elf_mips_gnu_vtinherit_howto;
1921 case R_MIPS_GNU_VTENTRY:
1922 return &elf_mips_gnu_vtentry_howto;
1924 BFD_ASSERT (r_type < (unsigned int) R_MIPS_max);
1926 return &elf_mips_howto_table_rela[r_type];
1928 return &elf_mips_howto_table_rel[r_type];
1933 /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure. */
1936 mips_info_to_howto_rel (abfd, cache_ptr, dst)
1939 Elf_Internal_Rela *dst;
1941 unsigned int r_type;
1943 r_type = ELF32_R_TYPE (dst->r_info);
1944 cache_ptr->howto = mips_elf_n32_rtype_to_howto (r_type, FALSE);
1946 /* The addend for a GPREL16 or LITERAL relocation comes from the GP
1947 value for the object file. We get the addend now, rather than
1948 when we do the relocation, because the symbol manipulations done
1949 by the linker may cause us to lose track of the input BFD. */
1950 if (((*cache_ptr->sym_ptr_ptr)->flags & BSF_SECTION_SYM) != 0
1951 && (r_type == (unsigned int) R_MIPS_GPREL16
1952 || r_type == (unsigned int) R_MIPS_LITERAL))
1953 cache_ptr->addend = elf_gp (abfd);
1956 /* Given a MIPS Elf_Internal_Rela, fill in an arelent structure. */
1959 mips_info_to_howto_rela (abfd, cache_ptr, dst)
1960 bfd *abfd ATTRIBUTE_UNUSED;
1962 Elf_Internal_Rela *dst;
1964 unsigned int r_type;
1966 r_type = ELF32_R_TYPE (dst->r_info);
1967 cache_ptr->howto = mips_elf_n32_rtype_to_howto (r_type, TRUE);
1968 cache_ptr->addend = dst->r_addend;
1971 /* Determine whether a symbol is global for the purposes of splitting
1972 the symbol table into global symbols and local symbols. At least
1973 on Irix 5, this split must be between section symbols and all other
1974 symbols. On most ELF targets the split is between static symbols
1975 and externally visible symbols. */
1978 mips_elf_sym_is_global (abfd, sym)
1979 bfd *abfd ATTRIBUTE_UNUSED;
1982 if (SGI_COMPAT (abfd))
1983 return (sym->flags & BSF_SECTION_SYM) == 0;
1985 return ((sym->flags & (BSF_GLOBAL | BSF_WEAK)) != 0
1986 || bfd_is_und_section (bfd_get_section (sym))
1987 || bfd_is_com_section (bfd_get_section (sym)));
1990 /* Set the right machine number for a MIPS ELF file. */
1993 mips_elf_n32_object_p (abfd)
1998 /* Irix 5 and 6 are broken. Object file symbol tables are not always
1999 sorted correctly such that local symbols precede global symbols,
2000 and the sh_info field in the symbol table is not always right. */
2001 if (SGI_COMPAT (abfd))
2002 elf_bad_symtab (abfd) = TRUE;
2004 mach = _bfd_elf_mips_mach (elf_elfheader (abfd)->e_flags);
2005 bfd_default_set_arch_mach (abfd, bfd_arch_mips, mach);
2007 if (! ABI_N32_P(abfd))
2013 /* Support for core dump NOTE sections. */
2015 elf32_mips_grok_prstatus (abfd, note)
2017 Elf_Internal_Note *note;
2020 unsigned int raw_size;
2022 switch (note->descsz)
2027 case 440: /* Linux/MIPS N32 */
2029 elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
2032 elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24);
2041 /* Make a ".reg/999" section. */
2042 return _bfd_elfcore_make_pseudosection (abfd, ".reg", raw_size,
2043 note->descpos + offset);
2047 elf32_mips_grok_psinfo (abfd, note)
2049 Elf_Internal_Note *note;
2051 switch (note->descsz)
2056 case 128: /* Linux/MIPS elf_prpsinfo */
2057 elf_tdata (abfd)->core_program
2058 = _bfd_elfcore_strndup (abfd, note->descdata + 32, 16);
2059 elf_tdata (abfd)->core_command
2060 = _bfd_elfcore_strndup (abfd, note->descdata + 48, 80);
2063 /* Note that for some reason, a spurious space is tacked
2064 onto the end of the args in some (at least one anyway)
2065 implementations, so strip it off if it exists. */
2068 char *command = elf_tdata (abfd)->core_command;
2069 int n = strlen (command);
2071 if (0 < n && command[n - 1] == ' ')
2072 command[n - 1] = '\0';
2078 /* Depending on the target vector we generate some version of Irix
2079 executables or "normal" MIPS ELF ABI executables. */
2080 static irix_compat_t
2081 elf_n32_mips_irix_compat (abfd)
2084 if ((abfd->xvec == &bfd_elf32_nbigmips_vec)
2085 || (abfd->xvec == &bfd_elf32_nlittlemips_vec))
2091 /* ECOFF swapping routines. These are used when dealing with the
2092 .mdebug section, which is in the ECOFF debugging format. */
2093 static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = {
2094 /* Symbol table magic number. */
2096 /* Alignment of debugging information. E.g., 4. */
2098 /* Sizes of external symbolic information. */
2099 sizeof (struct hdr_ext),
2100 sizeof (struct dnr_ext),
2101 sizeof (struct pdr_ext),
2102 sizeof (struct sym_ext),
2103 sizeof (struct opt_ext),
2104 sizeof (struct fdr_ext),
2105 sizeof (struct rfd_ext),
2106 sizeof (struct ext_ext),
2107 /* Functions to swap in external symbolic data. */
2116 _bfd_ecoff_swap_tir_in,
2117 _bfd_ecoff_swap_rndx_in,
2118 /* Functions to swap out external symbolic data. */
2127 _bfd_ecoff_swap_tir_out,
2128 _bfd_ecoff_swap_rndx_out,
2129 /* Function to read in symbolic data. */
2130 _bfd_mips_elf_read_ecoff_info
2133 #define ELF_ARCH bfd_arch_mips
2134 #define ELF_MACHINE_CODE EM_MIPS
2136 /* The SVR4 MIPS ABI says that this should be 0x10000, but Irix 5 uses
2137 a value of 0x1000, and we are compatible.
2138 FIXME: How does this affect NewABI? */
2139 #define ELF_MAXPAGESIZE 0x1000
2141 #define elf_backend_collect TRUE
2142 #define elf_backend_type_change_ok TRUE
2143 #define elf_backend_can_gc_sections TRUE
2144 #define elf_info_to_howto mips_info_to_howto_rela
2145 #define elf_info_to_howto_rel mips_info_to_howto_rel
2146 #define elf_backend_sym_is_global mips_elf_sym_is_global
2147 #define elf_backend_object_p mips_elf_n32_object_p
2148 #define elf_backend_symbol_processing _bfd_mips_elf_symbol_processing
2149 #define elf_backend_section_processing _bfd_mips_elf_section_processing
2150 #define elf_backend_section_from_shdr _bfd_mips_elf_section_from_shdr
2151 #define elf_backend_fake_sections _bfd_mips_elf_fake_sections
2152 #define elf_backend_section_from_bfd_section \
2153 _bfd_mips_elf_section_from_bfd_section
2154 #define elf_backend_add_symbol_hook _bfd_mips_elf_add_symbol_hook
2155 #define elf_backend_link_output_symbol_hook \
2156 _bfd_mips_elf_link_output_symbol_hook
2157 #define elf_backend_create_dynamic_sections \
2158 _bfd_mips_elf_create_dynamic_sections
2159 #define elf_backend_check_relocs _bfd_mips_elf_check_relocs
2160 #define elf_backend_adjust_dynamic_symbol \
2161 _bfd_mips_elf_adjust_dynamic_symbol
2162 #define elf_backend_always_size_sections \
2163 _bfd_mips_elf_always_size_sections
2164 #define elf_backend_size_dynamic_sections \
2165 _bfd_mips_elf_size_dynamic_sections
2166 #define elf_backend_relocate_section _bfd_mips_elf_relocate_section
2167 #define elf_backend_finish_dynamic_symbol \
2168 _bfd_mips_elf_finish_dynamic_symbol
2169 #define elf_backend_finish_dynamic_sections \
2170 _bfd_mips_elf_finish_dynamic_sections
2171 #define elf_backend_final_write_processing \
2172 _bfd_mips_elf_final_write_processing
2173 #define elf_backend_additional_program_headers \
2174 _bfd_mips_elf_additional_program_headers
2175 #define elf_backend_modify_segment_map _bfd_mips_elf_modify_segment_map
2176 #define elf_backend_gc_mark_hook _bfd_mips_elf_gc_mark_hook
2177 #define elf_backend_gc_sweep_hook _bfd_mips_elf_gc_sweep_hook
2178 #define elf_backend_copy_indirect_symbol \
2179 _bfd_mips_elf_copy_indirect_symbol
2180 #define elf_backend_hide_symbol _bfd_mips_elf_hide_symbol
2181 #define elf_backend_grok_prstatus elf32_mips_grok_prstatus
2182 #define elf_backend_grok_psinfo elf32_mips_grok_psinfo
2183 #define elf_backend_ecoff_debug_swap &mips_elf32_ecoff_debug_swap
2185 #define elf_backend_got_header_size (4 * MIPS_RESERVED_GOTNO)
2186 #define elf_backend_plt_header_size 0
2188 /* MIPS n32 ELF can use a mixture of REL and RELA, but some Relocations
2189 work better/work only in RELA, so we default to this. */
2190 #define elf_backend_may_use_rel_p 1
2191 #define elf_backend_may_use_rela_p 1
2192 #define elf_backend_default_use_rela_p 1
2193 #define elf_backend_sign_extend_vma TRUE
2195 #define elf_backend_discard_info _bfd_mips_elf_discard_info
2196 #define elf_backend_ignore_discarded_relocs \
2197 _bfd_mips_elf_ignore_discarded_relocs
2198 #define elf_backend_write_section _bfd_mips_elf_write_section
2199 #define elf_backend_mips_irix_compat elf_n32_mips_irix_compat
2200 #define elf_backend_mips_rtype_to_howto mips_elf_n32_rtype_to_howto
2201 #define bfd_elf32_find_nearest_line _bfd_mips_elf_find_nearest_line
2202 #define bfd_elf32_new_section_hook _bfd_mips_elf_new_section_hook
2203 #define bfd_elf32_set_section_contents _bfd_mips_elf_set_section_contents
2204 #define bfd_elf32_bfd_get_relocated_section_contents \
2205 _bfd_elf_mips_get_relocated_section_contents
2206 #define bfd_elf32_bfd_link_hash_table_create \
2207 _bfd_mips_elf_link_hash_table_create
2208 #define bfd_elf32_bfd_final_link _bfd_mips_elf_final_link
2209 #define bfd_elf32_bfd_merge_private_bfd_data \
2210 _bfd_mips_elf_merge_private_bfd_data
2211 #define bfd_elf32_bfd_set_private_flags _bfd_mips_elf_set_private_flags
2212 #define bfd_elf32_bfd_print_private_bfd_data \
2213 _bfd_mips_elf_print_private_bfd_data
2214 #define bfd_elf32_bfd_relax_section _bfd_mips_relax_section
2216 /* Support for SGI-ish mips targets using n32 ABI. */
2218 #define TARGET_LITTLE_SYM bfd_elf32_nlittlemips_vec
2219 #define TARGET_LITTLE_NAME "elf32-nlittlemips"
2220 #define TARGET_BIG_SYM bfd_elf32_nbigmips_vec
2221 #define TARGET_BIG_NAME "elf32-nbigmips"
2223 #include "elf32-target.h"
2225 /* Support for traditional mips targets using n32 ABI. */
2226 #define INCLUDED_TARGET_FILE /* More a type of flag. */
2228 #undef TARGET_LITTLE_SYM
2229 #undef TARGET_LITTLE_NAME
2230 #undef TARGET_BIG_SYM
2231 #undef TARGET_BIG_NAME
2233 #define TARGET_LITTLE_SYM bfd_elf32_ntradlittlemips_vec
2234 #define TARGET_LITTLE_NAME "elf32-ntradlittlemips"
2235 #define TARGET_BIG_SYM bfd_elf32_ntradbigmips_vec
2236 #define TARGET_BIG_NAME "elf32-ntradbigmips"
2238 /* Include the target file again for this target. */
2239 #include "elf32-target.h"