1 /* BFD back-end for MIPS Extended-Coff files.
2 Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
3 Original version by Per Bothner.
4 Full support added by Ian Lance Taylor, ian@cygnus.com.
6 This file is part of BFD, the Binary File Descriptor library.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
26 #include "coff/internal.h"
28 #include "coff/symconst.h"
29 #include "coff/ecoff.h"
30 #include "coff/mips.h"
34 /* Prototypes for static functions. */
36 static boolean mips_ecoff_bad_format_hook PARAMS ((bfd *abfd, PTR filehdr));
37 static void mips_ecoff_swap_reloc_in PARAMS ((bfd *, PTR,
38 struct internal_reloc *));
39 static void mips_ecoff_swap_reloc_out PARAMS ((bfd *,
40 const struct internal_reloc *,
42 static void mips_adjust_reloc_in PARAMS ((bfd *,
43 const struct internal_reloc *,
45 static void mips_adjust_reloc_out PARAMS ((bfd *, const arelent *,
46 struct internal_reloc *));
47 static bfd_reloc_status_type mips_generic_reloc PARAMS ((bfd *abfd,
54 static bfd_reloc_status_type mips_refhi_reloc PARAMS ((bfd *abfd,
61 static bfd_reloc_status_type mips_reflo_reloc PARAMS ((bfd *abfd,
68 static bfd_reloc_status_type mips_gprel_reloc PARAMS ((bfd *abfd,
75 static bfd_reloc_status_type mips_relhi_reloc PARAMS ((bfd *abfd,
82 static bfd_reloc_status_type mips_rello_reloc PARAMS ((bfd *abfd,
89 static bfd_reloc_status_type mips_switch_reloc PARAMS ((bfd *abfd,
96 static void mips_relocate_hi PARAMS ((struct internal_reloc *refhi,
97 struct internal_reloc *reflo,
99 asection *input_section,
104 static boolean mips_relocate_section PARAMS ((bfd *, struct bfd_link_info *,
107 static boolean mips_relax_section PARAMS ((bfd *, asection *,
108 struct bfd_link_info *,
110 static boolean mips_relax_pcrel16 PARAMS ((struct bfd_link_info *, bfd *,
112 struct ecoff_link_hash_entry *,
113 bfd_byte *, bfd_vma));
115 /* ECOFF has COFF sections, but the debugging information is stored in
116 a completely different format. ECOFF targets use some of the
117 swapping routines from coffswap.h, and some of the generic COFF
118 routines in coffgen.c, but, unlike the real COFF targets, do not
119 use coffcode.h itself.
121 Get the generic COFF swapping routines, except for the reloc,
122 symbol, and lineno ones. Give them ECOFF names. */
124 #define NO_COFF_RELOCS
125 #define NO_COFF_SYMBOLS
126 #define NO_COFF_LINENOS
127 #define coff_swap_filehdr_in mips_ecoff_swap_filehdr_in
128 #define coff_swap_filehdr_out mips_ecoff_swap_filehdr_out
129 #define coff_swap_aouthdr_in mips_ecoff_swap_aouthdr_in
130 #define coff_swap_aouthdr_out mips_ecoff_swap_aouthdr_out
131 #define coff_swap_scnhdr_in mips_ecoff_swap_scnhdr_in
132 #define coff_swap_scnhdr_out mips_ecoff_swap_scnhdr_out
133 #include "coffswap.h"
135 /* Get the ECOFF swapping routines. */
137 #include "ecoffswap.h"
139 /* How to process the various relocs types. */
141 static reloc_howto_type mips_howto_table[] =
143 /* Reloc type 0 is ignored. The reloc reading code ensures that
144 this is a reference to the .abs section, which will cause
145 bfd_perform_relocation to do nothing. */
146 HOWTO (MIPS_R_IGNORE, /* type */
148 0, /* size (0 = byte, 1 = short, 2 = long) */
150 false, /* pc_relative */
152 complain_overflow_dont, /* complain_on_overflow */
153 0, /* special_function */
155 false, /* partial_inplace */
158 false), /* pcrel_offset */
160 /* A 16 bit reference to a symbol, normally from a data section. */
161 HOWTO (MIPS_R_REFHALF, /* type */
163 1, /* size (0 = byte, 1 = short, 2 = long) */
165 false, /* pc_relative */
167 complain_overflow_bitfield, /* complain_on_overflow */
168 mips_generic_reloc, /* special_function */
169 "REFHALF", /* name */
170 true, /* partial_inplace */
171 0xffff, /* src_mask */
172 0xffff, /* dst_mask */
173 false), /* pcrel_offset */
175 /* A 32 bit reference to a symbol, normally from a data section. */
176 HOWTO (MIPS_R_REFWORD, /* type */
178 2, /* size (0 = byte, 1 = short, 2 = long) */
180 false, /* pc_relative */
182 complain_overflow_bitfield, /* complain_on_overflow */
183 mips_generic_reloc, /* special_function */
184 "REFWORD", /* name */
185 true, /* partial_inplace */
186 0xffffffff, /* src_mask */
187 0xffffffff, /* dst_mask */
188 false), /* pcrel_offset */
190 /* A 26 bit absolute jump address. */
191 HOWTO (MIPS_R_JMPADDR, /* type */
193 2, /* size (0 = byte, 1 = short, 2 = long) */
195 false, /* pc_relative */
197 complain_overflow_dont, /* complain_on_overflow */
198 /* This needs complex overflow
199 detection, because the upper four
200 bits must match the PC. */
201 mips_generic_reloc, /* special_function */
202 "JMPADDR", /* name */
203 true, /* partial_inplace */
204 0x3ffffff, /* src_mask */
205 0x3ffffff, /* dst_mask */
206 false), /* pcrel_offset */
208 /* The high 16 bits of a symbol value. Handled by the function
210 HOWTO (MIPS_R_REFHI, /* type */
212 2, /* size (0 = byte, 1 = short, 2 = long) */
214 false, /* pc_relative */
216 complain_overflow_bitfield, /* complain_on_overflow */
217 mips_refhi_reloc, /* special_function */
219 true, /* partial_inplace */
220 0xffff, /* src_mask */
221 0xffff, /* dst_mask */
222 false), /* pcrel_offset */
224 /* The low 16 bits of a symbol value. */
225 HOWTO (MIPS_R_REFLO, /* type */
227 2, /* size (0 = byte, 1 = short, 2 = long) */
229 false, /* pc_relative */
231 complain_overflow_dont, /* complain_on_overflow */
232 mips_reflo_reloc, /* special_function */
234 true, /* partial_inplace */
235 0xffff, /* src_mask */
236 0xffff, /* dst_mask */
237 false), /* pcrel_offset */
239 /* A reference to an offset from the gp register. Handled by the
240 function mips_gprel_reloc. */
241 HOWTO (MIPS_R_GPREL, /* type */
243 2, /* size (0 = byte, 1 = short, 2 = long) */
245 false, /* pc_relative */
247 complain_overflow_signed, /* complain_on_overflow */
248 mips_gprel_reloc, /* special_function */
250 true, /* partial_inplace */
251 0xffff, /* src_mask */
252 0xffff, /* dst_mask */
253 false), /* pcrel_offset */
255 /* A reference to a literal using an offset from the gp register.
256 Handled by the function mips_gprel_reloc. */
257 HOWTO (MIPS_R_LITERAL, /* type */
259 2, /* size (0 = byte, 1 = short, 2 = long) */
261 false, /* pc_relative */
263 complain_overflow_signed, /* complain_on_overflow */
264 mips_gprel_reloc, /* special_function */
265 "LITERAL", /* name */
266 true, /* partial_inplace */
267 0xffff, /* src_mask */
268 0xffff, /* dst_mask */
269 false), /* pcrel_offset */
276 /* This reloc is a Cygnus extension used when generating position
277 independent code for embedded systems. It represents a 16 bit PC
278 relative reloc rightshifted twice as used in the MIPS branch
280 HOWTO (MIPS_R_PCREL16, /* type */
282 2, /* size (0 = byte, 1 = short, 2 = long) */
284 true, /* pc_relative */
286 complain_overflow_signed, /* complain_on_overflow */
287 mips_generic_reloc, /* special_function */
288 "PCREL16", /* name */
289 true, /* partial_inplace */
290 0xffff, /* src_mask */
291 0xffff, /* dst_mask */
292 true), /* pcrel_offset */
294 /* This reloc is a Cygnus extension used when generating position
295 independent code for embedded systems. It represents the high 16
296 bits of a PC relative reloc. The next reloc must be
297 MIPS_R_RELLO, and the addend is formed from the addends of the
298 two instructions, just as in MIPS_R_REFHI and MIPS_R_REFLO. The
299 final value is actually PC relative to the location of the
300 MIPS_R_RELLO reloc, not the MIPS_R_RELHI reloc. */
301 HOWTO (MIPS_R_RELHI, /* type */
303 2, /* size (0 = byte, 1 = short, 2 = long) */
305 true, /* pc_relative */
307 complain_overflow_bitfield, /* complain_on_overflow */
308 mips_relhi_reloc, /* special_function */
310 true, /* partial_inplace */
311 0xffff, /* src_mask */
312 0xffff, /* dst_mask */
313 true), /* pcrel_offset */
315 /* This reloc is a Cygnus extension used when generating position
316 independent code for embedded systems. It represents the low 16
317 bits of a PC relative reloc. */
318 HOWTO (MIPS_R_RELLO, /* type */
320 2, /* size (0 = byte, 1 = short, 2 = long) */
322 true, /* pc_relative */
324 complain_overflow_dont, /* complain_on_overflow */
325 mips_rello_reloc, /* special_function */
327 true, /* partial_inplace */
328 0xffff, /* src_mask */
329 0xffff, /* dst_mask */
330 true), /* pcrel_offset */
340 /* This reloc is a Cygnus extension used when generating position
341 independent code for embedded systems. It represents an entry in
342 a switch table, which is the difference between two symbols in
343 the .text section. The symndx is actually the offset from the
344 reloc address to the subtrahend. See include/coff/mips.h for
346 HOWTO (MIPS_R_SWITCH, /* type */
348 2, /* size (0 = byte, 1 = short, 2 = long) */
350 true, /* pc_relative */
352 complain_overflow_dont, /* complain_on_overflow */
353 mips_switch_reloc, /* special_function */
355 true, /* partial_inplace */
356 0xffffffff, /* src_mask */
357 0xffffffff, /* dst_mask */
358 true) /* pcrel_offset */
361 #define MIPS_HOWTO_COUNT \
362 (sizeof mips_howto_table / sizeof mips_howto_table[0])
364 /* When the linker is doing relaxing, it may change a external PCREL16
365 reloc. This typically represents an instruction like
370 lui $at,%hi(foo - $L1)
372 addiu $at,%lo(foo - $L1)
375 PCREL16_EXPANSION_ADJUSTMENT is the number of bytes this changes the
378 #define PCREL16_EXPANSION_ADJUSTMENT (4 * 4)
380 /* See whether the magic number matches. */
383 mips_ecoff_bad_format_hook (abfd, filehdr)
387 struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
389 switch (internal_f->f_magic)
392 /* I don't know what endianness this implies. */
396 case MIPS_MAGIC_BIG2:
397 case MIPS_MAGIC_BIG3:
398 return abfd->xvec->byteorder_big_p;
400 case MIPS_MAGIC_LITTLE:
401 case MIPS_MAGIC_LITTLE2:
402 case MIPS_MAGIC_LITTLE3:
403 return abfd->xvec->byteorder_big_p == false;
410 /* Reloc handling. MIPS ECOFF relocs are packed into 8 bytes in
411 external form. They use a bit which indicates whether the symbol
414 /* Swap a reloc in. */
417 mips_ecoff_swap_reloc_in (abfd, ext_ptr, intern)
420 struct internal_reloc *intern;
422 const RELOC *ext = (RELOC *) ext_ptr;
424 intern->r_vaddr = bfd_h_get_32 (abfd, (bfd_byte *) ext->r_vaddr);
425 if (abfd->xvec->header_byteorder_big_p != false)
427 intern->r_symndx = (((int) ext->r_bits[0]
428 << RELOC_BITS0_SYMNDX_SH_LEFT_BIG)
429 | ((int) ext->r_bits[1]
430 << RELOC_BITS1_SYMNDX_SH_LEFT_BIG)
431 | ((int) ext->r_bits[2]
432 << RELOC_BITS2_SYMNDX_SH_LEFT_BIG));
433 intern->r_type = ((ext->r_bits[3] & RELOC_BITS3_TYPE_BIG)
434 >> RELOC_BITS3_TYPE_SH_BIG);
435 intern->r_extern = (ext->r_bits[3] & RELOC_BITS3_EXTERN_BIG) != 0;
439 intern->r_symndx = (((int) ext->r_bits[0]
440 << RELOC_BITS0_SYMNDX_SH_LEFT_LITTLE)
441 | ((int) ext->r_bits[1]
442 << RELOC_BITS1_SYMNDX_SH_LEFT_LITTLE)
443 | ((int) ext->r_bits[2]
444 << RELOC_BITS2_SYMNDX_SH_LEFT_LITTLE));
445 intern->r_type = (((ext->r_bits[3] & RELOC_BITS3_TYPE_LITTLE)
446 >> RELOC_BITS3_TYPE_SH_LITTLE)
447 | ((ext->r_bits[3] & RELOC_BITS3_TYPEHI_LITTLE)
448 << RELOC_BITS3_TYPEHI_SH_LITTLE));
449 intern->r_extern = (ext->r_bits[3] & RELOC_BITS3_EXTERN_LITTLE) != 0;
452 /* If this is a MIPS_R_SWITCH reloc, or an internal MIPS_R_RELHI or
453 MIPS_R_RELLO reloc, r_symndx is actually the offset from the
454 reloc address to the base of the difference (see
455 include/coff/mips.h for more details). We copy symndx into the
456 r_offset field so as not to confuse ecoff_slurp_reloc_table in
457 ecoff.c. In adjust_reloc_in we then copy r_offset into the reloc
459 if (intern->r_type == MIPS_R_SWITCH
460 || (! intern->r_extern
461 && (intern->r_type == MIPS_R_RELLO
462 || intern->r_type == MIPS_R_RELHI)))
464 BFD_ASSERT (! intern->r_extern);
465 intern->r_offset = intern->r_symndx;
466 if (intern->r_offset & 0x800000)
467 intern->r_offset -= 0x1000000;
468 intern->r_symndx = RELOC_SECTION_TEXT;
472 /* Swap a reloc out. */
475 mips_ecoff_swap_reloc_out (abfd, intern, dst)
477 const struct internal_reloc *intern;
480 RELOC *ext = (RELOC *) dst;
483 BFD_ASSERT (intern->r_extern
484 || (intern->r_symndx >= 0 && intern->r_symndx <= 12));
486 /* If this is a MIPS_R_SWITCH reloc, or an internal MIPS_R_RELLO or
487 MIPS_R_RELHI reloc, we actually want to write the contents of
488 r_offset out as the symbol index. This undoes the change made by
489 mips_ecoff_swap_reloc_in. */
490 if (intern->r_type != MIPS_R_SWITCH
492 || (intern->r_type != MIPS_R_RELHI
493 && intern->r_type != MIPS_R_RELLO)))
494 r_symndx = intern->r_symndx;
497 BFD_ASSERT (intern->r_symndx == RELOC_SECTION_TEXT);
498 r_symndx = intern->r_offset & 0xffffff;
501 bfd_h_put_32 (abfd, intern->r_vaddr, (bfd_byte *) ext->r_vaddr);
502 if (abfd->xvec->header_byteorder_big_p != false)
504 ext->r_bits[0] = r_symndx >> RELOC_BITS0_SYMNDX_SH_LEFT_BIG;
505 ext->r_bits[1] = r_symndx >> RELOC_BITS1_SYMNDX_SH_LEFT_BIG;
506 ext->r_bits[2] = r_symndx >> RELOC_BITS2_SYMNDX_SH_LEFT_BIG;
507 ext->r_bits[3] = (((intern->r_type << RELOC_BITS3_TYPE_SH_BIG)
508 & RELOC_BITS3_TYPE_BIG)
509 | (intern->r_extern ? RELOC_BITS3_EXTERN_BIG : 0));
513 ext->r_bits[0] = r_symndx >> RELOC_BITS0_SYMNDX_SH_LEFT_LITTLE;
514 ext->r_bits[1] = r_symndx >> RELOC_BITS1_SYMNDX_SH_LEFT_LITTLE;
515 ext->r_bits[2] = r_symndx >> RELOC_BITS2_SYMNDX_SH_LEFT_LITTLE;
516 ext->r_bits[3] = (((intern->r_type << RELOC_BITS3_TYPE_SH_LITTLE)
517 & RELOC_BITS3_TYPE_LITTLE)
518 | ((intern->r_type >> RELOC_BITS3_TYPEHI_SH_LITTLE
519 & RELOC_BITS3_TYPEHI_LITTLE))
520 | (intern->r_extern ? RELOC_BITS3_EXTERN_LITTLE : 0));
524 /* Finish canonicalizing a reloc. Part of this is generic to all
525 ECOFF targets, and that part is in ecoff.c. The rest is done in
526 this backend routine. It must fill in the howto field. */
529 mips_adjust_reloc_in (abfd, intern, rptr)
531 const struct internal_reloc *intern;
534 if (intern->r_type > MIPS_R_SWITCH)
537 if (! intern->r_extern
538 && (intern->r_type == MIPS_R_GPREL
539 || intern->r_type == MIPS_R_LITERAL))
540 rptr->addend += ecoff_data (abfd)->gp;
542 /* If the type is MIPS_R_IGNORE, make sure this is a reference to
543 the absolute section so that the reloc is ignored. */
544 if (intern->r_type == MIPS_R_IGNORE)
545 rptr->sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr;
547 /* If this is a MIPS_R_SWITCH reloc, or an internal MIPS_R_RELHI or
548 MIPS_R_RELLO reloc, we want the addend field of the BFD relocto
549 hold the value which was originally in the symndx field of the
550 internal MIPS ECOFF reloc. This value was copied into
551 intern->r_offset by mips_swap_reloc_in, and here we copy it into
553 if (intern->r_type == MIPS_R_SWITCH
554 || (! intern->r_extern
555 && (intern->r_type == MIPS_R_RELHI
556 || intern->r_type == MIPS_R_RELLO)))
557 rptr->addend = intern->r_offset;
559 rptr->howto = &mips_howto_table[intern->r_type];
562 /* Make any adjustments needed to a reloc before writing it out. None
563 are needed for MIPS. */
566 mips_adjust_reloc_out (abfd, rel, intern)
569 struct internal_reloc *intern;
571 /* For a MIPS_R_SWITCH reloc, or an internal MIPS_R_RELHI or
572 MIPS_R_RELLO reloc, we must copy rel->addend into
573 intern->r_offset. This will then be written out as the symbol
574 index by mips_ecoff_swap_reloc_out. This operation parallels the
575 action of mips_adjust_reloc_in. */
576 if (intern->r_type == MIPS_R_SWITCH
577 || (! intern->r_extern
578 && (intern->r_type == MIPS_R_RELHI
579 || intern->r_type == MIPS_R_RELLO)))
580 intern->r_offset = rel->addend;
583 /* ECOFF relocs are either against external symbols, or against
584 sections. If we are producing relocateable output, and the reloc
585 is against an external symbol, and nothing has given us any
586 additional addend, the resulting reloc will also be against the
587 same symbol. In such a case, we don't want to change anything
588 about the way the reloc is handled, since it will all be done at
589 final link time. Rather than put special case code into
590 bfd_perform_relocation, all the reloc types use this howto
591 function. It just short circuits the reloc if producing
592 relocateable output against an external symbol. */
594 static bfd_reloc_status_type
595 mips_generic_reloc (abfd,
603 arelent *reloc_entry;
606 asection *input_section;
608 char **error_message;
610 if (output_bfd != (bfd *) NULL
611 && (symbol->flags & BSF_SECTION_SYM) == 0
612 && reloc_entry->addend == 0)
614 reloc_entry->address += input_section->output_offset;
618 return bfd_reloc_continue;
621 /* Do a REFHI relocation. This has to be done in combination with a
622 REFLO reloc, because there is a carry from the REFLO to the REFHI.
623 Here we just save the information we need; we do the actual
624 relocation when we see the REFLO. MIPS ECOFF requires that the
625 REFLO immediately follow the REFHI, so this ought to work. */
627 static bfd_byte *mips_refhi_addr;
628 static bfd_vma mips_refhi_addend;
630 static bfd_reloc_status_type
631 mips_refhi_reloc (abfd,
639 arelent *reloc_entry;
642 asection *input_section;
644 char **error_message;
646 bfd_reloc_status_type ret;
649 /* If we're relocating, and this an external symbol, we don't want
650 to change anything. */
651 if (output_bfd != (bfd *) NULL
652 && (symbol->flags & BSF_SECTION_SYM) == 0
653 && reloc_entry->addend == 0)
655 reloc_entry->address += input_section->output_offset;
660 if (symbol->section == &bfd_und_section
661 && output_bfd == (bfd *) NULL)
662 ret = bfd_reloc_undefined;
664 if (bfd_is_com_section (symbol->section))
667 relocation = symbol->value;
669 relocation += symbol->section->output_section->vma;
670 relocation += symbol->section->output_offset;
671 relocation += reloc_entry->addend;
673 if (reloc_entry->address > input_section->_cooked_size)
674 return bfd_reloc_outofrange;
676 /* Save the information, and let REFLO do the actual relocation. */
677 mips_refhi_addr = (bfd_byte *) data + reloc_entry->address;
678 mips_refhi_addend = relocation;
680 if (output_bfd != (bfd *) NULL)
681 reloc_entry->address += input_section->output_offset;
686 /* Do a REFLO relocation. This is a straightforward 16 bit inplace
687 relocation; this function exists in order to do the REFHI
688 relocation described above. */
690 static bfd_reloc_status_type
691 mips_reflo_reloc (abfd,
699 arelent *reloc_entry;
702 asection *input_section;
704 char **error_message;
706 if (mips_refhi_addr != (bfd_byte *) NULL)
712 /* Do the REFHI relocation. Note that we actually don't need to
713 know anything about the REFLO itself, except where to find
714 the low 16 bits of the addend needed by the REFHI. */
715 insn = bfd_get_32 (abfd, mips_refhi_addr);
716 vallo = (bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address)
718 val = ((insn & 0xffff) << 16) + vallo;
719 val += mips_refhi_addend;
721 /* The low order 16 bits are always treated as a signed value.
722 Therefore, a negative value in the low order bits requires an
723 adjustment in the high order bits. We need to make this
724 adjustment in two ways: once for the bits we took from the
725 data, and once for the bits we are putting back in to the
727 if ((vallo & 0x8000) != 0)
729 if ((val & 0x8000) != 0)
732 insn = (insn &~ 0xffff) | ((val >> 16) & 0xffff);
733 bfd_put_32 (abfd, insn, mips_refhi_addr);
735 mips_refhi_addr = (bfd_byte *) NULL;
738 /* Now do the REFLO reloc in the usual way. */
739 return mips_generic_reloc (abfd, reloc_entry, symbol, data,
740 input_section, output_bfd, error_message);
743 /* Do a GPREL relocation. This is a 16 bit value which must become
744 the offset from the gp register. */
746 static bfd_reloc_status_type
747 mips_gprel_reloc (abfd,
755 arelent *reloc_entry;
758 asection *input_section;
760 char **error_message;
762 boolean relocateable;
767 /* If we're relocating, and this is an external symbol with no
768 addend, we don't want to change anything. We will only have an
769 addend if this is a newly created reloc, not read from an ECOFF
771 if (output_bfd != (bfd *) NULL
772 && (symbol->flags & BSF_SECTION_SYM) == 0
773 && reloc_entry->addend == 0)
775 reloc_entry->address += input_section->output_offset;
779 if (output_bfd != (bfd *) NULL)
783 relocateable = false;
784 output_bfd = symbol->section->output_section->owner;
787 if (symbol->section == &bfd_und_section
788 && relocateable == false)
789 return bfd_reloc_undefined;
791 /* We have to figure out the gp value, so that we can adjust the
792 symbol value correctly. We look up the symbol _gp in the output
793 BFD. If we can't find it, we're stuck. We cache it in the ECOFF
794 target data. We don't need to adjust the symbol value for an
795 external symbol if we are producing relocateable output. */
796 if (ecoff_data (output_bfd)->gp == 0
797 && (relocateable == false
798 || (symbol->flags & BSF_SECTION_SYM) != 0))
800 if (relocateable != false)
802 /* Make up a value. */
803 ecoff_data (output_bfd)->gp =
804 symbol->section->output_section->vma + 0x4000;
812 count = bfd_get_symcount (output_bfd);
813 sym = bfd_get_outsymbols (output_bfd);
815 if (sym == (asymbol **) NULL)
819 for (i = 0; i < count; i++, sym++)
821 register CONST char *name;
823 name = bfd_asymbol_name (*sym);
824 if (*name == '_' && strcmp (name, "_gp") == 0)
826 ecoff_data (output_bfd)->gp = bfd_asymbol_value (*sym);
834 /* Only get the error once. */
835 ecoff_data (output_bfd)->gp = 4;
837 (char *) "GP relative relocation when _gp not defined";
838 return bfd_reloc_dangerous;
843 if (bfd_is_com_section (symbol->section))
846 relocation = symbol->value;
848 relocation += symbol->section->output_section->vma;
849 relocation += symbol->section->output_offset;
851 if (reloc_entry->address > input_section->_cooked_size)
852 return bfd_reloc_outofrange;
854 insn = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
856 /* Set val to the offset into the section or symbol. */
857 val = ((insn & 0xffff) + reloc_entry->addend) & 0xffff;
861 /* Adjust val for the final section location and GP value. If we
862 are producing relocateable output, we don't want to do this for
863 an external symbol. */
864 if (relocateable == false
865 || (symbol->flags & BSF_SECTION_SYM) != 0)
866 val += relocation - ecoff_data (output_bfd)->gp;
868 insn = (insn &~ 0xffff) | (val & 0xffff);
869 bfd_put_32 (abfd, insn, (bfd_byte *) data + reloc_entry->address);
871 if (relocateable != false)
872 reloc_entry->address += input_section->output_offset;
874 /* Make sure it fit in 16 bits. */
875 if (val >= 0x8000 && val < 0xffff8000)
876 return bfd_reloc_overflow;
881 /* Do a RELHI relocation. We do this in conjunction with a RELLO
882 reloc, just as REFHI and REFLO are done together. RELHI and RELLO
883 are Cygnus extensions used when generating position independent
884 code for embedded systems. */
886 static bfd_byte *mips_relhi_addr;
887 static bfd_vma mips_relhi_addend;
889 static bfd_reloc_status_type
890 mips_relhi_reloc (abfd,
898 arelent *reloc_entry;
901 asection *input_section;
903 char **error_message;
905 bfd_reloc_status_type ret;
908 /* If this is a reloc against a section symbol, then it is correct
909 in the object file. The only time we want to change this case is
910 when we are relaxing, and that is handled entirely by
911 mips_relocate_section and never calls this function. */
912 if ((symbol->flags & BSF_SECTION_SYM) != 0)
914 if (output_bfd != (bfd *) NULL)
915 reloc_entry->address += input_section->output_offset;
919 /* This is an external symbol. If we're relocating, we don't want
920 to change anything. */
921 if (output_bfd != (bfd *) NULL)
923 reloc_entry->address += input_section->output_offset;
928 if (symbol->section == &bfd_und_section
929 && output_bfd == (bfd *) NULL)
930 ret = bfd_reloc_undefined;
932 if (bfd_is_com_section (symbol->section))
935 relocation = symbol->value;
937 relocation += symbol->section->output_section->vma;
938 relocation += symbol->section->output_offset;
939 relocation += reloc_entry->addend;
941 if (reloc_entry->address > input_section->_cooked_size)
942 return bfd_reloc_outofrange;
944 /* Save the information, and let RELLO do the actual relocation. */
945 mips_relhi_addr = (bfd_byte *) data + reloc_entry->address;
946 mips_relhi_addend = relocation;
948 if (output_bfd != (bfd *) NULL)
949 reloc_entry->address += input_section->output_offset;
954 /* Do a RELLO relocation. This is a straightforward 16 bit PC
955 relative relocation; this function exists in order to do the RELHI
956 relocation described above. */
958 static bfd_reloc_status_type
959 mips_rello_reloc (abfd,
967 arelent *reloc_entry;
970 asection *input_section;
972 char **error_message;
974 if (mips_relhi_addr != (bfd_byte *) NULL)
980 /* Do the RELHI relocation. Note that we actually don't need to
981 know anything about the RELLO itself, except where to find
982 the low 16 bits of the addend needed by the RELHI. */
983 insn = bfd_get_32 (abfd, mips_relhi_addr);
984 vallo = (bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address)
986 val = ((insn & 0xffff) << 16) + vallo;
987 val += mips_relhi_addend;
989 /* If the symbol is defined, make val PC relative. If the
990 symbol is not defined we don't want to do this, because we
991 don't want the value in the object file to incorporate the
992 address of the reloc. */
993 if (bfd_get_section (symbol) != &bfd_und_section
994 && ! bfd_is_com_section (bfd_get_section (symbol)))
995 val -= (input_section->output_section->vma
996 + input_section->output_offset
997 + reloc_entry->address);
999 /* The low order 16 bits are always treated as a signed value.
1000 Therefore, a negative value in the low order bits requires an
1001 adjustment in the high order bits. We need to make this
1002 adjustment in two ways: once for the bits we took from the
1003 data, and once for the bits we are putting back in to the
1005 if ((vallo & 0x8000) != 0)
1007 if ((val & 0x8000) != 0)
1010 insn = (insn &~ 0xffff) | ((val >> 16) & 0xffff);
1011 bfd_put_32 (abfd, insn, mips_relhi_addr);
1013 mips_relhi_addr = (bfd_byte *) NULL;
1016 /* If this is a reloc against a section symbol, then it is correct
1017 in the object file. The only time we want to change this case is
1018 when we are relaxing, and that is handled entirely by
1019 mips_relocate_section and never calls this function. */
1020 if ((symbol->flags & BSF_SECTION_SYM) != 0)
1022 if (output_bfd != (bfd *) NULL)
1023 reloc_entry->address += input_section->output_offset;
1024 return bfd_reloc_ok;
1027 /* bfd_perform_relocation does not handle pcrel_offset relocations
1028 correctly when generating a relocateable file, so handle them
1030 if (output_bfd != (bfd *) NULL)
1032 reloc_entry->address += input_section->output_offset;
1033 return bfd_reloc_ok;
1036 /* Now do the RELLO reloc in the usual way. */
1037 return mips_generic_reloc (abfd, reloc_entry, symbol, data,
1038 input_section, output_bfd, error_message);
1041 /* This is the special function for the MIPS_R_SWITCH reloc. This
1042 special reloc is normally correct in the object file, and only
1043 requires special handling when relaxing. We don't want
1044 bfd_perform_relocation to tamper with it at all. */
1047 static bfd_reloc_status_type
1048 mips_switch_reloc (abfd,
1056 arelent *reloc_entry;
1059 asection *input_section;
1061 char **error_message;
1063 return bfd_reloc_ok;
1066 /* Get the howto structure for a generic reloc type. */
1068 static CONST struct reloc_howto_struct *
1069 mips_bfd_reloc_type_lookup (abfd, code)
1071 bfd_reloc_code_real_type code;
1078 mips_type = MIPS_R_REFHALF;
1081 case BFD_RELOC_CTOR:
1082 mips_type = MIPS_R_REFWORD;
1084 case BFD_RELOC_MIPS_JMP:
1085 mips_type = MIPS_R_JMPADDR;
1087 case BFD_RELOC_HI16_S:
1088 mips_type = MIPS_R_REFHI;
1090 case BFD_RELOC_LO16:
1091 mips_type = MIPS_R_REFLO;
1093 case BFD_RELOC_MIPS_GPREL:
1094 mips_type = MIPS_R_GPREL;
1096 case BFD_RELOC_MIPS_LITERAL:
1097 mips_type = MIPS_R_LITERAL;
1099 case BFD_RELOC_16_PCREL_S2:
1100 mips_type = MIPS_R_PCREL16;
1102 case BFD_RELOC_PCREL_HI16_S:
1103 mips_type = MIPS_R_RELHI;
1105 case BFD_RELOC_PCREL_LO16:
1106 mips_type = MIPS_R_RELLO;
1108 case BFD_RELOC_GPREL32:
1109 mips_type = MIPS_R_SWITCH;
1112 return (CONST struct reloc_howto_struct *) NULL;
1115 return &mips_howto_table[mips_type];
1118 /* A helper routine for mips_relocate_section which handles the REFHI
1119 and RELHI relocations. The REFHI relocation must be followed by a
1120 REFLO relocation (and RELHI by a RELLO), and the addend used is
1121 formed from the addends of both instructions. */
1124 mips_relocate_hi (refhi, reflo, input_bfd, input_section, contents, adjust,
1126 struct internal_reloc *refhi;
1127 struct internal_reloc *reflo;
1129 asection *input_section;
1137 unsigned long vallo;
1139 insn = bfd_get_32 (input_bfd,
1140 contents + adjust + refhi->r_vaddr - input_section->vma);
1141 vallo = (bfd_get_32 (input_bfd,
1142 contents + adjust + reflo->r_vaddr - input_section->vma)
1144 val = ((insn & 0xffff) << 16) + vallo;
1147 /* The low order 16 bits are always treated as a signed value.
1148 Therefore, a negative value in the low order bits requires an
1149 adjustment in the high order bits. We need to make this
1150 adjustment in two ways: once for the bits we took from the data,
1151 and once for the bits we are putting back in to the data. */
1152 if ((vallo & 0x8000) != 0)
1156 val -= (input_section->output_section->vma
1157 + input_section->output_offset
1158 + (reflo->r_vaddr - input_section->vma + adjust));
1160 if ((val & 0x8000) != 0)
1163 insn = (insn &~ 0xffff) | ((val >> 16) & 0xffff);
1164 bfd_put_32 (input_bfd, (bfd_vma) insn,
1165 contents + adjust + refhi->r_vaddr - input_section->vma);
1168 /* Relocate a section while linking a MIPS ECOFF file. */
1171 mips_relocate_section (output_bfd, info, input_bfd, input_section,
1172 contents, external_relocs)
1174 struct bfd_link_info *info;
1176 asection *input_section;
1178 PTR external_relocs;
1180 asection **symndx_to_section;
1181 struct ecoff_link_hash_entry **sym_hashes;
1183 boolean gp_undefined;
1186 struct external_reloc *ext_rel;
1187 struct external_reloc *ext_rel_end;
1190 struct internal_reloc lo_int_rel;
1192 BFD_ASSERT (input_bfd->xvec->header_byteorder_big_p
1193 == output_bfd->xvec->header_byteorder_big_p);
1195 /* We keep a table mapping the symndx found in an internal reloc to
1196 the appropriate section. This is faster than looking up the
1197 section by name each time. */
1198 symndx_to_section = ecoff_data (input_bfd)->symndx_to_section;
1199 if (symndx_to_section == (asection **) NULL)
1201 symndx_to_section = ((asection **)
1202 bfd_alloc (input_bfd,
1204 * sizeof (asection *))));
1205 if (!symndx_to_section)
1207 bfd_set_error (bfd_error_no_memory);
1211 symndx_to_section[RELOC_SECTION_NONE] = NULL;
1212 symndx_to_section[RELOC_SECTION_TEXT] =
1213 bfd_get_section_by_name (input_bfd, ".text");
1214 symndx_to_section[RELOC_SECTION_RDATA] =
1215 bfd_get_section_by_name (input_bfd, ".rdata");
1216 symndx_to_section[RELOC_SECTION_DATA] =
1217 bfd_get_section_by_name (input_bfd, ".data");
1218 symndx_to_section[RELOC_SECTION_SDATA] =
1219 bfd_get_section_by_name (input_bfd, ".sdata");
1220 symndx_to_section[RELOC_SECTION_SBSS] =
1221 bfd_get_section_by_name (input_bfd, ".sbss");
1222 symndx_to_section[RELOC_SECTION_BSS] =
1223 bfd_get_section_by_name (input_bfd, ".bss");
1224 symndx_to_section[RELOC_SECTION_INIT] =
1225 bfd_get_section_by_name (input_bfd, ".init");
1226 symndx_to_section[RELOC_SECTION_LIT8] =
1227 bfd_get_section_by_name (input_bfd, ".lit8");
1228 symndx_to_section[RELOC_SECTION_LIT4] =
1229 bfd_get_section_by_name (input_bfd, ".lit4");
1230 symndx_to_section[RELOC_SECTION_XDATA] = NULL;
1231 symndx_to_section[RELOC_SECTION_PDATA] = NULL;
1232 symndx_to_section[RELOC_SECTION_FINI] =
1233 bfd_get_section_by_name (input_bfd, ".fini");
1234 symndx_to_section[RELOC_SECTION_LITA] = NULL;
1235 symndx_to_section[RELOC_SECTION_ABS] = NULL;
1237 ecoff_data (input_bfd)->symndx_to_section = symndx_to_section;
1240 sym_hashes = ecoff_data (input_bfd)->sym_hashes;
1242 gp = ecoff_data (output_bfd)->gp;
1244 gp_undefined = true;
1246 gp_undefined = false;
1252 if (ecoff_section_data (input_bfd, input_section) == NULL)
1255 offsets = ecoff_section_data (input_bfd, input_section)->offsets;
1257 ext_rel = (struct external_reloc *) external_relocs;
1258 ext_rel_end = ext_rel + input_section->reloc_count;
1259 for (i = 0; ext_rel < ext_rel_end; ext_rel++, i++)
1261 struct internal_reloc int_rel;
1263 reloc_howto_type *howto;
1264 struct ecoff_link_hash_entry *h = NULL;
1267 bfd_reloc_status_type r;
1270 mips_ecoff_swap_reloc_in (input_bfd, (PTR) ext_rel, &int_rel);
1273 int_rel = lo_int_rel;
1277 BFD_ASSERT (int_rel.r_type
1278 < sizeof mips_howto_table / sizeof mips_howto_table[0]);
1280 /* The REFHI and RELHI relocs requires special handling. they
1281 must be followed by a REFLO or RELLO reloc, respectively, and
1282 the addend is formed from both relocs. */
1283 if (int_rel.r_type == MIPS_R_REFHI
1284 || int_rel.r_type == MIPS_R_RELHI)
1286 BFD_ASSERT ((ext_rel + 1) < ext_rel_end);
1287 mips_ecoff_swap_reloc_in (input_bfd, (PTR) (ext_rel + 1),
1289 BFD_ASSERT ((lo_int_rel.r_type
1290 == (int_rel.r_type == MIPS_R_REFHI
1293 && int_rel.r_extern == lo_int_rel.r_extern
1294 && int_rel.r_symndx == lo_int_rel.r_symndx);
1298 howto = &mips_howto_table[int_rel.r_type];
1300 /* The SWITCH reloc must be handled specially. This reloc is
1301 marks the location of a difference between two portions of an
1302 object file. The symbol index does not reference a symbol,
1303 but is actually the offset from the reloc to the subtrahend
1304 of the difference. This reloc is correct in the object file,
1305 and needs no further adjustment, unless we are relaxing. If
1306 we are relaxing, we may have to add in an offset. Since no
1307 symbols are involved in this reloc, we handle it completely
1309 if (int_rel.r_type == MIPS_R_SWITCH)
1314 r = _bfd_relocate_contents (howto, input_bfd,
1315 (bfd_vma) offsets[i],
1319 - input_section->vma));
1320 BFD_ASSERT (r == bfd_reloc_ok);
1326 if (int_rel.r_extern)
1328 h = sym_hashes[int_rel.r_symndx];
1329 /* If h is NULL, that means that there is a reloc against an
1330 external symbol which we thought was just a debugging
1331 symbol. This should not happen. */
1332 if (h == (struct ecoff_link_hash_entry *) NULL)
1337 if (int_rel.r_symndx < 0 || int_rel.r_symndx >= NUM_RELOC_SECTIONS)
1340 s = symndx_to_section[int_rel.r_symndx];
1342 if (s == (asection *) NULL)
1346 /* The GPREL reloc uses an addend: the difference in the GP
1348 if (int_rel.r_type != MIPS_R_GPREL
1349 && int_rel.r_type != MIPS_R_LITERAL)
1355 if (! ((*info->callbacks->reloc_dangerous)
1356 (info, "GP relative relocation when GP not defined",
1357 input_bfd, input_section,
1358 int_rel.r_vaddr - input_section->vma)))
1360 /* Only give the error once per link. */
1361 ecoff_data (output_bfd)->gp = gp = 4;
1362 gp_undefined = false;
1364 if (! int_rel.r_extern)
1366 /* This is a relocation against a section. The current
1367 addend in the instruction is the difference between
1368 INPUT_SECTION->vma and the GP value of INPUT_BFD. We
1369 must change this to be the difference between the
1370 final definition (which will end up in RELOCATION)
1371 and the GP value of OUTPUT_BFD (which is in GP). */
1372 addend = ecoff_data (input_bfd)->gp - gp;
1374 else if (! info->relocateable
1375 || h->root.type == bfd_link_hash_defined)
1377 /* This is a relocation against an undefined or common
1378 symbol. The current addend in the instruction is
1379 simply the desired offset into the symbol (normally
1380 zero). We are going to change this into a relocation
1381 against a defined symbol, so we want the instruction
1382 to hold the difference between the final definition
1383 of the symbol (which will end up in RELOCATION) and
1384 the GP value of OUTPUT_BFD (which is in GP). */
1389 /* This is a relocation against an undefined or common
1390 symbol. The current addend in the instruction is
1391 simply the desired offset into the symbol (normally
1392 zero). We are generating relocateable output, and we
1393 aren't going to define this symbol, so we just leave
1394 the instruction alone. */
1399 /* If we are relaxing, mips_relax_section may have set
1400 offsets[i] to some value. A value of 1 means we must expand
1401 a PC relative branch into a multi-instruction of sequence,
1402 and any other value is an addend. */
1406 BFD_ASSERT (! info->relocateable);
1407 BFD_ASSERT (int_rel.r_type == MIPS_R_PCREL16
1408 || int_rel.r_type == MIPS_R_RELHI
1409 || int_rel.r_type == MIPS_R_RELLO);
1410 if (offsets[i] != 1)
1411 addend += offsets[i];
1416 BFD_ASSERT (int_rel.r_extern
1417 && int_rel.r_type == MIPS_R_PCREL16);
1419 /* Move the rest of the instructions up. */
1423 - input_section->vma);
1424 memmove (here + PCREL16_EXPANSION_ADJUSTMENT, here,
1425 (input_section->_raw_size
1426 - (int_rel.r_vaddr - input_section->vma)));
1428 /* Generate the new instructions. */
1429 if (! mips_relax_pcrel16 (info, input_bfd, input_section,
1431 (input_section->output_section->vma
1432 + input_section->output_offset
1434 - input_section->vma)
1438 /* We must adjust everything else up a notch. */
1439 adjust += PCREL16_EXPANSION_ADJUSTMENT;
1441 /* mips_relax_pcrel16 handles all the details of this
1447 if (info->relocateable)
1449 /* We are generating relocateable output, and must convert
1450 the existing reloc. */
1451 if (int_rel.r_extern)
1453 if (h->root.type == bfd_link_hash_defined)
1457 /* This symbol is defined in the output. Convert
1458 the reloc from being against the symbol to being
1459 against the section. */
1461 /* Clear the r_extern bit. */
1462 int_rel.r_extern = 0;
1464 /* Compute a new r_symndx value. */
1465 s = h->root.u.def.section;
1466 name = bfd_get_section_name (output_bfd,
1469 int_rel.r_symndx = -1;
1473 if (strcmp (name, ".bss") == 0)
1474 int_rel.r_symndx = RELOC_SECTION_BSS;
1477 if (strcmp (name, ".data") == 0)
1478 int_rel.r_symndx = RELOC_SECTION_DATA;
1481 if (strcmp (name, ".fini") == 0)
1482 int_rel.r_symndx = RELOC_SECTION_FINI;
1485 if (strcmp (name, ".init") == 0)
1486 int_rel.r_symndx = RELOC_SECTION_INIT;
1489 if (strcmp (name, ".lit8") == 0)
1490 int_rel.r_symndx = RELOC_SECTION_LIT8;
1491 else if (strcmp (name, ".lit4") == 0)
1492 int_rel.r_symndx = RELOC_SECTION_LIT4;
1495 if (strcmp (name, ".rdata") == 0)
1496 int_rel.r_symndx = RELOC_SECTION_RDATA;
1499 if (strcmp (name, ".sdata") == 0)
1500 int_rel.r_symndx = RELOC_SECTION_SDATA;
1501 else if (strcmp (name, ".sbss") == 0)
1502 int_rel.r_symndx = RELOC_SECTION_SBSS;
1505 if (strcmp (name, ".text") == 0)
1506 int_rel.r_symndx = RELOC_SECTION_TEXT;
1510 if (int_rel.r_symndx == -1)
1513 /* Add the section VMA and the symbol value. */
1514 relocation = (h->root.u.def.value
1515 + s->output_section->vma
1516 + s->output_offset);
1518 /* For a PC relative relocation, the object file
1519 currently holds just the addend. We must adjust
1520 by the address to get the right value. */
1521 if (howto->pc_relative)
1523 relocation -= int_rel.r_vaddr - input_section->vma;
1525 /* If we are converting a RELHI or RELLO reloc
1526 from being against an external symbol to
1527 being against a section, we must put a
1528 special value into the r_offset field. This
1529 value is the old addend. The r_offset for
1530 both the RELOHI and RELLO relocs are the
1531 same, and we set both when we see RELHI. */
1532 if (int_rel.r_type == MIPS_R_RELHI)
1536 addhi = bfd_get_32 (input_bfd,
1540 - input_section->vma));
1546 addlo = bfd_get_32 (input_bfd,
1549 + lo_int_rel.r_vaddr
1550 - input_section->vma));
1555 int_rel.r_offset = addhi + addlo;
1556 lo_int_rel.r_offset = int_rel.r_offset;
1564 /* Change the symndx value to the right one for the
1566 int_rel.r_symndx = h->indx;
1567 if (int_rel.r_symndx == -1)
1569 /* This symbol is not being written out. */
1570 if (! ((*info->callbacks->unattached_reloc)
1571 (info, h->root.root.string, input_bfd,
1573 int_rel.r_vaddr - input_section->vma)))
1575 int_rel.r_symndx = 0;
1582 /* This is a relocation against a section. Adjust the
1583 value by the amount the section moved. */
1584 relocation = (s->output_section->vma
1589 relocation += addend;
1591 /* Adjust a PC relative relocation by removing the reference
1592 to the original address in the section and including the
1593 reference to the new address. However, external RELHI
1594 and RELLO relocs are PC relative, but don't include any
1595 reference to the address. The addend is merely an
1597 if (howto->pc_relative
1598 && (! int_rel.r_extern
1599 || (int_rel.r_type != MIPS_R_RELHI
1600 && int_rel.r_type != MIPS_R_RELLO)))
1601 relocation -= (input_section->output_section->vma
1602 + input_section->output_offset
1603 - input_section->vma);
1605 /* Adjust the contents. */
1606 if (relocation == 0)
1610 if (int_rel.r_type != MIPS_R_REFHI
1611 && int_rel.r_type != MIPS_R_RELHI)
1612 r = _bfd_relocate_contents (howto, input_bfd, relocation,
1616 - input_section->vma));
1619 mips_relocate_hi (&int_rel, &lo_int_rel,
1620 input_bfd, input_section, contents,
1622 int_rel.r_type == MIPS_R_RELHI);
1627 /* Adjust the reloc address. */
1628 int_rel.r_vaddr += (input_section->output_section->vma
1629 + input_section->output_offset
1630 - input_section->vma);
1632 /* Save the changed reloc information. */
1633 mips_ecoff_swap_reloc_out (input_bfd, &int_rel, (PTR) ext_rel);
1637 /* We are producing a final executable. */
1638 if (int_rel.r_extern)
1640 /* This is a reloc against a symbol. */
1641 if (h->root.type == bfd_link_hash_defined)
1645 hsec = h->root.u.def.section;
1646 relocation = (h->root.u.def.value
1647 + hsec->output_section->vma
1648 + hsec->output_offset);
1652 if (! ((*info->callbacks->undefined_symbol)
1653 (info, h->root.root.string, input_bfd,
1655 int_rel.r_vaddr - input_section->vma)))
1662 /* This is a reloc against a section. */
1663 relocation = (s->output_section->vma
1667 /* A PC relative reloc is already correct in the object
1668 file. Make it look like a pcrel_offset relocation by
1669 adding in the start address. */
1670 if (howto->pc_relative)
1672 if (int_rel.r_type != MIPS_R_RELHI)
1673 relocation += int_rel.r_vaddr + adjust;
1675 relocation += lo_int_rel.r_vaddr + adjust;
1679 if (int_rel.r_type != MIPS_R_REFHI
1680 && int_rel.r_type != MIPS_R_RELHI)
1681 r = _bfd_final_link_relocate (howto,
1686 - input_section->vma
1692 mips_relocate_hi (&int_rel, &lo_int_rel, input_bfd,
1693 input_section, contents, adjust,
1695 int_rel.r_type == MIPS_R_RELHI);
1700 if (r != bfd_reloc_ok)
1705 case bfd_reloc_outofrange:
1707 case bfd_reloc_overflow:
1711 if (int_rel.r_extern)
1712 name = h->root.root.string;
1714 name = bfd_section_name (input_bfd, s);
1715 if (! ((*info->callbacks->reloc_overflow)
1716 (info, name, howto->name, (bfd_vma) 0,
1717 input_bfd, input_section,
1718 int_rel.r_vaddr - input_section->vma)))
1729 /* Relax a section when linking a MIPS ECOFF file. This is used for
1730 embedded PIC code, which always uses PC relative branches which
1731 only have an 18 bit range on MIPS. If a branch is not in range, we
1732 generate a long instruction sequence to compensate. Each time we
1733 find a branch to expand, we have to check all the others again to
1734 make sure they are still in range. This is slow, but it only has
1735 to be done when -relax is passed to the linker.
1737 This routine figures out which branches need to expand; the actual
1738 expansion is done in mips_relocate_section when the section
1739 contents are relocated. The information is stored in the offsets
1740 field of the ecoff_section_tdata structure. An offset of 1 means
1741 that the branch must be expanded into a multi-instruction PC
1742 relative branch (such an offset will only occur for a PC relative
1743 branch to an external symbol). Any other offset must be a multiple
1744 of four, and is the amount to change the branch by (such an offset
1745 will only occur for a PC relative branch within the same section).
1747 We do not modify the section relocs or contents themselves so that
1748 if memory usage becomes an issue we can discard them and read them
1749 again. The only information we must save in memory between this
1750 routine and the mips_relocate_section routine is the table of
1754 mips_relax_section (abfd, sec, info, again)
1757 struct bfd_link_info *info;
1760 struct ecoff_section_tdata *section_tdata;
1761 bfd_byte *contents = NULL;
1763 struct external_reloc *ext_rel;
1764 struct external_reloc *ext_rel_end;
1767 /* Assume we are not going to need another pass. */
1770 /* If we are not generating an ECOFF file, this is much too
1771 confusing to deal with. */
1772 if (info->hash->creator->flavour != bfd_get_flavour (abfd))
1775 /* If there are no relocs, there is nothing to do. */
1776 if (sec->reloc_count == 0)
1779 /* We are only interested in PC relative relocs, and why would there
1780 ever be one from anything but the .text section? */
1781 if (strcmp (bfd_get_section_name (abfd, sec), ".text") != 0)
1784 /* Read in the relocs, if we haven't already got them. */
1785 section_tdata = ecoff_section_data (abfd, sec);
1786 if (section_tdata == (struct ecoff_section_tdata *) NULL)
1788 bfd_size_type external_reloc_size;
1789 bfd_size_type external_relocs_size;
1792 (PTR) bfd_alloc_by_size_t (abfd, sizeof (struct ecoff_section_tdata));
1793 if (sec->used_by_bfd == NULL)
1795 bfd_set_error (bfd_error_no_memory);
1799 section_tdata = ecoff_section_data (abfd, sec);
1800 section_tdata->contents = NULL;
1801 section_tdata->offsets = NULL;
1803 external_reloc_size = ecoff_backend (abfd)->external_reloc_size;
1804 external_relocs_size = external_reloc_size * sec->reloc_count;
1806 section_tdata->external_relocs =
1807 (PTR) bfd_alloc (abfd, external_relocs_size);
1808 if (section_tdata->external_relocs == NULL && external_relocs_size != 0)
1810 bfd_set_error (bfd_error_no_memory);
1814 if (bfd_seek (abfd, sec->rel_filepos, SEEK_SET) != 0
1815 || (bfd_read (section_tdata->external_relocs, 1,
1816 external_relocs_size, abfd)
1817 != external_relocs_size))
1820 /* We must initialize _cooked_size only the first time we are
1822 sec->_cooked_size = sec->_raw_size;
1825 contents = section_tdata->contents;
1826 offsets = section_tdata->offsets;
1828 /* Look for any external PC relative relocs. Internal PC relative
1829 relocs are already correct in the object file, so they certainly
1830 can not overflow. */
1831 ext_rel = (struct external_reloc *) section_tdata->external_relocs;
1832 ext_rel_end = ext_rel + sec->reloc_count;
1833 for (i = 0; ext_rel < ext_rel_end; ext_rel++, i++)
1835 struct internal_reloc int_rel;
1836 struct ecoff_link_hash_entry *h;
1838 bfd_signed_vma relocation;
1839 struct external_reloc *adj_ext_rel;
1841 unsigned long ext_count;
1842 struct ecoff_link_hash_entry **adj_h_ptr;
1843 struct ecoff_link_hash_entry **adj_h_ptr_end;
1844 struct ecoff_value_adjust *adjust;
1846 /* If we have already expanded this reloc, we certainly don't
1847 need to do it again. */
1848 if (offsets != (long *) NULL && offsets[i] == 1)
1851 /* Quickly check that this reloc is external PCREL16. */
1852 if (abfd->xvec->header_byteorder_big_p)
1854 if ((ext_rel->r_bits[3] & RELOC_BITS3_EXTERN_BIG) == 0
1855 || (((ext_rel->r_bits[3] & RELOC_BITS3_TYPE_BIG)
1856 >> RELOC_BITS3_TYPE_SH_BIG)
1862 if ((ext_rel->r_bits[3] & RELOC_BITS3_EXTERN_LITTLE) == 0
1863 || (((ext_rel->r_bits[3] & RELOC_BITS3_TYPE_LITTLE)
1864 >> RELOC_BITS3_TYPE_SH_LITTLE)
1869 mips_ecoff_swap_reloc_in (abfd, (PTR) ext_rel, &int_rel);
1871 h = ecoff_data (abfd)->sym_hashes[int_rel.r_symndx];
1872 if (h == (struct ecoff_link_hash_entry *) NULL)
1875 if (h->root.type != bfd_link_hash_defined)
1877 /* Just ignore undefined symbols. These will presumably
1878 generate an error later in the link. */
1882 /* Get the value of the symbol. */
1883 hsec = h->root.u.def.section;
1884 relocation = (h->root.u.def.value
1885 + hsec->output_section->vma
1886 + hsec->output_offset);
1888 /* Subtract out the current address. */
1889 relocation -= (sec->output_section->vma
1890 + sec->output_offset
1891 + (int_rel.r_vaddr - sec->vma));
1893 /* The addend is stored in the object file. In the normal case
1894 of ``bal symbol'', the addend will be -4. It will only be
1895 different in the case of ``bal symbol+constant''. To avoid
1896 always reading in the section contents, we don't check the
1897 addend in the object file (we could easily check the contents
1898 if we happen to have already read them in, but I fear that
1899 this could be confusing). This means we will screw up if
1900 there is a branch to a symbol that is in range, but added to
1901 a constant which puts it out of range; in such a case the
1902 link will fail with a reloc overflow error. Since the
1903 compiler will never generate such code, it should be easy
1904 enough to work around it by changing the assembly code in the
1908 /* Now RELOCATION is the number we want to put in the object
1909 file. See whether it fits. */
1910 if (relocation >= -0x20000 && relocation < 0x20000)
1913 /* Now that we know this reloc needs work, which will rarely
1914 happen, go ahead and grab the section contents. */
1915 if (contents == (bfd_byte *) NULL)
1917 if (info->keep_memory)
1918 contents = (bfd_byte *) bfd_alloc (abfd, sec->_raw_size);
1920 contents = (bfd_byte *) malloc (sec->_raw_size);
1921 if (contents == (bfd_byte *) NULL)
1923 bfd_set_error (bfd_error_no_memory);
1926 if (! bfd_get_section_contents (abfd, sec, (PTR) contents,
1927 (file_ptr) 0, sec->_raw_size))
1929 if (info->keep_memory)
1930 section_tdata->contents = contents;
1933 /* We only support changing the bal instruction. It would be
1934 possible to handle other PC relative branches, but some of
1935 them (the conditional branches) would require a different
1936 length instruction sequence which would complicate both this
1937 routine and mips_relax_pcrel16. It could be written if
1938 somebody felt it were important. Ignoring this reloc will
1939 presumably cause a reloc overflow error later on. */
1940 if (bfd_get_32 (abfd, contents + int_rel.r_vaddr - sec->vma)
1941 != 0x0411ffff) /* bgezal $0,. == bal . */
1944 /* Bother. We need to expand this reloc, and we will need to
1945 make another relaxation pass since this change may put other
1946 relocs out of range. We need to examine the local branches
1947 and we need to allocate memory to hold the offsets we must
1948 add to them. We also need to adjust the values of all
1949 symbols in the object file following this location. */
1951 sec->_cooked_size += PCREL16_EXPANSION_ADJUSTMENT;
1954 if (offsets == (long *) NULL)
1958 size = sec->reloc_count * sizeof (long);
1959 offsets = (long *) bfd_alloc_by_size_t (abfd, size);
1960 if (offsets == (long *) NULL)
1962 bfd_set_error (bfd_error_no_memory);
1965 memset (offsets, 0, size);
1966 section_tdata->offsets = offsets;
1971 /* Now look for all PC relative references that cross this reloc
1972 and adjust their offsets. */
1973 adj_ext_rel = (struct external_reloc *) section_tdata->external_relocs;
1974 for (adj_i = 0; adj_ext_rel < ext_rel_end; adj_ext_rel++, adj_i++)
1976 struct internal_reloc adj_int_rel;
1977 bfd_vma start, stop;
1980 mips_ecoff_swap_reloc_in (abfd, (PTR) adj_ext_rel, &adj_int_rel);
1982 if (adj_int_rel.r_type == MIPS_R_PCREL16)
1986 /* We only care about local references. External ones
1987 will be relocated correctly anyhow. */
1988 if (adj_int_rel.r_extern)
1991 /* We are only interested in a PC relative reloc within
1992 this section. FIXME: Cross section PC relative
1993 relocs may not be handled correctly; does anybody
1995 if (adj_int_rel.r_symndx != RELOC_SECTION_TEXT)
1998 start = adj_int_rel.r_vaddr;
2000 insn = bfd_get_32 (abfd,
2001 contents + adj_int_rel.r_vaddr - sec->vma);
2003 stop = (insn & 0xffff) << 2;
2004 if ((stop & 0x20000) != 0)
2006 stop += adj_int_rel.r_vaddr + 4;
2008 else if (adj_int_rel.r_type == MIPS_R_RELHI)
2010 struct internal_reloc rello;
2013 /* The next reloc must be MIPS_R_RELLO, and we handle
2015 BFD_ASSERT (adj_ext_rel + 1 < ext_rel_end);
2017 mips_ecoff_swap_reloc_in (abfd, (PTR) (adj_ext_rel + 1), &rello);
2019 BFD_ASSERT (rello.r_type == MIPS_R_RELLO);
2021 addhi = bfd_get_32 (abfd,
2022 contents + adj_int_rel.r_vaddr - sec->vma);
2028 addlo = bfd_get_32 (abfd, contents + rello.r_vaddr - sec->vma);
2033 if (adj_int_rel.r_extern)
2035 /* The value we want here is
2036 sym - RELLOaddr + addend
2037 which we can express as
2038 sym - (RELLOaddr - addend)
2039 Therefore if we are expanding the area between
2040 RELLOaddr and RELLOaddr - addend we must adjust
2041 the addend. This is admittedly ambiguous, since
2042 we might mean (sym + addend) - RELLOaddr, but in
2043 practice we don't, and there is no way to handle
2044 that case correctly since at this point we have
2045 no idea whether any reloc is being expanded
2046 between sym and sym + addend. */
2047 start = rello.r_vaddr - (addhi + addlo);
2048 stop = rello.r_vaddr;
2052 /* An internal RELHI/RELLO pair represents the
2053 difference between two addresses, $LC0 - foo.
2054 The symndx value is actually the difference
2055 between the reloc address and $LC0. This lets us
2056 compute $LC0, and, by considering the addend,
2057 foo. If the reloc we are expanding falls between
2058 those two relocs, we must adjust the addend. At
2059 this point, the symndx value is actually in the
2060 r_offset field, where it was put by
2061 mips_ecoff_swap_reloc_in. */
2062 start = rello.r_vaddr - adj_int_rel.r_offset;
2063 stop = start + addhi + addlo;
2066 else if (adj_int_rel.r_type == MIPS_R_SWITCH)
2068 /* A MIPS_R_SWITCH reloc represents a word of the form
2070 The value in the object file is correct, assuming the
2071 original value of $L3. The symndx value is actually
2072 the difference between the reloc address and $LS12.
2073 This lets us compute the original value of $LS12 as
2075 and the original value of $L3 as
2076 vaddr - symndx + addend
2077 where addend is the value from the object file. At
2078 this point, the symndx value is actually found in the
2079 r_offset field, since it was moved by
2080 mips_ecoff_swap_reloc_in. */
2081 start = adj_int_rel.r_vaddr - adj_int_rel.r_offset;
2082 stop = start + bfd_get_32 (abfd,
2084 + adj_int_rel.r_vaddr
2090 /* If the range expressed by this reloc, which is the
2091 distance between START and STOP crosses the reloc we are
2092 expanding, we must adjust the offset. The sign of the
2093 adjustment depends upon the direction in which the range
2094 crosses the reloc being expanded. */
2095 if (start <= int_rel.r_vaddr && stop > int_rel.r_vaddr)
2096 change = PCREL16_EXPANSION_ADJUSTMENT;
2097 else if (start > int_rel.r_vaddr && stop <= int_rel.r_vaddr)
2098 change = - PCREL16_EXPANSION_ADJUSTMENT;
2102 offsets[adj_i] += change;
2104 if (adj_int_rel.r_type == MIPS_R_RELHI)
2108 offsets[adj_i] += change;
2112 /* Find all symbols in this section defined by this object file
2113 and adjust their values. Note that we decide whether to
2114 adjust the value based on the value stored in the ECOFF EXTR
2115 structure, because the value stored in the hash table may
2116 have been changed by an earlier expanded reloc and thus may
2117 no longer correctly indicate whether the symbol is before or
2118 after the expanded reloc. */
2119 ext_count = ecoff_data (abfd)->debug_info.symbolic_header.iextMax;
2120 adj_h_ptr = ecoff_data (abfd)->sym_hashes;
2121 adj_h_ptr_end = adj_h_ptr + ext_count;
2122 for (; adj_h_ptr < adj_h_ptr_end; adj_h_ptr++)
2124 struct ecoff_link_hash_entry *adj_h;
2127 if (adj_h != (struct ecoff_link_hash_entry *) NULL
2128 && adj_h->root.type == bfd_link_hash_defined
2129 && adj_h->root.u.def.section == sec
2130 && adj_h->esym.asym.value > int_rel.r_vaddr)
2131 adj_h->root.u.def.value += PCREL16_EXPANSION_ADJUSTMENT;
2134 /* Add an entry to the symbol value adjust list. This is used
2135 by bfd_ecoff_debug_accumulate to adjust the values of
2136 internal symbols and FDR's. */
2137 adjust = ((struct ecoff_value_adjust *)
2138 bfd_alloc (abfd, sizeof (struct ecoff_value_adjust)));
2139 if (adjust == (struct ecoff_value_adjust *) NULL)
2141 bfd_set_error (bfd_error_no_memory);
2145 adjust->start = int_rel.r_vaddr;
2146 adjust->end = sec->vma + sec->_raw_size;
2147 adjust->adjust = PCREL16_EXPANSION_ADJUSTMENT;
2149 adjust->next = ecoff_data (abfd)->debug_info.adjust;
2150 ecoff_data (abfd)->debug_info.adjust = adjust;
2153 if (contents != (bfd_byte *) NULL && ! info->keep_memory)
2159 if (contents != (bfd_byte *) NULL && ! info->keep_memory)
2164 /* This routine is called from mips_relocate_section when a PC
2165 relative reloc must be expanded into the five instruction sequence.
2166 It handles all the details of the expansion, including resolving
2170 mips_relax_pcrel16 (info, input_bfd, input_section, h, location, address)
2171 struct bfd_link_info *info;
2173 asection *input_section;
2174 struct ecoff_link_hash_entry *h;
2180 /* 0x0411ffff is bgezal $0,. == bal . */
2181 BFD_ASSERT (bfd_get_32 (input_bfd, location) == 0x0411ffff);
2183 /* We need to compute the distance between the symbol and the
2184 current address plus eight. */
2185 relocation = (h->root.u.def.value
2186 + h->root.u.def.section->output_section->vma
2187 + h->root.u.def.section->output_offset);
2188 relocation -= address + 8;
2190 /* If the lower half is negative, increment the upper 16 half. */
2191 if ((relocation & 0x8000) != 0)
2192 relocation += 0x10000;
2194 bfd_put_32 (input_bfd, 0x04110001, location); /* bal .+8 */
2195 bfd_put_32 (input_bfd,
2196 0x3c010000 | ((relocation >> 16) & 0xffff), /* lui $at,XX */
2198 bfd_put_32 (input_bfd,
2199 0x24210000 | (relocation & 0xffff), /* addiu $at,$at,XX */
2201 bfd_put_32 (input_bfd, 0x003f0821, location + 12); /* addu $at,$at,$ra */
2202 bfd_put_32 (input_bfd, 0x0020f809, location + 16); /* jalr $at */
2207 /* This is the ECOFF backend structure. The backend field of the
2208 target vector points to this. */
2210 static const struct ecoff_backend_data mips_ecoff_backend_data =
2212 /* COFF backend structure. */
2214 (void (*) PARAMS ((bfd *,PTR,int,int,int,int,PTR))) bfd_void, /* aux_in */
2215 (void (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* sym_in */
2216 (void (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* lineno_in */
2217 (unsigned (*) PARAMS ((bfd *,PTR,int,int,int,int,PTR)))bfd_void,/*aux_out*/
2218 (unsigned (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* sym_out */
2219 (unsigned (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* lineno_out */
2220 (unsigned (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* reloc_out */
2221 mips_ecoff_swap_filehdr_out, mips_ecoff_swap_aouthdr_out,
2222 mips_ecoff_swap_scnhdr_out,
2223 FILHSZ, AOUTSZ, SCNHSZ, 0, 0, 0, true,
2224 mips_ecoff_swap_filehdr_in, mips_ecoff_swap_aouthdr_in,
2225 mips_ecoff_swap_scnhdr_in, mips_ecoff_bad_format_hook,
2226 ecoff_set_arch_mach_hook, ecoff_mkobject_hook,
2227 ecoff_styp_to_sec_flags, ecoff_make_section_hook, ecoff_set_alignment_hook,
2228 ecoff_slurp_symbol_table, NULL, NULL
2230 /* Supported architecture. */
2232 /* Initial portion of armap string. */
2234 /* The page boundary used to align sections in a demand-paged
2235 executable file. E.g., 0x1000. */
2237 /* True if the .rdata section is part of the text segment, as on the
2238 Alpha. False if .rdata is part of the data segment, as on the
2241 /* Bitsize of constructor entries. */
2243 /* Reloc to use for constructor entries. */
2244 &mips_howto_table[MIPS_R_REFWORD],
2246 /* Symbol table magic number. */
2248 /* Alignment of debugging information. E.g., 4. */
2250 /* Sizes of external symbolic information. */
2251 sizeof (struct hdr_ext),
2252 sizeof (struct dnr_ext),
2253 sizeof (struct pdr_ext),
2254 sizeof (struct sym_ext),
2255 sizeof (struct opt_ext),
2256 sizeof (struct fdr_ext),
2257 sizeof (struct rfd_ext),
2258 sizeof (struct ext_ext),
2259 /* Functions to swap in external symbolic data. */
2268 /* Functions to swap out external symbolic data. */
2278 /* External reloc size. */
2280 /* Reloc swapping functions. */
2281 mips_ecoff_swap_reloc_in,
2282 mips_ecoff_swap_reloc_out,
2283 /* Backend reloc tweaking. */
2284 mips_adjust_reloc_in,
2285 mips_adjust_reloc_out,
2286 /* Relocate section contents while linking. */
2287 mips_relocate_section
2290 /* Looking up a reloc type is MIPS specific. */
2291 #define ecoff_bfd_reloc_type_lookup mips_bfd_reloc_type_lookup
2293 /* Getting relocated section contents is generic. */
2294 #define ecoff_bfd_get_relocated_section_contents \
2295 bfd_generic_get_relocated_section_contents
2297 /* Relaxing sections is MIPS specific. */
2298 #define ecoff_bfd_relax_section mips_relax_section
2300 bfd_target ecoff_little_vec =
2302 "ecoff-littlemips", /* name */
2303 bfd_target_ecoff_flavour,
2304 false, /* data byte order is little */
2305 false, /* header byte order is little */
2307 (HAS_RELOC | EXEC_P | /* object flags */
2308 HAS_LINENO | HAS_DEBUG |
2309 HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
2311 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* sect
2313 0, /* leading underscore */
2314 ' ', /* ar_pad_char */
2315 15, /* ar_max_namelen */
2316 4, /* minimum alignment power */
2317 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
2318 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
2319 bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
2320 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
2321 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
2322 bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
2324 {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
2325 ecoff_archive_p, _bfd_dummy_target},
2326 {bfd_false, ecoff_mkobject, /* bfd_set_format */
2327 _bfd_generic_mkarchive, bfd_false},
2328 {bfd_false, ecoff_write_object_contents, /* bfd_write_contents */
2329 _bfd_write_archive_contents, bfd_false},
2331 BFD_JUMP_TABLE_GENERIC (ecoff),
2332 BFD_JUMP_TABLE_COPY (ecoff),
2333 BFD_JUMP_TABLE_CORE (_bfd_nocore),
2334 BFD_JUMP_TABLE_ARCHIVE (ecoff),
2335 BFD_JUMP_TABLE_SYMBOLS (ecoff),
2336 BFD_JUMP_TABLE_RELOCS (ecoff),
2337 BFD_JUMP_TABLE_WRITE (ecoff),
2338 BFD_JUMP_TABLE_LINK (ecoff),
2339 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
2341 (PTR) &mips_ecoff_backend_data
2344 bfd_target ecoff_big_vec =
2346 "ecoff-bigmips", /* name */
2347 bfd_target_ecoff_flavour,
2348 true, /* data byte order is big */
2349 true, /* header byte order is big */
2351 (HAS_RELOC | EXEC_P | /* object flags */
2352 HAS_LINENO | HAS_DEBUG |
2353 HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
2355 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* sect flags */
2356 0, /* leading underscore */
2357 ' ', /* ar_pad_char */
2358 15, /* ar_max_namelen */
2359 4, /* minimum alignment power */
2360 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
2361 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
2362 bfd_getb16, bfd_getb_signed_16, bfd_putb16,
2363 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
2364 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
2365 bfd_getb16, bfd_getb_signed_16, bfd_putb16,
2366 {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
2367 ecoff_archive_p, _bfd_dummy_target},
2368 {bfd_false, ecoff_mkobject, /* bfd_set_format */
2369 _bfd_generic_mkarchive, bfd_false},
2370 {bfd_false, ecoff_write_object_contents, /* bfd_write_contents */
2371 _bfd_write_archive_contents, bfd_false},
2373 BFD_JUMP_TABLE_GENERIC (ecoff),
2374 BFD_JUMP_TABLE_COPY (ecoff),
2375 BFD_JUMP_TABLE_CORE (_bfd_nocore),
2376 BFD_JUMP_TABLE_ARCHIVE (ecoff),
2377 BFD_JUMP_TABLE_SYMBOLS (ecoff),
2378 BFD_JUMP_TABLE_RELOCS (ecoff),
2379 BFD_JUMP_TABLE_WRITE (ecoff),
2380 BFD_JUMP_TABLE_LINK (ecoff),
2381 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
2383 (PTR) &mips_ecoff_backend_data