1 /* BFD back-end for MIPS Extended-Coff files.
2 Copyright 1990, 1991, 1992 Free Software Foundation, Inc.
3 Original version by Per Bothner.
4 Full support 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. */
27 #include "aout/ranlib.h"
28 #include "coff/mips.h"
29 #include "coff/internal.h"
31 #include "coff/symconst.h"
32 #include "coff/ecoff-ext.h"
35 /* `Tdata' information kept for ECOFF files. */
37 #define ecoff_data(abfd) ((abfd)->tdata.ecoff_obj_data)
39 typedef struct ecoff_tdata
41 /* The reloc file position, set by
42 ecoff_compute_section_file_positions. */
43 file_ptr reloc_filepos
;
45 /* The symbol table file position, set by ecoff_mkobject_hook. */
48 /* The cached gp value. This is used when relocating. */
51 /* The register masks. When linking, all the masks found in the
52 input files are combined into the masks of the output file. */
53 unsigned long gprmask
;
54 unsigned long cprmask
[4];
56 /* The size of the unswapped ECOFF symbolic information. */
57 bfd_size_type raw_size
;
59 /* The unswapped ECOFF symbolic information. */
62 /* The swapped ECOFF symbolic header. */
65 /* Pointers to the unswapped symbolic information. */
67 struct dnr_ext
*external_dnr
;
68 struct pdr_ext
*external_pdr
;
69 struct sym_ext
*external_sym
;
70 struct opt_ext
*external_opt
;
71 union aux_ext
*external_aux
;
74 struct fdr_ext
*external_fdr
;
75 struct rfd_ext
*external_rfd
;
76 struct ext_ext
*external_ext
;
78 /* The swapped FDR information. */
81 /* The FDR index. This is set for an input BFD to a link so that
82 the external symbols can set their FDR index correctly. */
85 /* The canonical BFD symbols. */
86 struct ecoff_symbol_struct
*canonical_symbols
;
90 /* Each canonical asymbol really looks like this. */
92 typedef struct ecoff_symbol_struct
94 /* The actual symbol which the rest of BFD works with */
97 /* The fdr for this symbol. */
100 /* true if this is a local symbol rather than an external one. */
103 /* A pointer to the unswapped hidden information for this symbol */
106 struct sym_ext
*lnative
;
107 struct ext_ext
*enative
;
112 /* We take the address of the first element of a asymbol to ensure that the
113 macro is only ever applied to an asymbol. */
114 #define ecoffsymbol(asymbol) ((ecoff_symbol_type *) (&((asymbol)->the_bfd)))
116 /* This is a hack borrowed from coffcode.h; we need to save the index
117 of a symbol when we write it out so that can set the symbol index
118 correctly when we write out the relocs. */
119 #define ecoff_get_sym_index(symbol) ((unsigned long) (symbol)->udata)
120 #define ecoff_set_sym_index(symbol, idx) ((symbol)->udata = (PTR) (idx))
122 /* The page boundary used to align sections in the executable file. */
123 #define PAGE_SIZE 0x2000
125 /* MIPS ECOFF has COFF sections, but the debugging information is
126 stored in a completely different format. This files uses the some
127 of the swapping routines from coffswap.h, and some of the generic
128 COFF routines in coffgen.c, but, unlike the real COFF targets, does
129 not use coffcode.h itself. */
131 /* Get the generic COFF swapping routines, except for the reloc,
132 symbol, and lineno ones. Give them ecoff names. */
134 #define NO_COFF_RELOCS
135 #define NO_COFF_SYMBOLS
136 #define NO_COFF_LINENOS
137 #define coff_swap_filehdr_in ecoff_swap_filehdr_in
138 #define coff_swap_filehdr_out ecoff_swap_filehdr_out
139 #define coff_swap_aouthdr_in ecoff_swap_aouthdr_in
140 #define coff_swap_aouthdr_out ecoff_swap_aouthdr_out
141 #define coff_swap_scnhdr_in ecoff_swap_scnhdr_in
142 #define coff_swap_scnhdr_out ecoff_swap_scnhdr_out
143 #include "coffswap.h"
145 /* This stuff is somewhat copied from coffcode.h. */
147 static asection bfd_debug_section
= { "*DEBUG*" };
149 /* See whether the magic number matches. */
152 DEFUN(ecoff_bad_format_hook
, (abfd
, filehdr
),
156 struct internal_filehdr
*internal_f
= (struct internal_filehdr
*) filehdr
;
158 if (ECOFFBADMAG (*internal_f
))
164 /* This is a hook needed by SCO COFF, but we have nothing to do. */
167 DEFUN (ecoff_make_section_hook
, (abfd
, name
),
171 return (asection
*) NULL
;
174 /* Initialize a new section. */
177 DEFUN (ecoff_new_section_hook
, (abfd
, section
),
181 section
->alignment_power
= abfd
->xvec
->align_power_min
;
183 if (strcmp (section
->name
, _TEXT
) == 0)
184 section
->flags
|= SEC_CODE
| SEC_LOAD
| SEC_ALLOC
;
185 else if (strcmp (section
->name
, _DATA
) == 0
186 || strcmp (section
->name
, _SDATA
) == 0)
187 section
->flags
|= SEC_DATA
| SEC_LOAD
| SEC_ALLOC
;
188 else if (strcmp (section
->name
, _RDATA
) == 0
189 || strcmp (section
->name
, _LIT8
) == 0
190 || strcmp (section
->name
, _LIT4
) == 0)
191 section
->flags
|= SEC_DATA
| SEC_LOAD
| SEC_ALLOC
| SEC_READONLY
;
192 else if (strcmp (section
->name
, _BSS
) == 0
193 || strcmp (section
->name
, _SBSS
) == 0)
194 section
->flags
|= SEC_ALLOC
| SEC_IS_COMMON
;
196 /* Probably any other section name is SEC_NEVER_LOAD, but I'm
197 uncertain about .init on some systems and I don't know how shared
203 #define ecoff_set_alignment_hook \
204 ((void (*) PARAMS ((bfd *, asection *, PTR))) bfd_void)
207 DEFUN (ecoff_mkobject
, (abfd
),
210 abfd
->tdata
.ecoff_obj_data
= ((struct ecoff_tdata
*)
211 bfd_zalloc (abfd
, sizeof(ecoff_data_type
)));
212 if (abfd
->tdata
.ecoff_obj_data
== NULL
)
214 bfd_error
= no_memory
;
221 /* Create the COFF backend specific information. */
224 ecoff_mkobject_hook (abfd
, filehdr
, aouthdr
)
229 struct internal_filehdr
*internal_f
= (struct internal_filehdr
*) filehdr
;
230 struct internal_aouthdr
*internal_a
= (struct internal_aouthdr
*) aouthdr
;
231 ecoff_data_type
*ecoff
;
233 if (ecoff_mkobject (abfd
) == false)
236 ecoff
= ecoff_data (abfd
);
237 ecoff
->sym_filepos
= internal_f
->f_symptr
;
239 if (internal_a
!= (struct internal_aouthdr
*) NULL
)
243 ecoff
->gp
= internal_a
->gp_value
;
244 ecoff
->gprmask
= internal_a
->gprmask
;
245 for (i
= 0; i
< 3; i
++)
246 ecoff
->cprmask
[i
] = internal_a
->cprmask
[i
];
252 /* Determine the machine architecture and type. */
254 DEFUN (ecoff_set_arch_mach_hook
, (abfd
, filehdr
),
259 enum bfd_architecture arch
;
260 struct internal_filehdr
*internal_f
= (struct internal_filehdr
*) filehdr
;
263 switch (internal_f
->f_magic
) {
267 arch
= bfd_arch_mips
;
271 default: /* Unreadable input file type */
272 arch
= bfd_arch_obscure
;
276 bfd_default_set_arch_mach(abfd
, arch
, machine
);
280 /* Get the section s_flags to use for a section. */
283 DEFUN (sec_to_styp_flags
, (name
, flags
),
291 if (strcmp (name
, _TEXT
) == 0)
293 else if (strcmp (name
, _DATA
) == 0)
295 else if (strcmp (name
, _SDATA
) == 0)
297 else if (strcmp (name
, _RDATA
) == 0)
299 else if (strcmp (name
, _LIT8
) == 0)
301 else if (strcmp (name
, _LIT4
) == 0)
303 else if (strcmp (name
, _BSS
) == 0)
305 else if (strcmp (name
, _SBSS
) == 0)
307 else if (flags
& SEC_CODE
)
309 else if (flags
& SEC_DATA
)
311 else if (flags
& SEC_READONLY
)
313 else if (flags
& SEC_LOAD
)
318 if (flags
& SEC_NEVER_LOAD
)
324 /* Get the BFD flags to use for a section. */
327 DEFUN (styp_to_sec_flags
, (abfd
, hdr
),
331 struct internal_scnhdr
*internal_s
= (struct internal_scnhdr
*) hdr
;
332 long styp_flags
= internal_s
->s_flags
;
333 flagword sec_flags
=0;
335 if (styp_flags
& STYP_NOLOAD
)
336 sec_flags
|= SEC_NEVER_LOAD
;
338 /* For 386 COFF, at least, an unloadable text or data section is
339 actually a shared library section. */
340 if (styp_flags
& STYP_TEXT
)
342 if (sec_flags
& SEC_NEVER_LOAD
)
343 sec_flags
|= SEC_CODE
| SEC_SHARED_LIBRARY
;
345 sec_flags
|= SEC_CODE
| SEC_LOAD
| SEC_ALLOC
;
347 else if ((styp_flags
& STYP_DATA
)
348 || (styp_flags
& STYP_RDATA
)
349 || (styp_flags
& STYP_SDATA
))
351 if (sec_flags
& SEC_NEVER_LOAD
)
352 sec_flags
|= SEC_DATA
| SEC_SHARED_LIBRARY
;
354 sec_flags
|= SEC_DATA
| SEC_LOAD
| SEC_ALLOC
;
355 if (styp_flags
& STYP_RDATA
)
356 sec_flags
|= SEC_READONLY
;
358 else if ((styp_flags
& STYP_BSS
)
359 || (styp_flags
& STYP_SBSS
))
361 sec_flags
|= SEC_ALLOC
;
363 else if (styp_flags
& STYP_INFO
)
365 sec_flags
|= SEC_NEVER_LOAD
;
367 else if ((styp_flags
& STYP_LIT8
)
368 || (styp_flags
& STYP_LIT4
))
370 sec_flags
|= SEC_DATA
| SEC_LOAD
| SEC_ALLOC
| SEC_READONLY
;
374 sec_flags
|= SEC_ALLOC
| SEC_LOAD
;
380 /* Read in and swap the important symbolic information for an ECOFF
384 DEFUN (ecoff_slurp_symbolic_info
, (abfd
),
387 struct hdr_ext external_symhdr
;
388 HDRR
*internal_symhdr
;
389 bfd_size_type raw_base
;
390 bfd_size_type raw_size
;
392 struct fdr_ext
*fraw_src
;
393 struct fdr_ext
*fraw_end
;
396 /* Check whether we've already gotten it, and whether there's any to
398 if (ecoff_data (abfd
)->raw_syments
!= (PTR
) NULL
)
400 if (ecoff_data (abfd
)->sym_filepos
== 0)
402 bfd_get_symcount (abfd
) = 0;
406 /* At this point bfd_get_symcount (abfd) holds the number of symbols
407 as read from the file header, but on ECOFF this is always the
408 size of the symbolic information header. It would be cleaner to
409 handle this when we first read the file in coffgen.c. */
410 if (bfd_get_symcount (abfd
) != sizeof (external_symhdr
))
412 bfd_error
= bad_value
;
416 /* Read the symbolic information header. */
417 if (bfd_seek (abfd
, ecoff_data (abfd
)->sym_filepos
, SEEK_SET
) == -1
418 || (bfd_read ((PTR
) &external_symhdr
, sizeof (external_symhdr
), 1, abfd
)
419 != sizeof (external_symhdr
)))
421 bfd_error
= system_call_error
;
424 internal_symhdr
= &ecoff_data (abfd
)->symbolic_header
;
425 ecoff_swap_hdr_in (abfd
, &external_symhdr
, internal_symhdr
);
427 if (internal_symhdr
->magic
!= magicSym
)
429 bfd_error
= bad_value
;
433 /* Now we can get the correct number of symbols. */
434 bfd_get_symcount (abfd
) = (internal_symhdr
->isymMax
435 + internal_symhdr
->iextMax
);
437 /* Read all the symbolic information at once. */
438 raw_size
= (internal_symhdr
->cbLine
* sizeof (unsigned char)
439 + internal_symhdr
->idnMax
* sizeof (struct dnr_ext
)
440 + internal_symhdr
->ipdMax
* sizeof (struct pdr_ext
)
441 + internal_symhdr
->isymMax
* sizeof (struct sym_ext
)
442 + internal_symhdr
->ioptMax
* sizeof (struct opt_ext
)
443 + internal_symhdr
->iauxMax
* sizeof (union aux_ext
)
444 + internal_symhdr
->issMax
* sizeof (char)
445 + internal_symhdr
->issExtMax
* sizeof (char)
446 + internal_symhdr
->ifdMax
* sizeof (struct fdr_ext
)
447 + internal_symhdr
->crfd
* sizeof (struct rfd_ext
)
448 + internal_symhdr
->iextMax
* sizeof (struct ext_ext
));
451 ecoff_data (abfd
)->sym_filepos
= 0;
454 raw
= (PTR
) bfd_alloc (abfd
, raw_size
);
457 bfd_error
= no_memory
;
460 if (bfd_read (raw
, raw_size
, 1, abfd
) != raw_size
)
462 bfd_error
= system_call_error
;
463 bfd_release (abfd
, raw
);
467 ecoff_data (abfd
)->raw_size
= raw_size
;
468 ecoff_data (abfd
)->raw_syments
= raw
;
470 /* Get pointers for the numeric offsets in the HDRR structure. */
471 raw_base
= ecoff_data (abfd
)->sym_filepos
+ sizeof (struct hdr_ext
);
473 #define FIX(off1, off2, type) \
474 if (internal_symhdr->off1 == 0) \
475 ecoff_data (abfd)->off2 = (type *) NULL; \
477 ecoff_data (abfd)->off2 = (type *) ((char *) raw \
478 + internal_symhdr->off1 \
480 FIX (cbLineOffset
, line
, unsigned char);
481 FIX (cbDnOffset
, external_dnr
, struct dnr_ext
);
482 FIX (cbPdOffset
, external_pdr
, struct pdr_ext
);
483 FIX (cbSymOffset
, external_sym
, struct sym_ext
);
484 FIX (cbOptOffset
, external_opt
, struct opt_ext
);
485 FIX (cbAuxOffset
, external_aux
, union aux_ext
);
486 FIX (cbSsOffset
, ss
, char);
487 FIX (cbSsExtOffset
, ssext
, char);
488 FIX (cbFdOffset
, external_fdr
, struct fdr_ext
);
489 FIX (cbRfdOffset
, external_rfd
, struct rfd_ext
);
490 FIX (cbExtOffset
, external_ext
, struct ext_ext
);
493 /* I don't want to always swap all the data, because it will just
494 waste time and most programs will never look at it. The only
495 time the linker needs most of the debugging information swapped
496 is when linking big-endian and little-endian MIPS object files
497 together, which is not a common occurrence.
499 We need to look at the fdr to deal with a lot of information in
500 the symbols, so we swap them here. */
501 ecoff_data (abfd
)->fdr
= (struct fdr
*) bfd_alloc (abfd
,
502 (internal_symhdr
->ifdMax
*
503 sizeof (struct fdr
)));
504 if (ecoff_data (abfd
)->fdr
== NULL
)
506 bfd_error
= no_memory
;
509 fdr_ptr
= ecoff_data (abfd
)->fdr
;
510 fraw_src
= ecoff_data (abfd
)->external_fdr
;
511 fraw_end
= fraw_src
+ internal_symhdr
->ifdMax
;
512 for (; fraw_src
< fraw_end
; fraw_src
++, fdr_ptr
++)
513 ecoff_swap_fdr_in (abfd
, fraw_src
, fdr_ptr
);
518 /* ECOFF symbol table routines. The ECOFF symbol table is described
519 in gcc/mips-tfile.c. */
521 /* Create an empty symbol. */
524 DEFUN (ecoff_make_empty_symbol
, (abfd
),
527 ecoff_symbol_type
*new;
529 new = (ecoff_symbol_type
*) bfd_alloc (abfd
, sizeof (ecoff_symbol_type
));
530 if (new == (ecoff_symbol_type
*) NULL
)
532 bfd_error
= no_memory
;
533 return (asymbol
*) NULL
;
535 new->symbol
.section
= (asection
*) NULL
;
536 new->fdr
= (FDR
*) NULL
;
538 new->native
.lnative
= (struct sym_ext
*) NULL
;
539 new->symbol
.the_bfd
= abfd
;
543 /* Set the BFD flags and section for an ECOFF symbol. */
546 DEFUN (ecoff_set_symbol_info
, (abfd
, ecoff_sym
, asym
, ext
),
552 asym
->the_bfd
= abfd
;
553 asym
->value
= ecoff_sym
->value
;
554 asym
->section
= &bfd_debug_section
;
557 /* Most symbol types are just for debugging. */
558 switch (ecoff_sym
->st
)
568 asym
->flags
= BSF_DEBUGGING
;
573 asym
->flags
= BSF_EXPORT
| BSF_GLOBAL
;
575 asym
->flags
= BSF_LOCAL
;
576 switch (ecoff_sym
->sc
)
579 asym
->flags
= BSF_DEBUGGING
;
582 asym
->section
= bfd_make_section_old_way (abfd
, ".text");
583 asym
->value
-= asym
->section
->vma
;
586 asym
->section
= bfd_make_section_old_way (abfd
, ".data");
587 asym
->value
-= asym
->section
->vma
;
591 asym
->section
= &bfd_com_section
;
594 asym
->section
= bfd_make_section_old_way (abfd
, ".bss");
595 asym
->value
-= asym
->section
->vma
;
599 asym
->flags
= BSF_DEBUGGING
;
602 asym
->section
= &bfd_abs_section
;
605 asym
->section
= &bfd_und_section
;
613 asym
->flags
= BSF_DEBUGGING
;
616 asym
->section
= bfd_make_section_old_way (abfd
, ".sdata");
617 asym
->value
-= asym
->section
->vma
;
620 asym
->section
= bfd_make_section_old_way (abfd
, ".sbss");
621 asym
->value
-= asym
->section
->vma
;
624 asym
->section
= bfd_make_section_old_way (abfd
, ".rdata");
625 asym
->value
-= asym
->section
->vma
;
628 asym
->flags
= BSF_DEBUGGING
;
631 asym
->section
= &bfd_com_section
;
634 asym
->section
= bfd_make_section_old_way (abfd
, ".sbss");
635 asym
->value
-= asym
->section
->vma
;
639 asym
->flags
= BSF_DEBUGGING
;
642 asym
->section
= &bfd_und_section
;
645 asym
->section
= bfd_make_section_old_way (abfd
, ".init");
646 asym
->value
-= asym
->section
->vma
;
651 asym
->flags
= BSF_DEBUGGING
;
654 asym
->section
= bfd_make_section_old_way (abfd
, ".fini");
655 asym
->value
-= asym
->section
->vma
;
662 /* Read an ECOFF symbol table. */
665 DEFUN (ecoff_slurp_symbol_table
, (abfd
),
668 bfd_size_type internal_size
;
669 ecoff_symbol_type
*internal
;
670 ecoff_symbol_type
*internal_ptr
;
671 struct ext_ext
*eraw_src
;
672 struct ext_ext
*eraw_end
;
676 /* If we've already read in the symbol table, do nothing. */
677 if (ecoff_data (abfd
)->canonical_symbols
!= NULL
)
680 /* Get the symbolic information. */
681 if (ecoff_slurp_symbolic_info (abfd
) == false)
683 if (bfd_get_symcount (abfd
) == 0)
686 internal_size
= bfd_get_symcount (abfd
) * sizeof (ecoff_symbol_type
);
687 internal
= (ecoff_symbol_type
*) bfd_alloc (abfd
, internal_size
);
688 if (internal
== NULL
)
690 bfd_error
= no_memory
;
694 internal_ptr
= internal
;
695 eraw_src
= ecoff_data (abfd
)->external_ext
;
696 eraw_end
= eraw_src
+ ecoff_data (abfd
)->symbolic_header
.iextMax
;
697 for (; eraw_src
< eraw_end
; eraw_src
++, internal_ptr
++)
701 ecoff_swap_ext_in (abfd
, eraw_src
, &internal_esym
);
702 internal_ptr
->symbol
.name
= (ecoff_data (abfd
)->ssext
703 + internal_esym
.asym
.iss
);
704 ecoff_set_symbol_info (abfd
, &internal_esym
.asym
,
705 &internal_ptr
->symbol
, 1);
706 internal_ptr
->fdr
= ecoff_data (abfd
)->fdr
+ internal_esym
.ifd
;
707 internal_ptr
->local
= false;
708 internal_ptr
->native
.enative
= eraw_src
;
711 /* The local symbols must be accessed via the fdr's, because the
712 string and aux indices are relative to the fdr information. */
713 fdr_ptr
= ecoff_data (abfd
)->fdr
;
714 fdr_end
= fdr_ptr
+ ecoff_data (abfd
)->symbolic_header
.ifdMax
;
715 for (; fdr_ptr
< fdr_end
; fdr_ptr
++)
717 struct sym_ext
*lraw_src
;
718 struct sym_ext
*lraw_end
;
720 lraw_src
= ecoff_data (abfd
)->external_sym
+ fdr_ptr
->isymBase
;
721 lraw_end
= lraw_src
+ fdr_ptr
->csym
;
722 for (; lraw_src
< lraw_end
; lraw_src
++, internal_ptr
++)
726 ecoff_swap_sym_in (abfd
, lraw_src
, &internal_sym
);
727 internal_ptr
->symbol
.name
= (ecoff_data (abfd
)->ss
730 ecoff_set_symbol_info (abfd
, &internal_sym
,
731 &internal_ptr
->symbol
, 0);
732 internal_ptr
->fdr
= fdr_ptr
;
733 internal_ptr
->local
= true;
734 internal_ptr
->native
.lnative
= lraw_src
;
738 ecoff_data (abfd
)->canonical_symbols
= internal
;
744 DEFUN (ecoff_get_symtab_upper_bound
, (abfd
),
747 if (ecoff_slurp_symbolic_info (abfd
) == false
748 || bfd_get_symcount (abfd
) == 0)
751 return (bfd_get_symcount (abfd
) + 1) * (sizeof (ecoff_symbol_type
*));
755 DEFUN (ecoff_get_symtab
, (abfd
, alocation
),
759 unsigned int counter
= 0;
760 ecoff_symbol_type
*symbase
;
761 ecoff_symbol_type
**location
= (ecoff_symbol_type
**) alocation
;
763 if (ecoff_slurp_symbol_table (abfd
) == false
764 || bfd_get_symcount (abfd
) == 0)
767 symbase
= ecoff_data (abfd
)->canonical_symbols
;
768 while (counter
< bfd_get_symcount (abfd
))
770 *(location
++) = symbase
++;
773 *location
++ = (ecoff_symbol_type
*) NULL
;
774 return bfd_get_symcount (abfd
);
777 /* Turn ECOFF type information into a printable string.
778 emit_aggregate and type_to_string are from gcc/mips-tdump.c, with
779 swapping added and used_ptr removed. */
781 /* Write aggregate information to a string. */
784 DEFUN (emit_aggregate
, (abfd
, string
, rndx
, isym
, which
),
792 int indx
= rndx
->index
;
793 int sym_base
, ss_base
;
799 sym_base
= ecoff_data (abfd
)->fdr
[ifd
].isymBase
;
800 ss_base
= ecoff_data (abfd
)->fdr
[ifd
].issBase
;
802 if (indx
== indexNil
)
803 name
= "/* no name */";
809 ecoff_swap_sym_in (abfd
,
810 ecoff_data (abfd
)->external_sym
+ indx
,
812 name
= ecoff_data (abfd
)->ss
+ ss_base
+ sym
.iss
;
816 "%s %s { ifd = %d, index = %d }",
818 indx
+ ecoff_data (abfd
)->symbolic_header
.iextMax
);
821 /* Convert the type information to string format. */
824 DEFUN (type_to_string
, (abfd
, aux_ptr
, indx
, bigendian
),
826 union aux_ext
*aux_ptr AND
838 unsigned int basic_type
;
840 static char buffer1
[1024];
841 static char buffer2
[1024];
846 for (i
= 0; i
< 7; i
++)
848 qualifiers
[i
].low_bound
= 0;
849 qualifiers
[i
].high_bound
= 0;
850 qualifiers
[i
].stride
= 0;
853 if (AUX_GET_ISYM (bigendian
, &aux_ptr
[indx
]) == -1)
854 return "-1 (no type)";
855 ecoff_swap_tir_in (bigendian
, &aux_ptr
[indx
++].a_ti
, &u
.ti
);
857 basic_type
= u
.ti
.bt
;
858 qualifiers
[0].type
= u
.ti
.tq0
;
859 qualifiers
[1].type
= u
.ti
.tq1
;
860 qualifiers
[2].type
= u
.ti
.tq2
;
861 qualifiers
[3].type
= u
.ti
.tq3
;
862 qualifiers
[4].type
= u
.ti
.tq4
;
863 qualifiers
[5].type
= u
.ti
.tq5
;
864 qualifiers
[6].type
= tqNil
;
867 * Go get the basic type.
871 case btNil
: /* undefined */
875 case btAdr
: /* address - integer same size as pointer */
876 strcpy (p1
, "address");
879 case btChar
: /* character */
883 case btUChar
: /* unsigned character */
884 strcpy (p1
, "unsigned char");
887 case btShort
: /* short */
888 strcpy (p1
, "short");
891 case btUShort
: /* unsigned short */
892 strcpy (p1
, "unsigned short");
895 case btInt
: /* int */
899 case btUInt
: /* unsigned int */
900 strcpy (p1
, "unsigned int");
903 case btLong
: /* long */
907 case btULong
: /* unsigned long */
908 strcpy (p1
, "unsigned long");
911 case btFloat
: /* float (real) */
912 strcpy (p1
, "float");
915 case btDouble
: /* Double (real) */
916 strcpy (p1
, "double");
919 /* Structures add 1-2 aux words:
920 1st word is [ST_RFDESCAPE, offset] pointer to struct def;
921 2nd word is file index if 1st word rfd is ST_RFDESCAPE. */
923 case btStruct
: /* Structure (Record) */
924 ecoff_swap_rndx_in (bigendian
, &aux_ptr
[indx
].a_rndx
, &rndx
);
925 emit_aggregate (abfd
, p1
, &rndx
,
926 AUX_GET_ISYM (bigendian
, &aux_ptr
[indx
+1]),
928 indx
++; /* skip aux words */
931 /* Unions add 1-2 aux words:
932 1st word is [ST_RFDESCAPE, offset] pointer to union def;
933 2nd word is file index if 1st word rfd is ST_RFDESCAPE. */
935 case btUnion
: /* Union */
936 ecoff_swap_rndx_in (bigendian
, &aux_ptr
[indx
].a_rndx
, &rndx
);
937 emit_aggregate (abfd
, p1
, &rndx
,
938 AUX_GET_ISYM (bigendian
, &aux_ptr
[indx
+1]),
940 indx
++; /* skip aux words */
943 /* Enumerations add 1-2 aux words:
944 1st word is [ST_RFDESCAPE, offset] pointer to enum def;
945 2nd word is file index if 1st word rfd is ST_RFDESCAPE. */
947 case btEnum
: /* Enumeration */
948 ecoff_swap_rndx_in (bigendian
, &aux_ptr
[indx
].a_rndx
, &rndx
);
949 emit_aggregate (abfd
, p1
, &rndx
,
950 AUX_GET_ISYM (bigendian
, &aux_ptr
[indx
+1]),
952 indx
++; /* skip aux words */
955 case btTypedef
: /* defined via a typedef, isymRef points */
956 strcpy (p1
, "typedef");
959 case btRange
: /* subrange of int */
960 strcpy (p1
, "subrange");
963 case btSet
: /* pascal sets */
967 case btComplex
: /* fortran complex */
968 strcpy (p1
, "complex");
971 case btDComplex
: /* fortran double complex */
972 strcpy (p1
, "double complex");
975 case btIndirect
: /* forward or unnamed typedef */
976 strcpy (p1
, "forward/unamed typedef");
979 case btFixedDec
: /* Fixed Decimal */
980 strcpy (p1
, "fixed decimal");
983 case btFloatDec
: /* Float Decimal */
984 strcpy (p1
, "float decimal");
987 case btString
: /* Varying Length Character String */
988 strcpy (p1
, "string");
991 case btBit
: /* Aligned Bit String */
995 case btPicture
: /* Picture */
996 strcpy (p1
, "picture");
999 case btVoid
: /* Void */
1000 strcpy (p1
, "void");
1004 sprintf (p1
, "Unknown basic type %d", (int) basic_type
);
1008 p1
+= strlen (buffer1
);
1011 * If this is a bitfield, get the bitsize.
1017 bitsize
= AUX_GET_WIDTH (bigendian
, &aux_ptr
[indx
++]);
1018 sprintf (p1
, " : %d", bitsize
);
1019 p1
+= strlen (buffer1
);
1024 * Deal with any qualifiers.
1026 if (qualifiers
[0].type
!= tqNil
)
1029 * Snarf up any array bounds in the correct order. Arrays
1030 * store 5 successive words in the aux. table:
1031 * word 0 RNDXR to type of the bounds (ie, int)
1032 * word 1 Current file descriptor index
1034 * word 3 high bound (or -1 if [])
1035 * word 4 stride size in bits
1037 for (i
= 0; i
< 7; i
++)
1039 if (qualifiers
[i
].type
== tqArray
)
1041 qualifiers
[i
].low_bound
=
1042 AUX_GET_DNLOW (bigendian
, &aux_ptr
[indx
+2]);
1043 qualifiers
[i
].high_bound
=
1044 AUX_GET_DNHIGH (bigendian
, &aux_ptr
[indx
+3]);
1045 qualifiers
[i
].stride
=
1046 AUX_GET_WIDTH (bigendian
, &aux_ptr
[indx
+4]);
1052 * Now print out the qualifiers.
1054 for (i
= 0; i
< 6; i
++)
1056 switch (qualifiers
[i
].type
)
1063 strcpy (p2
, "ptr to ");
1064 p2
+= sizeof ("ptr to ")-1;
1068 strcpy (p2
, "volatile ");
1069 p2
+= sizeof ("volatile ")-1;
1073 strcpy (p2
, "far ");
1074 p2
+= sizeof ("far ")-1;
1078 strcpy (p2
, "func. ret. ");
1079 p2
+= sizeof ("func. ret. ");
1084 int first_array
= i
;
1087 /* Print array bounds reversed (ie, in the order the C
1088 programmer writes them). C is such a fun language.... */
1090 while (i
< 5 && qualifiers
[i
+1].type
== tqArray
)
1093 for (j
= i
; j
>= first_array
; j
--)
1095 strcpy (p2
, "array [");
1096 p2
+= sizeof ("array [")-1;
1097 if (qualifiers
[j
].low_bound
!= 0)
1099 "%ld:%ld {%ld bits}",
1100 (long) qualifiers
[j
].low_bound
,
1101 (long) qualifiers
[j
].high_bound
,
1102 (long) qualifiers
[j
].stride
);
1104 else if (qualifiers
[j
].high_bound
!= -1)
1107 (long) (qualifiers
[j
].high_bound
+ 1),
1108 (long) (qualifiers
[j
].stride
));
1111 sprintf (p2
, " {%ld bits}", (long) (qualifiers
[j
].stride
));
1114 strcpy (p2
, "] of ");
1115 p2
+= sizeof ("] of ")-1;
1123 strcpy (p2
, buffer1
);
1127 /* Print information about an ECOFF symbol. */
1130 DEFUN (ecoff_print_symbol
, (abfd
, filep
, symbol
, how
),
1134 bfd_print_symbol_type how
)
1136 FILE *file
= (FILE *)filep
;
1140 case bfd_print_symbol_name
:
1141 fprintf (file
, "%s", symbol
->name
);
1143 case bfd_print_symbol_more
:
1144 if (ecoffsymbol (symbol
)->local
)
1148 ecoff_swap_sym_in (abfd
, ecoffsymbol (symbol
)->native
.lnative
,
1150 fprintf (file
, "ecoff local %lx %x %x",
1151 (unsigned long) ecoff_sym
.value
,
1152 (unsigned) ecoff_sym
.st
, (unsigned) ecoff_sym
.sc
);
1158 ecoff_swap_ext_in (abfd
, ecoffsymbol (symbol
)->native
.enative
,
1160 fprintf (file
, "ecoff extern %lx %x %x",
1161 (unsigned long) ecoff_ext
.asym
.value
,
1162 (unsigned) ecoff_ext
.asym
.st
,
1163 (unsigned) ecoff_ext
.asym
.sc
);
1166 case bfd_print_symbol_nm
:
1168 CONST
char *section_name
= symbol
->section
->name
;
1170 bfd_print_symbol_vandf ((PTR
) file
, symbol
);
1171 fprintf (file
, " %-5s %s %s",
1173 ecoffsymbol (symbol
)->local
? "l" : "e",
1177 case bfd_print_symbol_all
:
1178 /* Print out the symbols in a reasonable way */
1187 if (ecoffsymbol (symbol
)->local
)
1189 ecoff_swap_sym_in (abfd
, ecoffsymbol (symbol
)->native
.lnative
,
1192 pos
= (ecoffsymbol (symbol
)->native
.lnative
1193 - ecoff_data (abfd
)->external_sym
1194 + ecoff_data (abfd
)->symbolic_header
.iextMax
);
1201 ecoff_swap_ext_in (abfd
, ecoffsymbol (symbol
)->native
.enative
,
1204 pos
= (ecoffsymbol (symbol
)->native
.enative
1205 - ecoff_data (abfd
)->external_ext
);
1206 jmptbl
= ecoff_ext
.jmptbl
? 'j' : ' ';
1207 cobol_main
= ecoff_ext
.cobol_main
? 'c' : ' ';
1208 weakext
= ecoff_ext
.weakext
? 'w' : ' ';
1211 fprintf (file
, "[%3d] %c %lx st %x sc %x indx %x %c%c%c %s",
1212 pos
, type
, (unsigned long) ecoff_ext
.asym
.value
,
1213 (unsigned) ecoff_ext
.asym
.st
,
1214 (unsigned) ecoff_ext
.asym
.sc
,
1215 (unsigned) ecoff_ext
.asym
.index
,
1216 jmptbl
, cobol_main
, weakext
,
1219 if (ecoffsymbol (symbol
)->fdr
!= NULL
1220 && ecoff_ext
.asym
.index
!= indexNil
)
1225 union aux_ext
*aux_base
;
1227 indx
= ecoff_ext
.asym
.index
;
1229 /* sym_base is used to map the fdr relative indices which
1230 appear in the file to the position number which we are
1232 sym_base
= ecoffsymbol (symbol
)->fdr
->isymBase
;
1233 if (ecoffsymbol (symbol
)->local
)
1234 sym_base
+= ecoff_data (abfd
)->symbolic_header
.iextMax
;
1236 /* aux_base is the start of the aux entries for this file;
1237 asym.index is an offset from this. */
1238 aux_base
= (ecoff_data (abfd
)->external_aux
1239 + ecoffsymbol (symbol
)->fdr
->iauxBase
);
1241 /* The aux entries are stored in host byte order; the
1242 order is indicated by a bit in the fdr. */
1243 bigendian
= ecoffsymbol (symbol
)->fdr
->fBigendian
;
1245 /* This switch is basically from gcc/mips-tdump.c */
1246 switch (ecoff_ext
.asym
.st
)
1254 printf ("\n End+1 symbol: %ld", indx
+ sym_base
);
1258 if (ecoff_ext
.asym
.sc
== scText
1259 || ecoff_ext
.asym
.sc
== scInfo
)
1260 printf ("\n First symbol: %ld", indx
+ sym_base
);
1262 printf ("\n First symbol: %ld",
1263 (AUX_GET_ISYM (bigendian
,
1264 &aux_base
[ecoff_ext
.asym
.index
])
1270 if (MIPS_IS_STAB (&ecoff_ext
.asym
))
1272 else if (ecoffsymbol (symbol
)->local
)
1273 printf ("\n End+1 symbol: %-7ld Type: %s",
1274 (AUX_GET_ISYM (bigendian
,
1275 &aux_base
[ecoff_ext
.asym
.index
])
1277 type_to_string (abfd
, aux_base
, indx
+ 1,
1280 printf ("\n Local symbol: %d",
1283 + ecoff_data (abfd
)->symbolic_header
.iextMax
));
1287 if (!MIPS_IS_STAB (&ecoff_ext
.asym
))
1288 printf ("\n Type: %s",
1289 type_to_string (abfd
, aux_base
, indx
, bigendian
));
1298 /* Reloc handling. MIPS ECOFF relocs are packed into 8 bytes in
1299 external form. They use a bit which indicates whether the symbol
1302 /* Swap a reloc in. */
1305 DEFUN (ecoff_swap_reloc_in
, (abfd
, ext
, intern
),
1308 struct internal_reloc
*intern
)
1310 intern
->r_vaddr
= bfd_h_get_32 (abfd
, (bfd_byte
*) ext
->r_vaddr
);
1311 if (abfd
->xvec
->header_byteorder_big_p
!= false)
1313 intern
->r_symndx
= (((int) ext
->r_bits
[0]
1314 << RELOC_BITS0_SYMNDX_SH_LEFT_BIG
)
1315 | ((int) ext
->r_bits
[1]
1316 << RELOC_BITS1_SYMNDX_SH_LEFT_BIG
)
1317 | ((int) ext
->r_bits
[2]
1318 << RELOC_BITS2_SYMNDX_SH_LEFT_BIG
));
1319 intern
->r_type
= ((ext
->r_bits
[3] & RELOC_BITS3_TYPE_BIG
)
1320 >> RELOC_BITS3_TYPE_SH_BIG
);
1321 intern
->r_extern
= (ext
->r_bits
[3] & RELOC_BITS3_EXTERN_BIG
) != 0;
1325 intern
->r_symndx
= (((int) ext
->r_bits
[0]
1326 << RELOC_BITS0_SYMNDX_SH_LEFT_LITTLE
)
1327 | ((int) ext
->r_bits
[1]
1328 << RELOC_BITS1_SYMNDX_SH_LEFT_LITTLE
)
1329 | ((int) ext
->r_bits
[2]
1330 << RELOC_BITS2_SYMNDX_SH_LEFT_LITTLE
));
1331 intern
->r_type
= ((ext
->r_bits
[3] & RELOC_BITS3_TYPE_LITTLE
)
1332 >> RELOC_BITS3_TYPE_SH_LITTLE
);
1333 intern
->r_extern
= (ext
->r_bits
[3] & RELOC_BITS3_EXTERN_LITTLE
) != 0;
1337 /* Swap a reloc out. */
1340 DEFUN (ecoff_swap_reloc_out
, (abfd
, src
, dst
),
1345 struct internal_reloc
*intern
= (struct internal_reloc
*) src
;
1346 RELOC
*ext
= (RELOC
*) dst
;
1348 bfd_h_put_32 (abfd
, intern
->r_vaddr
, (bfd_byte
*) ext
->r_vaddr
);
1349 if (abfd
->xvec
->header_byteorder_big_p
!= false)
1351 ext
->r_bits
[0] = intern
->r_symndx
>> RELOC_BITS0_SYMNDX_SH_LEFT_BIG
;
1352 ext
->r_bits
[1] = intern
->r_symndx
>> RELOC_BITS1_SYMNDX_SH_LEFT_BIG
;
1353 ext
->r_bits
[2] = intern
->r_symndx
>> RELOC_BITS2_SYMNDX_SH_LEFT_BIG
;
1354 ext
->r_bits
[3] = (((intern
->r_type
<< RELOC_BITS3_TYPE_SH_BIG
)
1355 & RELOC_BITS3_TYPE_BIG
)
1356 | (intern
->r_extern
? RELOC_BITS3_EXTERN_BIG
: 0));
1360 ext
->r_bits
[0] = intern
->r_symndx
>> RELOC_BITS0_SYMNDX_SH_LEFT_LITTLE
;
1361 ext
->r_bits
[1] = intern
->r_symndx
>> RELOC_BITS1_SYMNDX_SH_LEFT_LITTLE
;
1362 ext
->r_bits
[2] = intern
->r_symndx
>> RELOC_BITS2_SYMNDX_SH_LEFT_LITTLE
;
1363 ext
->r_bits
[3] = (((intern
->r_type
<< RELOC_BITS3_TYPE_SH_LITTLE
)
1364 & RELOC_BITS3_TYPE_LITTLE
)
1365 | (intern
->r_extern
? RELOC_BITS3_EXTERN_LITTLE
: 0));
1371 /* Do a REFHI relocation. The next reloc must be the corresponding
1372 REFLO. This has to be done in a function so that carry is handled
1375 static bfd_reloc_status_type
1376 DEFUN (ecoff_refhi_reloc
, (abfd
,
1383 arelent
*reloc_entry AND
1386 asection
*input_section AND
1389 bfd_reloc_status_type ret
;
1394 unsigned long vallo
;
1397 if (symbol
->section
== &bfd_und_section
1398 && output_bfd
== (bfd
*) NULL
)
1399 ret
= bfd_reloc_undefined
;
1401 rello
= reloc_entry
+ 1;
1402 BFD_ASSERT (rello
->howto
->type
== ECOFF_R_REFLO
1403 && *rello
->sym_ptr_ptr
== *reloc_entry
->sym_ptr_ptr
);
1405 if (bfd_is_com_section (symbol
->section
))
1408 relocation
= symbol
->value
;
1410 if (output_bfd
== (bfd
*) NULL
)
1412 relocation
+= symbol
->section
->output_section
->vma
;
1413 relocation
+= symbol
->section
->output_offset
;
1416 relocation
+= reloc_entry
->addend
;
1418 if (reloc_entry
->address
> input_section
->_cooked_size
)
1419 return bfd_reloc_outofrange
;
1421 insn
= bfd_get_32 (abfd
, (bfd_byte
*) data
+ reloc_entry
->address
);
1422 vallo
= bfd_get_32 (abfd
, (bfd_byte
*) data
+ rello
->address
) & 0xffff;
1423 val
= ((insn
& 0xffff) << 16) + vallo
;
1426 /* The low order 16 bits are always treated as a signed value.
1427 Therefore, a negative value in the low order bits requires an
1428 adjustment in the high order bits. We need to make this
1429 adjustment in two ways: once for the bits we took from the data,
1430 and once for the bits we are putting back in to the data. */
1431 if ((vallo
& 0x8000) != 0)
1433 if ((val
& 0x8000) != 0)
1436 insn
= (insn
&~ 0xffff) | ((val
>> 16) & 0xffff);
1437 bfd_put_32 (abfd
, insn
, (bfd_byte
*) data
+ reloc_entry
->address
);
1439 if (output_bfd
!= (bfd
*) NULL
)
1440 reloc_entry
->address
+= input_section
->output_offset
;
1445 /* Do a GPREL relocation. This is a 16 bit value which must become
1446 the offset from the gp register. */
1448 static bfd_reloc_status_type
1449 DEFUN (ecoff_gprel_reloc
, (abfd
,
1456 arelent
*reloc_entry AND
1459 asection
*input_section AND
1462 boolean relocateable
;
1467 if (output_bfd
!= (bfd
*) NULL
)
1468 relocateable
= true;
1471 relocateable
= false;
1472 output_bfd
= symbol
->section
->output_section
->owner
;
1475 if (symbol
->section
== &bfd_und_section
1476 && relocateable
== false)
1477 return bfd_reloc_undefined
;
1479 /* We have to figure out the gp value, so that we can adjust the
1480 symbol value correctly. We look up the symbol _gp in the output
1481 BFD. If we can't find it, we're stuck. We cache it in the ECOFF
1483 if (ecoff_data (output_bfd
)->gp
== 0)
1487 /* Make up a value. */
1488 ecoff_data (output_bfd
)->gp
=
1489 symbol
->section
->output_section
->vma
+ 0x4000;
1497 count
= bfd_get_symcount (output_bfd
);
1498 sym
= bfd_get_outsymbols (output_bfd
);
1500 /* We should do something more friendly here, but we don't
1501 have a good reloc status to return. */
1502 if (sym
== (asymbol
**) NULL
)
1505 for (i
= 0; i
< count
; i
++, sym
++)
1507 register CONST
char *name
;
1509 name
= bfd_asymbol_name (*sym
);
1510 if (*name
== '_' && strcmp (name
, "_gp") == 0)
1512 ecoff_data (output_bfd
)->gp
= bfd_asymbol_value (*sym
);
1517 /* We should do something more friendly here, but we don't have
1518 a good reloc status to return. */
1524 if (bfd_is_com_section (symbol
->section
))
1527 relocation
= symbol
->value
;
1529 relocation
+= symbol
->section
->output_section
->vma
;
1530 relocation
+= symbol
->section
->output_offset
;
1532 if (reloc_entry
->address
> input_section
->_cooked_size
)
1533 return bfd_reloc_outofrange
;
1535 insn
= bfd_get_32 (abfd
, (bfd_byte
*) data
+ reloc_entry
->address
);
1537 /* Set val to the offset into the section (if we are relocating
1538 against an external symbol, insn & 0xffff will be zero and so
1539 will reloc_entry->addend). */
1540 val
= ((insn
& 0xffff) + reloc_entry
->addend
) & 0xffff;
1544 /* Adjust val for the final section location and GP value. */
1545 val
+= (relocation
- ecoff_data (output_bfd
)->gp
);
1547 insn
= (insn
&~ 0xffff) | (val
& 0xffff);
1548 bfd_put_32 (abfd
, insn
, (bfd_byte
*) data
+ reloc_entry
->address
);
1551 reloc_entry
->address
+= input_section
->output_offset
;
1553 /* Make sure it fit in 16 bits. */
1554 if (val
>= 0x8000 && val
< 0xffff8000)
1555 return bfd_reloc_outofrange
;
1557 return bfd_reloc_ok
;
1560 /* How to process the various relocs types. */
1562 static reloc_howto_type ecoff_howto_table
[] =
1564 /* Reloc type 0 is ignored. The reloc reading code ensures that
1565 this is a reference to the .abs section, which will cause
1566 bfd_perform_relocation to do nothing. */
1567 HOWTO (ECOFF_R_IGNORE
, /* type */
1569 0, /* size (0 = byte, 1 = short, 2 = long) */
1570 8, /* bitsize (obsolete) */
1571 false, /* pc_relative */
1573 false, /* absolute (obsolete) */
1574 false, /* complain_on_overflow */
1575 0, /* special_function */
1576 "IGNORE", /* name */
1577 false, /* partial_inplace */
1580 false), /* pcrel_offset */
1582 /* A 16 bit reference to a symbol, normally from a data section. */
1583 HOWTO (ECOFF_R_REFHALF
, /* type */
1585 1, /* size (0 = byte, 1 = short, 2 = long) */
1586 16, /* bitsize (obsolete) */
1587 false, /* pc_relative */
1589 false, /* absolute (obsolete) */
1590 true, /* complain_on_overflow */
1591 0, /* special_function */
1592 "REFHALF", /* name */
1593 true, /* partial_inplace */
1594 0xffff, /* src_mask */
1595 0xffff, /* dst_mask */
1596 false), /* pcrel_offset */
1598 /* A 32 bit reference to a symbol, normally from a data section. */
1599 HOWTO (ECOFF_R_REFWORD
, /* type */
1601 2, /* size (0 = byte, 1 = short, 2 = long) */
1602 32, /* bitsize (obsolete) */
1603 false, /* pc_relative */
1605 false, /* absolute (obsolete) */
1606 true, /* complain_on_overflow */
1607 0, /* special_function */
1608 "REFWORD", /* name */
1609 true, /* partial_inplace */
1610 0xffffffff, /* src_mask */
1611 0xffffffff, /* dst_mask */
1612 false), /* pcrel_offset */
1614 /* A 26 bit absolute jump address. */
1615 HOWTO (ECOFF_R_JMPADDR
, /* type */
1617 2, /* size (0 = byte, 1 = short, 2 = long) */
1618 32, /* bitsize (obsolete) */
1619 false, /* pc_relative */
1621 false, /* absolute (obsolete) */
1622 true, /* complain_on_overflow */
1623 0, /* special_function */
1624 "JMPADDR", /* name */
1625 true, /* partial_inplace */
1626 0x3ffffff, /* src_mask */
1627 0x3ffffff, /* dst_mask */
1628 false), /* pcrel_offset */
1630 /* The high 16 bits of a symbol value. Handled by the function
1631 ecoff_refhi_reloc. */
1632 HOWTO (ECOFF_R_REFHI
, /* type */
1633 16, /* rightshift */
1634 2, /* size (0 = byte, 1 = short, 2 = long) */
1635 32, /* bitsize (obsolete) */
1636 false, /* pc_relative */
1638 false, /* absolute (obsolete) */
1639 true, /* complain_on_overflow */
1640 ecoff_refhi_reloc
, /* special_function */
1642 true, /* partial_inplace */
1643 0xffff, /* src_mask */
1644 0xffff, /* dst_mask */
1645 false), /* pcrel_offset */
1647 /* The low 16 bits of a symbol value. */
1648 HOWTO (ECOFF_R_REFLO
, /* type */
1650 2, /* size (0 = byte, 1 = short, 2 = long) */
1651 32, /* bitsize (obsolete) */
1652 false, /* pc_relative */
1654 false, /* absolute (obsolete) */
1655 true, /* complain_on_overflow */
1656 0, /* special_function */
1658 true, /* partial_inplace */
1659 0xffff, /* src_mask */
1660 0xffff, /* dst_mask */
1661 false), /* pcrel_offset */
1663 /* A reference to an offset from the gp register. Handled by the
1664 function ecoff_gprel_reloc. */
1665 HOWTO (ECOFF_R_GPREL
, /* type */
1667 2, /* size (0 = byte, 1 = short, 2 = long) */
1668 32, /* bitsize (obsolete) */
1669 false, /* pc_relative */
1671 false, /* absolute (obsolete) */
1672 true, /* complain_on_overflow */
1673 ecoff_gprel_reloc
, /* special_function */
1675 true, /* partial_inplace */
1676 0xffff, /* src_mask */
1677 0xffff, /* dst_mask */
1678 false), /* pcrel_offset */
1680 /* A reference to a literal using an offset from the gp register.
1681 Handled by the function ecoff_gprel_reloc. */
1682 HOWTO (ECOFF_R_LITERAL
, /* type */
1684 2, /* size (0 = byte, 1 = short, 2 = long) */
1685 32, /* bitsize (obsolete) */
1686 false, /* pc_relative */
1688 false, /* absolute (obsolete) */
1689 true, /* complain_on_overflow */
1690 ecoff_gprel_reloc
, /* special_function */
1691 "LITERAL", /* name */
1692 true, /* partial_inplace */
1693 0xffff, /* src_mask */
1694 0xffff, /* dst_mask */
1695 false) /* pcrel_offset */
1698 /* Read in the relocs for a section. */
1701 DEFUN (ecoff_slurp_reloc_table
, (abfd
, section
, symbols
),
1703 asection
*section AND
1706 RELOC
*external_relocs
;
1707 arelent
*internal_relocs
;
1711 if (section
->relocation
!= (arelent
*) NULL
1712 || section
->reloc_count
== 0
1713 || (section
->flags
& SEC_CONSTRUCTOR
) != 0)
1716 if (ecoff_slurp_symbol_table (abfd
) == false)
1719 internal_relocs
= (arelent
*) bfd_alloc (abfd
,
1721 * section
->reloc_count
));
1722 external_relocs
= (RELOC
*) bfd_alloc (abfd
, RELSZ
* section
->reloc_count
);
1723 if (internal_relocs
== (arelent
*) NULL
1724 || external_relocs
== (RELOC
*) NULL
)
1726 bfd_error
= no_memory
;
1729 if (bfd_seek (abfd
, section
->rel_filepos
, SEEK_SET
) != 0)
1731 if (bfd_read (external_relocs
, 1, RELSZ
* section
->reloc_count
, abfd
)
1732 != RELSZ
* section
->reloc_count
)
1734 bfd_error
= system_call_error
;
1738 for (i
= 0, rptr
= internal_relocs
; i
< section
->reloc_count
; i
++, rptr
++)
1740 struct internal_reloc intern
;
1742 ecoff_swap_reloc_in (abfd
, external_relocs
+ i
, &intern
);
1744 if (intern
.r_type
> ECOFF_R_LITERAL
)
1747 if (intern
.r_extern
)
1749 /* r_symndx is an index into the external symbols. */
1750 BFD_ASSERT (intern
.r_symndx
>= 0
1752 < ecoff_data (abfd
)->symbolic_header
.iextMax
));
1753 rptr
->sym_ptr_ptr
= symbols
+ intern
.r_symndx
;
1758 CONST
char *sec_name
;
1761 /* r_symndx is a section key. */
1762 switch (intern
.r_symndx
)
1764 case RELOC_SECTION_TEXT
: sec_name
= ".text"; break;
1765 case RELOC_SECTION_RDATA
: sec_name
= ".rdata"; break;
1766 case RELOC_SECTION_DATA
: sec_name
= ".data"; break;
1767 case RELOC_SECTION_SDATA
: sec_name
= ".sdata"; break;
1768 case RELOC_SECTION_SBSS
: sec_name
= ".sbss"; break;
1769 case RELOC_SECTION_BSS
: sec_name
= ".bss"; break;
1770 case RELOC_SECTION_INIT
: sec_name
= ".init"; break;
1771 case RELOC_SECTION_LIT8
: sec_name
= ".lit8"; break;
1772 case RELOC_SECTION_LIT4
: sec_name
= ".lit4"; break;
1776 sec
= bfd_get_section_by_name (abfd
, sec_name
);
1777 if (sec
== (asection
*) NULL
)
1779 rptr
->sym_ptr_ptr
= sec
->symbol_ptr_ptr
;
1781 rptr
->addend
= - bfd_get_section_vma (abfd
, sec
);
1782 if (intern
.r_type
== ECOFF_R_GPREL
1783 || intern
.r_type
== ECOFF_R_LITERAL
)
1784 rptr
->addend
+= ecoff_data (abfd
)->gp
;
1787 rptr
->address
= intern
.r_vaddr
- bfd_get_section_vma (abfd
, section
);
1788 rptr
->howto
= &ecoff_howto_table
[intern
.r_type
];
1790 /* If the type is ECOFF_R_IGNORE, make sure this is a reference
1791 to the absolute section so that the reloc is ignored. */
1792 if (intern
.r_type
== ECOFF_R_IGNORE
)
1793 rptr
->sym_ptr_ptr
= bfd_abs_section
.symbol_ptr_ptr
;
1796 bfd_release (abfd
, external_relocs
);
1798 section
->relocation
= internal_relocs
;
1803 /* Get a canonical list of relocs. */
1806 DEFUN (ecoff_canonicalize_reloc
, (abfd
, section
, relptr
, symbols
),
1808 asection
*section AND
1809 arelent
**relptr AND
1814 if (section
->flags
& SEC_CONSTRUCTOR
)
1816 arelent_chain
*chain
;
1818 /* This section has relocs made up by us, not the file, so take
1819 them out of their chain and place them into the data area
1821 for (count
= 0, chain
= section
->constructor_chain
;
1822 count
< section
->reloc_count
;
1823 count
++, chain
= chain
->next
)
1824 *relptr
++ = &chain
->relent
;
1830 if (ecoff_slurp_reloc_table (abfd
, section
, symbols
) == false)
1833 tblptr
= section
->relocation
;
1834 if (tblptr
== (arelent
*) NULL
)
1837 for (count
= 0; count
< section
->reloc_count
; count
++)
1838 *relptr
++ = tblptr
++;
1841 *relptr
= (arelent
*) NULL
;
1843 return section
->reloc_count
;
1846 /* Provided a BFD, a section and an offset into the section, calculate
1847 and return the name of the source file and the line nearest to the
1851 DEFUN (ecoff_find_nearest_line
, (abfd
,
1859 asection
*section AND
1860 asymbol
**ignore_symbols AND
1862 CONST
char **filename_ptr AND
1863 CONST
char **functionname_ptr AND
1864 unsigned int *retline_ptr
)
1870 struct pdr_ext
*pdr_ptr
;
1871 struct pdr_ext
*pdr_end
;
1873 unsigned char *line_ptr
;
1874 unsigned char *line_end
;
1878 /* If we're not in the .text section, we don't have any line
1880 if (strcmp (section
->name
, _TEXT
) != 0)
1883 /* Make sure we have the FDR's. */
1884 if (ecoff_slurp_symbolic_info (abfd
) == false
1885 || bfd_get_symcount (abfd
) == 0)
1888 /* Each file descriptor (FDR) has a memory address. Here we track
1889 down which FDR we want. The FDR's are stored in increasing
1890 memory order. If speed is ever important, this can become a
1891 binary search. We must ignore FDR's with no PDR entries; they
1892 will have the adr of the FDR before or after them. */
1893 fdr_start
= ecoff_data (abfd
)->fdr
;
1894 fdr_end
= fdr_start
+ ecoff_data (abfd
)->symbolic_header
.ifdMax
;
1895 fdr_hold
= (FDR
*) NULL
;
1896 for (fdr_ptr
= fdr_start
; fdr_ptr
< fdr_end
; fdr_ptr
++)
1898 if (offset
< fdr_ptr
->adr
)
1900 if (fdr_ptr
->cpd
> 0)
1903 if (fdr_hold
== (FDR
*) NULL
)
1907 /* Each FDR has a list of procedure descriptors (PDR). PDR's also
1908 have an address, which is relative to the FDR address, and are
1909 also stored in increasing memory order. */
1910 offset
-= fdr_ptr
->adr
;
1911 pdr_ptr
= ecoff_data (abfd
)->external_pdr
+ fdr_ptr
->ipdFirst
;
1912 pdr_end
= pdr_ptr
+ fdr_ptr
->cpd
;
1913 ecoff_swap_pdr_in (abfd
, pdr_ptr
, &pdr
);
1914 if (offset
< pdr
.adr
)
1916 for (pdr_ptr
++; pdr_ptr
< pdr_end
; pdr_ptr
++)
1918 ecoff_swap_pdr_in (abfd
, pdr_ptr
, &pdr
);
1919 if (offset
< pdr
.adr
)
1923 /* Now we can look for the actual line number. The line numbers are
1924 stored in a very funky format, which I won't try to describe.
1925 Note that right here pdr_ptr and pdr hold the PDR *after* the one
1926 we want; we need this to compute line_end. */
1927 line_end
= ecoff_data (abfd
)->line
;
1928 if (pdr_ptr
== pdr_end
)
1929 line_end
+= fdr_ptr
->cbLineOffset
+ fdr_ptr
->cbLine
;
1931 line_end
+= fdr_ptr
->cbLineOffset
+ pdr
.cbLineOffset
;
1933 /* Now change pdr and pdr_ptr to the one we want. */
1935 ecoff_swap_pdr_in (abfd
, pdr_ptr
, &pdr
);
1939 line_ptr
= (ecoff_data (abfd
)->line
1940 + fdr_ptr
->cbLineOffset
1941 + pdr
.cbLineOffset
);
1942 while (line_ptr
< line_end
)
1947 delta
= *line_ptr
>> 4;
1950 count
= (*line_ptr
& 0xf) + 1;
1954 delta
= (((line_ptr
[0]) & 0xff) << 8) + ((line_ptr
[1]) & 0xff);
1955 if (delta
>= 0x8000)
1960 if (offset
< count
* 4)
1962 offset
-= count
* 4;
1965 /* If offset is too large, this line is not interesting. */
1969 *filename_ptr
= ecoff_data (abfd
)->ss
+ fdr_ptr
->issBase
+ fdr_ptr
->rss
;
1970 ecoff_swap_sym_in (abfd
,
1971 (ecoff_data (abfd
)->external_sym
1975 *functionname_ptr
= ecoff_data (abfd
)->ss
+ proc_sym
.iss
;
1976 *retline_ptr
= lineno
;
1980 /* We can't use the generic linking routines for ECOFF, because we
1981 have to handle all the debugging information. The generic link
1982 routine just works out the section contents and attaches a list of
1985 We link by looping over all the seclets. We make two passes. On
1986 the first we set the actual section contents and determine the size
1987 of the debugging information. On the second we accumulate the
1988 debugging information and write it out.
1990 This currently always accumulates the debugging information, which
1991 is incorrect, because it ignores the -s and -S options of the
1992 linker. The linker needs to be modified to give us that
1993 information in a more useful format (currently it just provides a
1994 list of symbols which should appear in the output file). */
1996 /* Clear the output_has_begun flag for all the input BFD's. We use it
1997 to avoid linking in the debugging information for a BFD more than
2001 DEFUN (ecoff_clear_output_flags
, (abfd
),
2004 register asection
*o
;
2005 register bfd_seclet_type
*p
;
2007 for (o
= abfd
->sections
; o
!= (asection
*) NULL
; o
= o
->next
)
2008 for (p
= o
->seclets_head
;
2009 p
!= (bfd_seclet_type
*) NULL
;
2011 if (p
->type
== bfd_indirect_seclet
)
2012 p
->u
.indirect
.section
->owner
->output_has_begun
= false;
2015 /* Handle an indirect seclet on the first pass. Set the contents of
2016 the output section, and accumulate the debugging information if
2020 DEFUN (ecoff_rel
, (output_bfd
, seclet
, output_section
, data
, relocateable
),
2022 bfd_seclet_type
*seclet AND
2023 asection
*output_section AND
2025 boolean relocateable
)
2028 HDRR
*output_symhdr
;
2030 ecoff_symbol_type
*sym_ptr
;
2031 ecoff_symbol_type
*sym_end
;
2033 if ((output_section
->flags
& SEC_HAS_CONTENTS
)
2034 && !(output_section
->flags
& SEC_NEVER_LOAD
)
2035 && (output_section
->flags
& SEC_LOAD
)
2038 data
= (PTR
) bfd_get_relocated_section_contents (output_bfd
,
2042 if (bfd_set_section_contents (output_bfd
,
2053 input_bfd
= seclet
->u
.indirect
.section
->owner
;
2055 /* We want to figure out how much space will be required to
2056 incorporate all the debugging information from input_bfd. We use
2057 the output_has_begun field to avoid adding it in more than once.
2058 The actual incorporation is done in the second pass, in
2059 ecoff_get_debug. The code has to parallel that code in its
2060 manipulations of output_symhdr. */
2062 if (input_bfd
->output_has_begun
)
2064 input_bfd
->output_has_begun
= true;
2066 output_symhdr
= &ecoff_data (output_bfd
)->symbolic_header
;
2068 if (input_bfd
->xvec
->flavour
!= bfd_target_ecoff_flavour
)
2074 /* We just accumulate local symbols from a non-ECOFF BFD. The
2075 external symbols are handled separately. */
2077 symbols
= (asymbol
**) bfd_alloc (output_bfd
,
2078 get_symtab_upper_bound (input_bfd
));
2079 if (symbols
== (asymbol
**) NULL
)
2081 bfd_error
= no_memory
;
2084 sym_end
= symbols
+ bfd_canonicalize_symtab (input_bfd
, symbols
);
2086 for (sym_ptr
= symbols
; sym_ptr
< sym_end
; sym_ptr
++)
2090 len
= strlen ((*sym_ptr
)->name
);
2091 if (((*sym_ptr
)->flags
& BSF_EXPORT
) == 0)
2093 ++output_symhdr
->isymMax
;
2094 output_symhdr
->issMax
+= len
+ 1;
2098 bfd_release (output_bfd
, (PTR
) symbols
);
2100 ++output_symhdr
->ifdMax
;
2105 /* We simply add in the information from another ECOFF BFD. First
2106 we make sure we have the symbolic information. */
2107 if (ecoff_slurp_symbol_table (input_bfd
) == false)
2109 if (bfd_get_symcount (input_bfd
) == 0)
2112 input_symhdr
= &ecoff_data (input_bfd
)->symbolic_header
;
2114 /* Figure out how much information we are going to be putting in.
2115 The external symbols are handled separately. */
2116 output_symhdr
->ilineMax
+= input_symhdr
->ilineMax
;
2117 output_symhdr
->cbLine
+= input_symhdr
->cbLine
;
2118 output_symhdr
->idnMax
+= input_symhdr
->idnMax
;
2119 output_symhdr
->ipdMax
+= input_symhdr
->ipdMax
;
2120 output_symhdr
->isymMax
+= input_symhdr
->isymMax
;
2121 output_symhdr
->ioptMax
+= input_symhdr
->ioptMax
;
2122 output_symhdr
->iauxMax
+= input_symhdr
->iauxMax
;
2123 output_symhdr
->issMax
+= input_symhdr
->issMax
;
2124 output_symhdr
->ifdMax
+= input_symhdr
->ifdMax
;
2126 /* The RFD's are special, since we create them if needed. */
2127 if (input_symhdr
->crfd
> 0)
2128 output_symhdr
->crfd
+= input_symhdr
->crfd
;
2130 output_symhdr
->crfd
+= input_symhdr
->ifdMax
;
2135 /* Handle an arbitrary seclet on the first pass. */
2138 DEFUN (ecoff_dump_seclet
, (abfd
, seclet
, section
, data
, relocateable
),
2140 bfd_seclet_type
*seclet AND
2141 asection
*section AND
2143 boolean relocateable
)
2145 switch (seclet
->type
)
2147 case bfd_indirect_seclet
:
2148 /* The contents of this section come from another one somewhere
2150 return ecoff_rel (abfd
, seclet
, section
, data
, relocateable
);
2152 case bfd_fill_seclet
:
2153 /* Fill in the section with fill.value. This is used to pad out
2154 sections, but we must avoid padding the .bss section. */
2155 if ((section
->flags
& SEC_HAS_CONTENTS
) == 0)
2157 if (seclet
->u
.fill
.value
!= 0)
2162 char *d
= (char *) bfd_alloc (abfd
, seclet
->size
);
2166 for (i
= 0; i
< seclet
->size
; i
+=2)
2167 d
[i
] = seclet
->u
.fill
.value
>> 8;
2168 for (i
= 1; i
< seclet
->size
; i
+=2)
2169 d
[i
] = seclet
->u
.fill
.value
;
2170 ret
= bfd_set_section_contents (abfd
, section
, d
, seclet
->offset
,
2172 bfd_release (abfd
, (PTR
) d
);
2184 /* Add a string to the debugging information we are accumulating for a
2185 file. Return the offset from the fdr string base or from the
2186 external string base. */
2189 DEFUN (ecoff_add_string
, (output_bfd
, fdr
, string
, external
),
2192 CONST
char *string AND
2199 symhdr
= &ecoff_data (output_bfd
)->symbolic_header
;
2200 len
= strlen (string
);
2203 strcpy (ecoff_data (output_bfd
)->ssext
+ symhdr
->issExtMax
, string
);
2204 ret
= symhdr
->issExtMax
;
2205 symhdr
->issExtMax
+= len
+ 1;
2209 strcpy (ecoff_data (output_bfd
)->ss
+ symhdr
->issMax
, string
);
2211 symhdr
->issMax
+= len
+ 1;
2212 fdr
->cbSs
+= len
+ 1;
2217 /* Accumulate the debugging information from an input section. */
2220 DEFUN (ecoff_get_debug
, (output_bfd
, seclet
, section
),
2222 bfd_seclet_type
*seclet AND
2226 HDRR
*output_symhdr
;
2228 ecoff_data_type
*output_ecoff
;
2229 ecoff_data_type
*input_ecoff
;
2231 struct sym_ext
*sym_out
;
2232 struct ext_ext
*ext_out
;
2233 ecoff_symbol_type
*esym_ptr
;
2234 ecoff_symbol_type
*esym_end
;
2237 struct fdr_ext
*fdr_out
;
2247 input_bfd
= seclet
->u
.indirect
.section
->owner
;
2249 /* Don't get the information more than once. */
2250 if (input_bfd
->output_has_begun
)
2252 input_bfd
->output_has_begun
= true;
2254 output_ecoff
= ecoff_data (output_bfd
);
2255 output_symhdr
= &output_ecoff
->symbolic_header
;
2257 if (input_bfd
->xvec
->flavour
!= bfd_target_ecoff_flavour
)
2264 /* This is not an ECOFF BFD. Just gather the symbols. */
2266 memset (&fdr
, 0, sizeof fdr
);
2268 fdr
.adr
= bfd_get_section_vma (output_bfd
, section
) + seclet
->offset
;
2269 fdr
.issBase
= output_symhdr
->issMax
;
2271 fdr
.rss
= ecoff_add_string (output_bfd
,
2273 bfd_get_filename (input_bfd
),
2275 fdr
.isymBase
= output_symhdr
->isymMax
;
2277 /* Get the local symbols from the input BFD. */
2278 symbols
= (asymbol
**) bfd_alloc (output_bfd
,
2279 get_symtab_upper_bound (input_bfd
));
2280 if (symbols
== (asymbol
**) NULL
)
2282 bfd_error
= no_memory
;
2285 sym_end
= symbols
+ bfd_canonicalize_symtab (input_bfd
, symbols
);
2287 /* Handle the local symbols. Any external symbols are handled
2290 for (sym_ptr
= symbols
; sym_ptr
!= sym_end
; sym_ptr
++)
2294 if (((*sym_ptr
)->flags
& BSF_EXPORT
) != 0)
2296 memset (&internal_sym
, 0, sizeof internal_sym
);
2297 internal_sym
.iss
= ecoff_add_string (output_bfd
,
2301 internal_sym
.value
= (*sym_ptr
)->value
;
2302 internal_sym
.st
= stNil
;
2303 internal_sym
.sc
= scUndefined
;
2304 internal_sym
.index
= indexNil
;
2305 ecoff_swap_sym_out (output_bfd
, &internal_sym
,
2306 (output_ecoff
->external_sym
2307 + output_symhdr
->isymMax
));
2309 ++output_symhdr
->isymMax
;
2312 bfd_release (output_bfd
, (PTR
) symbols
);
2314 /* Leave everything else in the FDR zeroed out. This will cause
2315 the lang field to be langC. The fBigendian field will
2316 indicate little endian format, but it doesn't matter because
2317 it only applies to aux fields and there are none. */
2319 ecoff_swap_fdr_out (output_bfd
, &fdr
,
2320 (output_ecoff
->external_fdr
2321 + output_symhdr
->ifdMax
));
2322 ++output_symhdr
->ifdMax
;
2326 /* This is an ECOFF BFD. We want to grab the information from
2327 input_bfd and attach it to output_bfd. */
2328 count
= bfd_get_symcount (input_bfd
);
2331 input_ecoff
= ecoff_data (input_bfd
);
2332 input_symhdr
= &input_ecoff
->symbolic_header
;
2334 /* I think that it is more efficient to simply copy the debugging
2335 information from the input BFD to the output BFD. Because ECOFF
2336 uses relative pointers for most of the debugging information,
2337 only a little of it has to be changed at all. */
2339 /* Swap in the local symbols, adjust their values, and swap them out
2340 again. The external symbols are handled separately. */
2341 sym_out
= output_ecoff
->external_sym
+ output_symhdr
->isymMax
;
2343 esym_ptr
= ecoff_data (input_bfd
)->canonical_symbols
;
2344 esym_end
= esym_ptr
+ count
;
2345 for (; esym_ptr
< esym_end
; esym_ptr
++)
2347 if (esym_ptr
->local
)
2351 ecoff_swap_sym_in (input_bfd
, esym_ptr
->native
.lnative
, &sym
);
2352 if (! bfd_is_com_section (esym_ptr
->symbol
.section
)
2353 && (esym_ptr
->symbol
.flags
& BSF_DEBUGGING
) == 0
2354 && esym_ptr
->symbol
.section
!= &bfd_und_section
)
2355 sym
.value
= (esym_ptr
->symbol
.value
2356 + esym_ptr
->symbol
.section
->output_offset
2357 + esym_ptr
->symbol
.section
->output_section
->vma
);
2358 ecoff_swap_sym_out (output_bfd
, &sym
, sym_out
);
2363 /* That should have accounted for all the local symbols in
2365 BFD_ASSERT ((sym_out
- output_ecoff
->external_sym
) - output_symhdr
->isymMax
2366 == input_symhdr
->isymMax
);
2368 /* Copy the information that does not need swapping. */
2369 memcpy (output_ecoff
->line
+ output_symhdr
->cbLine
,
2371 input_symhdr
->cbLine
* sizeof (unsigned char));
2372 memcpy (output_ecoff
->external_aux
+ output_symhdr
->iauxMax
,
2373 input_ecoff
->external_aux
,
2374 input_symhdr
->iauxMax
* sizeof (union aux_ext
));
2375 memcpy (output_ecoff
->ss
+ output_symhdr
->issMax
,
2377 input_symhdr
->issMax
* sizeof (char));
2379 /* Some of the information may need to be swapped. */
2380 if (output_bfd
->xvec
->header_byteorder_big_p
2381 == input_bfd
->xvec
->header_byteorder_big_p
)
2383 /* The two BFD's have the same endianness, so memcpy will
2385 memcpy (output_ecoff
->external_dnr
+ output_symhdr
->idnMax
,
2386 input_ecoff
->external_dnr
,
2387 input_symhdr
->idnMax
* sizeof (struct dnr_ext
));
2388 memcpy (output_ecoff
->external_pdr
+ output_symhdr
->ipdMax
,
2389 input_ecoff
->external_pdr
,
2390 input_symhdr
->ipdMax
* sizeof (struct pdr_ext
));
2391 memcpy (output_ecoff
->external_opt
+ output_symhdr
->ioptMax
,
2392 input_ecoff
->external_opt
,
2393 input_symhdr
->ioptMax
* sizeof (struct opt_ext
));
2397 struct dnr_ext
*dnr_in
;
2398 struct dnr_ext
*dnr_end
;
2399 struct dnr_ext
*dnr_out
;
2400 struct pdr_ext
*pdr_in
;
2401 struct pdr_ext
*pdr_end
;
2402 struct pdr_ext
*pdr_out
;
2403 struct opt_ext
*opt_in
;
2404 struct opt_ext
*opt_end
;
2405 struct opt_ext
*opt_out
;
2407 /* The two BFD's have different endianness, so we must swap
2408 everything in and out. This code would always work, but it
2409 would be slow in the normal case. */
2410 dnr_in
= input_ecoff
->external_dnr
;
2411 dnr_end
= dnr_in
+ input_symhdr
->idnMax
;
2412 dnr_out
= output_ecoff
->external_dnr
+ output_symhdr
->idnMax
;
2413 for (; dnr_in
< dnr_end
; dnr_in
++, dnr_out
++)
2417 ecoff_swap_dnr_in (input_bfd
, dnr_in
, &dnr
);
2418 ecoff_swap_dnr_out (output_bfd
, &dnr
, dnr_out
);
2420 pdr_in
= input_ecoff
->external_pdr
;
2421 pdr_end
= pdr_in
+ input_symhdr
->ipdMax
;
2422 pdr_out
= output_ecoff
->external_pdr
+ output_symhdr
->ipdMax
;
2423 for (; pdr_in
< pdr_end
; pdr_in
++, pdr_out
++)
2427 ecoff_swap_pdr_in (input_bfd
, pdr_in
, &pdr
);
2428 ecoff_swap_pdr_out (output_bfd
, &pdr
, pdr_out
);
2430 opt_in
= input_ecoff
->external_opt
;
2431 opt_end
= opt_in
+ input_symhdr
->ioptMax
;
2432 opt_out
= output_ecoff
->external_opt
+ output_symhdr
->ioptMax
;
2433 for (; opt_in
< opt_end
; opt_in
++, opt_out
++)
2437 ecoff_swap_opt_in (input_bfd
, opt_in
, &opt
);
2438 ecoff_swap_opt_out (output_bfd
, &opt
, opt_out
);
2442 /* Set ifdbase so that the external symbols know how to adjust their
2444 input_ecoff
->ifdbase
= output_symhdr
->ifdMax
;
2446 /* Step through the FDR's of input_bfd, adjust the offsets, and
2448 iss
= output_symhdr
->issMax
;
2449 isym
= output_symhdr
->isymMax
;
2450 iline
= output_symhdr
->ilineMax
;
2451 iopt
= output_symhdr
->ioptMax
;
2452 ipdr
= output_symhdr
->ipdMax
;
2453 iaux
= output_symhdr
->iauxMax
;
2454 irfd
= output_symhdr
->crfd
;
2455 cbline
= output_symhdr
->cbLine
;
2457 fdr_ptr
= input_ecoff
->fdr
;
2458 fdr_end
= fdr_ptr
+ input_symhdr
->ifdMax
;
2459 fdr_out
= output_ecoff
->external_fdr
+ output_symhdr
->ifdMax
;
2460 for (; fdr_ptr
< fdr_end
; fdr_ptr
++, fdr_out
++)
2466 /* The memory address for this fdr is the address for the seclet
2467 plus the offset to this fdr within input_bfd. */
2468 fdr
.adr
= (bfd_get_section_vma (output_bfd
, section
)
2470 + (fdr_ptr
->adr
- input_ecoff
->fdr
->adr
));
2474 fdr
.isymBase
= isym
;
2476 fdr
.ilineBase
= iline
;
2478 fdr
.ioptBase
= iopt
;
2480 fdr
.ipdFirst
= ipdr
;
2482 fdr
.iauxBase
= iaux
;
2487 /* If there are no RFD's, we are going to add some. We don't
2488 want to adjust irfd for this, so that all the FDR's can share
2490 if (input_symhdr
->crfd
== 0)
2491 fdr
.crfd
= input_symhdr
->ifdMax
;
2493 if (fdr
.cbLine
!= 0)
2495 fdr
.cbLineOffset
= cbline
;
2496 cbline
+= fdr
.cbLine
;
2499 ecoff_swap_fdr_out (output_bfd
, &fdr
, fdr_out
);
2502 if (input_symhdr
->crfd
> 0)
2504 struct rfd_ext
*rfd_in
;
2505 struct rfd_ext
*rfd_end
;
2506 struct rfd_ext
*rfd_out
;
2508 /* Swap and adjust the RFD's. RFD's are only created by the
2509 linker, so this will only be necessary if one of the input
2510 files is the result of a partial link. Presumably all
2511 necessary RFD's are present. */
2512 rfd_in
= input_ecoff
->external_rfd
;
2513 rfd_end
= rfd_in
+ input_symhdr
->crfd
;
2514 rfd_out
= output_ecoff
->external_rfd
+ output_symhdr
->crfd
;
2515 for (; rfd_in
< rfd_end
; rfd_in
++, rfd_out
++)
2519 ecoff_swap_rfd_in (input_bfd
, rfd_in
, &rfd
);
2520 rfd
+= output_symhdr
->ifdMax
;
2521 ecoff_swap_rfd_out (output_bfd
, &rfd
, rfd_out
);
2523 output_symhdr
->crfd
+= input_symhdr
->crfd
;
2527 struct rfd_ext
*rfd_out
;
2528 struct rfd_ext
*rfd_end
;
2531 /* Create RFD's. Some of the debugging information includes
2532 relative file indices. These indices are taken as indices to
2533 the RFD table if there is one, or to the global table if
2534 there is not. If we did not create RFD's, we would have to
2535 parse and adjust all the debugging information which contains
2537 rfd
= output_symhdr
->ifdMax
;
2538 rfd_out
= output_ecoff
->external_rfd
+ output_symhdr
->crfd
;
2539 rfd_end
= rfd_out
+ input_symhdr
->ifdMax
;
2540 for (; rfd_out
< rfd_end
; rfd_out
++, rfd
++)
2541 ecoff_swap_rfd_out (output_bfd
, &rfd
, rfd_out
);
2542 output_symhdr
->crfd
+= input_symhdr
->ifdMax
;
2545 /* Combine the register masks. */
2549 output_ecoff
->gprmask
|= input_ecoff
->gprmask
;
2550 for (i
= 0; i
< 3; i
++)
2551 output_ecoff
->cprmask
[i
] |= input_ecoff
->cprmask
[i
];
2554 /* Update the counts. */
2555 output_symhdr
->ilineMax
+= input_symhdr
->ilineMax
;
2556 output_symhdr
->cbLine
+= input_symhdr
->cbLine
;
2557 output_symhdr
->idnMax
+= input_symhdr
->idnMax
;
2558 output_symhdr
->ipdMax
+= input_symhdr
->ipdMax
;
2559 output_symhdr
->isymMax
+= input_symhdr
->isymMax
;
2560 output_symhdr
->ioptMax
+= input_symhdr
->ioptMax
;
2561 output_symhdr
->iauxMax
+= input_symhdr
->iauxMax
;
2562 output_symhdr
->issMax
+= input_symhdr
->issMax
;
2563 output_symhdr
->ifdMax
+= input_symhdr
->ifdMax
;
2565 /* Double check that the counts we got by stepping through the FDR's
2566 match the counts we got from input_symhdr. We don't check iss or
2567 cbline because they are rounded. */
2568 BFD_ASSERT (output_symhdr
->isymMax
== isym
2569 && output_symhdr
->ilineMax
== iline
2570 && output_symhdr
->ioptMax
== iopt
2571 && output_symhdr
->ipdMax
== ipdr
2572 && output_symhdr
->iauxMax
== iaux
);
2577 /* This is the actual link routine. It makes two passes over all the
2581 DEFUN (ecoff_bfd_seclet_link
, (abfd
, data
, relocateable
),
2584 boolean relocateable
)
2588 register asection
*o
;
2589 register bfd_seclet_type
*p
;
2590 asymbol
**sym_ptr_ptr
;
2594 /* We accumulate the debugging information counts in the symbolic
2596 symhdr
= &ecoff_data (abfd
)->symbolic_header
;
2597 symhdr
->magic
= magicSym
;
2598 /* FIXME: What should the version stamp be? */
2600 symhdr
->ilineMax
= 0;
2604 symhdr
->isymMax
= 0;
2605 symhdr
->ioptMax
= 0;
2606 symhdr
->iauxMax
= 0;
2608 symhdr
->issExtMax
= 0;
2611 symhdr
->iextMax
= 0;
2613 /* We need to copy over the debugging symbols from each input BFD.
2614 When we do this copying, we have to adjust the text address in
2615 the FDR structures, so we have to know the text address used for
2616 the input BFD. Since we only want to copy the symbols once per
2617 input BFD, but we are going to look at each input BFD multiple
2618 times (once for each section it provides), we arrange to always
2619 look at the text section first. That means that when we copy the
2620 debugging information, we always know the text address. So we
2621 actually do each pass in two sub passes; first the text sections,
2622 then the non-text sections. We use the output_has_begun flag to
2623 determine whether we have copied over the debugging information
2626 /* Do the first pass: set the output section contents and count the
2627 debugging information. */
2628 ecoff_clear_output_flags (abfd
);
2629 for (ipass
= 0; ipass
< 2; ipass
++)
2631 for (o
= abfd
->sections
; o
!= (asection
*) NULL
; o
= o
->next
)
2633 /* For SEC_CODE sections, (flags & SEC_CODE) == 0 is false,
2634 so they are done on pass 0. For other sections the
2635 expression is true, so they are done on pass 1. */
2636 if (((o
->flags
& SEC_CODE
) == 0) != ipass
)
2639 for (p
= o
->seclets_head
;
2640 p
!= (bfd_seclet_type
*) NULL
;
2643 if (ecoff_dump_seclet (abfd
, p
, o
, data
, relocateable
)
2650 /* We handle the external symbols differently. We use the ones
2651 attached to the output_bfd. The linker will have already
2652 determined which symbols are to be attached. Here we just
2653 determine how much space we will need for them. */
2654 sym_ptr_ptr
= bfd_get_outsymbols (abfd
);
2655 if (sym_ptr_ptr
!= NULL
)
2659 sym_end
= sym_ptr_ptr
+ bfd_get_symcount (abfd
);
2660 for (; sym_ptr_ptr
< sym_end
; sym_ptr_ptr
++)
2662 if (((*sym_ptr_ptr
)->flags
& BSF_DEBUGGING
) == 0
2663 && ((*sym_ptr_ptr
)->flags
& BSF_LOCAL
) == 0)
2666 symhdr
->issExtMax
+= strlen ((*sym_ptr_ptr
)->name
) + 1;
2671 /* Adjust the counts so that structures are longword aligned. */
2672 symhdr
->cbLine
= (symhdr
->cbLine
+ 3) &~ 3;
2673 symhdr
->issMax
= (symhdr
->issMax
+ 3) &~ 3;
2674 symhdr
->issExtMax
= (symhdr
->issExtMax
+ 3) &~ 3;
2676 /* Now the counts in symhdr are the correct size for the debugging
2677 information. We allocate the right amount of space, and reset
2678 the counts so that the second pass can use them as indices. It
2679 would be possible to output the debugging information directly to
2680 the file in pass 2, rather than to build it in memory and then
2681 write it out. Outputting to the file would require a lot of
2682 seeks and small writes, though, and I think this approach is
2684 size
= (symhdr
->cbLine
* sizeof (unsigned char)
2685 + symhdr
->idnMax
* sizeof (struct dnr_ext
)
2686 + symhdr
->ipdMax
* sizeof (struct pdr_ext
)
2687 + symhdr
->isymMax
* sizeof (struct sym_ext
)
2688 + symhdr
->ioptMax
* sizeof (struct opt_ext
)
2689 + symhdr
->iauxMax
* sizeof (union aux_ext
)
2690 + symhdr
->issMax
* sizeof (char)
2691 + symhdr
->issExtMax
* sizeof (char)
2692 + symhdr
->ifdMax
* sizeof (struct fdr_ext
)
2693 + symhdr
->crfd
* sizeof (struct rfd_ext
)
2694 + symhdr
->iextMax
* sizeof (struct ext_ext
));
2695 raw
= (char *) bfd_alloc (abfd
, size
);
2696 if (raw
== (char *) NULL
)
2698 bfd_error
= no_memory
;
2701 ecoff_data (abfd
)->raw_size
= size
;
2702 ecoff_data (abfd
)->raw_syments
= (PTR
) raw
;
2704 /* Initialize the raw pointers. */
2705 #define SET(field, count, type) \
2706 ecoff_data (abfd)->field = (type *) raw; \
2707 raw += symhdr->count * sizeof (type)
2709 SET (line
, cbLine
, unsigned char);
2710 SET (external_dnr
, idnMax
, struct dnr_ext
);
2711 SET (external_pdr
, ipdMax
, struct pdr_ext
);
2712 SET (external_sym
, isymMax
, struct sym_ext
);
2713 SET (external_opt
, ioptMax
, struct opt_ext
);
2714 SET (external_aux
, iauxMax
, union aux_ext
);
2715 SET (ss
, issMax
, char);
2716 SET (ssext
, issExtMax
, char);
2717 SET (external_fdr
, ifdMax
, struct fdr_ext
);
2718 SET (external_rfd
, crfd
, struct rfd_ext
);
2719 SET (external_ext
, iextMax
, struct ext_ext
);
2722 /* Reset the counts so the second pass can use them to know how far
2724 symhdr
->ilineMax
= 0;
2728 symhdr
->isymMax
= 0;
2729 symhdr
->ioptMax
= 0;
2730 symhdr
->iauxMax
= 0;
2732 symhdr
->issExtMax
= 0;
2735 symhdr
->iextMax
= 0;
2737 /* Do the second pass: accumulate the debugging information. */
2738 ecoff_clear_output_flags (abfd
);
2739 for (ipass
= 0; ipass
< 2; ipass
++)
2741 for (o
= abfd
->sections
; o
!= (asection
*) NULL
; o
= o
->next
)
2743 if (((o
->flags
& SEC_CODE
) == 0) != ipass
)
2745 for (p
= o
->seclets_head
;
2746 p
!= (bfd_seclet_type
*) NULL
;
2749 if (p
->type
== bfd_indirect_seclet
)
2751 if (ecoff_get_debug (abfd
, p
, o
) == false)
2758 /* Put in the external symbols. */
2759 sym_ptr_ptr
= bfd_get_outsymbols (abfd
);
2760 if (sym_ptr_ptr
!= NULL
)
2763 struct ext_ext
*external_ext
;
2765 ssext
= ecoff_data (abfd
)->ssext
;
2766 external_ext
= ecoff_data (abfd
)->external_ext
;
2767 for (; *sym_ptr_ptr
!= NULL
; sym_ptr_ptr
++)
2772 sym_ptr
= *sym_ptr_ptr
;
2774 if ((sym_ptr
->flags
& BSF_DEBUGGING
) != 0
2775 || (sym_ptr
->flags
& BSF_LOCAL
) != 0)
2778 /* The enative pointer can be NULL for a symbol created by
2779 the linker via ecoff_make_empty_symbol. */
2780 if (bfd_asymbol_flavour (sym_ptr
) != bfd_target_ecoff_flavour
2781 || (((ecoff_symbol_type
*) sym_ptr
)->native
.enative
2782 == (struct ext_ext
*) NULL
))
2785 esym
.cobol_main
= 0;
2789 /* FIXME: we can do better than this for st and sc. */
2790 esym
.asym
.st
= stGlobal
;
2791 esym
.asym
.sc
= scAbs
;
2792 esym
.asym
.reserved
= 0;
2793 esym
.asym
.index
= indexNil
;
2797 ecoff_symbol_type
*ecoff_sym_ptr
;
2799 ecoff_sym_ptr
= (ecoff_symbol_type
*) sym_ptr
;
2800 if (ecoff_sym_ptr
->local
)
2802 ecoff_swap_ext_in (abfd
, ecoff_sym_ptr
->native
.enative
, &esym
);
2804 /* Adjust the FDR index for the symbol by that used for
2806 esym
.ifd
+= ecoff_data (bfd_asymbol_bfd (sym_ptr
))->ifdbase
;
2809 esym
.asym
.iss
= symhdr
->issExtMax
;
2811 if (bfd_is_com_section (sym_ptr
->section
)
2812 || sym_ptr
->section
== &bfd_und_section
)
2813 esym
.asym
.value
= sym_ptr
->value
;
2815 esym
.asym
.value
= (sym_ptr
->value
2816 + sym_ptr
->section
->output_offset
2817 + sym_ptr
->section
->output_section
->vma
);
2819 ecoff_swap_ext_out (abfd
, &esym
, external_ext
+ symhdr
->iextMax
);
2821 ecoff_set_sym_index (sym_ptr
, symhdr
->iextMax
);
2825 strcpy (ssext
+ symhdr
->issExtMax
, sym_ptr
->name
);
2826 symhdr
->issExtMax
+= strlen (sym_ptr
->name
) + 1;
2830 /* Adjust the counts so that structures are longword aligned. */
2831 symhdr
->cbLine
= (symhdr
->cbLine
+ 3) &~ 3;
2832 symhdr
->issMax
= (symhdr
->issMax
+ 3) &~ 3;
2833 symhdr
->issExtMax
= (symhdr
->issExtMax
+ 3) &~ 3;
2838 /* Set the architecture. The only architecture we support here is
2839 mips. We set the architecture anyhow, since many callers ignore
2840 the return value. */
2843 DEFUN (ecoff_set_arch_mach
, (abfd
, arch
, machine
),
2845 enum bfd_architecture arch AND
2846 unsigned long machine
)
2848 bfd_default_set_arch_mach (abfd
, arch
, machine
);
2849 return arch
== bfd_arch_mips
;
2852 /* Calculate the file position for each section, and set
2856 DEFUN (ecoff_compute_section_file_positions
, (abfd
),
2866 if (bfd_get_start_address (abfd
))
2867 abfd
->flags
|= EXEC_P
;
2869 /* Unlike normal COFF, ECOFF always use the ``optional'' header. */
2872 sofar
+= abfd
->section_count
* SCNHSZ
;
2875 for (current
= abfd
->sections
;
2876 current
!= (asection
*) NULL
;
2877 current
= current
->next
)
2879 /* Only deal with sections which have contents */
2880 if (! (current
->flags
& SEC_HAS_CONTENTS
))
2883 /* On Ultrix, the data sections in an executable file must be
2884 aligned to a page boundary within the file. This does not
2885 affect the section size, though. FIXME: Does this work for
2887 if ((abfd
->flags
& EXEC_P
) != 0
2888 && first_data
!= false
2889 && (current
->flags
& SEC_CODE
) == 0)
2891 sofar
= (sofar
+ PAGE_SIZE
- 1) &~ (PAGE_SIZE
- 1);
2895 /* Align the sections in the file to the same boundary on
2896 which they are aligned in virtual memory. */
2898 sofar
= BFD_ALIGN (sofar
, 1 << current
->alignment_power
);
2900 current
->filepos
= sofar
;
2902 sofar
+= current
->_raw_size
;
2904 /* make sure that this section is of the right size too */
2906 sofar
= BFD_ALIGN (sofar
, 1 << current
->alignment_power
);
2907 current
->_raw_size
+= sofar
- old_sofar
;
2910 ecoff_data (abfd
)->reloc_filepos
= sofar
;
2913 /* Set the contents of a section. */
2916 DEFUN (ecoff_set_section_contents
, (abfd
, section
, location
, offset
, count
),
2918 asection
*section AND
2921 bfd_size_type count
)
2923 if (abfd
->output_has_begun
== false)
2924 ecoff_compute_section_file_positions (abfd
);
2926 bfd_seek (abfd
, (file_ptr
) (section
->filepos
+ offset
), SEEK_SET
);
2929 return (bfd_write (location
, 1, count
, abfd
) == count
) ? true : false;
2934 /* Write out an ECOFF file. */
2937 DEFUN (ecoff_write_object_contents
, (abfd
),
2943 file_ptr reloc_base
;
2945 unsigned long reloc_size
;
2946 unsigned long text_size
;
2947 unsigned long text_start
;
2948 unsigned long data_size
;
2949 unsigned long data_start
;
2950 unsigned long bss_size
;
2951 struct internal_filehdr internal_f
;
2952 struct internal_aouthdr internal_a
;
2955 bfd_error
= system_call_error
;
2957 if(abfd
->output_has_begun
== false)
2958 ecoff_compute_section_file_positions(abfd
);
2960 if (abfd
->sections
!= (asection
*) NULL
)
2961 scn_base
= abfd
->sections
->filepos
;
2964 reloc_base
= ecoff_data (abfd
)->reloc_filepos
;
2968 for (current
= abfd
->sections
;
2969 current
!= (asection
*)NULL
;
2970 current
= current
->next
)
2972 current
->target_index
= count
;
2974 if (current
->reloc_count
!= 0)
2976 bfd_size_type relsize
;
2978 current
->rel_filepos
= reloc_base
;
2979 relsize
= current
->reloc_count
* RELSZ
;
2980 reloc_size
+= relsize
;
2981 reloc_base
+= relsize
;
2984 current
->rel_filepos
= 0;
2987 sym_base
= reloc_base
+ reloc_size
;
2989 /* At least on Ultrix, the symbol table of an executable file must
2990 be aligned to a page boundary. FIXME: Is this true on other
2992 if ((abfd
->flags
& EXEC_P
) != 0)
2993 sym_base
= (sym_base
+ PAGE_SIZE
- 1) &~ (PAGE_SIZE
- 1);
2995 ecoff_data (abfd
)->sym_filepos
= sym_base
;
3003 /* Write section headers to the file. */
3005 internal_f
.f_nscns
= 0;
3006 if (bfd_seek (abfd
, (file_ptr
) (FILHSZ
+ AOUTSZ
), SEEK_SET
) != 0)
3008 for (current
= abfd
->sections
;
3009 current
!= (asection
*) NULL
;
3010 current
= current
->next
)
3012 struct internal_scnhdr section
;
3015 ++internal_f
.f_nscns
;
3017 strncpy (section
.s_name
, current
->name
, sizeof section
.s_name
);
3019 /* FIXME: is this correct for shared libraries? I think it is
3020 but I have no platform to check. Ian Lance Taylor. */
3021 vma
= bfd_get_section_vma (abfd
, current
);
3022 if (strcmp (current
->name
, _LIB
) == 0)
3023 section
.s_vaddr
= 0;
3025 section
.s_vaddr
= vma
;
3027 section
.s_paddr
= vma
;
3028 section
.s_size
= bfd_get_section_size_before_reloc (current
);
3030 /* If this section has no size or is unloadable then the scnptr
3032 if (current
->_raw_size
== 0
3033 || (current
->flags
& (SEC_LOAD
| SEC_HAS_CONTENTS
)) == 0)
3034 section
.s_scnptr
= 0;
3036 section
.s_scnptr
= current
->filepos
;
3037 section
.s_relptr
= current
->rel_filepos
;
3039 /* FIXME: the lnnoptr of the .sbss or .sdata section of an
3040 object file produced by the assembler is supposed to point to
3041 information about how much room is required by objects of
3042 various different sizes. I think this only matters if we
3043 want the linker to compute the best size to use, or
3044 something. I don't know what happens if the information is
3046 section
.s_lnnoptr
= 0;
3048 section
.s_nreloc
= current
->reloc_count
;
3049 section
.s_nlnno
= 0;
3050 section
.s_flags
= sec_to_styp_flags (current
->name
, current
->flags
);
3055 ecoff_swap_scnhdr_out (abfd
, (PTR
) §ion
, (PTR
) &buff
);
3056 if (bfd_write ((PTR
) &buff
, 1, SCNHSZ
, abfd
) != SCNHSZ
)
3060 if ((section
.s_flags
& STYP_TEXT
) != 0)
3062 text_size
+= bfd_get_section_size_before_reloc (current
);
3063 if (text_start
== 0 || text_start
> vma
)
3066 else if ((section
.s_flags
& STYP_RDATA
) != 0
3067 || (section
.s_flags
& STYP_DATA
) != 0
3068 || (section
.s_flags
& STYP_LIT8
) != 0
3069 || (section
.s_flags
& STYP_LIT4
) != 0
3070 || (section
.s_flags
& STYP_SDATA
) != 0)
3072 data_size
+= bfd_get_section_size_before_reloc (current
);
3073 if (data_start
== 0 || data_start
> vma
)
3076 else if ((section
.s_flags
& STYP_BSS
) != 0
3077 || (section
.s_flags
& STYP_SBSS
) != 0)
3078 bss_size
+= bfd_get_section_size_before_reloc (current
);
3081 /* Set up the file header. */
3083 internal_f
.f_magic
= MIPS_MAGIC_2
;
3086 We will NOT put a fucking timestamp in the header here. Every time you
3087 put it back, I will come in and take it out again. I'm sorry. This
3088 field does not belong here. We fill it with a 0 so it compares the
3089 same but is not a reasonable time. -- gnu@cygnus.com
3091 internal_f
.f_timdat
= 0;
3093 if (bfd_get_symcount (abfd
) != 0)
3095 /* The ECOFF f_nsyms field is not actually the number of
3096 symbols, it's the size of symbolic information header. */
3097 internal_f
.f_nsyms
= sizeof (struct hdr_ext
);
3098 internal_f
.f_symptr
= sym_base
;
3102 internal_f
.f_nsyms
= 0;
3103 internal_f
.f_symptr
= 0;
3106 internal_f
.f_opthdr
= AOUTSZ
;
3108 internal_f
.f_flags
= F_LNNO
;
3109 if (reloc_size
== 0)
3110 internal_f
.f_flags
|= F_RELFLG
;
3111 if (bfd_get_symcount (abfd
) == 0)
3112 internal_f
.f_flags
|= F_LSYMS
;
3113 if (abfd
->flags
& EXEC_P
)
3114 internal_f
.f_flags
|= F_EXEC
;
3116 if (! abfd
->xvec
->byteorder_big_p
)
3117 internal_f
.f_flags
|= F_AR32WR
;
3119 internal_f
.f_flags
|= F_AR32W
;
3121 /* Set up the ``optional'' header. */
3122 internal_a
.magic
= ZMAGIC
;
3124 /* FIXME: What should this be? */
3125 internal_a
.vstamp
= 0;
3127 /* At least on Ultrix, these have to be rounded to page boundaries.
3128 FIXME: Is this true on other platforms? */
3129 internal_a
.tsize
= (text_size
+ PAGE_SIZE
- 1) &~ (PAGE_SIZE
- 1);
3130 internal_a
.text_start
= text_start
&~ (PAGE_SIZE
- 1);
3131 internal_a
.dsize
= (data_size
+ PAGE_SIZE
- 1) &~ (PAGE_SIZE
- 1);
3132 internal_a
.data_start
= data_start
&~ (PAGE_SIZE
- 1);
3134 /* On Ultrix, the initial portions of the .sbss and .bss segments
3135 are at the end of the data section. The bsize field in the
3136 optional header records how many bss bytes are required beyond
3137 those in the data section. The value is not rounded to a page
3139 if (bss_size
< internal_a
.dsize
- data_size
)
3142 bss_size
-= internal_a
.dsize
- data_size
;
3143 internal_a
.bsize
= bss_size
;
3144 internal_a
.bss_start
= internal_a
.data_start
+ internal_a
.dsize
;
3146 internal_a
.entry
= bfd_get_start_address (abfd
);
3148 internal_a
.gp_value
= ecoff_data (abfd
)->gp
;
3150 internal_a
.gprmask
= ecoff_data (abfd
)->gprmask
;
3151 for (i
= 0; i
< 3; i
++)
3152 internal_a
.cprmask
[i
] = ecoff_data (abfd
)->cprmask
[i
];
3154 /* Write out the file header and the optional header. */
3156 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
) != 0)
3161 ecoff_swap_filehdr_out (abfd
, (PTR
) &internal_f
, (PTR
) &buff
);
3162 if (bfd_write ((PTR
) &buff
, 1, FILHSZ
, abfd
) != FILHSZ
)
3169 ecoff_swap_aouthdr_out (abfd
, (PTR
) &internal_a
, (PTR
) &buff
);
3170 if (bfd_write ((PTR
) &buff
, 1, AOUTSZ
, abfd
) != AOUTSZ
)
3174 /* Write out the relocs. */
3175 for (current
= abfd
->sections
;
3176 current
!= (asection
*) NULL
;
3177 current
= current
->next
)
3180 arelent
**reloc_ptr_ptr
;
3181 arelent
**reloc_end
;
3184 if (current
->reloc_count
== 0)
3187 buff
= (RELOC
*) bfd_alloc (abfd
, current
->reloc_count
* RELSZ
);
3188 if (buff
== (RELOC
*) NULL
)
3190 bfd_error
= no_memory
;
3194 reloc_ptr_ptr
= current
->orelocation
;
3195 reloc_end
= reloc_ptr_ptr
+ current
->reloc_count
;
3197 for (; reloc_ptr_ptr
< reloc_end
; reloc_ptr_ptr
++, out_ptr
++)
3201 struct internal_reloc in
;
3203 memset (&in
, 0, sizeof in
);
3205 reloc
= *reloc_ptr_ptr
;
3206 sym
= *reloc
->sym_ptr_ptr
;
3208 in
.r_vaddr
= reloc
->address
+ bfd_get_section_vma (abfd
, current
);
3209 in
.r_type
= reloc
->howto
->type
;
3210 if ((sym
->flags
& BSF_SECTION_SYM
) == 0)
3212 in
.r_symndx
= ecoff_get_sym_index (*reloc
->sym_ptr_ptr
);
3219 name
= bfd_get_section_name (abfd
, bfd_get_section (sym
));
3220 if (strcmp (name
, ".text") == 0)
3221 in
.r_symndx
= RELOC_SECTION_TEXT
;
3222 else if (strcmp (name
, ".rdata") == 0)
3223 in
.r_symndx
= RELOC_SECTION_RDATA
;
3224 else if (strcmp (name
, ".data") == 0)
3225 in
.r_symndx
= RELOC_SECTION_DATA
;
3226 else if (strcmp (name
, ".sdata") == 0)
3227 in
.r_symndx
= RELOC_SECTION_SDATA
;
3228 else if (strcmp (name
, ".sbss") == 0)
3229 in
.r_symndx
= RELOC_SECTION_SBSS
;
3230 else if (strcmp (name
, ".bss") == 0)
3231 in
.r_symndx
= RELOC_SECTION_BSS
;
3232 else if (strcmp (name
, ".init") == 0)
3233 in
.r_symndx
= RELOC_SECTION_INIT
;
3234 else if (strcmp (name
, ".lit8") == 0)
3235 in
.r_symndx
= RELOC_SECTION_LIT8
;
3236 else if (strcmp (name
, ".lit4") == 0)
3237 in
.r_symndx
= RELOC_SECTION_LIT4
;
3243 ecoff_swap_reloc_out (abfd
, (PTR
) &in
, (PTR
) out_ptr
);
3246 if (bfd_seek (abfd
, current
->rel_filepos
, SEEK_SET
) != 0)
3248 if (bfd_write ((PTR
) buff
, RELSZ
, current
->reloc_count
, abfd
)
3249 != RELSZ
* current
->reloc_count
)
3251 bfd_release (abfd
, (PTR
) buff
);
3254 /* Write out the symbolic debugging information. */
3255 if (bfd_get_symcount (abfd
) > 0)
3258 unsigned long sym_offset
;
3259 struct hdr_ext buff
;
3261 /* Set up the offsets in the symbolic header. */
3262 symhdr
= &ecoff_data (abfd
)->symbolic_header
;
3263 sym_offset
= ecoff_data (abfd
)->sym_filepos
+ sizeof (struct hdr_ext
);
3265 #define SET(offset, size, ptr) \
3266 if (symhdr->size == 0) \
3267 symhdr->offset = 0; \
3269 symhdr->offset = (((char *) ecoff_data (abfd)->ptr \
3270 - (char *) ecoff_data (abfd)->raw_syments) \
3273 SET (cbLineOffset
, cbLine
, line
);
3274 SET (cbDnOffset
, idnMax
, external_dnr
);
3275 SET (cbPdOffset
, ipdMax
, external_pdr
);
3276 SET (cbSymOffset
, isymMax
, external_sym
);
3277 SET (cbOptOffset
, ioptMax
, external_opt
);
3278 SET (cbAuxOffset
, iauxMax
, external_aux
);
3279 SET (cbSsOffset
, issMax
, ss
);
3280 SET (cbSsExtOffset
, issExtMax
, ssext
);
3281 SET (cbFdOffset
, ifdMax
, external_fdr
);
3282 SET (cbRfdOffset
, crfd
, external_rfd
);
3283 SET (cbExtOffset
, iextMax
, external_ext
);
3286 if (bfd_seek (abfd
, (file_ptr
) ecoff_data (abfd
)->sym_filepos
,
3289 ecoff_swap_hdr_out (abfd
, &ecoff_data (abfd
)->symbolic_header
, &buff
);
3290 if (bfd_write ((PTR
) &buff
, 1, sizeof buff
, abfd
) != sizeof buff
)
3292 if (bfd_write ((PTR
) ecoff_data (abfd
)->raw_syments
, 1,
3293 ecoff_data (abfd
)->raw_size
, abfd
)
3294 != ecoff_data (abfd
)->raw_size
)
3301 /* Archive handling. ECOFF uses what appears to be a unique type of
3302 archive header (which I call an armap). The byte ordering of the
3303 armap and the contents are encoded in the name of the armap itself.
3304 At least for now, we only support archives with the same byte
3305 ordering in the armap and the contents.
3307 The first four bytes in the armap are the number of symbol
3308 definitions. This always seems to be a power of two, presumably
3309 because ranlib uses a hash table of some sort. I don't know what
3310 the hashing scheme is at the moment.
3312 This is followed by the symbol definitions. Each symbol definition
3313 occupies 8 bytes. The first four bytes are the offset from the
3314 start of the armap strings to the null-terminated string naming
3315 this symbol. The second four bytes are the file offset to the
3316 archive member which defines this symbol. If the second four bytes
3317 are 0, then this is not actually a symbol definition, and it should
3320 After the symbol definitions comes four bytes holding the size of
3321 the string table, followed by the string table itself. */
3323 /* The name of an archive headers looks like this:
3324 __________E[BL]E[BL]_ (with a trailing space). */
3326 #define ARMAP_BIG_ENDIAN 'B'
3327 #define ARMAP_LITTLE_ENDIAN 'L'
3328 #define ARMAP_MARKER 'E'
3329 #define ARMAP_START "__________"
3330 #define ARMAP_HEADER_MARKER_INDEX 10
3331 #define ARMAP_HEADER_ENDIAN_INDEX 11
3332 #define ARMAP_OBJECT_MARKER_INDEX 12
3333 #define ARMAP_OBJECT_ENDIAN_INDEX 13
3334 #define ARMAP_END_INDEX 14
3335 #define ARMAP_END "_ "
3337 /* Read in the armap. */
3340 DEFUN (ecoff_slurp_armap
, (abfd
),
3345 struct areltdata
*mapdata
;
3346 bfd_size_type parsed_size
;
3348 struct artdata
*ardata
;
3351 struct symdef
*symdef_ptr
;
3354 /* Get the name of the first element. */
3355 i
= bfd_read ((PTR
) nextname
, 1, 16, abfd
);
3361 bfd_seek (abfd
, (file_ptr
) -16, SEEK_CUR
);
3363 /* See if the first element is an armap. */
3364 if (strncmp (nextname
, ARMAP_START
, sizeof ARMAP_START
- 1) != 0
3365 || nextname
[ARMAP_HEADER_MARKER_INDEX
] != ARMAP_MARKER
3366 || (nextname
[ARMAP_HEADER_ENDIAN_INDEX
] != ARMAP_BIG_ENDIAN
3367 && nextname
[ARMAP_HEADER_ENDIAN_INDEX
] != ARMAP_LITTLE_ENDIAN
)
3368 || nextname
[ARMAP_OBJECT_MARKER_INDEX
] != ARMAP_MARKER
3369 || (nextname
[ARMAP_OBJECT_ENDIAN_INDEX
] != ARMAP_BIG_ENDIAN
3370 && nextname
[ARMAP_OBJECT_ENDIAN_INDEX
] != ARMAP_LITTLE_ENDIAN
)
3371 || strncmp (nextname
+ ARMAP_END_INDEX
,
3372 ARMAP_END
, sizeof ARMAP_END
- 1) != 0)
3374 bfd_has_map (abfd
) = false;
3378 /* Make sure we have the right byte ordering. */
3379 if (((nextname
[ARMAP_HEADER_ENDIAN_INDEX
] == ARMAP_BIG_ENDIAN
)
3380 ^ (abfd
->xvec
->header_byteorder_big_p
!= false))
3381 || ((nextname
[ARMAP_OBJECT_MARKER_INDEX
] == ARMAP_BIG_ENDIAN
)
3382 ^ (abfd
->xvec
->byteorder_big_p
!= false)))
3384 bfd_error
= wrong_format
;
3388 /* Read in the armap. */
3389 ardata
= bfd_ardata (abfd
);
3390 mapdata
= snarf_ar_hdr (abfd
);
3391 if (mapdata
== (struct areltdata
*) NULL
)
3393 parsed_size
= mapdata
->parsed_size
;
3394 bfd_release (abfd
, (PTR
) mapdata
);
3396 raw_armap
= (char *) bfd_alloc (abfd
, parsed_size
);
3397 if (raw_armap
== (char *) NULL
)
3399 bfd_error
= no_memory
;
3403 if (bfd_read ((PTR
) raw_armap
, 1, parsed_size
, abfd
) != parsed_size
)
3405 bfd_error
= malformed_archive
;
3406 bfd_release (abfd
, (PTR
) raw_armap
);
3410 count
= bfd_h_get_32 (abfd
, (PTR
) raw_armap
);
3412 ardata
->symdef_count
= 0;
3413 ardata
->cache
= (struct ar_cache
*) NULL
;
3415 /* Hack: overlay the symdefs on top of the raw archive data. This
3416 is the way do_slurp_bsd_armap works. */
3417 raw_ptr
= raw_armap
+ LONG_SIZE
;
3418 symdef_ptr
= (struct symdef
*) raw_ptr
;
3419 ardata
->symdefs
= (carsym
*) symdef_ptr
;
3420 stringbase
= raw_ptr
+ count
* (2 * LONG_SIZE
) + LONG_SIZE
;
3422 for (i
= 0; i
< count
; i
++, raw_ptr
+= 2 * LONG_SIZE
)
3424 unsigned long name_offset
, file_offset
;
3426 name_offset
= bfd_h_get_32 (abfd
, (PTR
) raw_ptr
);
3427 file_offset
= bfd_h_get_32 (abfd
, (PTR
) (raw_ptr
+ LONG_SIZE
));
3428 if (file_offset
== 0)
3430 symdef_ptr
->s
.name
= stringbase
+ name_offset
;
3431 symdef_ptr
->file_offset
= file_offset
;
3433 ++ardata
->symdef_count
;
3436 ardata
->first_file_filepos
= bfd_tell (abfd
);
3437 /* Pad to an even boundary. */
3438 ardata
->first_file_filepos
+= ardata
->first_file_filepos
% 2;
3440 bfd_has_map (abfd
) = true;
3445 /* Write out an armap. */
3448 DEFUN (ecoff_write_armap
, (abfd
, elength
, map
, orl_count
, stridx
),
3450 unsigned int elength AND
3452 unsigned int orl_count AND
3455 unsigned int symdefsize
;
3457 unsigned int stringsize
;
3458 unsigned int mapsize
;
3461 struct stat statbuf
;
3467 symdefsize
= orl_count
* 8;
3469 stringsize
= stridx
+ padit
;
3471 /* Include 8 bytes to store symdefsize and stringsize in output. */
3472 mapsize
= 4 + symdefsize
+ stringsize
+ 4;
3474 firstreal
= SARMAG
+ sizeof (struct ar_hdr
) + mapsize
+ elength
;
3476 memset ((PTR
) &hdr
, 0, sizeof hdr
);
3478 /* Work out the ECOFF armap name. */
3479 strcpy (hdr
.ar_name
, ARMAP_START
);
3480 hdr
.ar_name
[ARMAP_HEADER_MARKER_INDEX
] = ARMAP_MARKER
;
3481 hdr
.ar_name
[ARMAP_HEADER_ENDIAN_INDEX
] =
3482 (abfd
->xvec
->header_byteorder_big_p
3484 : ARMAP_LITTLE_ENDIAN
);
3485 hdr
.ar_name
[ARMAP_OBJECT_MARKER_INDEX
] = ARMAP_MARKER
;
3486 hdr
.ar_name
[ARMAP_OBJECT_ENDIAN_INDEX
] =
3487 abfd
->xvec
->byteorder_big_p
? ARMAP_BIG_ENDIAN
: ARMAP_LITTLE_ENDIAN
;
3488 memcpy (hdr
.ar_name
+ ARMAP_END_INDEX
, ARMAP_END
, sizeof ARMAP_END
- 1);
3490 /* Write the timestamp of the archive header to be just a little bit
3491 later than the timestamp of the file, otherwise the linker will
3492 complain that the index is out of date. */
3493 if (stat (abfd
->filename
, &statbuf
) < 0)
3494 statbuf
.st_mtime
= time ((PTR
) NULL
);
3495 sprintf (hdr
.ar_date
, "%ld", (long) (statbuf
.st_mtime
+ 60));
3497 /* The DECstation uses zeroes for the uid, gid and mode of the
3499 hdr
.ar_uid
[0] = '0';
3500 hdr
.ar_gid
[0] = '0';
3501 hdr
.ar_mode
[0] = '0';
3503 sprintf (hdr
.ar_size
, "%-10d", (int) mapsize
);
3505 hdr
.ar_fmag
[0] = '`';
3506 hdr
.ar_fmag
[1] = '\n';
3508 /* Turn all null bytes in the header into spaces. */
3509 for (i
= 0; i
< sizeof (struct ar_hdr
); i
++)
3510 if (((char *)(&hdr
))[i
] == '\0')
3511 (((char *)(&hdr
))[i
]) = ' ';
3513 bfd_write ((PTR
) &hdr
, 1, sizeof (struct ar_hdr
), abfd
);
3515 bfd_h_put_32 (abfd
, symdefsize
, temp
);
3516 bfd_write (temp
, 1, LONG_SIZE
, abfd
);
3518 current
= abfd
->archive_head
;
3520 for (i
= 0; i
< orl_count
; i
++)
3524 /* Advance firstreal to the file position of this archive
3526 if (((bfd
*) map
[i
].pos
) != last_elt
)
3530 firstreal
+= arelt_size (current
) + sizeof (struct ar_hdr
);
3531 firstreal
+= firstreal
% 2;
3532 current
= current
->next
;
3534 while (current
!= (bfd
*) map
[i
].pos
);
3539 bfd_h_put_32 (abfd
, map
[i
].namidx
, buff
);
3540 bfd_h_put_32 (abfd
, firstreal
, buff
+ LONG_SIZE
);
3541 bfd_write (buff
, 1, 2 * LONG_SIZE
, abfd
);
3544 /* Now write the strings. */
3545 bfd_h_put_32 (abfd
, stringsize
, temp
);
3546 bfd_write (temp
, 1, LONG_SIZE
, abfd
);
3547 for (i
= 0; i
< orl_count
; i
++)
3548 bfd_write ((PTR
) (*map
[i
].name
), 1, strlen (*map
[i
].name
) + 1, abfd
);
3550 /* The spec sez this should be a newline. But in order to be
3551 bug-compatible for DECstation ar we use a null. */
3553 bfd_write ("\0", 1, 1, abfd
);
3558 /* We just use the generic extended name support. This is a GNU
3560 #define ecoff_slurp_extended_name_table _bfd_slurp_extended_name_table
3562 /* See whether this BFD is an archive. If it is, read in the armap
3563 and the extended name table. */
3566 DEFUN (ecoff_archive_p
, (abfd
),
3569 char armag
[SARMAG
+ 1];
3571 if (bfd_read ((PTR
) armag
, 1, SARMAG
, abfd
) != SARMAG
3572 || strncmp (armag
, ARMAG
, SARMAG
) != 0)
3574 bfd_error
= wrong_format
;
3575 return (bfd_target
*) NULL
;
3578 /* We are setting bfd_ardata(abfd) here, but since bfd_ardata
3579 involves a cast, we can't do it as the left operand of
3581 abfd
->tdata
.aout_ar_data
=
3582 (struct artdata
*) bfd_zalloc (abfd
, sizeof (struct artdata
));
3584 if (bfd_ardata (abfd
) == (struct artdata
*) NULL
)
3586 bfd_error
= no_memory
;
3587 return (bfd_target
*) NULL
;
3590 bfd_ardata (abfd
)->first_file_filepos
= SARMAG
;
3592 if (ecoff_slurp_armap (abfd
) == false
3593 || ecoff_slurp_extended_name_table (abfd
) == false)
3595 bfd_release (abfd
, bfd_ardata (abfd
));
3596 abfd
->tdata
.aout_ar_data
= (struct artdata
*) NULL
;
3597 return (bfd_target
*) NULL
;
3603 static CONST bfd_coff_backend_data bfd_ecoff_std_swap_table
= {
3604 (void (*) PARAMS ((bfd
*,PTR
,int,int,PTR
))) bfd_void
, /* aux_in */
3605 (void (*) PARAMS ((bfd
*,PTR
,PTR
))) bfd_void
, /* sym_in */
3606 (void (*) PARAMS ((bfd
*,PTR
,PTR
))) bfd_void
, /* lineno_in */
3607 (unsigned (*) PARAMS ((bfd
*,PTR
,int,int,PTR
))) bfd_void
, /* aux_out */
3608 (unsigned (*) PARAMS ((bfd
*,PTR
,PTR
))) bfd_void
, /* sym_out */
3609 (unsigned (*) PARAMS ((bfd
*,PTR
,PTR
))) bfd_void
, /* lineno_out */
3610 ecoff_swap_reloc_out
, ecoff_swap_filehdr_out
, ecoff_swap_aouthdr_out
,
3611 ecoff_swap_scnhdr_out
,
3612 FILHSZ
, AOUTSZ
, SCNHSZ
, 0, 0, 0, true,
3613 ecoff_swap_filehdr_in
, ecoff_swap_aouthdr_in
, ecoff_swap_scnhdr_in
,
3614 ecoff_bad_format_hook
, ecoff_set_arch_mach_hook
, ecoff_mkobject_hook
,
3615 styp_to_sec_flags
, ecoff_make_section_hook
, ecoff_set_alignment_hook
,
3616 ecoff_slurp_symbol_table
3619 /* get_lineno could be written for ECOFF, but it would currently only
3620 be useful for linking ECOFF and COFF files together, which doesn't
3622 #define ecoff_get_lineno \
3623 ((alent *(*) PARAMS ((bfd *, asymbol *))) bfd_nullvoidptr)
3625 #define ecoff_core_file_failing_command _bfd_dummy_core_file_failing_command
3626 #define ecoff_core_file_failing_signal _bfd_dummy_core_file_failing_signal
3627 #define ecoff_core_file_matches_executable_p _bfd_dummy_core_file_matches_executable_p
3628 #define ecoff_truncate_arname bfd_dont_truncate_arname
3629 #define ecoff_openr_next_archived_file bfd_generic_openr_next_archived_file
3630 #define ecoff_generic_stat_arch_elt bfd_generic_stat_arch_elt
3631 #define ecoff_get_section_contents bfd_generic_get_section_contents
3632 #define ecoff_get_reloc_upper_bound coff_get_reloc_upper_bound
3633 #define ecoff_close_and_cleanup bfd_generic_close_and_cleanup
3634 #define ecoff_sizeof_headers coff_sizeof_headers
3635 #define ecoff_bfd_debug_info_start bfd_void
3636 #define ecoff_bfd_debug_info_end bfd_void
3637 #define ecoff_bfd_debug_info_accumulate \
3638 ((void (*) PARAMS ((bfd *, struct sec *))) bfd_void)
3639 #define ecoff_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents
3640 #define ecoff_bfd_relax_section bfd_generic_relax_section
3642 bfd_target ecoff_little_vec
=
3644 "ecoff-littlemips", /* name */
3645 bfd_target_ecoff_flavour
,
3646 false, /* data byte order is little */
3647 false, /* header byte order is little */
3649 (HAS_RELOC
| EXEC_P
| /* object flags */
3650 HAS_LINENO
| HAS_DEBUG
|
3651 HAS_SYMS
| HAS_LOCALS
| DYNAMIC
| WP_TEXT
),
3653 (SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
), /* sect
3655 0, /* leading underscore */
3656 '/', /* ar_pad_char */
3657 15, /* ar_max_namelen */
3658 3, /* minimum alignment power */
3659 _do_getl64
, _do_putl64
, _do_getl32
, _do_putl32
, _do_getl16
, _do_putl16
, /* data */
3660 _do_getl64
, _do_putl64
, _do_getl32
, _do_putl32
, _do_getl16
, _do_putl16
, /* hdrs */
3662 {_bfd_dummy_target
, coff_object_p
, /* bfd_check_format */
3663 ecoff_archive_p
, _bfd_dummy_target
},
3664 {bfd_false
, ecoff_mkobject
, _bfd_generic_mkarchive
, /* bfd_set_format */
3666 {bfd_false
, ecoff_write_object_contents
, /* bfd_write_contents */
3667 _bfd_write_archive_contents
, bfd_false
},
3670 (PTR
) &bfd_ecoff_std_swap_table
3673 bfd_target ecoff_big_vec
=
3675 "ecoff-bigmips", /* name */
3676 bfd_target_ecoff_flavour
,
3677 true, /* data byte order is big */
3678 true, /* header byte order is big */
3680 (HAS_RELOC
| EXEC_P
| /* object flags */
3681 HAS_LINENO
| HAS_DEBUG
|
3682 HAS_SYMS
| HAS_LOCALS
| DYNAMIC
| WP_TEXT
),
3684 (SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
), /* sect flags */
3685 0, /* leading underscore */
3686 ' ', /* ar_pad_char */
3687 16, /* ar_max_namelen */
3688 3, /* minimum alignment power */
3689 _do_getb64
, _do_putb64
, _do_getb32
, _do_putb32
, _do_getb16
, _do_putb16
,
3690 _do_getb64
, _do_putb64
, _do_getb32
, _do_putb32
, _do_getb16
, _do_putb16
,
3691 {_bfd_dummy_target
, coff_object_p
, /* bfd_check_format */
3692 ecoff_archive_p
, _bfd_dummy_target
},
3693 {bfd_false
, ecoff_mkobject
, _bfd_generic_mkarchive
, /* bfd_set_format */
3695 {bfd_false
, ecoff_write_object_contents
, /* bfd_write_contents */
3696 _bfd_write_archive_contents
, bfd_false
},
3699 (PTR
) &bfd_ecoff_std_swap_table
3700 /* Note that there is another bfd_target just above this one. If
3701 you are adding initializers here, you should be adding them there