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 gprel32_with_gp
51 (bfd
*, asymbol
*, arelent
*, asection
*, bfd_boolean
, void *, bfd_vma
);
52 static bfd_reloc_status_type mips_elf_gprel32_reloc
53 (bfd
*, arelent
*, asymbol
*, void *, asection
*, bfd
*, char **);
54 static bfd_reloc_status_type mips32_64bit_reloc
55 (bfd
*, arelent
*, asymbol
*, void *, asection
*, bfd
*, char **);
56 static reloc_howto_type
*bfd_elf32_bfd_reloc_type_lookup
57 (bfd
*, bfd_reloc_code_real_type
);
58 static reloc_howto_type
*mips_elf32_rtype_to_howto
59 (unsigned int, bfd_boolean
);
60 static void mips_info_to_howto_rel
61 (bfd
*, arelent
*, Elf_Internal_Rela
*);
62 static void mips_info_to_howto_rela
63 (bfd
*, arelent
*, Elf_Internal_Rela
*);
64 static bfd_boolean mips_elf_sym_is_global
66 static bfd_boolean mips_elf32_object_p
68 static bfd_boolean mips_elf_is_local_label_name
69 (bfd
*, const char *);
70 static bfd_reloc_status_type mips16_jump_reloc
71 (bfd
*, arelent
*, asymbol
*, void *, asection
*, bfd
*, char **);
72 static bfd_reloc_status_type mips16_gprel_reloc
73 (bfd
*, arelent
*, asymbol
*, void *, asection
*, bfd
*, char **);
74 static bfd_reloc_status_type mips_elf_final_gp
75 (bfd
*, asymbol
*, bfd_boolean
, char **, bfd_vma
*);
76 static bfd_boolean mips_elf_assign_gp
78 static bfd_boolean elf32_mips_grok_prstatus
79 (bfd
*, Elf_Internal_Note
*);
80 static bfd_boolean elf32_mips_grok_psinfo
81 (bfd
*, Elf_Internal_Note
*);
82 static irix_compat_t elf32_mips_irix_compat
85 extern const bfd_target bfd_elf32_bigmips_vec
;
86 extern const bfd_target bfd_elf32_littlemips_vec
;
88 /* Nonzero if ABFD is using the N32 ABI. */
89 #define ABI_N32_P(abfd) \
90 ((elf_elfheader (abfd)->e_flags & EF_MIPS_ABI2) != 0)
92 /* Whether we are trying to be compatible with IRIX at all. */
93 #define SGI_COMPAT(abfd) \
94 (elf32_mips_irix_compat (abfd) != ict_none)
96 /* The number of local .got entries we reserve. */
97 #define MIPS_RESERVED_GOTNO (2)
99 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
100 from smaller values. Start with zero, widen, *then* decrement. */
101 #define MINUS_ONE (((bfd_vma)0) - 1)
103 /* The relocation table used for SHT_REL sections. */
105 static reloc_howto_type elf_mips_howto_table_rel
[] =
108 HOWTO (R_MIPS_NONE
, /* type */
110 0, /* size (0 = byte, 1 = short, 2 = long) */
112 FALSE
, /* pc_relative */
114 complain_overflow_dont
, /* complain_on_overflow */
115 _bfd_mips_elf_generic_reloc
, /* special_function */
116 "R_MIPS_NONE", /* name */
117 FALSE
, /* partial_inplace */
120 FALSE
), /* pcrel_offset */
122 /* 16 bit relocation. */
123 HOWTO (R_MIPS_16
, /* type */
125 2, /* size (0 = byte, 1 = short, 2 = long) */
127 FALSE
, /* pc_relative */
129 complain_overflow_signed
, /* complain_on_overflow */
130 _bfd_mips_elf_generic_reloc
, /* special_function */
131 "R_MIPS_16", /* name */
132 TRUE
, /* partial_inplace */
133 0x0000ffff, /* src_mask */
134 0x0000ffff, /* dst_mask */
135 FALSE
), /* pcrel_offset */
137 /* 32 bit relocation. */
138 HOWTO (R_MIPS_32
, /* type */
140 2, /* size (0 = byte, 1 = short, 2 = long) */
142 FALSE
, /* pc_relative */
144 complain_overflow_dont
, /* complain_on_overflow */
145 _bfd_mips_elf_generic_reloc
, /* special_function */
146 "R_MIPS_32", /* name */
147 TRUE
, /* partial_inplace */
148 0xffffffff, /* src_mask */
149 0xffffffff, /* dst_mask */
150 FALSE
), /* pcrel_offset */
152 /* 32 bit symbol relative relocation. */
153 HOWTO (R_MIPS_REL32
, /* type */
155 2, /* size (0 = byte, 1 = short, 2 = long) */
157 FALSE
, /* pc_relative */
159 complain_overflow_dont
, /* complain_on_overflow */
160 _bfd_mips_elf_generic_reloc
, /* special_function */
161 "R_MIPS_REL32", /* name */
162 TRUE
, /* partial_inplace */
163 0xffffffff, /* src_mask */
164 0xffffffff, /* dst_mask */
165 FALSE
), /* pcrel_offset */
167 /* 26 bit jump address. */
168 HOWTO (R_MIPS_26
, /* type */
170 2, /* size (0 = byte, 1 = short, 2 = long) */
172 FALSE
, /* pc_relative */
174 complain_overflow_dont
, /* complain_on_overflow */
175 /* This needs complex overflow
176 detection, because the upper four
177 bits must match the PC + 4. */
178 _bfd_mips_elf_generic_reloc
, /* special_function */
179 "R_MIPS_26", /* name */
180 TRUE
, /* partial_inplace */
181 0x03ffffff, /* src_mask */
182 0x03ffffff, /* dst_mask */
183 FALSE
), /* pcrel_offset */
185 /* High 16 bits of symbol value. */
186 HOWTO (R_MIPS_HI16
, /* type */
188 2, /* size (0 = byte, 1 = short, 2 = long) */
190 FALSE
, /* pc_relative */
192 complain_overflow_dont
, /* complain_on_overflow */
193 _bfd_mips_elf_hi16_reloc
, /* special_function */
194 "R_MIPS_HI16", /* name */
195 TRUE
, /* partial_inplace */
196 0x0000ffff, /* src_mask */
197 0x0000ffff, /* dst_mask */
198 FALSE
), /* pcrel_offset */
200 /* Low 16 bits of symbol value. */
201 HOWTO (R_MIPS_LO16
, /* type */
203 2, /* size (0 = byte, 1 = short, 2 = long) */
205 FALSE
, /* pc_relative */
207 complain_overflow_dont
, /* complain_on_overflow */
208 _bfd_mips_elf_lo16_reloc
, /* special_function */
209 "R_MIPS_LO16", /* name */
210 TRUE
, /* partial_inplace */
211 0x0000ffff, /* src_mask */
212 0x0000ffff, /* dst_mask */
213 FALSE
), /* pcrel_offset */
215 /* GP relative reference. */
216 HOWTO (R_MIPS_GPREL16
, /* type */
218 2, /* size (0 = byte, 1 = short, 2 = long) */
220 FALSE
, /* pc_relative */
222 complain_overflow_signed
, /* complain_on_overflow */
223 _bfd_mips_elf32_gprel16_reloc
, /* special_function */
224 "R_MIPS_GPREL16", /* name */
225 TRUE
, /* partial_inplace */
226 0x0000ffff, /* src_mask */
227 0x0000ffff, /* dst_mask */
228 FALSE
), /* pcrel_offset */
230 /* Reference to literal section. */
231 HOWTO (R_MIPS_LITERAL
, /* type */
233 2, /* size (0 = byte, 1 = short, 2 = long) */
235 FALSE
, /* pc_relative */
237 complain_overflow_signed
, /* complain_on_overflow */
238 _bfd_mips_elf32_gprel16_reloc
, /* special_function */
239 "R_MIPS_LITERAL", /* name */
240 TRUE
, /* partial_inplace */
241 0x0000ffff, /* src_mask */
242 0x0000ffff, /* dst_mask */
243 FALSE
), /* pcrel_offset */
245 /* Reference to global offset table. */
246 HOWTO (R_MIPS_GOT16
, /* type */
248 2, /* size (0 = byte, 1 = short, 2 = long) */
250 FALSE
, /* pc_relative */
252 complain_overflow_signed
, /* complain_on_overflow */
253 _bfd_mips_elf_got16_reloc
, /* special_function */
254 "R_MIPS_GOT16", /* name */
255 TRUE
, /* partial_inplace */
256 0x0000ffff, /* src_mask */
257 0x0000ffff, /* dst_mask */
258 FALSE
), /* pcrel_offset */
260 /* 16 bit PC relative reference. */
261 HOWTO (R_MIPS_PC16
, /* type */
263 2, /* size (0 = byte, 1 = short, 2 = long) */
265 TRUE
, /* pc_relative */
267 complain_overflow_signed
, /* complain_on_overflow */
268 _bfd_mips_elf_generic_reloc
, /* special_function */
269 "R_MIPS_PC16", /* name */
270 TRUE
, /* partial_inplace */
271 0x0000ffff, /* src_mask */
272 0x0000ffff, /* dst_mask */
273 TRUE
), /* pcrel_offset */
275 /* 16 bit call through global offset table. */
276 HOWTO (R_MIPS_CALL16
, /* type */
278 2, /* size (0 = byte, 1 = short, 2 = long) */
280 FALSE
, /* pc_relative */
282 complain_overflow_signed
, /* complain_on_overflow */
283 _bfd_mips_elf_generic_reloc
, /* special_function */
284 "R_MIPS_CALL16", /* name */
285 TRUE
, /* partial_inplace */
286 0x0000ffff, /* src_mask */
287 0x0000ffff, /* dst_mask */
288 FALSE
), /* pcrel_offset */
290 /* 32 bit GP relative reference. */
291 HOWTO (R_MIPS_GPREL32
, /* type */
293 2, /* size (0 = byte, 1 = short, 2 = long) */
295 FALSE
, /* pc_relative */
297 complain_overflow_dont
, /* complain_on_overflow */
298 mips_elf_gprel32_reloc
, /* special_function */
299 "R_MIPS_GPREL32", /* name */
300 TRUE
, /* partial_inplace */
301 0xffffffff, /* src_mask */
302 0xffffffff, /* dst_mask */
303 FALSE
), /* pcrel_offset */
305 /* The remaining relocs are defined on Irix 5, although they are
306 not defined by the ABI. */
311 /* A 5 bit shift field. */
312 HOWTO (R_MIPS_SHIFT5
, /* type */
314 2, /* size (0 = byte, 1 = short, 2 = long) */
316 FALSE
, /* pc_relative */
318 complain_overflow_bitfield
, /* complain_on_overflow */
319 _bfd_mips_elf_generic_reloc
, /* special_function */
320 "R_MIPS_SHIFT5", /* name */
321 TRUE
, /* partial_inplace */
322 0x000007c0, /* src_mask */
323 0x000007c0, /* dst_mask */
324 FALSE
), /* pcrel_offset */
326 /* A 6 bit shift field. */
327 /* FIXME: This is not handled correctly; a special function is
328 needed to put the most significant bit in the right place. */
329 HOWTO (R_MIPS_SHIFT6
, /* type */
331 2, /* size (0 = byte, 1 = short, 2 = long) */
333 FALSE
, /* pc_relative */
335 complain_overflow_bitfield
, /* complain_on_overflow */
336 _bfd_mips_elf_generic_reloc
, /* special_function */
337 "R_MIPS_SHIFT6", /* name */
338 TRUE
, /* partial_inplace */
339 0x000007c4, /* src_mask */
340 0x000007c4, /* dst_mask */
341 FALSE
), /* pcrel_offset */
343 /* A 64 bit relocation. */
344 HOWTO (R_MIPS_64
, /* type */
346 4, /* size (0 = byte, 1 = short, 2 = long) */
348 FALSE
, /* pc_relative */
350 complain_overflow_dont
, /* complain_on_overflow */
351 mips32_64bit_reloc
, /* special_function */
352 "R_MIPS_64", /* name */
353 TRUE
, /* partial_inplace */
354 MINUS_ONE
, /* src_mask */
355 MINUS_ONE
, /* dst_mask */
356 FALSE
), /* pcrel_offset */
358 /* Displacement in the global offset table. */
359 HOWTO (R_MIPS_GOT_DISP
, /* type */
361 2, /* size (0 = byte, 1 = short, 2 = long) */
363 FALSE
, /* pc_relative */
365 complain_overflow_signed
, /* complain_on_overflow */
366 _bfd_mips_elf_generic_reloc
, /* special_function */
367 "R_MIPS_GOT_DISP", /* name */
368 TRUE
, /* partial_inplace */
369 0x0000ffff, /* src_mask */
370 0x0000ffff, /* dst_mask */
371 FALSE
), /* pcrel_offset */
373 /* Displacement to page pointer in the global offset table. */
374 HOWTO (R_MIPS_GOT_PAGE
, /* type */
376 2, /* size (0 = byte, 1 = short, 2 = long) */
378 FALSE
, /* pc_relative */
380 complain_overflow_signed
, /* complain_on_overflow */
381 _bfd_mips_elf_generic_reloc
, /* special_function */
382 "R_MIPS_GOT_PAGE", /* name */
383 TRUE
, /* partial_inplace */
384 0x0000ffff, /* src_mask */
385 0x0000ffff, /* dst_mask */
386 FALSE
), /* pcrel_offset */
388 /* Offset from page pointer in the global offset table. */
389 HOWTO (R_MIPS_GOT_OFST
, /* type */
391 2, /* size (0 = byte, 1 = short, 2 = long) */
393 FALSE
, /* pc_relative */
395 complain_overflow_signed
, /* complain_on_overflow */
396 _bfd_mips_elf_generic_reloc
, /* special_function */
397 "R_MIPS_GOT_OFST", /* name */
398 TRUE
, /* partial_inplace */
399 0x0000ffff, /* src_mask */
400 0x0000ffff, /* dst_mask */
401 FALSE
), /* pcrel_offset */
403 /* High 16 bits of displacement in global offset table. */
404 HOWTO (R_MIPS_GOT_HI16
, /* type */
406 2, /* size (0 = byte, 1 = short, 2 = long) */
408 FALSE
, /* pc_relative */
410 complain_overflow_dont
, /* complain_on_overflow */
411 _bfd_mips_elf_generic_reloc
, /* special_function */
412 "R_MIPS_GOT_HI16", /* name */
413 TRUE
, /* partial_inplace */
414 0x0000ffff, /* src_mask */
415 0x0000ffff, /* dst_mask */
416 FALSE
), /* pcrel_offset */
418 /* Low 16 bits of displacement in global offset table. */
419 HOWTO (R_MIPS_GOT_LO16
, /* type */
421 2, /* size (0 = byte, 1 = short, 2 = long) */
423 FALSE
, /* pc_relative */
425 complain_overflow_dont
, /* complain_on_overflow */
426 _bfd_mips_elf_generic_reloc
, /* special_function */
427 "R_MIPS_GOT_LO16", /* name */
428 TRUE
, /* partial_inplace */
429 0x0000ffff, /* src_mask */
430 0x0000ffff, /* dst_mask */
431 FALSE
), /* pcrel_offset */
433 /* 64 bit subtraction. Used in the N32 ABI. */
434 HOWTO (R_MIPS_SUB
, /* type */
436 4, /* size (0 = byte, 1 = short, 2 = long) */
438 FALSE
, /* pc_relative */
440 complain_overflow_dont
, /* complain_on_overflow */
441 _bfd_mips_elf_generic_reloc
, /* special_function */
442 "R_MIPS_SUB", /* name */
443 TRUE
, /* partial_inplace */
444 MINUS_ONE
, /* src_mask */
445 MINUS_ONE
, /* dst_mask */
446 FALSE
), /* pcrel_offset */
448 /* Used to cause the linker to insert and delete instructions? */
449 EMPTY_HOWTO (R_MIPS_INSERT_A
),
450 EMPTY_HOWTO (R_MIPS_INSERT_B
),
451 EMPTY_HOWTO (R_MIPS_DELETE
),
453 /* Get the higher value of a 64 bit addend. */
454 HOWTO (R_MIPS_HIGHER
, /* type */
456 2, /* size (0 = byte, 1 = short, 2 = long) */
458 FALSE
, /* pc_relative */
460 complain_overflow_dont
, /* complain_on_overflow */
461 _bfd_mips_elf_generic_reloc
, /* special_function */
462 "R_MIPS_HIGHER", /* name */
463 TRUE
, /* partial_inplace */
464 0x0000ffff, /* src_mask */
465 0x0000ffff, /* dst_mask */
466 FALSE
), /* pcrel_offset */
468 /* Get the highest value of a 64 bit addend. */
469 HOWTO (R_MIPS_HIGHEST
, /* type */
471 2, /* size (0 = byte, 1 = short, 2 = long) */
473 FALSE
, /* pc_relative */
475 complain_overflow_dont
, /* complain_on_overflow */
476 _bfd_mips_elf_generic_reloc
, /* special_function */
477 "R_MIPS_HIGHEST", /* name */
478 TRUE
, /* partial_inplace */
479 0x0000ffff, /* src_mask */
480 0x0000ffff, /* dst_mask */
481 FALSE
), /* pcrel_offset */
483 /* High 16 bits of displacement in global offset table. */
484 HOWTO (R_MIPS_CALL_HI16
, /* type */
486 2, /* size (0 = byte, 1 = short, 2 = long) */
488 FALSE
, /* pc_relative */
490 complain_overflow_dont
, /* complain_on_overflow */
491 _bfd_mips_elf_generic_reloc
, /* special_function */
492 "R_MIPS_CALL_HI16", /* name */
493 TRUE
, /* partial_inplace */
494 0x0000ffff, /* src_mask */
495 0x0000ffff, /* dst_mask */
496 FALSE
), /* pcrel_offset */
498 /* Low 16 bits of displacement in global offset table. */
499 HOWTO (R_MIPS_CALL_LO16
, /* type */
501 2, /* size (0 = byte, 1 = short, 2 = long) */
503 FALSE
, /* pc_relative */
505 complain_overflow_dont
, /* complain_on_overflow */
506 _bfd_mips_elf_generic_reloc
, /* special_function */
507 "R_MIPS_CALL_LO16", /* name */
508 TRUE
, /* partial_inplace */
509 0x0000ffff, /* src_mask */
510 0x0000ffff, /* dst_mask */
511 FALSE
), /* pcrel_offset */
513 /* Section displacement. */
514 HOWTO (R_MIPS_SCN_DISP
, /* type */
516 2, /* size (0 = byte, 1 = short, 2 = long) */
518 FALSE
, /* pc_relative */
520 complain_overflow_dont
, /* complain_on_overflow */
521 _bfd_mips_elf_generic_reloc
, /* special_function */
522 "R_MIPS_SCN_DISP", /* name */
523 TRUE
, /* partial_inplace */
524 0xffffffff, /* src_mask */
525 0xffffffff, /* dst_mask */
526 FALSE
), /* pcrel_offset */
528 EMPTY_HOWTO (R_MIPS_REL16
),
529 EMPTY_HOWTO (R_MIPS_ADD_IMMEDIATE
),
530 EMPTY_HOWTO (R_MIPS_PJUMP
),
531 EMPTY_HOWTO (R_MIPS_RELGOT
),
533 /* Protected jump conversion. This is an optimization hint. No
534 relocation is required for correctness. */
535 HOWTO (R_MIPS_JALR
, /* type */
537 2, /* size (0 = byte, 1 = short, 2 = long) */
539 FALSE
, /* pc_relative */
541 complain_overflow_dont
, /* complain_on_overflow */
542 _bfd_mips_elf_generic_reloc
, /* special_function */
543 "R_MIPS_JALR", /* name */
544 FALSE
, /* partial_inplace */
545 0x00000000, /* src_mask */
546 0x00000000, /* dst_mask */
547 FALSE
), /* pcrel_offset */
550 /* The reloc used for BFD_RELOC_CTOR when doing a 64 bit link. This
551 is a hack to make the linker think that we need 64 bit values. */
552 static reloc_howto_type elf_mips_ctor64_howto
=
553 HOWTO (R_MIPS_64
, /* type */
555 4, /* size (0 = byte, 1 = short, 2 = long) */
557 FALSE
, /* pc_relative */
559 complain_overflow_signed
, /* complain_on_overflow */
560 mips32_64bit_reloc
, /* special_function */
561 "R_MIPS_64", /* name */
562 TRUE
, /* partial_inplace */
563 0xffffffff, /* src_mask */
564 0xffffffff, /* dst_mask */
565 FALSE
); /* pcrel_offset */
567 /* The reloc used for the mips16 jump instruction. */
568 static reloc_howto_type elf_mips16_jump_howto
=
569 HOWTO (R_MIPS16_26
, /* type */
571 2, /* size (0 = byte, 1 = short, 2 = long) */
573 FALSE
, /* pc_relative */
575 complain_overflow_dont
, /* complain_on_overflow */
576 /* This needs complex overflow
577 detection, because the upper four
578 bits must match the PC. */
579 mips16_jump_reloc
, /* special_function */
580 "R_MIPS16_26", /* name */
581 TRUE
, /* partial_inplace */
582 0x3ffffff, /* src_mask */
583 0x3ffffff, /* dst_mask */
584 FALSE
); /* pcrel_offset */
586 /* The reloc used for the mips16 gprel instruction. */
587 static reloc_howto_type elf_mips16_gprel_howto
=
588 HOWTO (R_MIPS16_GPREL
, /* type */
590 2, /* size (0 = byte, 1 = short, 2 = long) */
592 FALSE
, /* pc_relative */
594 complain_overflow_signed
, /* complain_on_overflow */
595 mips16_gprel_reloc
, /* special_function */
596 "R_MIPS16_GPREL", /* name */
597 TRUE
, /* partial_inplace */
598 0x07ff001f, /* src_mask */
599 0x07ff001f, /* dst_mask */
600 FALSE
); /* pcrel_offset */
602 /* 16 bit offset for pc-relative branches. */
603 static reloc_howto_type elf_mips_gnu_rel16_s2
=
604 HOWTO (R_MIPS_GNU_REL16_S2
, /* type */
606 2, /* size (0 = byte, 1 = short, 2 = long) */
608 TRUE
, /* pc_relative */
610 complain_overflow_signed
, /* complain_on_overflow */
611 _bfd_mips_elf_generic_reloc
, /* special_function */
612 "R_MIPS_GNU_REL16_S2", /* name */
613 TRUE
, /* partial_inplace */
614 0xffff, /* src_mask */
615 0xffff, /* dst_mask */
616 TRUE
); /* pcrel_offset */
618 /* GNU extension to record C++ vtable hierarchy */
619 static reloc_howto_type elf_mips_gnu_vtinherit_howto
=
620 HOWTO (R_MIPS_GNU_VTINHERIT
, /* type */
622 2, /* size (0 = byte, 1 = short, 2 = long) */
624 FALSE
, /* pc_relative */
626 complain_overflow_dont
, /* complain_on_overflow */
627 NULL
, /* special_function */
628 "R_MIPS_GNU_VTINHERIT", /* name */
629 FALSE
, /* partial_inplace */
632 FALSE
); /* pcrel_offset */
634 /* GNU extension to record C++ vtable member usage */
635 static reloc_howto_type elf_mips_gnu_vtentry_howto
=
636 HOWTO (R_MIPS_GNU_VTENTRY
, /* type */
638 2, /* size (0 = byte, 1 = short, 2 = long) */
640 FALSE
, /* pc_relative */
642 complain_overflow_dont
, /* complain_on_overflow */
643 _bfd_elf_rel_vtable_reloc_fn
, /* special_function */
644 "R_MIPS_GNU_VTENTRY", /* name */
645 FALSE
, /* partial_inplace */
648 FALSE
); /* pcrel_offset */
650 /* Set the GP value for OUTPUT_BFD. Returns FALSE if this is a
651 dangerous relocation. */
654 mips_elf_assign_gp (bfd
*output_bfd
, bfd_vma
*pgp
)
660 /* If we've already figured out what GP will be, just return it. */
661 *pgp
= _bfd_get_gp_value (output_bfd
);
665 count
= bfd_get_symcount (output_bfd
);
666 sym
= bfd_get_outsymbols (output_bfd
);
668 /* The linker script will have created a symbol named `_gp' with the
669 appropriate value. */
674 for (i
= 0; i
< count
; i
++, sym
++)
676 register const char *name
;
678 name
= bfd_asymbol_name (*sym
);
679 if (*name
== '_' && strcmp (name
, "_gp") == 0)
681 *pgp
= bfd_asymbol_value (*sym
);
682 _bfd_set_gp_value (output_bfd
, *pgp
);
690 /* Only get the error once. */
692 _bfd_set_gp_value (output_bfd
, *pgp
);
699 /* We have to figure out the gp value, so that we can adjust the
700 symbol value correctly. We look up the symbol _gp in the output
701 BFD. If we can't find it, we're stuck. We cache it in the ELF
702 target data. We don't need to adjust the symbol value for an
703 external symbol if we are producing relocatable output. */
705 static bfd_reloc_status_type
706 mips_elf_final_gp (bfd
*output_bfd
, asymbol
*symbol
, bfd_boolean relocatable
,
707 char **error_message
, bfd_vma
*pgp
)
709 if (bfd_is_und_section (symbol
->section
)
713 return bfd_reloc_undefined
;
716 *pgp
= _bfd_get_gp_value (output_bfd
);
719 || (symbol
->flags
& BSF_SECTION_SYM
) != 0))
723 /* Make up a value. */
724 *pgp
= symbol
->section
->output_section
->vma
+ 0x4000;
725 _bfd_set_gp_value (output_bfd
, *pgp
);
727 else if (!mips_elf_assign_gp (output_bfd
, pgp
))
730 (char *) _("GP relative relocation when _gp not defined");
731 return bfd_reloc_dangerous
;
738 /* Do a R_MIPS_GPREL16 relocation. This is a 16 bit value which must
739 become the offset from the gp register. This function also handles
740 R_MIPS_LITERAL relocations, although those can be handled more
741 cleverly because the entries in the .lit8 and .lit4 sections can be
744 bfd_reloc_status_type
745 _bfd_mips_elf32_gprel16_reloc (bfd
*abfd
, arelent
*reloc_entry
,
746 asymbol
*symbol
, void *data
,
747 asection
*input_section
, bfd
*output_bfd
,
748 char **error_message
)
750 bfd_boolean relocatable
;
751 bfd_reloc_status_type ret
;
754 if (output_bfd
!= NULL
)
759 output_bfd
= symbol
->section
->output_section
->owner
;
762 ret
= mips_elf_final_gp (output_bfd
, symbol
, relocatable
, error_message
,
764 if (ret
!= bfd_reloc_ok
)
767 return _bfd_mips_elf_gprel16_with_gp (abfd
, symbol
, reloc_entry
,
768 input_section
, relocatable
,
772 /* Do a R_MIPS_GPREL32 relocation. This is a 32 bit value which must
773 become the offset from the gp register. */
775 static bfd_reloc_status_type
776 mips_elf_gprel32_reloc (bfd
*abfd
, arelent
*reloc_entry
, asymbol
*symbol
,
777 void *data
, asection
*input_section
, bfd
*output_bfd
,
778 char **error_message
)
780 bfd_boolean relocatable
;
781 bfd_reloc_status_type ret
;
784 if (output_bfd
!= NULL
)
789 output_bfd
= symbol
->section
->output_section
->owner
;
792 ret
= mips_elf_final_gp (output_bfd
, symbol
, relocatable
,
794 if (ret
!= bfd_reloc_ok
)
797 return gprel32_with_gp (abfd
, symbol
, reloc_entry
, input_section
,
798 relocatable
, data
, gp
);
801 static bfd_reloc_status_type
802 gprel32_with_gp (bfd
*abfd
, asymbol
*symbol
, arelent
*reloc_entry
,
803 asection
*input_section
, bfd_boolean relocatable
,
804 void *data
, bfd_vma gp
)
809 if (bfd_is_com_section (symbol
->section
))
812 relocation
= symbol
->value
;
814 relocation
+= symbol
->section
->output_section
->vma
;
815 relocation
+= symbol
->section
->output_offset
;
817 if (reloc_entry
->address
> input_section
->_cooked_size
)
818 return bfd_reloc_outofrange
;
820 /* Set val to the offset into the section or symbol. */
821 val
= reloc_entry
->addend
;
823 if (reloc_entry
->howto
->partial_inplace
)
824 val
+= bfd_get_32 (abfd
, (bfd_byte
*) data
+ reloc_entry
->address
);
826 /* Adjust val for the final section location and GP value. If we
827 are producing relocatable output, we don't want to do this for
828 an external symbol. */
830 || (symbol
->flags
& BSF_SECTION_SYM
) != 0)
831 val
+= relocation
- gp
;
833 if (reloc_entry
->howto
->partial_inplace
)
834 bfd_put_32 (abfd
, val
, (bfd_byte
*) data
+ reloc_entry
->address
);
836 reloc_entry
->addend
= val
;
839 reloc_entry
->address
+= input_section
->output_offset
;
844 /* Handle a 64 bit reloc in a 32 bit MIPS ELF file. These are
845 generated when addresses are 64 bits. The upper 32 bits are a simple
848 static bfd_reloc_status_type
849 mips32_64bit_reloc (bfd
*abfd
, arelent
*reloc_entry
,
850 asymbol
*symbol ATTRIBUTE_UNUSED
,
851 void *data
, asection
*input_section
,
852 bfd
*output_bfd
, char **error_message
)
854 bfd_reloc_status_type r
;
859 /* Do a normal 32 bit relocation on the lower 32 bits. */
860 reloc32
= *reloc_entry
;
861 if (bfd_big_endian (abfd
))
862 reloc32
.address
+= 4;
863 reloc32
.howto
= &elf_mips_howto_table_rel
[R_MIPS_32
];
864 r
= bfd_perform_relocation (abfd
, &reloc32
, data
, input_section
,
865 output_bfd
, error_message
);
867 /* Sign extend into the upper 32 bits. */
868 val
= bfd_get_32 (abfd
, (bfd_byte
*) data
+ reloc32
.address
);
869 if ((val
& 0x80000000) != 0)
873 addr
= reloc_entry
->address
;
874 if (bfd_little_endian (abfd
))
876 bfd_put_32 (abfd
, val
, (bfd_byte
*) data
+ addr
);
881 /* Handle a mips16 jump. */
883 static bfd_reloc_status_type
884 mips16_jump_reloc (bfd
*abfd ATTRIBUTE_UNUSED
, arelent
*reloc_entry
,
885 asymbol
*symbol
, void *data ATTRIBUTE_UNUSED
,
886 asection
*input_section
, bfd
*output_bfd
,
887 char **error_message ATTRIBUTE_UNUSED
)
889 if (output_bfd
!= NULL
890 && (symbol
->flags
& BSF_SECTION_SYM
) == 0
891 && reloc_entry
->addend
== 0)
893 reloc_entry
->address
+= input_section
->output_offset
;
899 static bfd_boolean warned
;
902 (*_bfd_error_handler
)
903 (_("Linking mips16 objects into %s format is not supported"),
904 bfd_get_target (input_section
->output_section
->owner
));
908 return bfd_reloc_undefined
;
911 /* Handle a mips16 GP relative reloc. */
913 static bfd_reloc_status_type
914 mips16_gprel_reloc (bfd
*abfd
, arelent
*reloc_entry
, asymbol
*symbol
,
915 void *data
, asection
*input_section
, bfd
*output_bfd
,
916 char **error_message
)
918 bfd_boolean relocatable
;
919 bfd_reloc_status_type ret
;
921 unsigned short extend
= 0;
922 unsigned short insn
= 0;
926 /* If we're relocating, and this is an external symbol, we don't want
927 to change anything. */
928 if (output_bfd
!= NULL
929 && (symbol
->flags
& BSF_SECTION_SYM
) == 0
930 && (symbol
->flags
& BSF_LOCAL
) != 0)
932 reloc_entry
->address
+= input_section
->output_offset
;
936 if (output_bfd
!= NULL
)
941 output_bfd
= symbol
->section
->output_section
->owner
;
944 ret
= mips_elf_final_gp (output_bfd
, symbol
, relocatable
, error_message
,
946 if (ret
!= bfd_reloc_ok
)
949 if (reloc_entry
->address
> input_section
->_cooked_size
)
950 return bfd_reloc_outofrange
;
952 if (bfd_is_com_section (symbol
->section
))
955 relocation
= symbol
->value
;
957 relocation
+= symbol
->section
->output_section
->vma
;
958 relocation
+= symbol
->section
->output_offset
;
960 /* Set val to the offset into the section or symbol. */
961 val
= reloc_entry
->addend
;
963 if (reloc_entry
->howto
->partial_inplace
)
965 /* Pick up the mips16 extend instruction and the real instruction. */
966 extend
= bfd_get_16 (abfd
, (bfd_byte
*) data
+ reloc_entry
->address
);
967 insn
= bfd_get_16 (abfd
, (bfd_byte
*) data
+ reloc_entry
->address
+ 2);
968 val
+= ((extend
& 0x1f) << 11) | (extend
& 0x7e0) | (insn
& 0x1f);
971 _bfd_mips_elf_sign_extend(val
, 16);
973 /* Adjust val for the final section location and GP value. If we
974 are producing relocatable output, we don't want to do this for
975 an external symbol. */
977 || (symbol
->flags
& BSF_SECTION_SYM
) != 0)
978 val
+= relocation
- gp
;
980 if (reloc_entry
->howto
->partial_inplace
)
983 (extend
& 0xf800) | ((val
>> 11) & 0x1f) | (val
& 0x7e0),
984 (bfd_byte
*) data
+ reloc_entry
->address
);
986 (insn
& 0xffe0) | (val
& 0x1f),
987 (bfd_byte
*) data
+ reloc_entry
->address
+ 2);
990 reloc_entry
->addend
= val
;
993 reloc_entry
->address
+= input_section
->output_offset
;
994 else if (((val
& ~0xffff) != ~0xffff) && ((val
& ~0xffff) != 0))
995 return bfd_reloc_overflow
;
1000 /* A mapping from BFD reloc types to MIPS ELF reloc types. */
1002 struct elf_reloc_map
{
1003 bfd_reloc_code_real_type bfd_val
;
1004 enum elf_mips_reloc_type elf_val
;
1007 static const struct elf_reloc_map mips_reloc_map
[] =
1009 { BFD_RELOC_NONE
, R_MIPS_NONE
},
1010 { BFD_RELOC_16
, R_MIPS_16
},
1011 { BFD_RELOC_32
, R_MIPS_32
},
1012 /* There is no BFD reloc for R_MIPS_REL32. */
1013 { BFD_RELOC_64
, R_MIPS_64
},
1014 { BFD_RELOC_MIPS_JMP
, R_MIPS_26
},
1015 { BFD_RELOC_HI16_S
, R_MIPS_HI16
},
1016 { BFD_RELOC_LO16
, R_MIPS_LO16
},
1017 { BFD_RELOC_GPREL16
, R_MIPS_GPREL16
},
1018 { BFD_RELOC_MIPS_LITERAL
, R_MIPS_LITERAL
},
1019 { BFD_RELOC_MIPS_GOT16
, R_MIPS_GOT16
},
1020 { BFD_RELOC_16_PCREL
, R_MIPS_PC16
},
1021 { BFD_RELOC_MIPS_CALL16
, R_MIPS_CALL16
},
1022 { BFD_RELOC_GPREL32
, R_MIPS_GPREL32
},
1023 { BFD_RELOC_MIPS_GOT_HI16
, R_MIPS_GOT_HI16
},
1024 { BFD_RELOC_MIPS_GOT_LO16
, R_MIPS_GOT_LO16
},
1025 { BFD_RELOC_MIPS_CALL_HI16
, R_MIPS_CALL_HI16
},
1026 { BFD_RELOC_MIPS_CALL_LO16
, R_MIPS_CALL_LO16
},
1027 { BFD_RELOC_MIPS_SUB
, R_MIPS_SUB
},
1028 { BFD_RELOC_MIPS_GOT_PAGE
, R_MIPS_GOT_PAGE
},
1029 { BFD_RELOC_MIPS_GOT_OFST
, R_MIPS_GOT_OFST
},
1030 { BFD_RELOC_MIPS_GOT_DISP
, R_MIPS_GOT_DISP
}
1033 /* Given a BFD reloc type, return a howto structure. */
1035 static reloc_howto_type
*
1036 bfd_elf32_bfd_reloc_type_lookup (bfd
*abfd
, bfd_reloc_code_real_type code
)
1039 reloc_howto_type
*howto_table
= elf_mips_howto_table_rel
;
1041 for (i
= 0; i
< sizeof (mips_reloc_map
) / sizeof (struct elf_reloc_map
);
1044 if (mips_reloc_map
[i
].bfd_val
== code
)
1045 return &howto_table
[(int) mips_reloc_map
[i
].elf_val
];
1051 bfd_set_error (bfd_error_bad_value
);
1054 case BFD_RELOC_CTOR
:
1055 /* We need to handle BFD_RELOC_CTOR specially.
1056 Select the right relocation (R_MIPS_32 or R_MIPS_64) based on the
1057 size of addresses of the ABI. */
1058 if ((elf_elfheader (abfd
)->e_flags
& (E_MIPS_ABI_O64
1059 | E_MIPS_ABI_EABI64
)) != 0)
1060 return &elf_mips_ctor64_howto
;
1062 return &howto_table
[(int) R_MIPS_32
];
1064 case BFD_RELOC_MIPS16_JMP
:
1065 return &elf_mips16_jump_howto
;
1066 case BFD_RELOC_MIPS16_GPREL
:
1067 return &elf_mips16_gprel_howto
;
1068 case BFD_RELOC_VTABLE_INHERIT
:
1069 return &elf_mips_gnu_vtinherit_howto
;
1070 case BFD_RELOC_VTABLE_ENTRY
:
1071 return &elf_mips_gnu_vtentry_howto
;
1072 case BFD_RELOC_16_PCREL_S2
:
1073 return &elf_mips_gnu_rel16_s2
;
1077 /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure. */
1079 static reloc_howto_type
*
1080 mips_elf32_rtype_to_howto (unsigned int r_type
,
1081 bfd_boolean rela_p ATTRIBUTE_UNUSED
)
1086 return &elf_mips16_jump_howto
;
1087 case R_MIPS16_GPREL
:
1088 return &elf_mips16_gprel_howto
;
1089 case R_MIPS_GNU_VTINHERIT
:
1090 return &elf_mips_gnu_vtinherit_howto
;
1091 case R_MIPS_GNU_VTENTRY
:
1092 return &elf_mips_gnu_vtentry_howto
;
1093 case R_MIPS_GNU_REL16_S2
:
1094 return &elf_mips_gnu_rel16_s2
;
1096 BFD_ASSERT (r_type
< (unsigned int) R_MIPS_max
);
1097 return &elf_mips_howto_table_rel
[r_type
];
1101 /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure. */
1104 mips_info_to_howto_rel (bfd
*abfd
, arelent
*cache_ptr
, Elf_Internal_Rela
*dst
)
1106 unsigned int r_type
;
1108 r_type
= ELF32_R_TYPE (dst
->r_info
);
1109 cache_ptr
->howto
= mips_elf32_rtype_to_howto (r_type
, FALSE
);
1111 /* The addend for a GPREL16 or LITERAL relocation comes from the GP
1112 value for the object file. We get the addend now, rather than
1113 when we do the relocation, because the symbol manipulations done
1114 by the linker may cause us to lose track of the input BFD. */
1115 if (((*cache_ptr
->sym_ptr_ptr
)->flags
& BSF_SECTION_SYM
) != 0
1116 && (r_type
== (unsigned int) R_MIPS_GPREL16
1117 || r_type
== (unsigned int) R_MIPS_LITERAL
))
1118 cache_ptr
->addend
= elf_gp (abfd
);
1121 /* Given a MIPS Elf_Internal_Rela, fill in an arelent structure. */
1124 mips_info_to_howto_rela (bfd
*abfd
, arelent
*cache_ptr
, Elf_Internal_Rela
*dst
)
1126 mips_info_to_howto_rel (abfd
, cache_ptr
, dst
);
1128 /* If we ever need to do any extra processing with dst->r_addend
1129 (the field omitted in an Elf_Internal_Rel) we can do it here. */
1132 /* Determine whether a symbol is global for the purposes of splitting
1133 the symbol table into global symbols and local symbols. At least
1134 on Irix 5, this split must be between section symbols and all other
1135 symbols. On most ELF targets the split is between static symbols
1136 and externally visible symbols. */
1139 mips_elf_sym_is_global (bfd
*abfd ATTRIBUTE_UNUSED
, asymbol
*sym
)
1141 if (SGI_COMPAT (abfd
))
1142 return (sym
->flags
& BSF_SECTION_SYM
) == 0;
1144 return ((sym
->flags
& (BSF_GLOBAL
| BSF_WEAK
)) != 0
1145 || bfd_is_und_section (bfd_get_section (sym
))
1146 || bfd_is_com_section (bfd_get_section (sym
)));
1149 /* Set the right machine number for a MIPS ELF file. */
1152 mips_elf32_object_p (bfd
*abfd
)
1156 /* Irix 5 and 6 are broken. Object file symbol tables are not always
1157 sorted correctly such that local symbols precede global symbols,
1158 and the sh_info field in the symbol table is not always right. */
1159 if (SGI_COMPAT (abfd
))
1160 elf_bad_symtab (abfd
) = TRUE
;
1162 if (ABI_N32_P (abfd
))
1165 mach
= _bfd_elf_mips_mach (elf_elfheader (abfd
)->e_flags
);
1166 bfd_default_set_arch_mach (abfd
, bfd_arch_mips
, mach
);
1171 /* MIPS ELF local labels start with '$', not 'L'. */
1174 mips_elf_is_local_label_name (bfd
*abfd
, const char *name
)
1179 /* On Irix 6, the labels go back to starting with '.', so we accept
1180 the generic ELF local label syntax as well. */
1181 return _bfd_elf_is_local_label_name (abfd
, name
);
1184 /* Support for core dump NOTE sections. */
1186 elf32_mips_grok_prstatus (bfd
*abfd
, Elf_Internal_Note
*note
)
1189 unsigned int raw_size
;
1191 switch (note
->descsz
)
1196 case 256: /* Linux/MIPS */
1198 elf_tdata (abfd
)->core_signal
= bfd_get_16 (abfd
, note
->descdata
+ 12);
1201 elf_tdata (abfd
)->core_pid
= bfd_get_32 (abfd
, note
->descdata
+ 24);
1210 /* Make a ".reg/999" section. */
1211 return _bfd_elfcore_make_pseudosection (abfd
, ".reg",
1212 raw_size
, note
->descpos
+ offset
);
1216 elf32_mips_grok_psinfo (bfd
*abfd
, Elf_Internal_Note
*note
)
1218 switch (note
->descsz
)
1223 case 128: /* Linux/MIPS elf_prpsinfo */
1224 elf_tdata (abfd
)->core_program
1225 = _bfd_elfcore_strndup (abfd
, note
->descdata
+ 32, 16);
1226 elf_tdata (abfd
)->core_command
1227 = _bfd_elfcore_strndup (abfd
, note
->descdata
+ 48, 80);
1230 /* Note that for some reason, a spurious space is tacked
1231 onto the end of the args in some (at least one anyway)
1232 implementations, so strip it off if it exists. */
1235 char *command
= elf_tdata (abfd
)->core_command
;
1236 int n
= strlen (command
);
1238 if (0 < n
&& command
[n
- 1] == ' ')
1239 command
[n
- 1] = '\0';
1245 /* Depending on the target vector we generate some version of Irix
1246 executables or "normal" MIPS ELF ABI executables. */
1247 static irix_compat_t
1248 elf32_mips_irix_compat (bfd
*abfd
)
1250 if ((abfd
->xvec
== &bfd_elf32_bigmips_vec
)
1251 || (abfd
->xvec
== &bfd_elf32_littlemips_vec
))
1257 /* ECOFF swapping routines. These are used when dealing with the
1258 .mdebug section, which is in the ECOFF debugging format. */
1259 static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap
= {
1260 /* Symbol table magic number. */
1262 /* Alignment of debugging information. E.g., 4. */
1264 /* Sizes of external symbolic information. */
1265 sizeof (struct hdr_ext
),
1266 sizeof (struct dnr_ext
),
1267 sizeof (struct pdr_ext
),
1268 sizeof (struct sym_ext
),
1269 sizeof (struct opt_ext
),
1270 sizeof (struct fdr_ext
),
1271 sizeof (struct rfd_ext
),
1272 sizeof (struct ext_ext
),
1273 /* Functions to swap in external symbolic data. */
1282 _bfd_ecoff_swap_tir_in
,
1283 _bfd_ecoff_swap_rndx_in
,
1284 /* Functions to swap out external symbolic data. */
1293 _bfd_ecoff_swap_tir_out
,
1294 _bfd_ecoff_swap_rndx_out
,
1295 /* Function to read in symbolic data. */
1296 _bfd_mips_elf_read_ecoff_info
1299 #define ELF_ARCH bfd_arch_mips
1300 #define ELF_MACHINE_CODE EM_MIPS
1302 #define elf_backend_collect TRUE
1303 #define elf_backend_type_change_ok TRUE
1304 #define elf_backend_can_gc_sections TRUE
1305 #define elf_info_to_howto mips_info_to_howto_rela
1306 #define elf_info_to_howto_rel mips_info_to_howto_rel
1307 #define elf_backend_sym_is_global mips_elf_sym_is_global
1308 #define elf_backend_object_p mips_elf32_object_p
1309 #define elf_backend_symbol_processing _bfd_mips_elf_symbol_processing
1310 #define elf_backend_section_processing _bfd_mips_elf_section_processing
1311 #define elf_backend_section_from_shdr _bfd_mips_elf_section_from_shdr
1312 #define elf_backend_fake_sections _bfd_mips_elf_fake_sections
1313 #define elf_backend_section_from_bfd_section \
1314 _bfd_mips_elf_section_from_bfd_section
1315 #define elf_backend_add_symbol_hook _bfd_mips_elf_add_symbol_hook
1316 #define elf_backend_link_output_symbol_hook \
1317 _bfd_mips_elf_link_output_symbol_hook
1318 #define elf_backend_create_dynamic_sections \
1319 _bfd_mips_elf_create_dynamic_sections
1320 #define elf_backend_check_relocs _bfd_mips_elf_check_relocs
1321 #define elf_backend_adjust_dynamic_symbol \
1322 _bfd_mips_elf_adjust_dynamic_symbol
1323 #define elf_backend_always_size_sections \
1324 _bfd_mips_elf_always_size_sections
1325 #define elf_backend_size_dynamic_sections \
1326 _bfd_mips_elf_size_dynamic_sections
1327 #define elf_backend_relocate_section _bfd_mips_elf_relocate_section
1328 #define elf_backend_finish_dynamic_symbol \
1329 _bfd_mips_elf_finish_dynamic_symbol
1330 #define elf_backend_finish_dynamic_sections \
1331 _bfd_mips_elf_finish_dynamic_sections
1332 #define elf_backend_final_write_processing \
1333 _bfd_mips_elf_final_write_processing
1334 #define elf_backend_additional_program_headers \
1335 _bfd_mips_elf_additional_program_headers
1336 #define elf_backend_modify_segment_map _bfd_mips_elf_modify_segment_map
1337 #define elf_backend_gc_mark_hook _bfd_mips_elf_gc_mark_hook
1338 #define elf_backend_gc_sweep_hook _bfd_mips_elf_gc_sweep_hook
1339 #define elf_backend_copy_indirect_symbol \
1340 _bfd_mips_elf_copy_indirect_symbol
1341 #define elf_backend_hide_symbol _bfd_mips_elf_hide_symbol
1342 #define elf_backend_grok_prstatus elf32_mips_grok_prstatus
1343 #define elf_backend_grok_psinfo elf32_mips_grok_psinfo
1344 #define elf_backend_ecoff_debug_swap &mips_elf32_ecoff_debug_swap
1346 #define elf_backend_got_header_size (4 * MIPS_RESERVED_GOTNO)
1347 #define elf_backend_may_use_rel_p 1
1348 #define elf_backend_may_use_rela_p 0
1349 #define elf_backend_default_use_rela_p 0
1350 #define elf_backend_sign_extend_vma TRUE
1352 #define elf_backend_discard_info _bfd_mips_elf_discard_info
1353 #define elf_backend_ignore_discarded_relocs \
1354 _bfd_mips_elf_ignore_discarded_relocs
1355 #define elf_backend_mips_irix_compat elf32_mips_irix_compat
1356 #define elf_backend_mips_rtype_to_howto mips_elf32_rtype_to_howto
1357 #define bfd_elf32_bfd_is_local_label_name \
1358 mips_elf_is_local_label_name
1359 #define bfd_elf32_find_nearest_line _bfd_mips_elf_find_nearest_line
1360 #define bfd_elf32_new_section_hook _bfd_mips_elf_new_section_hook
1361 #define bfd_elf32_set_section_contents _bfd_mips_elf_set_section_contents
1362 #define bfd_elf32_bfd_get_relocated_section_contents \
1363 _bfd_elf_mips_get_relocated_section_contents
1364 #define bfd_elf32_bfd_link_hash_table_create \
1365 _bfd_mips_elf_link_hash_table_create
1366 #define bfd_elf32_bfd_final_link _bfd_mips_elf_final_link
1367 #define bfd_elf32_bfd_merge_private_bfd_data \
1368 _bfd_mips_elf_merge_private_bfd_data
1369 #define bfd_elf32_bfd_set_private_flags _bfd_mips_elf_set_private_flags
1370 #define bfd_elf32_bfd_print_private_bfd_data \
1371 _bfd_mips_elf_print_private_bfd_data
1373 /* Support for SGI-ish mips targets. */
1374 #define TARGET_LITTLE_SYM bfd_elf32_littlemips_vec
1375 #define TARGET_LITTLE_NAME "elf32-littlemips"
1376 #define TARGET_BIG_SYM bfd_elf32_bigmips_vec
1377 #define TARGET_BIG_NAME "elf32-bigmips"
1379 /* The SVR4 MIPS ABI says that this should be 0x10000, but Irix 5 uses
1380 a value of 0x1000, and we are compatible. */
1381 #define ELF_MAXPAGESIZE 0x1000
1383 #include "elf32-target.h"
1385 /* Support for traditional mips targets. */
1386 #undef TARGET_LITTLE_SYM
1387 #undef TARGET_LITTLE_NAME
1388 #undef TARGET_BIG_SYM
1389 #undef TARGET_BIG_NAME
1391 #undef ELF_MAXPAGESIZE
1393 #define TARGET_LITTLE_SYM bfd_elf32_tradlittlemips_vec
1394 #define TARGET_LITTLE_NAME "elf32-tradlittlemips"
1395 #define TARGET_BIG_SYM bfd_elf32_tradbigmips_vec
1396 #define TARGET_BIG_NAME "elf32-tradbigmips"
1398 /* The SVR4 MIPS ABI says that this should be 0x10000, and Linux uses
1399 page sizes of up to that limit, so we need to respect it. */
1400 #define ELF_MAXPAGESIZE 0x10000
1401 #define elf32_bed elf32_tradbed
1403 /* Include the target file again for this target. */
1404 #include "elf32-target.h"