1 /* BFD back-end for MIPS Extended-Coff files.
2 Copyright 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
3 Original version by Per Bothner.
4 Full support added by Ian Lance Taylor, ian@cygnus.com.
6 This file is part of BFD, the Binary File Descriptor library.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
27 #include "aout/ranlib.h"
29 /* FIXME: We need the definitions of N_SET[ADTB], but aout64.h defines
30 some other stuff which we don't want and which conflicts with stuff
33 #include "aout/aout64.h"
38 #undef obj_sym_filepos
40 #include "coff/mips.h"
41 #include "coff/internal.h"
43 #include "coff/symconst.h"
44 #include "coff/ecoff-ext.h"
48 /* Each canonical asymbol really looks like this. */
50 typedef struct ecoff_symbol_struct
52 /* The actual symbol which the rest of BFD works with */
55 /* The fdr for this symbol. */
58 /* true if this is a local symbol rather than an external one. */
61 /* A pointer to the unswapped hidden information for this symbol */
64 struct sym_ext
*lnative
;
65 struct ext_ext
*enative
;
70 /* We take the address of the first element of a asymbol to ensure that the
71 macro is only ever applied to an asymbol. */
72 #define ecoffsymbol(asymbol) ((ecoff_symbol_type *) (&((asymbol)->the_bfd)))
74 /* The page boundary used to align sections in the executable file. */
75 #define ROUND_SIZE 0x1000
77 /* The linker needs a section to hold small common variables while
78 linking. There is no convenient way to create it when the linker
79 needs it, so we always create one for each BFD. We then avoid
81 #define SCOMMON ".scommon"
83 /* MIPS ECOFF has COFF sections, but the debugging information is
84 stored in a completely different format. This files uses the some
85 of the swapping routines from coffswap.h, and some of the generic
86 COFF routines in coffgen.c, but, unlike the real COFF targets, does
87 not use coffcode.h itself. */
89 /* Prototypes for static functions. */
91 static boolean ecoff_bad_format_hook
PARAMS ((bfd
*abfd
, PTR filehdr
));
92 static asection
*ecoff_make_section_hook
PARAMS ((bfd
*abfd
, char *name
));
93 static boolean ecoff_new_section_hook
PARAMS ((bfd
*abfd
, asection
*section
));
94 static boolean ecoff_mkobject
PARAMS ((bfd
*abfd
));
95 static PTR ecoff_mkobject_hook
PARAMS ((bfd
*abfd
, PTR filehdr
, PTR aouthdr
));
96 static boolean ecoff_set_arch_mach_hook
PARAMS ((bfd
*abfd
, PTR filehdr
));
97 static long ecoff_sec_to_styp_flags
PARAMS ((CONST
char *name
,
99 static flagword ecoff_styp_to_sec_flags
PARAMS ((bfd
*abfd
, PTR hdr
));
100 static asymbol
*ecoff_make_empty_symbol
PARAMS ((bfd
*abfd
));
101 static void ecoff_set_symbol_info
PARAMS ((bfd
*abfd
, SYMR
*ecoff_sym
,
102 asymbol
*asym
, int ext
,
103 asymbol
**indirect_ptr_ptr
));
104 static boolean ecoff_slurp_symbol_table
PARAMS ((bfd
*abfd
));
105 static unsigned int ecoff_get_symtab_upper_bound
PARAMS ((bfd
*abfd
));
106 static unsigned int ecoff_get_symtab
PARAMS ((bfd
*abfd
,
107 asymbol
**alocation
));
108 static void ecoff_emit_aggregate
PARAMS ((bfd
*abfd
, char *string
,
109 RNDXR
*rndx
, long isym
,
111 static char *ecoff_type_to_string
PARAMS ((bfd
*abfd
, union aux_ext
*aux_ptr
,
112 int indx
, int bigendian
));
113 static void ecoff_print_symbol
PARAMS ((bfd
*abfd
, PTR filep
,
115 bfd_print_symbol_type how
));
116 static void ecoff_get_symbol_info
PARAMS ((bfd
*abfd
,
119 static void ecoff_swap_reloc_in
PARAMS ((bfd
*abfd
, RELOC
*ext
,
120 struct internal_reloc
*intern
));
121 static unsigned int ecoff_swap_reloc_out
PARAMS ((bfd
*abfd
, PTR src
,
123 static bfd_reloc_status_type ecoff_generic_reloc
PARAMS ((bfd
*abfd
,
129 static bfd_reloc_status_type ecoff_refhi_reloc
PARAMS ((bfd
*abfd
,
135 static bfd_reloc_status_type ecoff_reflo_reloc
PARAMS ((bfd
*abfd
,
141 static bfd_reloc_status_type ecoff_gprel_reloc
PARAMS ((bfd
*abfd
,
147 static boolean ecoff_slurp_reloc_table
PARAMS ((bfd
*abfd
, asection
*section
,
149 static unsigned int ecoff_canonicalize_reloc
PARAMS ((bfd
*abfd
,
153 static CONST
struct reloc_howto_struct
*ecoff_bfd_reloc_type_lookup
154 PARAMS ((bfd
*abfd
, bfd_reloc_code_real_type code
));
155 static boolean ecoff_find_nearest_line
PARAMS ((bfd
*abfd
,
159 CONST
char **filename_ptr
,
160 CONST
char **fnname_ptr
,
161 unsigned int *retline_ptr
));
162 static void ecoff_clear_output_flags
PARAMS ((bfd
*abfd
));
163 static boolean ecoff_rel
PARAMS ((bfd
*output_bfd
, bfd_seclet_type
*seclet
,
164 asection
*output_section
, PTR data
,
165 boolean relocateable
));
166 static boolean ecoff_dump_seclet
PARAMS ((bfd
*abfd
, bfd_seclet_type
*seclet
,
167 asection
*section
, PTR data
,
168 boolean relocateable
));
169 static long ecoff_add_string
PARAMS ((bfd
*output_bfd
, FDR
*fdr
,
170 CONST
char *string
, boolean external
));
171 static boolean ecoff_get_debug
PARAMS ((bfd
*output_bfd
,
172 bfd_seclet_type
*seclet
,
174 boolean relocateable
));
175 static boolean ecoff_bfd_seclet_link
PARAMS ((bfd
*abfd
, PTR data
,
176 boolean relocateable
));
177 static boolean ecoff_set_arch_mach
PARAMS ((bfd
*abfd
,
178 enum bfd_architecture arch
,
179 unsigned long machine
));
180 static int ecoff_sizeof_headers
PARAMS ((bfd
*abfd
, boolean reloc
));
181 static void ecoff_compute_section_file_positions
PARAMS ((bfd
*abfd
));
182 static boolean ecoff_set_section_contents
PARAMS ((bfd
*abfd
,
186 bfd_size_type count
));
187 static boolean ecoff_write_object_contents
PARAMS ((bfd
*abfd
));
188 static unsigned int ecoff_armap_hash
PARAMS ((CONST
char *s
,
189 unsigned int *rehash
,
192 static boolean ecoff_slurp_armap
PARAMS ((bfd
*abfd
));
193 static boolean ecoff_write_armap
PARAMS ((bfd
*abfd
, unsigned int elength
,
195 unsigned int orl_count
,
197 static bfd_target
*ecoff_archive_p
PARAMS ((bfd
*abfd
));
199 /* Get the generic COFF swapping routines, except for the reloc,
200 symbol, and lineno ones. Give them ecoff names. */
202 #define NO_COFF_RELOCS
203 #define NO_COFF_SYMBOLS
204 #define NO_COFF_LINENOS
205 #define coff_swap_filehdr_in ecoff_swap_filehdr_in
206 #define coff_swap_filehdr_out ecoff_swap_filehdr_out
207 #define coff_swap_aouthdr_in ecoff_swap_aouthdr_in
208 #define coff_swap_aouthdr_out ecoff_swap_aouthdr_out
209 #define coff_swap_scnhdr_in ecoff_swap_scnhdr_in
210 #define coff_swap_scnhdr_out ecoff_swap_scnhdr_out
211 #include "coffswap.h"
213 /* How to process the various relocs types. */
215 static reloc_howto_type ecoff_howto_table
[] =
217 /* Reloc type 0 is ignored. The reloc reading code ensures that
218 this is a reference to the .abs section, which will cause
219 bfd_perform_relocation to do nothing. */
220 HOWTO (ECOFF_R_IGNORE
, /* type */
222 0, /* size (0 = byte, 1 = short, 2 = long) */
223 8, /* bitsize (obsolete) */
224 false, /* pc_relative */
226 false, /* absolute (obsolete) */
227 false, /* complain_on_overflow */
228 0, /* special_function */
230 false, /* partial_inplace */
233 false), /* pcrel_offset */
235 /* A 16 bit reference to a symbol, normally from a data section. */
236 HOWTO (ECOFF_R_REFHALF
, /* type */
238 1, /* size (0 = byte, 1 = short, 2 = long) */
239 16, /* bitsize (obsolete) */
240 false, /* pc_relative */
242 false, /* absolute (obsolete) */
243 true, /* complain_on_overflow */
244 ecoff_generic_reloc
, /* special_function */
245 "REFHALF", /* name */
246 true, /* partial_inplace */
247 0xffff, /* src_mask */
248 0xffff, /* dst_mask */
249 false), /* pcrel_offset */
251 /* A 32 bit reference to a symbol, normally from a data section. */
252 HOWTO (ECOFF_R_REFWORD
, /* type */
254 2, /* size (0 = byte, 1 = short, 2 = long) */
255 32, /* bitsize (obsolete) */
256 false, /* pc_relative */
258 false, /* absolute (obsolete) */
259 true, /* complain_on_overflow */
260 ecoff_generic_reloc
, /* special_function */
261 "REFWORD", /* name */
262 true, /* partial_inplace */
263 0xffffffff, /* src_mask */
264 0xffffffff, /* dst_mask */
265 false), /* pcrel_offset */
267 /* A 26 bit absolute jump address. */
268 HOWTO (ECOFF_R_JMPADDR
, /* type */
270 2, /* size (0 = byte, 1 = short, 2 = long) */
271 32, /* bitsize (obsolete) */
272 false, /* pc_relative */
274 false, /* absolute (obsolete) */
275 true, /* complain_on_overflow */
276 ecoff_generic_reloc
, /* special_function */
277 "JMPADDR", /* name */
278 true, /* partial_inplace */
279 0x3ffffff, /* src_mask */
280 0x3ffffff, /* dst_mask */
281 false), /* pcrel_offset */
283 /* The high 16 bits of a symbol value. Handled by the function
284 ecoff_refhi_reloc. */
285 HOWTO (ECOFF_R_REFHI
, /* type */
287 2, /* size (0 = byte, 1 = short, 2 = long) */
288 32, /* bitsize (obsolete) */
289 false, /* pc_relative */
291 false, /* absolute (obsolete) */
292 true, /* complain_on_overflow */
293 ecoff_refhi_reloc
, /* special_function */
295 true, /* partial_inplace */
296 0xffff, /* src_mask */
297 0xffff, /* dst_mask */
298 false), /* pcrel_offset */
300 /* The low 16 bits of a symbol value. */
301 HOWTO (ECOFF_R_REFLO
, /* type */
303 2, /* size (0 = byte, 1 = short, 2 = long) */
304 32, /* bitsize (obsolete) */
305 false, /* pc_relative */
307 false, /* absolute (obsolete) */
308 true, /* complain_on_overflow */
309 ecoff_reflo_reloc
, /* special_function */
311 true, /* partial_inplace */
312 0xffff, /* src_mask */
313 0xffff, /* dst_mask */
314 false), /* pcrel_offset */
316 /* A reference to an offset from the gp register. Handled by the
317 function ecoff_gprel_reloc. */
318 HOWTO (ECOFF_R_GPREL
, /* type */
320 2, /* size (0 = byte, 1 = short, 2 = long) */
321 32, /* bitsize (obsolete) */
322 false, /* pc_relative */
324 false, /* absolute (obsolete) */
325 true, /* complain_on_overflow */
326 ecoff_gprel_reloc
, /* special_function */
328 true, /* partial_inplace */
329 0xffff, /* src_mask */
330 0xffff, /* dst_mask */
331 false), /* pcrel_offset */
333 /* A reference to a literal using an offset from the gp register.
334 Handled by the function ecoff_gprel_reloc. */
335 HOWTO (ECOFF_R_LITERAL
, /* type */
337 2, /* size (0 = byte, 1 = short, 2 = long) */
338 32, /* bitsize (obsolete) */
339 false, /* pc_relative */
341 false, /* absolute (obsolete) */
342 true, /* complain_on_overflow */
343 ecoff_gprel_reloc
, /* special_function */
344 "LITERAL", /* name */
345 true, /* partial_inplace */
346 0xffff, /* src_mask */
347 0xffff, /* dst_mask */
348 false) /* pcrel_offset */
351 #define ECOFF_HOWTO_COUNT \
352 (sizeof ecoff_howto_table / sizeof ecoff_howto_table[0])
354 /* This stuff is somewhat copied from coffcode.h. */
356 static asection bfd_debug_section
= { "*DEBUG*" };
358 /* See whether the magic number matches. */
361 ecoff_bad_format_hook (abfd
, filehdr
)
365 struct internal_filehdr
*internal_f
= (struct internal_filehdr
*) filehdr
;
367 if (ECOFFBADMAG (*internal_f
))
373 /* This is a hook needed by SCO COFF, but we have nothing to do. */
376 ecoff_make_section_hook (abfd
, name
)
380 return (asection
*) NULL
;
383 /* Initialize a new section. */
386 ecoff_new_section_hook (abfd
, section
)
390 section
->alignment_power
= abfd
->xvec
->align_power_min
;
392 if (strcmp (section
->name
, _TEXT
) == 0)
393 section
->flags
|= SEC_CODE
| SEC_LOAD
| SEC_ALLOC
;
394 else if (strcmp (section
->name
, _DATA
) == 0
395 || strcmp (section
->name
, _SDATA
) == 0)
396 section
->flags
|= SEC_DATA
| SEC_LOAD
| SEC_ALLOC
;
397 else if (strcmp (section
->name
, _RDATA
) == 0
398 || strcmp (section
->name
, _LIT8
) == 0
399 || strcmp (section
->name
, _LIT4
) == 0)
400 section
->flags
|= SEC_DATA
| SEC_LOAD
| SEC_ALLOC
| SEC_READONLY
;
401 else if (strcmp (section
->name
, _BSS
) == 0
402 || strcmp (section
->name
, _SBSS
) == 0)
403 section
->flags
|= SEC_ALLOC
;
405 /* Probably any other section name is SEC_NEVER_LOAD, but I'm
406 uncertain about .init on some systems and I don't know how shared
412 /* Set the alignment of a section; we have nothing to do. */
414 #define ecoff_set_alignment_hook \
415 ((void (*) PARAMS ((bfd *, asection *, PTR))) bfd_void)
417 /* Create an ECOFF object. */
420 ecoff_mkobject (abfd
)
423 abfd
->tdata
.ecoff_obj_data
= ((struct ecoff_tdata
*)
424 bfd_zalloc (abfd
, sizeof (ecoff_data_type
)));
425 if (abfd
->tdata
.ecoff_obj_data
== NULL
)
427 bfd_error
= no_memory
;
431 /* Always create a .scommon section for every BFD. This is a hack so
432 that the linker has something to attach scSCommon symbols to. */
433 bfd_make_section (abfd
, SCOMMON
);
438 /* Create the ECOFF backend specific information. */
441 ecoff_mkobject_hook (abfd
, filehdr
, aouthdr
)
446 struct internal_filehdr
*internal_f
= (struct internal_filehdr
*) filehdr
;
447 struct internal_aouthdr
*internal_a
= (struct internal_aouthdr
*) aouthdr
;
448 ecoff_data_type
*ecoff
;
450 if (ecoff_mkobject (abfd
) == false)
453 ecoff
= ecoff_data (abfd
);
455 ecoff
->sym_filepos
= internal_f
->f_symptr
;
457 if (internal_a
!= (struct internal_aouthdr
*) NULL
)
461 ecoff
->text_start
= internal_a
->text_start
;
462 ecoff
->text_end
= internal_a
->text_start
+ internal_a
->tsize
;
463 ecoff
->gp
= internal_a
->gp_value
;
464 ecoff
->gprmask
= internal_a
->gprmask
;
465 for (i
= 0; i
< 4; i
++)
466 ecoff
->cprmask
[i
] = internal_a
->cprmask
[i
];
467 if (internal_a
->magic
== ZMAGIC
)
468 abfd
->flags
|= D_PAGED
;
474 /* Determine the machine architecture and type. */
477 ecoff_set_arch_mach_hook (abfd
, filehdr
)
481 struct internal_filehdr
*internal_f
= (struct internal_filehdr
*) filehdr
;
482 enum bfd_architecture arch
;
484 switch (internal_f
->f_magic
)
487 case MIPS_MAGIC_LITTLE
:
489 arch
= bfd_arch_mips
;
493 arch
= bfd_arch_obscure
;
497 bfd_default_set_arch_mach (abfd
, arch
, (unsigned long) 0);
502 /* Get the section s_flags to use for a section. */
505 ecoff_sec_to_styp_flags (name
, flags
)
513 if (strcmp (name
, _TEXT
) == 0)
515 else if (strcmp (name
, _DATA
) == 0)
517 else if (strcmp (name
, _SDATA
) == 0)
519 else if (strcmp (name
, _RDATA
) == 0)
521 else if (strcmp (name
, _LIT8
) == 0)
523 else if (strcmp (name
, _LIT4
) == 0)
525 else if (strcmp (name
, _BSS
) == 0)
527 else if (strcmp (name
, _SBSS
) == 0)
529 else if (strcmp (name
, _INIT
) == 0)
530 styp
= STYP_MIPS_INIT
;
531 else if (flags
& SEC_CODE
)
533 else if (flags
& SEC_DATA
)
535 else if (flags
& SEC_READONLY
)
537 else if (flags
& SEC_LOAD
)
542 if (flags
& SEC_NEVER_LOAD
)
548 /* Get the BFD flags to use for a section. */
551 ecoff_styp_to_sec_flags (abfd
, hdr
)
555 struct internal_scnhdr
*internal_s
= (struct internal_scnhdr
*) hdr
;
556 long styp_flags
= internal_s
->s_flags
;
557 flagword sec_flags
=0;
559 if (styp_flags
& STYP_NOLOAD
)
560 sec_flags
|= SEC_NEVER_LOAD
;
562 /* For 386 COFF, at least, an unloadable text or data section is
563 actually a shared library section. */
564 if ((styp_flags
& STYP_TEXT
)
565 || (stype_FLAGS
& STYP_MIPS_INIT
))
567 if (sec_flags
& SEC_NEVER_LOAD
)
568 sec_flags
|= SEC_CODE
| SEC_SHARED_LIBRARY
;
570 sec_flags
|= SEC_CODE
| SEC_LOAD
| SEC_ALLOC
;
572 else if ((styp_flags
& STYP_DATA
)
573 || (styp_flags
& STYP_RDATA
)
574 || (styp_flags
& STYP_SDATA
))
576 if (sec_flags
& SEC_NEVER_LOAD
)
577 sec_flags
|= SEC_DATA
| SEC_SHARED_LIBRARY
;
579 sec_flags
|= SEC_DATA
| SEC_LOAD
| SEC_ALLOC
;
580 if (styp_flags
& STYP_RDATA
)
581 sec_flags
|= SEC_READONLY
;
583 else if ((styp_flags
& STYP_BSS
)
584 || (styp_flags
& STYP_SBSS
))
586 sec_flags
|= SEC_ALLOC
;
588 else if (styp_flags
& STYP_INFO
)
590 sec_flags
|= SEC_NEVER_LOAD
;
592 else if ((styp_flags
& STYP_LIT8
)
593 || (styp_flags
& STYP_LIT4
))
595 sec_flags
|= SEC_DATA
| SEC_LOAD
| SEC_ALLOC
| SEC_READONLY
;
599 sec_flags
|= SEC_ALLOC
| SEC_LOAD
;
605 /* Read in and swap the important symbolic information for an ECOFF
606 object file. FIXME: This is called by gdb. If there is ever
607 another ECOFF target, it should be moved into some sort of target
608 specific structure. */
611 ecoff_slurp_symbolic_info (abfd
)
614 struct hdr_ext external_symhdr
;
615 HDRR
*internal_symhdr
;
616 bfd_size_type raw_base
;
617 bfd_size_type raw_size
;
619 struct fdr_ext
*fraw_src
;
620 struct fdr_ext
*fraw_end
;
623 /* Check whether we've already gotten it, and whether there's any to
625 if (ecoff_data (abfd
)->raw_syments
!= (PTR
) NULL
)
627 if (ecoff_data (abfd
)->sym_filepos
== 0)
629 bfd_get_symcount (abfd
) = 0;
633 /* At this point bfd_get_symcount (abfd) holds the number of symbols
634 as read from the file header, but on ECOFF this is always the
635 size of the symbolic information header. It would be cleaner to
636 handle this when we first read the file in coffgen.c. */
637 if (bfd_get_symcount (abfd
) != sizeof (external_symhdr
))
639 bfd_error
= bad_value
;
643 /* Read the symbolic information header. */
644 if (bfd_seek (abfd
, ecoff_data (abfd
)->sym_filepos
, SEEK_SET
) == -1
645 || (bfd_read ((PTR
) &external_symhdr
, sizeof (external_symhdr
), 1, abfd
)
646 != sizeof (external_symhdr
)))
648 bfd_error
= system_call_error
;
651 internal_symhdr
= &ecoff_data (abfd
)->symbolic_header
;
652 ecoff_swap_hdr_in (abfd
, &external_symhdr
, internal_symhdr
);
654 if (internal_symhdr
->magic
!= magicSym
)
656 bfd_error
= bad_value
;
660 /* Now we can get the correct number of symbols. */
661 bfd_get_symcount (abfd
) = (internal_symhdr
->isymMax
662 + internal_symhdr
->iextMax
);
664 /* Read all the symbolic information at once. */
665 raw_base
= ecoff_data (abfd
)->sym_filepos
+ sizeof (struct hdr_ext
);
667 if (internal_symhdr
->cbExtOffset
!= 0)
668 raw_size
= (internal_symhdr
->cbExtOffset
670 + internal_symhdr
->iextMax
* sizeof (struct ext_ext
));
673 long cbline
, issmax
, issextmax
;
675 cbline
= (internal_symhdr
->cbLine
+ 3) &~ 3;
676 issmax
= (internal_symhdr
->issMax
+ 3) &~ 3;
677 issextmax
= (internal_symhdr
->issExtMax
+ 3) &~ 3;
678 raw_size
= (cbline
* sizeof (unsigned char)
679 + internal_symhdr
->idnMax
* sizeof (struct dnr_ext
)
680 + internal_symhdr
->ipdMax
* sizeof (struct pdr_ext
)
681 + internal_symhdr
->isymMax
* sizeof (struct sym_ext
)
682 + internal_symhdr
->ioptMax
* sizeof (struct opt_ext
)
683 + internal_symhdr
->iauxMax
* sizeof (union aux_ext
)
684 + issmax
* sizeof (char)
685 + issextmax
* sizeof (char)
686 + internal_symhdr
->ifdMax
* sizeof (struct fdr_ext
)
687 + internal_symhdr
->crfd
* sizeof (struct rfd_ext
)
688 + internal_symhdr
->iextMax
* sizeof (struct ext_ext
));
693 ecoff_data (abfd
)->sym_filepos
= 0;
696 raw
= (PTR
) bfd_alloc (abfd
, raw_size
);
699 bfd_error
= no_memory
;
702 if (bfd_read (raw
, raw_size
, 1, abfd
) != raw_size
)
704 bfd_error
= system_call_error
;
705 bfd_release (abfd
, raw
);
709 ecoff_data (abfd
)->raw_size
= raw_size
;
710 ecoff_data (abfd
)->raw_syments
= raw
;
712 /* Get pointers for the numeric offsets in the HDRR structure. */
713 #define FIX(off1, off2, type) \
714 if (internal_symhdr->off1 == 0) \
715 ecoff_data (abfd)->off2 = (type *) NULL; \
717 ecoff_data (abfd)->off2 = (type *) ((char *) raw \
718 + internal_symhdr->off1 \
720 FIX (cbLineOffset
, line
, unsigned char);
721 FIX (cbDnOffset
, external_dnr
, struct dnr_ext
);
722 FIX (cbPdOffset
, external_pdr
, struct pdr_ext
);
723 FIX (cbSymOffset
, external_sym
, struct sym_ext
);
724 FIX (cbOptOffset
, external_opt
, struct opt_ext
);
725 FIX (cbAuxOffset
, external_aux
, union aux_ext
);
726 FIX (cbSsOffset
, ss
, char);
727 FIX (cbSsExtOffset
, ssext
, char);
728 FIX (cbFdOffset
, external_fdr
, struct fdr_ext
);
729 FIX (cbRfdOffset
, external_rfd
, struct rfd_ext
);
730 FIX (cbExtOffset
, external_ext
, struct ext_ext
);
733 /* I don't want to always swap all the data, because it will just
734 waste time and most programs will never look at it. The only
735 time the linker needs most of the debugging information swapped
736 is when linking big-endian and little-endian MIPS object files
737 together, which is not a common occurrence.
739 We need to look at the fdr to deal with a lot of information in
740 the symbols, so we swap them here. */
741 ecoff_data (abfd
)->fdr
= (struct fdr
*) bfd_alloc (abfd
,
742 (internal_symhdr
->ifdMax
*
743 sizeof (struct fdr
)));
744 if (ecoff_data (abfd
)->fdr
== NULL
)
746 bfd_error
= no_memory
;
749 fdr_ptr
= ecoff_data (abfd
)->fdr
;
750 fraw_src
= ecoff_data (abfd
)->external_fdr
;
751 fraw_end
= fraw_src
+ internal_symhdr
->ifdMax
;
752 for (; fraw_src
< fraw_end
; fraw_src
++, fdr_ptr
++)
753 ecoff_swap_fdr_in (abfd
, fraw_src
, fdr_ptr
);
758 /* ECOFF symbol table routines. The ECOFF symbol table is described
759 in gcc/mips-tfile.c. */
761 /* ECOFF uses two common sections. One is the usual one, and the
762 other is for small objects. All the small objects are kept
763 together, and then referenced via the gp pointer, which yields
764 faster assembler code. This is what we use for the small common
766 static asection ecoff_scom_section
;
767 static asymbol ecoff_scom_symbol
;
768 static asymbol
*ecoff_scom_symbol_ptr
;
770 /* Create an empty symbol. */
773 ecoff_make_empty_symbol (abfd
)
776 ecoff_symbol_type
*new;
778 new = (ecoff_symbol_type
*) bfd_alloc (abfd
, sizeof (ecoff_symbol_type
));
779 if (new == (ecoff_symbol_type
*) NULL
)
781 bfd_error
= no_memory
;
782 return (asymbol
*) NULL
;
784 memset (new, 0, sizeof *new);
785 new->symbol
.section
= (asection
*) NULL
;
786 new->fdr
= (FDR
*) NULL
;
788 new->native
.lnative
= (struct sym_ext
*) NULL
;
789 new->symbol
.the_bfd
= abfd
;
793 /* Set the BFD flags and section for an ECOFF symbol. */
796 ecoff_set_symbol_info (abfd
, ecoff_sym
, asym
, ext
, indirect_ptr_ptr
)
801 asymbol
**indirect_ptr_ptr
;
803 asym
->the_bfd
= abfd
;
804 asym
->value
= ecoff_sym
->value
;
805 asym
->section
= &bfd_debug_section
;
808 /* An indirect symbol requires two consecutive stabs symbols. */
809 if (*indirect_ptr_ptr
!= (asymbol
*) NULL
)
811 BFD_ASSERT (MIPS_IS_STAB (ecoff_sym
));
812 (*indirect_ptr_ptr
)->value
= (bfd_vma
) asym
;
813 asym
->flags
= BSF_DEBUGGING
;
814 asym
->section
= &bfd_und_section
;
815 *indirect_ptr_ptr
= NULL
;
819 if (MIPS_IS_STAB (ecoff_sym
)
820 && (MIPS_UNMARK_STAB (ecoff_sym
->index
) | N_EXT
) == (N_INDR
| N_EXT
))
822 asym
->flags
= BSF_DEBUGGING
| BSF_INDIRECT
;
823 asym
->section
= &bfd_ind_section
;
824 /* Pass this symbol on to the next call to this function. */
825 *indirect_ptr_ptr
= asym
;
829 /* Most symbol types are just for debugging. */
830 switch (ecoff_sym
->st
)
839 if (MIPS_IS_STAB (ecoff_sym
))
841 asym
->flags
= BSF_DEBUGGING
;
846 asym
->flags
= BSF_DEBUGGING
;
851 asym
->flags
= BSF_EXPORT
| BSF_GLOBAL
;
853 asym
->flags
= BSF_LOCAL
;
854 switch (ecoff_sym
->sc
)
857 /* Used for compiler generated labels. Leave them in the
858 debugging section, and mark them as local. If BSF_DEBUGGING
859 is set, then nm does not display them for some reason. If no
860 flags are set then the linker whines about them. */
861 asym
->flags
= BSF_LOCAL
;
864 asym
->section
= bfd_make_section_old_way (abfd
, ".text");
865 asym
->value
-= asym
->section
->vma
;
868 asym
->section
= bfd_make_section_old_way (abfd
, ".data");
869 asym
->value
-= asym
->section
->vma
;
874 asym
->section
= &bfd_com_section
;
879 asym
->section
= bfd_make_section_old_way (abfd
, ".bss");
880 asym
->value
-= asym
->section
->vma
;
884 asym
->flags
= BSF_DEBUGGING
;
887 asym
->section
= &bfd_abs_section
;
890 asym
->section
= &bfd_und_section
;
900 asym
->flags
= BSF_DEBUGGING
;
903 asym
->section
= bfd_make_section_old_way (abfd
, ".sdata");
904 asym
->value
-= asym
->section
->vma
;
907 asym
->section
= bfd_make_section_old_way (abfd
, ".sbss");
909 asym
->value
-= asym
->section
->vma
;
912 asym
->section
= bfd_make_section_old_way (abfd
, ".rdata");
913 asym
->value
-= asym
->section
->vma
;
916 asym
->flags
= BSF_DEBUGGING
;
919 if (asym
->value
> ecoff_data (abfd
)->gp_size
)
921 asym
->section
= &bfd_com_section
;
927 if (ecoff_scom_section
.name
== NULL
)
929 /* Initialize the small common section. */
930 ecoff_scom_section
.name
= SCOMMON
;
931 ecoff_scom_section
.flags
= SEC_IS_COMMON
;
932 ecoff_scom_section
.output_section
= &ecoff_scom_section
;
933 ecoff_scom_section
.symbol
= &ecoff_scom_symbol
;
934 ecoff_scom_section
.symbol_ptr_ptr
= &ecoff_scom_symbol_ptr
;
935 ecoff_scom_symbol
.name
= SCOMMON
;
936 ecoff_scom_symbol
.flags
= BSF_SECTION_SYM
;
937 ecoff_scom_symbol
.section
= &ecoff_scom_section
;
938 ecoff_scom_symbol_ptr
= &ecoff_scom_symbol
;
940 asym
->section
= &ecoff_scom_section
;
945 asym
->flags
= BSF_DEBUGGING
;
948 asym
->section
= &bfd_und_section
;
953 asym
->section
= bfd_make_section_old_way (abfd
, ".init");
954 asym
->value
-= asym
->section
->vma
;
959 asym
->flags
= BSF_DEBUGGING
;
962 asym
->section
= bfd_make_section_old_way (abfd
, ".fini");
963 asym
->value
-= asym
->section
->vma
;
969 /* Look for special constructors symbols and make relocation entries
970 in a special construction section. These are produced by the
971 -fgnu-linker argument to g++. */
972 if (MIPS_IS_STAB (ecoff_sym
))
974 switch (MIPS_UNMARK_STAB (ecoff_sym
->index
))
986 arelent_chain
*reloc_chain
;
988 /* Get a section with the same name as the symbol (usually
989 __CTOR_LIST__ or __DTOR_LIST__). FIXME: gcc uses the
990 name ___CTOR_LIST (three underscores). We need
991 __CTOR_LIST (two underscores), since ECOFF doesn't use
992 a leading underscore. This should be handled by gcc,
993 but instead we do it here. Actually, this should all
994 be done differently anyhow. */
995 name
= bfd_asymbol_name (asym
);
996 if (name
[0] == '_' && name
[1] == '_' && name
[2] == '_')
1001 section
= bfd_get_section_by_name (abfd
, name
);
1002 if (section
== (asection
*) NULL
)
1006 copy
= (char *) bfd_alloc (abfd
, strlen (name
) + 1);
1007 strcpy (copy
, name
);
1008 section
= bfd_make_section (abfd
, copy
);
1011 /* Build a reloc pointing to this constructor. */
1012 reloc_chain
= (arelent_chain
*) bfd_alloc (abfd
,
1013 sizeof (arelent_chain
));
1014 reloc_chain
->relent
.sym_ptr_ptr
=
1015 bfd_get_section (asym
)->symbol_ptr_ptr
;
1016 reloc_chain
->relent
.address
= section
->_raw_size
;
1017 reloc_chain
->relent
.addend
= asym
->value
;
1019 /* FIXME: Assumes 32 bit __CTOR_LIST__ entries. */
1020 reloc_chain
->relent
.howto
= ecoff_howto_table
+ ECOFF_R_REFWORD
;
1022 /* Set up the constructor section to hold the reloc. */
1023 section
->flags
= SEC_CONSTRUCTOR
;
1024 ++section
->reloc_count
;
1025 section
->alignment_power
= 4;
1026 reloc_chain
->next
= section
->constructor_chain
;
1027 section
->constructor_chain
= reloc_chain
;
1029 /* FIXME: Assumes 32 bit __CTOR_LIST__ entries. */
1030 section
->_raw_size
+= 4;
1032 /* Mark the symbol as a constructor. */
1033 asym
->flags
|= BSF_CONSTRUCTOR
;
1040 /* Read an ECOFF symbol table. */
1043 ecoff_slurp_symbol_table (abfd
)
1046 bfd_size_type internal_size
;
1047 ecoff_symbol_type
*internal
;
1048 ecoff_symbol_type
*internal_ptr
;
1049 asymbol
*indirect_ptr
;
1050 struct ext_ext
*eraw_src
;
1051 struct ext_ext
*eraw_end
;
1055 /* If we've already read in the symbol table, do nothing. */
1056 if (ecoff_data (abfd
)->canonical_symbols
!= NULL
)
1059 /* Get the symbolic information. */
1060 if (ecoff_slurp_symbolic_info (abfd
) == false)
1062 if (bfd_get_symcount (abfd
) == 0)
1065 internal_size
= bfd_get_symcount (abfd
) * sizeof (ecoff_symbol_type
);
1066 internal
= (ecoff_symbol_type
*) bfd_alloc (abfd
, internal_size
);
1067 if (internal
== NULL
)
1069 bfd_error
= no_memory
;
1073 internal_ptr
= internal
;
1074 indirect_ptr
= NULL
;
1075 eraw_src
= ecoff_data (abfd
)->external_ext
;
1076 eraw_end
= eraw_src
+ ecoff_data (abfd
)->symbolic_header
.iextMax
;
1077 for (; eraw_src
< eraw_end
; eraw_src
++, internal_ptr
++)
1081 ecoff_swap_ext_in (abfd
, eraw_src
, &internal_esym
);
1082 internal_ptr
->symbol
.name
= (ecoff_data (abfd
)->ssext
1083 + internal_esym
.asym
.iss
);
1084 ecoff_set_symbol_info (abfd
, &internal_esym
.asym
,
1085 &internal_ptr
->symbol
, 1, &indirect_ptr
);
1086 internal_ptr
->fdr
= ecoff_data (abfd
)->fdr
+ internal_esym
.ifd
;
1087 internal_ptr
->local
= false;
1088 internal_ptr
->native
.enative
= eraw_src
;
1090 BFD_ASSERT (indirect_ptr
== (asymbol
*) NULL
);
1092 /* The local symbols must be accessed via the fdr's, because the
1093 string and aux indices are relative to the fdr information. */
1094 fdr_ptr
= ecoff_data (abfd
)->fdr
;
1095 fdr_end
= fdr_ptr
+ ecoff_data (abfd
)->symbolic_header
.ifdMax
;
1096 for (; fdr_ptr
< fdr_end
; fdr_ptr
++)
1098 struct sym_ext
*lraw_src
;
1099 struct sym_ext
*lraw_end
;
1101 lraw_src
= ecoff_data (abfd
)->external_sym
+ fdr_ptr
->isymBase
;
1102 lraw_end
= lraw_src
+ fdr_ptr
->csym
;
1103 for (; lraw_src
< lraw_end
; lraw_src
++, internal_ptr
++)
1107 ecoff_swap_sym_in (abfd
, lraw_src
, &internal_sym
);
1108 internal_ptr
->symbol
.name
= (ecoff_data (abfd
)->ss
1110 + internal_sym
.iss
);
1111 ecoff_set_symbol_info (abfd
, &internal_sym
,
1112 &internal_ptr
->symbol
, 0, &indirect_ptr
);
1113 internal_ptr
->fdr
= fdr_ptr
;
1114 internal_ptr
->local
= true;
1115 internal_ptr
->native
.lnative
= lraw_src
;
1118 BFD_ASSERT (indirect_ptr
== (asymbol
*) NULL
);
1120 ecoff_data (abfd
)->canonical_symbols
= internal
;
1126 ecoff_get_symtab_upper_bound (abfd
)
1129 if (ecoff_slurp_symbolic_info (abfd
) == false
1130 || bfd_get_symcount (abfd
) == 0)
1133 return (bfd_get_symcount (abfd
) + 1) * (sizeof (ecoff_symbol_type
*));
1137 ecoff_get_symtab (abfd
, alocation
)
1139 asymbol
**alocation
;
1141 unsigned int counter
= 0;
1142 ecoff_symbol_type
*symbase
;
1143 ecoff_symbol_type
**location
= (ecoff_symbol_type
**) alocation
;
1145 if (ecoff_slurp_symbol_table (abfd
) == false
1146 || bfd_get_symcount (abfd
) == 0)
1149 symbase
= ecoff_data (abfd
)->canonical_symbols
;
1150 while (counter
< bfd_get_symcount (abfd
))
1152 *(location
++) = symbase
++;
1155 *location
++ = (ecoff_symbol_type
*) NULL
;
1156 return bfd_get_symcount (abfd
);
1159 /* Turn ECOFF type information into a printable string.
1160 ecoff_emit_aggregate and ecoff_type_to_string are from
1161 gcc/mips-tdump.c, with swapping added and used_ptr removed. */
1163 /* Write aggregate information to a string. */
1166 ecoff_emit_aggregate (abfd
, string
, rndx
, isym
, which
)
1173 int ifd
= rndx
->rfd
;
1174 int indx
= rndx
->index
;
1175 int sym_base
, ss_base
;
1181 sym_base
= ecoff_data (abfd
)->fdr
[ifd
].isymBase
;
1182 ss_base
= ecoff_data (abfd
)->fdr
[ifd
].issBase
;
1184 if (indx
== indexNil
)
1185 name
= "/* no name */";
1191 ecoff_swap_sym_in (abfd
,
1192 ecoff_data (abfd
)->external_sym
+ indx
,
1194 name
= ecoff_data (abfd
)->ss
+ ss_base
+ sym
.iss
;
1198 "%s %s { ifd = %d, index = %d }",
1200 indx
+ ecoff_data (abfd
)->symbolic_header
.iextMax
);
1203 /* Convert the type information to string format. */
1206 ecoff_type_to_string (abfd
, aux_ptr
, indx
, bigendian
)
1208 union aux_ext
*aux_ptr
;
1220 unsigned int basic_type
;
1222 static char buffer1
[1024];
1223 static char buffer2
[1024];
1228 for (i
= 0; i
< 7; i
++)
1230 qualifiers
[i
].low_bound
= 0;
1231 qualifiers
[i
].high_bound
= 0;
1232 qualifiers
[i
].stride
= 0;
1235 if (AUX_GET_ISYM (bigendian
, &aux_ptr
[indx
]) == -1)
1236 return "-1 (no type)";
1237 ecoff_swap_tir_in (bigendian
, &aux_ptr
[indx
++].a_ti
, &u
.ti
);
1239 basic_type
= u
.ti
.bt
;
1240 qualifiers
[0].type
= u
.ti
.tq0
;
1241 qualifiers
[1].type
= u
.ti
.tq1
;
1242 qualifiers
[2].type
= u
.ti
.tq2
;
1243 qualifiers
[3].type
= u
.ti
.tq3
;
1244 qualifiers
[4].type
= u
.ti
.tq4
;
1245 qualifiers
[5].type
= u
.ti
.tq5
;
1246 qualifiers
[6].type
= tqNil
;
1249 * Go get the basic type.
1253 case btNil
: /* undefined */
1257 case btAdr
: /* address - integer same size as pointer */
1258 strcpy (p1
, "address");
1261 case btChar
: /* character */
1262 strcpy (p1
, "char");
1265 case btUChar
: /* unsigned character */
1266 strcpy (p1
, "unsigned char");
1269 case btShort
: /* short */
1270 strcpy (p1
, "short");
1273 case btUShort
: /* unsigned short */
1274 strcpy (p1
, "unsigned short");
1277 case btInt
: /* int */
1281 case btUInt
: /* unsigned int */
1282 strcpy (p1
, "unsigned int");
1285 case btLong
: /* long */
1286 strcpy (p1
, "long");
1289 case btULong
: /* unsigned long */
1290 strcpy (p1
, "unsigned long");
1293 case btFloat
: /* float (real) */
1294 strcpy (p1
, "float");
1297 case btDouble
: /* Double (real) */
1298 strcpy (p1
, "double");
1301 /* Structures add 1-2 aux words:
1302 1st word is [ST_RFDESCAPE, offset] pointer to struct def;
1303 2nd word is file index if 1st word rfd is ST_RFDESCAPE. */
1305 case btStruct
: /* Structure (Record) */
1306 ecoff_swap_rndx_in (bigendian
, &aux_ptr
[indx
].a_rndx
, &rndx
);
1307 ecoff_emit_aggregate (abfd
, p1
, &rndx
,
1308 AUX_GET_ISYM (bigendian
, &aux_ptr
[indx
+1]),
1310 indx
++; /* skip aux words */
1313 /* Unions add 1-2 aux words:
1314 1st word is [ST_RFDESCAPE, offset] pointer to union def;
1315 2nd word is file index if 1st word rfd is ST_RFDESCAPE. */
1317 case btUnion
: /* Union */
1318 ecoff_swap_rndx_in (bigendian
, &aux_ptr
[indx
].a_rndx
, &rndx
);
1319 ecoff_emit_aggregate (abfd
, p1
, &rndx
,
1320 AUX_GET_ISYM (bigendian
, &aux_ptr
[indx
+1]),
1322 indx
++; /* skip aux words */
1325 /* Enumerations add 1-2 aux words:
1326 1st word is [ST_RFDESCAPE, offset] pointer to enum def;
1327 2nd word is file index if 1st word rfd is ST_RFDESCAPE. */
1329 case btEnum
: /* Enumeration */
1330 ecoff_swap_rndx_in (bigendian
, &aux_ptr
[indx
].a_rndx
, &rndx
);
1331 ecoff_emit_aggregate (abfd
, p1
, &rndx
,
1332 AUX_GET_ISYM (bigendian
, &aux_ptr
[indx
+1]),
1334 indx
++; /* skip aux words */
1337 case btTypedef
: /* defined via a typedef, isymRef points */
1338 strcpy (p1
, "typedef");
1341 case btRange
: /* subrange of int */
1342 strcpy (p1
, "subrange");
1345 case btSet
: /* pascal sets */
1349 case btComplex
: /* fortran complex */
1350 strcpy (p1
, "complex");
1353 case btDComplex
: /* fortran double complex */
1354 strcpy (p1
, "double complex");
1357 case btIndirect
: /* forward or unnamed typedef */
1358 strcpy (p1
, "forward/unamed typedef");
1361 case btFixedDec
: /* Fixed Decimal */
1362 strcpy (p1
, "fixed decimal");
1365 case btFloatDec
: /* Float Decimal */
1366 strcpy (p1
, "float decimal");
1369 case btString
: /* Varying Length Character String */
1370 strcpy (p1
, "string");
1373 case btBit
: /* Aligned Bit String */
1377 case btPicture
: /* Picture */
1378 strcpy (p1
, "picture");
1381 case btVoid
: /* Void */
1382 strcpy (p1
, "void");
1386 sprintf (p1
, "Unknown basic type %d", (int) basic_type
);
1390 p1
+= strlen (buffer1
);
1393 * If this is a bitfield, get the bitsize.
1399 bitsize
= AUX_GET_WIDTH (bigendian
, &aux_ptr
[indx
++]);
1400 sprintf (p1
, " : %d", bitsize
);
1401 p1
+= strlen (buffer1
);
1406 * Deal with any qualifiers.
1408 if (qualifiers
[0].type
!= tqNil
)
1411 * Snarf up any array bounds in the correct order. Arrays
1412 * store 5 successive words in the aux. table:
1413 * word 0 RNDXR to type of the bounds (ie, int)
1414 * word 1 Current file descriptor index
1416 * word 3 high bound (or -1 if [])
1417 * word 4 stride size in bits
1419 for (i
= 0; i
< 7; i
++)
1421 if (qualifiers
[i
].type
== tqArray
)
1423 qualifiers
[i
].low_bound
=
1424 AUX_GET_DNLOW (bigendian
, &aux_ptr
[indx
+2]);
1425 qualifiers
[i
].high_bound
=
1426 AUX_GET_DNHIGH (bigendian
, &aux_ptr
[indx
+3]);
1427 qualifiers
[i
].stride
=
1428 AUX_GET_WIDTH (bigendian
, &aux_ptr
[indx
+4]);
1434 * Now print out the qualifiers.
1436 for (i
= 0; i
< 6; i
++)
1438 switch (qualifiers
[i
].type
)
1445 strcpy (p2
, "ptr to ");
1446 p2
+= sizeof ("ptr to ")-1;
1450 strcpy (p2
, "volatile ");
1451 p2
+= sizeof ("volatile ")-1;
1455 strcpy (p2
, "far ");
1456 p2
+= sizeof ("far ")-1;
1460 strcpy (p2
, "func. ret. ");
1461 p2
+= sizeof ("func. ret. ");
1466 int first_array
= i
;
1469 /* Print array bounds reversed (ie, in the order the C
1470 programmer writes them). C is such a fun language.... */
1472 while (i
< 5 && qualifiers
[i
+1].type
== tqArray
)
1475 for (j
= i
; j
>= first_array
; j
--)
1477 strcpy (p2
, "array [");
1478 p2
+= sizeof ("array [")-1;
1479 if (qualifiers
[j
].low_bound
!= 0)
1481 "%ld:%ld {%ld bits}",
1482 (long) qualifiers
[j
].low_bound
,
1483 (long) qualifiers
[j
].high_bound
,
1484 (long) qualifiers
[j
].stride
);
1486 else if (qualifiers
[j
].high_bound
!= -1)
1489 (long) (qualifiers
[j
].high_bound
+ 1),
1490 (long) (qualifiers
[j
].stride
));
1493 sprintf (p2
, " {%ld bits}", (long) (qualifiers
[j
].stride
));
1496 strcpy (p2
, "] of ");
1497 p2
+= sizeof ("] of ")-1;
1505 strcpy (p2
, buffer1
);
1509 /* Return information about ECOFF symbol SYMBOL in RET. */
1512 ecoff_get_symbol_info (abfd
, symbol
, ret
)
1513 bfd
*abfd
; /* Ignored. */
1517 bfd_symbol_info (symbol
, ret
);
1520 /* Print information about an ECOFF symbol. */
1523 ecoff_print_symbol (abfd
, filep
, symbol
, how
)
1527 bfd_print_symbol_type how
;
1529 FILE *file
= (FILE *)filep
;
1533 case bfd_print_symbol_name
:
1534 fprintf (file
, "%s", symbol
->name
);
1536 case bfd_print_symbol_more
:
1537 if (ecoffsymbol (symbol
)->local
)
1541 ecoff_swap_sym_in (abfd
, ecoffsymbol (symbol
)->native
.lnative
,
1543 fprintf (file
, "ecoff local %lx %x %x",
1544 (unsigned long) ecoff_sym
.value
,
1545 (unsigned) ecoff_sym
.st
, (unsigned) ecoff_sym
.sc
);
1551 ecoff_swap_ext_in (abfd
, ecoffsymbol (symbol
)->native
.enative
,
1553 fprintf (file
, "ecoff extern %lx %x %x",
1554 (unsigned long) ecoff_ext
.asym
.value
,
1555 (unsigned) ecoff_ext
.asym
.st
,
1556 (unsigned) ecoff_ext
.asym
.sc
);
1559 case bfd_print_symbol_all
:
1560 /* Print out the symbols in a reasonable way */
1569 if (ecoffsymbol (symbol
)->local
)
1571 ecoff_swap_sym_in (abfd
, ecoffsymbol (symbol
)->native
.lnative
,
1574 pos
= (ecoffsymbol (symbol
)->native
.lnative
1575 - ecoff_data (abfd
)->external_sym
1576 + ecoff_data (abfd
)->symbolic_header
.iextMax
);
1583 ecoff_swap_ext_in (abfd
, ecoffsymbol (symbol
)->native
.enative
,
1586 pos
= (ecoffsymbol (symbol
)->native
.enative
1587 - ecoff_data (abfd
)->external_ext
);
1588 jmptbl
= ecoff_ext
.jmptbl
? 'j' : ' ';
1589 cobol_main
= ecoff_ext
.cobol_main
? 'c' : ' ';
1590 weakext
= ecoff_ext
.weakext
? 'w' : ' ';
1593 fprintf (file
, "[%3d] %c %lx st %x sc %x indx %x %c%c%c %s",
1594 pos
, type
, (unsigned long) ecoff_ext
.asym
.value
,
1595 (unsigned) ecoff_ext
.asym
.st
,
1596 (unsigned) ecoff_ext
.asym
.sc
,
1597 (unsigned) ecoff_ext
.asym
.index
,
1598 jmptbl
, cobol_main
, weakext
,
1601 if (ecoffsymbol (symbol
)->fdr
!= NULL
1602 && ecoff_ext
.asym
.index
!= indexNil
)
1607 union aux_ext
*aux_base
;
1609 indx
= ecoff_ext
.asym
.index
;
1611 /* sym_base is used to map the fdr relative indices which
1612 appear in the file to the position number which we are
1614 sym_base
= ecoffsymbol (symbol
)->fdr
->isymBase
;
1615 if (ecoffsymbol (symbol
)->local
)
1616 sym_base
+= ecoff_data (abfd
)->symbolic_header
.iextMax
;
1618 /* aux_base is the start of the aux entries for this file;
1619 asym.index is an offset from this. */
1620 aux_base
= (ecoff_data (abfd
)->external_aux
1621 + ecoffsymbol (symbol
)->fdr
->iauxBase
);
1623 /* The aux entries are stored in host byte order; the
1624 order is indicated by a bit in the fdr. */
1625 bigendian
= ecoffsymbol (symbol
)->fdr
->fBigendian
;
1627 /* This switch is basically from gcc/mips-tdump.c */
1628 switch (ecoff_ext
.asym
.st
)
1636 printf ("\n End+1 symbol: %ld", indx
+ sym_base
);
1640 if (ecoff_ext
.asym
.sc
== scText
1641 || ecoff_ext
.asym
.sc
== scInfo
)
1642 printf ("\n First symbol: %ld", indx
+ sym_base
);
1644 printf ("\n First symbol: %ld",
1645 (long) (AUX_GET_ISYM (bigendian
,
1646 &aux_base
[ecoff_ext
.asym
.index
])
1652 if (MIPS_IS_STAB (&ecoff_ext
.asym
))
1654 else if (ecoffsymbol (symbol
)->local
)
1655 printf ("\n End+1 symbol: %-7ld Type: %s",
1656 (long) (AUX_GET_ISYM (bigendian
,
1657 &aux_base
[ecoff_ext
.asym
.index
])
1659 ecoff_type_to_string (abfd
, aux_base
, indx
+ 1,
1662 printf ("\n Local symbol: %d",
1665 + ecoff_data (abfd
)->symbolic_header
.iextMax
));
1669 if (!MIPS_IS_STAB (&ecoff_ext
.asym
))
1670 printf ("\n Type: %s",
1671 ecoff_type_to_string (abfd
, aux_base
, indx
,
1681 /* Reloc handling. MIPS ECOFF relocs are packed into 8 bytes in
1682 external form. They use a bit which indicates whether the symbol
1685 /* Swap a reloc in. */
1688 ecoff_swap_reloc_in (abfd
, ext
, intern
)
1691 struct internal_reloc
*intern
;
1693 intern
->r_vaddr
= bfd_h_get_32 (abfd
, (bfd_byte
*) ext
->r_vaddr
);
1694 if (abfd
->xvec
->header_byteorder_big_p
!= false)
1696 intern
->r_symndx
= (((int) ext
->r_bits
[0]
1697 << RELOC_BITS0_SYMNDX_SH_LEFT_BIG
)
1698 | ((int) ext
->r_bits
[1]
1699 << RELOC_BITS1_SYMNDX_SH_LEFT_BIG
)
1700 | ((int) ext
->r_bits
[2]
1701 << RELOC_BITS2_SYMNDX_SH_LEFT_BIG
));
1702 intern
->r_type
= ((ext
->r_bits
[3] & RELOC_BITS3_TYPE_BIG
)
1703 >> RELOC_BITS3_TYPE_SH_BIG
);
1704 intern
->r_extern
= (ext
->r_bits
[3] & RELOC_BITS3_EXTERN_BIG
) != 0;
1708 intern
->r_symndx
= (((int) ext
->r_bits
[0]
1709 << RELOC_BITS0_SYMNDX_SH_LEFT_LITTLE
)
1710 | ((int) ext
->r_bits
[1]
1711 << RELOC_BITS1_SYMNDX_SH_LEFT_LITTLE
)
1712 | ((int) ext
->r_bits
[2]
1713 << RELOC_BITS2_SYMNDX_SH_LEFT_LITTLE
));
1714 intern
->r_type
= ((ext
->r_bits
[3] & RELOC_BITS3_TYPE_LITTLE
)
1715 >> RELOC_BITS3_TYPE_SH_LITTLE
);
1716 intern
->r_extern
= (ext
->r_bits
[3] & RELOC_BITS3_EXTERN_LITTLE
) != 0;
1720 /* Swap a reloc out. */
1723 ecoff_swap_reloc_out (abfd
, src
, dst
)
1728 struct internal_reloc
*intern
= (struct internal_reloc
*) src
;
1729 RELOC
*ext
= (RELOC
*) dst
;
1731 bfd_h_put_32 (abfd
, intern
->r_vaddr
, (bfd_byte
*) ext
->r_vaddr
);
1732 if (abfd
->xvec
->header_byteorder_big_p
!= false)
1734 ext
->r_bits
[0] = intern
->r_symndx
>> RELOC_BITS0_SYMNDX_SH_LEFT_BIG
;
1735 ext
->r_bits
[1] = intern
->r_symndx
>> RELOC_BITS1_SYMNDX_SH_LEFT_BIG
;
1736 ext
->r_bits
[2] = intern
->r_symndx
>> RELOC_BITS2_SYMNDX_SH_LEFT_BIG
;
1737 ext
->r_bits
[3] = (((intern
->r_type
<< RELOC_BITS3_TYPE_SH_BIG
)
1738 & RELOC_BITS3_TYPE_BIG
)
1739 | (intern
->r_extern
? RELOC_BITS3_EXTERN_BIG
: 0));
1743 ext
->r_bits
[0] = intern
->r_symndx
>> RELOC_BITS0_SYMNDX_SH_LEFT_LITTLE
;
1744 ext
->r_bits
[1] = intern
->r_symndx
>> RELOC_BITS1_SYMNDX_SH_LEFT_LITTLE
;
1745 ext
->r_bits
[2] = intern
->r_symndx
>> RELOC_BITS2_SYMNDX_SH_LEFT_LITTLE
;
1746 ext
->r_bits
[3] = (((intern
->r_type
<< RELOC_BITS3_TYPE_SH_LITTLE
)
1747 & RELOC_BITS3_TYPE_LITTLE
)
1748 | (intern
->r_extern
? RELOC_BITS3_EXTERN_LITTLE
: 0));
1754 /* ECOFF relocs are either against external symbols, or against
1755 sections. If we are producing relocateable output, and the reloc
1756 is against an external symbol, and nothing has given us any
1757 additional addend, the resulting reloc will also be against the
1758 same symbol. In such a case, we don't want to change anything
1759 about the way the reloc is handled, since it will all be done at
1760 final link time. Rather than put special case code into
1761 bfd_perform_relocation, all the reloc types use this howto
1762 function. It just short circuits the reloc if producing
1763 relocateable output against an external symbol. */
1765 static bfd_reloc_status_type
1766 ecoff_generic_reloc (abfd
,
1773 arelent
*reloc_entry
;
1776 asection
*input_section
;
1779 if (output_bfd
!= (bfd
*) NULL
1780 && (symbol
->flags
& BSF_SECTION_SYM
) == 0
1781 && reloc_entry
->addend
== 0)
1783 reloc_entry
->address
+= input_section
->output_offset
;
1784 return bfd_reloc_ok
;
1787 return bfd_reloc_continue
;
1790 /* Do a REFHI relocation. This has to be done in combination with a
1791 REFLO reloc, because there is a carry from the REFLO to the REFHI.
1792 Here we just save the information we need; we do the actual
1793 relocation when we see the REFLO. ECOFF requires that the REFLO
1794 immediately follow the REFHI, so this ought to work. */
1796 static bfd_byte
*ecoff_refhi_addr
;
1797 static bfd_vma ecoff_refhi_addend
;
1799 static bfd_reloc_status_type
1800 ecoff_refhi_reloc (abfd
,
1807 arelent
*reloc_entry
;
1810 asection
*input_section
;
1813 bfd_reloc_status_type ret
;
1816 /* If we're relocating, and this an external symbol, we don't want
1817 to change anything. */
1818 if (output_bfd
!= (bfd
*) NULL
1819 && (symbol
->flags
& BSF_SECTION_SYM
) == 0
1820 && reloc_entry
->addend
== 0)
1822 reloc_entry
->address
+= input_section
->output_offset
;
1823 return bfd_reloc_ok
;
1827 if (symbol
->section
== &bfd_und_section
1828 && output_bfd
== (bfd
*) NULL
)
1829 ret
= bfd_reloc_undefined
;
1831 if (bfd_is_com_section (symbol
->section
))
1834 relocation
= symbol
->value
;
1836 relocation
+= symbol
->section
->output_section
->vma
;
1837 relocation
+= symbol
->section
->output_offset
;
1838 relocation
+= reloc_entry
->addend
;
1840 if (reloc_entry
->address
> input_section
->_cooked_size
)
1841 return bfd_reloc_outofrange
;
1843 /* Save the information, and let REFLO do the actual relocation. */
1844 ecoff_refhi_addr
= (bfd_byte
*) data
+ reloc_entry
->address
;
1845 ecoff_refhi_addend
= relocation
;
1847 if (output_bfd
!= (bfd
*) NULL
)
1848 reloc_entry
->address
+= input_section
->output_offset
;
1853 /* Do a REFLO relocation. This is a straightforward 16 bit inplace
1854 relocation; this function exists in order to do the REFHI
1855 relocation described above. */
1857 static bfd_reloc_status_type
1858 ecoff_reflo_reloc (abfd
,
1865 arelent
*reloc_entry
;
1868 asection
*input_section
;
1871 if (ecoff_refhi_addr
!= (bfd_byte
*) NULL
)
1875 unsigned long vallo
;
1877 /* Do the REFHI relocation. Note that we actually don't need to
1878 know anything about the REFLO itself, except where to find
1879 the low 16 bits of the addend needed by the REFHI. */
1880 insn
= bfd_get_32 (abfd
, ecoff_refhi_addr
);
1881 vallo
= (bfd_get_32 (abfd
, (bfd_byte
*) data
+ reloc_entry
->address
)
1883 val
= ((insn
& 0xffff) << 16) + vallo
;
1884 val
+= ecoff_refhi_addend
;
1886 /* The low order 16 bits are always treated as a signed value.
1887 Therefore, a negative value in the low order bits requires an
1888 adjustment in the high order bits. We need to make this
1889 adjustment in two ways: once for the bits we took from the
1890 data, and once for the bits we are putting back in to the
1892 if ((vallo
& 0x8000) != 0)
1894 if ((val
& 0x8000) != 0)
1897 insn
= (insn
&~ 0xffff) | ((val
>> 16) & 0xffff);
1898 bfd_put_32 (abfd
, insn
, ecoff_refhi_addr
);
1900 ecoff_refhi_addr
= (bfd_byte
*) NULL
;
1903 /* Now do the REFLO reloc in the usual way. */
1904 return ecoff_generic_reloc (abfd
, reloc_entry
, symbol
, data
,
1905 input_section
, output_bfd
);
1908 /* Do a GPREL relocation. This is a 16 bit value which must become
1909 the offset from the gp register. */
1911 static bfd_reloc_status_type
1912 ecoff_gprel_reloc (abfd
,
1919 arelent
*reloc_entry
;
1922 asection
*input_section
;
1925 boolean relocateable
;
1930 /* If we're relocating, and this is an external symbol with no
1931 addend, we don't want to change anything. We will only have an
1932 addend if this is a newly created reloc, not read from an ECOFF
1934 if (output_bfd
!= (bfd
*) NULL
1935 && (symbol
->flags
& BSF_SECTION_SYM
) == 0
1936 && reloc_entry
->addend
== 0)
1938 reloc_entry
->address
+= input_section
->output_offset
;
1939 return bfd_reloc_ok
;
1942 if (output_bfd
!= (bfd
*) NULL
)
1943 relocateable
= true;
1946 relocateable
= false;
1947 output_bfd
= symbol
->section
->output_section
->owner
;
1950 if (symbol
->section
== &bfd_und_section
1951 && relocateable
== false)
1952 return bfd_reloc_undefined
;
1954 /* We have to figure out the gp value, so that we can adjust the
1955 symbol value correctly. We look up the symbol _gp in the output
1956 BFD. If we can't find it, we're stuck. We cache it in the ECOFF
1957 target data. We don't need to adjust the symbol value for an
1958 external symbol if we are producing relocateable output. */
1959 if (ecoff_data (output_bfd
)->gp
== 0
1960 && (relocateable
== false
1961 || (symbol
->flags
& BSF_SECTION_SYM
) != 0))
1963 if (relocateable
!= false)
1965 /* Make up a value. */
1966 ecoff_data (output_bfd
)->gp
=
1967 symbol
->section
->output_section
->vma
+ 0x4000;
1975 count
= bfd_get_symcount (output_bfd
);
1976 sym
= bfd_get_outsymbols (output_bfd
);
1978 /* We should do something more friendly here, but we don't
1979 have a good reloc status to return. */
1980 if (sym
== (asymbol
**) NULL
)
1983 for (i
= 0; i
< count
; i
++, sym
++)
1985 register CONST
char *name
;
1987 name
= bfd_asymbol_name (*sym
);
1988 if (*name
== '_' && strcmp (name
, "_gp") == 0)
1990 ecoff_data (output_bfd
)->gp
= bfd_asymbol_value (*sym
);
1995 /* We should do something more friendly here, but we don't have
1996 a good reloc status to return. */
2002 if (bfd_is_com_section (symbol
->section
))
2005 relocation
= symbol
->value
;
2007 relocation
+= symbol
->section
->output_section
->vma
;
2008 relocation
+= symbol
->section
->output_offset
;
2010 if (reloc_entry
->address
> input_section
->_cooked_size
)
2011 return bfd_reloc_outofrange
;
2013 insn
= bfd_get_32 (abfd
, (bfd_byte
*) data
+ reloc_entry
->address
);
2015 /* Set val to the offset into the section or symbol. */
2016 val
= ((insn
& 0xffff) + reloc_entry
->addend
) & 0xffff;
2020 /* Adjust val for the final section location and GP value. If we
2021 are producing relocateable output, we don't want to do this for
2022 an external symbol. */
2023 if (relocateable
== false
2024 || (symbol
->flags
& BSF_SECTION_SYM
) != 0)
2025 val
+= relocation
- ecoff_data (output_bfd
)->gp
;
2027 insn
= (insn
&~ 0xffff) | (val
& 0xffff);
2028 bfd_put_32 (abfd
, insn
, (bfd_byte
*) data
+ reloc_entry
->address
);
2030 if (relocateable
!= false)
2031 reloc_entry
->address
+= input_section
->output_offset
;
2033 /* Make sure it fit in 16 bits. */
2034 if (val
>= 0x8000 && val
< 0xffff8000)
2035 return bfd_reloc_outofrange
;
2037 return bfd_reloc_ok
;
2040 /* Read in the relocs for a section. */
2043 ecoff_slurp_reloc_table (abfd
, section
, symbols
)
2048 RELOC
*external_relocs
;
2049 arelent
*internal_relocs
;
2053 if (section
->relocation
!= (arelent
*) NULL
2054 || section
->reloc_count
== 0
2055 || (section
->flags
& SEC_CONSTRUCTOR
) != 0)
2058 if (ecoff_slurp_symbol_table (abfd
) == false)
2061 internal_relocs
= (arelent
*) bfd_alloc (abfd
,
2063 * section
->reloc_count
));
2064 external_relocs
= (RELOC
*) bfd_alloc (abfd
, RELSZ
* section
->reloc_count
);
2065 if (internal_relocs
== (arelent
*) NULL
2066 || external_relocs
== (RELOC
*) NULL
)
2068 bfd_error
= no_memory
;
2071 if (bfd_seek (abfd
, section
->rel_filepos
, SEEK_SET
) != 0)
2073 if (bfd_read (external_relocs
, 1, RELSZ
* section
->reloc_count
, abfd
)
2074 != RELSZ
* section
->reloc_count
)
2076 bfd_error
= system_call_error
;
2080 for (i
= 0, rptr
= internal_relocs
; i
< section
->reloc_count
; i
++, rptr
++)
2082 struct internal_reloc intern
;
2084 ecoff_swap_reloc_in (abfd
, external_relocs
+ i
, &intern
);
2086 if (intern
.r_type
> ECOFF_R_LITERAL
)
2089 if (intern
.r_extern
)
2091 /* r_symndx is an index into the external symbols. */
2092 BFD_ASSERT (intern
.r_symndx
>= 0
2094 < ecoff_data (abfd
)->symbolic_header
.iextMax
));
2095 rptr
->sym_ptr_ptr
= symbols
+ intern
.r_symndx
;
2100 CONST
char *sec_name
;
2103 /* r_symndx is a section key. */
2104 switch (intern
.r_symndx
)
2106 case RELOC_SECTION_TEXT
: sec_name
= ".text"; break;
2107 case RELOC_SECTION_RDATA
: sec_name
= ".rdata"; break;
2108 case RELOC_SECTION_DATA
: sec_name
= ".data"; break;
2109 case RELOC_SECTION_SDATA
: sec_name
= ".sdata"; break;
2110 case RELOC_SECTION_SBSS
: sec_name
= ".sbss"; break;
2111 case RELOC_SECTION_BSS
: sec_name
= ".bss"; break;
2112 case RELOC_SECTION_INIT
: sec_name
= ".init"; break;
2113 case RELOC_SECTION_LIT8
: sec_name
= ".lit8"; break;
2114 case RELOC_SECTION_LIT4
: sec_name
= ".lit4"; break;
2118 sec
= bfd_get_section_by_name (abfd
, sec_name
);
2119 if (sec
== (asection
*) NULL
)
2121 rptr
->sym_ptr_ptr
= sec
->symbol_ptr_ptr
;
2123 rptr
->addend
= - bfd_get_section_vma (abfd
, sec
);
2124 if (intern
.r_type
== ECOFF_R_GPREL
2125 || intern
.r_type
== ECOFF_R_LITERAL
)
2126 rptr
->addend
+= ecoff_data (abfd
)->gp
;
2129 rptr
->address
= intern
.r_vaddr
- bfd_get_section_vma (abfd
, section
);
2130 rptr
->howto
= &ecoff_howto_table
[intern
.r_type
];
2132 /* If the type is ECOFF_R_IGNORE, make sure this is a reference
2133 to the absolute section so that the reloc is ignored. */
2134 if (intern
.r_type
== ECOFF_R_IGNORE
)
2135 rptr
->sym_ptr_ptr
= bfd_abs_section
.symbol_ptr_ptr
;
2138 bfd_release (abfd
, external_relocs
);
2140 section
->relocation
= internal_relocs
;
2145 /* Get a canonical list of relocs. */
2148 ecoff_canonicalize_reloc (abfd
, section
, relptr
, symbols
)
2156 if (section
->flags
& SEC_CONSTRUCTOR
)
2158 arelent_chain
*chain
;
2160 /* This section has relocs made up by us, not the file, so take
2161 them out of their chain and place them into the data area
2163 for (count
= 0, chain
= section
->constructor_chain
;
2164 count
< section
->reloc_count
;
2165 count
++, chain
= chain
->next
)
2166 *relptr
++ = &chain
->relent
;
2172 if (ecoff_slurp_reloc_table (abfd
, section
, symbols
) == false)
2175 tblptr
= section
->relocation
;
2176 if (tblptr
== (arelent
*) NULL
)
2179 for (count
= 0; count
< section
->reloc_count
; count
++)
2180 *relptr
++ = tblptr
++;
2183 *relptr
= (arelent
*) NULL
;
2185 return section
->reloc_count
;
2188 /* Get the howto structure for a generic reloc type. */
2190 static CONST
struct reloc_howto_struct
*
2191 ecoff_bfd_reloc_type_lookup (abfd
, code
)
2193 bfd_reloc_code_real_type code
;
2200 ecoff_type
= ECOFF_R_REFHALF
;
2203 ecoff_type
= ECOFF_R_REFWORD
;
2205 case BFD_RELOC_MIPS_JMP
:
2206 ecoff_type
= ECOFF_R_JMPADDR
;
2208 case BFD_RELOC_HI16_S
:
2209 ecoff_type
= ECOFF_R_REFHI
;
2211 case BFD_RELOC_LO16
:
2212 ecoff_type
= ECOFF_R_REFLO
;
2214 case BFD_RELOC_MIPS_GPREL
:
2215 ecoff_type
= ECOFF_R_GPREL
;
2218 return (CONST
struct reloc_howto_struct
*) NULL
;
2221 return &ecoff_howto_table
[ecoff_type
];
2224 /* Provided a BFD, a section and an offset into the section, calculate
2225 and return the name of the source file and the line nearest to the
2229 ecoff_find_nearest_line (abfd
,
2238 asymbol
**ignore_symbols
;
2240 CONST
char **filename_ptr
;
2241 CONST
char **functionname_ptr
;
2242 unsigned int *retline_ptr
;
2248 struct pdr_ext
*pdr_ptr
;
2249 struct pdr_ext
*pdr_end
;
2251 unsigned char *line_ptr
;
2252 unsigned char *line_end
;
2255 /* If we're not in the .text section, we don't have any line
2257 if (strcmp (section
->name
, _TEXT
) != 0
2258 || offset
< ecoff_data (abfd
)->text_start
2259 || offset
>= ecoff_data (abfd
)->text_end
)
2262 /* Make sure we have the FDR's. */
2263 if (ecoff_slurp_symbolic_info (abfd
) == false
2264 || bfd_get_symcount (abfd
) == 0)
2267 /* Each file descriptor (FDR) has a memory address. Here we track
2268 down which FDR we want. The FDR's are stored in increasing
2269 memory order. If speed is ever important, this can become a
2270 binary search. We must ignore FDR's with no PDR entries; they
2271 will have the adr of the FDR before or after them. */
2272 fdr_start
= ecoff_data (abfd
)->fdr
;
2273 fdr_end
= fdr_start
+ ecoff_data (abfd
)->symbolic_header
.ifdMax
;
2274 fdr_hold
= (FDR
*) NULL
;
2275 for (fdr_ptr
= fdr_start
; fdr_ptr
< fdr_end
; fdr_ptr
++)
2277 if (fdr_ptr
->cpd
== 0)
2279 if (offset
< fdr_ptr
->adr
)
2283 if (fdr_hold
== (FDR
*) NULL
)
2287 /* Each FDR has a list of procedure descriptors (PDR). PDR's also
2288 have an address, which is relative to the FDR address, and are
2289 also stored in increasing memory order. */
2290 offset
-= fdr_ptr
->adr
;
2291 pdr_ptr
= ecoff_data (abfd
)->external_pdr
+ fdr_ptr
->ipdFirst
;
2292 pdr_end
= pdr_ptr
+ fdr_ptr
->cpd
;
2293 ecoff_swap_pdr_in (abfd
, pdr_ptr
, &pdr
);
2295 /* The address of the first PDR is an offset which applies to the
2296 addresses of all the PDR's. */
2299 for (pdr_ptr
++; pdr_ptr
< pdr_end
; pdr_ptr
++)
2301 ecoff_swap_pdr_in (abfd
, pdr_ptr
, &pdr
);
2302 if (offset
< pdr
.adr
)
2306 /* Now we can look for the actual line number. The line numbers are
2307 stored in a very funky format, which I won't try to describe.
2308 Note that right here pdr_ptr and pdr hold the PDR *after* the one
2309 we want; we need this to compute line_end. */
2310 line_end
= ecoff_data (abfd
)->line
;
2311 if (pdr_ptr
== pdr_end
)
2312 line_end
+= fdr_ptr
->cbLineOffset
+ fdr_ptr
->cbLine
;
2314 line_end
+= fdr_ptr
->cbLineOffset
+ pdr
.cbLineOffset
;
2316 /* Now change pdr and pdr_ptr to the one we want. */
2318 ecoff_swap_pdr_in (abfd
, pdr_ptr
, &pdr
);
2322 line_ptr
= (ecoff_data (abfd
)->line
2323 + fdr_ptr
->cbLineOffset
2324 + pdr
.cbLineOffset
);
2325 while (line_ptr
< line_end
)
2330 delta
= *line_ptr
>> 4;
2333 count
= (*line_ptr
& 0xf) + 1;
2337 delta
= (((line_ptr
[0]) & 0xff) << 8) + ((line_ptr
[1]) & 0xff);
2338 if (delta
>= 0x8000)
2343 if (offset
< count
* 4)
2345 offset
-= count
* 4;
2348 /* If fdr_ptr->rss is -1, then this file does not have full symbols,
2349 at least according to gdb/mipsread.c. */
2350 if (fdr_ptr
->rss
== -1)
2352 *filename_ptr
= NULL
;
2354 *functionname_ptr
= NULL
;
2359 ecoff_swap_ext_in (abfd
,
2360 (ecoff_data (abfd
)->external_ext
2363 *functionname_ptr
= ecoff_data (abfd
)->ssext
+ proc_ext
.asym
.iss
;
2370 *filename_ptr
= ecoff_data (abfd
)->ss
+ fdr_ptr
->issBase
+ fdr_ptr
->rss
;
2371 ecoff_swap_sym_in (abfd
,
2372 (ecoff_data (abfd
)->external_sym
2376 *functionname_ptr
= (ecoff_data (abfd
)->ss
2380 *retline_ptr
= lineno
;
2384 /* We can't use the generic linking routines for ECOFF, because we
2385 have to handle all the debugging information. The generic link
2386 routine just works out the section contents and attaches a list of
2389 We link by looping over all the seclets. We make two passes. On
2390 the first we set the actual section contents and determine the size
2391 of the debugging information. On the second we accumulate the
2392 debugging information and write it out.
2394 This currently always accumulates the debugging information, which
2395 is incorrect, because it ignores the -s and -S options of the
2396 linker. The linker needs to be modified to give us that
2397 information in a more useful format (currently it just provides a
2398 list of symbols which should appear in the output file). */
2400 /* Clear the output_has_begun flag for all the input BFD's. We use it
2401 to avoid linking in the debugging information for a BFD more than
2405 ecoff_clear_output_flags (abfd
)
2408 register asection
*o
;
2409 register bfd_seclet_type
*p
;
2411 for (o
= abfd
->sections
; o
!= (asection
*) NULL
; o
= o
->next
)
2412 for (p
= o
->seclets_head
;
2413 p
!= (bfd_seclet_type
*) NULL
;
2415 if (p
->type
== bfd_indirect_seclet
)
2416 p
->u
.indirect
.section
->owner
->output_has_begun
= false;
2419 /* Handle an indirect seclet on the first pass. Set the contents of
2420 the output section, and accumulate the debugging information if
2424 ecoff_rel (output_bfd
, seclet
, output_section
, data
, relocateable
)
2426 bfd_seclet_type
*seclet
;
2427 asection
*output_section
;
2429 boolean relocateable
;
2432 HDRR
*output_symhdr
;
2435 if ((output_section
->flags
& SEC_HAS_CONTENTS
)
2436 && !(output_section
->flags
& SEC_NEVER_LOAD
)
2437 && (output_section
->flags
& SEC_LOAD
)
2440 data
= (PTR
) bfd_get_relocated_section_contents (output_bfd
,
2444 if (bfd_set_section_contents (output_bfd
,
2455 input_bfd
= seclet
->u
.indirect
.section
->owner
;
2457 /* We want to figure out how much space will be required to
2458 incorporate all the debugging information from input_bfd. We use
2459 the output_has_begun field to avoid adding it in more than once.
2460 The actual incorporation is done in the second pass, in
2461 ecoff_get_debug. The code has to parallel that code in its
2462 manipulations of output_symhdr. */
2464 if (input_bfd
->output_has_begun
)
2466 input_bfd
->output_has_begun
= true;
2468 output_symhdr
= &ecoff_data (output_bfd
)->symbolic_header
;
2470 if (input_bfd
->xvec
->flavour
!= bfd_target_ecoff_flavour
)
2476 /* We just accumulate local symbols from a non-ECOFF BFD. The
2477 external symbols are handled separately. */
2479 symbols
= (asymbol
**) bfd_alloc (output_bfd
,
2480 get_symtab_upper_bound (input_bfd
));
2481 if (symbols
== (asymbol
**) NULL
)
2483 bfd_error
= no_memory
;
2486 sym_end
= symbols
+ bfd_canonicalize_symtab (input_bfd
, symbols
);
2488 for (sym_ptr
= symbols
; sym_ptr
< sym_end
; sym_ptr
++)
2492 len
= strlen ((*sym_ptr
)->name
);
2493 if (((*sym_ptr
)->flags
& BSF_EXPORT
) == 0)
2495 ++output_symhdr
->isymMax
;
2496 output_symhdr
->issMax
+= len
+ 1;
2500 bfd_release (output_bfd
, (PTR
) symbols
);
2502 ++output_symhdr
->ifdMax
;
2507 /* We simply add in the information from another ECOFF BFD. First
2508 we make sure we have the symbolic information. */
2509 if (ecoff_slurp_symbol_table (input_bfd
) == false)
2511 if (bfd_get_symcount (input_bfd
) == 0)
2514 input_symhdr
= &ecoff_data (input_bfd
)->symbolic_header
;
2516 /* Figure out how much information we are going to be putting in.
2517 The external symbols are handled separately. */
2518 output_symhdr
->ilineMax
+= input_symhdr
->ilineMax
;
2519 output_symhdr
->cbLine
+= input_symhdr
->cbLine
;
2520 output_symhdr
->idnMax
+= input_symhdr
->idnMax
;
2521 output_symhdr
->ipdMax
+= input_symhdr
->ipdMax
;
2522 output_symhdr
->isymMax
+= input_symhdr
->isymMax
;
2523 output_symhdr
->ioptMax
+= input_symhdr
->ioptMax
;
2524 output_symhdr
->iauxMax
+= input_symhdr
->iauxMax
;
2525 output_symhdr
->issMax
+= input_symhdr
->issMax
;
2526 output_symhdr
->ifdMax
+= input_symhdr
->ifdMax
;
2528 /* The RFD's are special, since we create them if needed. */
2529 if (input_symhdr
->crfd
> 0)
2530 output_symhdr
->crfd
+= input_symhdr
->crfd
;
2532 output_symhdr
->crfd
+= input_symhdr
->ifdMax
;
2537 /* Handle an arbitrary seclet on the first pass. */
2540 ecoff_dump_seclet (abfd
, seclet
, section
, data
, relocateable
)
2542 bfd_seclet_type
*seclet
;
2545 boolean relocateable
;
2547 switch (seclet
->type
)
2549 case bfd_indirect_seclet
:
2550 /* The contents of this section come from another one somewhere
2552 return ecoff_rel (abfd
, seclet
, section
, data
, relocateable
);
2554 case bfd_fill_seclet
:
2555 /* Fill in the section with fill.value. This is used to pad out
2556 sections, but we must avoid padding the .bss section. */
2557 if ((section
->flags
& SEC_HAS_CONTENTS
) == 0)
2559 if (seclet
->u
.fill
.value
!= 0)
2564 char *d
= (char *) bfd_alloc (abfd
, seclet
->size
);
2568 for (i
= 0; i
< seclet
->size
; i
+=2)
2569 d
[i
] = seclet
->u
.fill
.value
>> 8;
2570 for (i
= 1; i
< seclet
->size
; i
+=2)
2571 d
[i
] = seclet
->u
.fill
.value
;
2572 ret
= bfd_set_section_contents (abfd
, section
, d
, seclet
->offset
,
2574 bfd_release (abfd
, (PTR
) d
);
2586 /* Add a string to the debugging information we are accumulating for a
2587 file. Return the offset from the fdr string base or from the
2588 external string base. */
2591 ecoff_add_string (output_bfd
, fdr
, string
, external
)
2601 symhdr
= &ecoff_data (output_bfd
)->symbolic_header
;
2602 len
= strlen (string
);
2605 strcpy (ecoff_data (output_bfd
)->ssext
+ symhdr
->issExtMax
, string
);
2606 ret
= symhdr
->issExtMax
;
2607 symhdr
->issExtMax
+= len
+ 1;
2611 strcpy (ecoff_data (output_bfd
)->ss
+ symhdr
->issMax
, string
);
2613 symhdr
->issMax
+= len
+ 1;
2614 fdr
->cbSs
+= len
+ 1;
2619 /* Accumulate the debugging information from an input section. */
2622 ecoff_get_debug (output_bfd
, seclet
, section
, relocateable
)
2624 bfd_seclet_type
*seclet
;
2626 boolean relocateable
;
2629 HDRR
*output_symhdr
;
2631 ecoff_data_type
*output_ecoff
;
2632 ecoff_data_type
*input_ecoff
;
2634 struct sym_ext
*sym_out
;
2635 ecoff_symbol_type
*esym_ptr
;
2636 ecoff_symbol_type
*esym_end
;
2639 struct fdr_ext
*fdr_out
;
2641 input_bfd
= seclet
->u
.indirect
.section
->owner
;
2643 /* Don't get the information more than once. */
2644 if (input_bfd
->output_has_begun
)
2646 input_bfd
->output_has_begun
= true;
2648 output_ecoff
= ecoff_data (output_bfd
);
2649 output_symhdr
= &output_ecoff
->symbolic_header
;
2651 if (input_bfd
->xvec
->flavour
!= bfd_target_ecoff_flavour
)
2658 /* This is not an ECOFF BFD. Just gather the symbols. */
2660 memset (&fdr
, 0, sizeof fdr
);
2662 fdr
.adr
= bfd_get_section_vma (output_bfd
, section
) + seclet
->offset
;
2663 fdr
.issBase
= output_symhdr
->issMax
;
2665 fdr
.rss
= ecoff_add_string (output_bfd
,
2667 bfd_get_filename (input_bfd
),
2669 fdr
.isymBase
= output_symhdr
->isymMax
;
2671 /* Get the local symbols from the input BFD. */
2672 symbols
= (asymbol
**) bfd_alloc (output_bfd
,
2673 get_symtab_upper_bound (input_bfd
));
2674 if (symbols
== (asymbol
**) NULL
)
2676 bfd_error
= no_memory
;
2679 sym_end
= symbols
+ bfd_canonicalize_symtab (input_bfd
, symbols
);
2681 /* Handle the local symbols. Any external symbols are handled
2684 for (sym_ptr
= symbols
; sym_ptr
!= sym_end
; sym_ptr
++)
2688 if (((*sym_ptr
)->flags
& BSF_EXPORT
) != 0)
2690 memset (&internal_sym
, 0, sizeof internal_sym
);
2691 internal_sym
.iss
= ecoff_add_string (output_bfd
,
2696 if (bfd_is_com_section ((*sym_ptr
)->section
)
2697 || (*sym_ptr
)->section
== &bfd_und_section
)
2698 internal_sym
.value
= (*sym_ptr
)->value
;
2700 internal_sym
.value
= ((*sym_ptr
)->value
2701 + (*sym_ptr
)->section
->output_offset
2702 + (*sym_ptr
)->section
->output_section
->vma
);
2703 internal_sym
.st
= stNil
;
2704 internal_sym
.sc
= scUndefined
;
2705 internal_sym
.index
= indexNil
;
2706 ecoff_swap_sym_out (output_bfd
, &internal_sym
,
2707 (output_ecoff
->external_sym
2708 + output_symhdr
->isymMax
));
2710 ++output_symhdr
->isymMax
;
2713 bfd_release (output_bfd
, (PTR
) symbols
);
2715 /* Leave everything else in the FDR zeroed out. This will cause
2716 the lang field to be langC. The fBigendian field will
2717 indicate little endian format, but it doesn't matter because
2718 it only applies to aux fields and there are none. */
2720 ecoff_swap_fdr_out (output_bfd
, &fdr
,
2721 (output_ecoff
->external_fdr
2722 + output_symhdr
->ifdMax
));
2723 ++output_symhdr
->ifdMax
;
2727 /* This is an ECOFF BFD. We want to grab the information from
2728 input_bfd and attach it to output_bfd. */
2729 count
= bfd_get_symcount (input_bfd
);
2732 input_ecoff
= ecoff_data (input_bfd
);
2733 input_symhdr
= &input_ecoff
->symbolic_header
;
2735 /* I think that it is more efficient to simply copy the debugging
2736 information from the input BFD to the output BFD. Because ECOFF
2737 uses relative pointers for most of the debugging information,
2738 only a little of it has to be changed at all. */
2740 /* Swap in the local symbols, adjust their values, and swap them out
2741 again. The external symbols are handled separately. */
2742 sym_out
= output_ecoff
->external_sym
+ output_symhdr
->isymMax
;
2744 esym_ptr
= ecoff_data (input_bfd
)->canonical_symbols
;
2745 esym_end
= esym_ptr
+ count
;
2746 for (; esym_ptr
< esym_end
; esym_ptr
++)
2748 if (esym_ptr
->local
)
2752 ecoff_swap_sym_in (input_bfd
, esym_ptr
->native
.lnative
, &sym
);
2754 /* If we're producing an executable, move common symbols
2756 if (relocateable
== false)
2758 if (sym
.sc
== scCommon
)
2760 else if (sym
.sc
== scSCommon
)
2764 if (! bfd_is_com_section (esym_ptr
->symbol
.section
)
2765 && (esym_ptr
->symbol
.flags
& BSF_DEBUGGING
) == 0
2766 && esym_ptr
->symbol
.section
!= &bfd_und_section
)
2767 sym
.value
= (esym_ptr
->symbol
.value
2768 + esym_ptr
->symbol
.section
->output_offset
2769 + esym_ptr
->symbol
.section
->output_section
->vma
);
2770 ecoff_swap_sym_out (output_bfd
, &sym
, sym_out
);
2775 /* That should have accounted for all the local symbols in
2777 BFD_ASSERT ((sym_out
- output_ecoff
->external_sym
) - output_symhdr
->isymMax
2778 == input_symhdr
->isymMax
);
2780 /* Copy the information that does not need swapping. */
2781 memcpy (output_ecoff
->line
+ output_symhdr
->cbLine
,
2783 input_symhdr
->cbLine
* sizeof (unsigned char));
2784 memcpy (output_ecoff
->external_aux
+ output_symhdr
->iauxMax
,
2785 input_ecoff
->external_aux
,
2786 input_symhdr
->iauxMax
* sizeof (union aux_ext
));
2787 memcpy (output_ecoff
->ss
+ output_symhdr
->issMax
,
2789 input_symhdr
->issMax
* sizeof (char));
2791 /* Some of the information may need to be swapped. */
2792 if (output_bfd
->xvec
->header_byteorder_big_p
2793 == input_bfd
->xvec
->header_byteorder_big_p
)
2795 /* The two BFD's have the same endianness, so memcpy will
2797 memcpy (output_ecoff
->external_dnr
+ output_symhdr
->idnMax
,
2798 input_ecoff
->external_dnr
,
2799 input_symhdr
->idnMax
* sizeof (struct dnr_ext
));
2800 memcpy (output_ecoff
->external_pdr
+ output_symhdr
->ipdMax
,
2801 input_ecoff
->external_pdr
,
2802 input_symhdr
->ipdMax
* sizeof (struct pdr_ext
));
2803 memcpy (output_ecoff
->external_opt
+ output_symhdr
->ioptMax
,
2804 input_ecoff
->external_opt
,
2805 input_symhdr
->ioptMax
* sizeof (struct opt_ext
));
2809 struct dnr_ext
*dnr_in
;
2810 struct dnr_ext
*dnr_end
;
2811 struct dnr_ext
*dnr_out
;
2812 struct pdr_ext
*pdr_in
;
2813 struct pdr_ext
*pdr_end
;
2814 struct pdr_ext
*pdr_out
;
2815 struct opt_ext
*opt_in
;
2816 struct opt_ext
*opt_end
;
2817 struct opt_ext
*opt_out
;
2819 /* The two BFD's have different endianness, so we must swap
2820 everything in and out. This code would always work, but it
2821 would be slow in the normal case. */
2822 dnr_in
= input_ecoff
->external_dnr
;
2823 dnr_end
= dnr_in
+ input_symhdr
->idnMax
;
2824 dnr_out
= output_ecoff
->external_dnr
+ output_symhdr
->idnMax
;
2825 for (; dnr_in
< dnr_end
; dnr_in
++, dnr_out
++)
2829 ecoff_swap_dnr_in (input_bfd
, dnr_in
, &dnr
);
2830 ecoff_swap_dnr_out (output_bfd
, &dnr
, dnr_out
);
2832 pdr_in
= input_ecoff
->external_pdr
;
2833 pdr_end
= pdr_in
+ input_symhdr
->ipdMax
;
2834 pdr_out
= output_ecoff
->external_pdr
+ output_symhdr
->ipdMax
;
2835 for (; pdr_in
< pdr_end
; pdr_in
++, pdr_out
++)
2839 ecoff_swap_pdr_in (input_bfd
, pdr_in
, &pdr
);
2840 ecoff_swap_pdr_out (output_bfd
, &pdr
, pdr_out
);
2842 opt_in
= input_ecoff
->external_opt
;
2843 opt_end
= opt_in
+ input_symhdr
->ioptMax
;
2844 opt_out
= output_ecoff
->external_opt
+ output_symhdr
->ioptMax
;
2845 for (; opt_in
< opt_end
; opt_in
++, opt_out
++)
2849 ecoff_swap_opt_in (input_bfd
, opt_in
, &opt
);
2850 ecoff_swap_opt_out (output_bfd
, &opt
, opt_out
);
2854 /* Set ifdbase so that the external symbols know how to adjust their
2856 input_ecoff
->ifdbase
= output_symhdr
->ifdMax
;
2858 fdr_ptr
= input_ecoff
->fdr
;
2859 fdr_end
= fdr_ptr
+ input_symhdr
->ifdMax
;
2860 fdr_out
= output_ecoff
->external_fdr
+ output_symhdr
->ifdMax
;
2861 for (; fdr_ptr
< fdr_end
; fdr_ptr
++, fdr_out
++)
2864 unsigned long pdr_off
;
2868 /* The memory address for this fdr is the address for the seclet
2869 plus the offset to this fdr within input_bfd. For some
2870 reason the offset of the first procedure pointer is also
2878 ecoff_swap_pdr_in (input_bfd
,
2879 input_ecoff
->external_pdr
+ fdr
.ipdFirst
,
2883 fdr
.adr
= (bfd_get_section_vma (output_bfd
, section
)
2885 + (fdr_ptr
->adr
- input_ecoff
->fdr
->adr
)
2888 fdr
.issBase
+= output_symhdr
->issMax
;
2889 fdr
.isymBase
+= output_symhdr
->isymMax
;
2890 fdr
.ilineBase
+= output_symhdr
->ilineMax
;
2891 fdr
.ioptBase
+= output_symhdr
->ioptMax
;
2892 fdr
.ipdFirst
+= output_symhdr
->ipdMax
;
2893 fdr
.iauxBase
+= output_symhdr
->iauxMax
;
2894 fdr
.rfdBase
+= output_symhdr
->crfd
;
2896 /* If there are no RFD's, we are going to add some. We don't
2897 want to adjust irfd for this, so that all the FDR's can share
2899 if (input_symhdr
->crfd
== 0)
2900 fdr
.crfd
= input_symhdr
->ifdMax
;
2902 if (fdr
.cbLine
!= 0)
2903 fdr
.cbLineOffset
+= output_symhdr
->cbLine
;
2905 ecoff_swap_fdr_out (output_bfd
, &fdr
, fdr_out
);
2908 if (input_symhdr
->crfd
> 0)
2910 struct rfd_ext
*rfd_in
;
2911 struct rfd_ext
*rfd_end
;
2912 struct rfd_ext
*rfd_out
;
2914 /* Swap and adjust the RFD's. RFD's are only created by the
2915 linker, so this will only be necessary if one of the input
2916 files is the result of a partial link. Presumably all
2917 necessary RFD's are present. */
2918 rfd_in
= input_ecoff
->external_rfd
;
2919 rfd_end
= rfd_in
+ input_symhdr
->crfd
;
2920 rfd_out
= output_ecoff
->external_rfd
+ output_symhdr
->crfd
;
2921 for (; rfd_in
< rfd_end
; rfd_in
++, rfd_out
++)
2925 ecoff_swap_rfd_in (input_bfd
, rfd_in
, &rfd
);
2926 rfd
+= output_symhdr
->ifdMax
;
2927 ecoff_swap_rfd_out (output_bfd
, &rfd
, rfd_out
);
2929 output_symhdr
->crfd
+= input_symhdr
->crfd
;
2933 struct rfd_ext
*rfd_out
;
2934 struct rfd_ext
*rfd_end
;
2937 /* Create RFD's. Some of the debugging information includes
2938 relative file indices. These indices are taken as indices to
2939 the RFD table if there is one, or to the global table if
2940 there is not. If we did not create RFD's, we would have to
2941 parse and adjust all the debugging information which contains
2943 rfd
= output_symhdr
->ifdMax
;
2944 rfd_out
= output_ecoff
->external_rfd
+ output_symhdr
->crfd
;
2945 rfd_end
= rfd_out
+ input_symhdr
->ifdMax
;
2946 for (; rfd_out
< rfd_end
; rfd_out
++, rfd
++)
2947 ecoff_swap_rfd_out (output_bfd
, &rfd
, rfd_out
);
2948 output_symhdr
->crfd
+= input_symhdr
->ifdMax
;
2951 /* Combine the register masks. */
2955 output_ecoff
->gprmask
|= input_ecoff
->gprmask
;
2956 for (i
= 0; i
< 4; i
++)
2957 output_ecoff
->cprmask
[i
] |= input_ecoff
->cprmask
[i
];
2960 /* Update the counts. */
2961 output_symhdr
->ilineMax
+= input_symhdr
->ilineMax
;
2962 output_symhdr
->cbLine
+= input_symhdr
->cbLine
;
2963 output_symhdr
->idnMax
+= input_symhdr
->idnMax
;
2964 output_symhdr
->ipdMax
+= input_symhdr
->ipdMax
;
2965 output_symhdr
->isymMax
+= input_symhdr
->isymMax
;
2966 output_symhdr
->ioptMax
+= input_symhdr
->ioptMax
;
2967 output_symhdr
->iauxMax
+= input_symhdr
->iauxMax
;
2968 output_symhdr
->issMax
+= input_symhdr
->issMax
;
2969 output_symhdr
->ifdMax
+= input_symhdr
->ifdMax
;
2974 /* This is the actual link routine. It makes two passes over all the
2978 ecoff_bfd_seclet_link (abfd
, data
, relocateable
)
2981 boolean relocateable
;
2985 register asection
*o
;
2986 register bfd_seclet_type
*p
;
2987 asymbol
**sym_ptr_ptr
;
2991 /* We accumulate the debugging information counts in the symbolic
2993 symhdr
= &ecoff_data (abfd
)->symbolic_header
;
2994 symhdr
->magic
= magicSym
;
2995 /* FIXME: What should the version stamp be? */
2997 symhdr
->ilineMax
= 0;
3001 symhdr
->isymMax
= 0;
3002 symhdr
->ioptMax
= 0;
3003 symhdr
->iauxMax
= 0;
3005 symhdr
->issExtMax
= 0;
3008 symhdr
->iextMax
= 0;
3010 /* We need to copy over the debugging symbols from each input BFD.
3011 When we do this copying, we have to adjust the text address in
3012 the FDR structures, so we have to know the text address used for
3013 the input BFD. Since we only want to copy the symbols once per
3014 input BFD, but we are going to look at each input BFD multiple
3015 times (once for each section it provides), we arrange to always
3016 look at the text section first. That means that when we copy the
3017 debugging information, we always know the text address. So we
3018 actually do each pass in two sub passes; first the text sections,
3019 then the non-text sections. We use the output_has_begun flag to
3020 determine whether we have copied over the debugging information
3023 /* Do the first pass: set the output section contents and count the
3024 debugging information. */
3025 ecoff_clear_output_flags (abfd
);
3026 for (ipass
= 0; ipass
< 2; ipass
++)
3028 for (o
= abfd
->sections
; o
!= (asection
*) NULL
; o
= o
->next
)
3030 /* For SEC_CODE sections, (flags & SEC_CODE) == 0 is false,
3031 so they are done on pass 0. For other sections the
3032 expression is true, so they are done on pass 1. */
3033 if (((o
->flags
& SEC_CODE
) == 0) != ipass
)
3036 for (p
= o
->seclets_head
;
3037 p
!= (bfd_seclet_type
*) NULL
;
3040 if (ecoff_dump_seclet (abfd
, p
, o
, data
, relocateable
)
3047 /* We handle the external symbols differently. We use the ones
3048 attached to the output_bfd. The linker will have already
3049 determined which symbols are to be attached. Here we just
3050 determine how much space we will need for them. */
3051 sym_ptr_ptr
= bfd_get_outsymbols (abfd
);
3052 if (sym_ptr_ptr
!= NULL
)
3056 sym_end
= sym_ptr_ptr
+ bfd_get_symcount (abfd
);
3057 for (; sym_ptr_ptr
< sym_end
; sym_ptr_ptr
++)
3059 if (((*sym_ptr_ptr
)->flags
& BSF_DEBUGGING
) == 0
3060 && ((*sym_ptr_ptr
)->flags
& BSF_LOCAL
) == 0)
3063 symhdr
->issExtMax
+= strlen ((*sym_ptr_ptr
)->name
) + 1;
3068 /* Adjust the counts so that structures are longword aligned. */
3069 symhdr
->cbLine
= (symhdr
->cbLine
+ 3) &~ 3;
3070 symhdr
->issMax
= (symhdr
->issMax
+ 3) &~ 3;
3071 symhdr
->issExtMax
= (symhdr
->issExtMax
+ 3) &~ 3;
3073 /* Now the counts in symhdr are the correct size for the debugging
3074 information. We allocate the right amount of space, and reset
3075 the counts so that the second pass can use them as indices. It
3076 would be possible to output the debugging information directly to
3077 the file in pass 2, rather than to build it in memory and then
3078 write it out. Outputting to the file would require a lot of
3079 seeks and small writes, though, and I think this approach is
3081 size
= (symhdr
->cbLine
* sizeof (unsigned char)
3082 + symhdr
->idnMax
* sizeof (struct dnr_ext
)
3083 + symhdr
->ipdMax
* sizeof (struct pdr_ext
)
3084 + symhdr
->isymMax
* sizeof (struct sym_ext
)
3085 + symhdr
->ioptMax
* sizeof (struct opt_ext
)
3086 + symhdr
->iauxMax
* sizeof (union aux_ext
)
3087 + symhdr
->issMax
* sizeof (char)
3088 + symhdr
->issExtMax
* sizeof (char)
3089 + symhdr
->ifdMax
* sizeof (struct fdr_ext
)
3090 + symhdr
->crfd
* sizeof (struct rfd_ext
)
3091 + symhdr
->iextMax
* sizeof (struct ext_ext
));
3092 raw
= (char *) bfd_alloc (abfd
, size
);
3093 if (raw
== (char *) NULL
)
3095 bfd_error
= no_memory
;
3098 ecoff_data (abfd
)->raw_size
= size
;
3099 ecoff_data (abfd
)->raw_syments
= (PTR
) raw
;
3101 /* Initialize the raw pointers. */
3102 #define SET(field, count, type) \
3103 ecoff_data (abfd)->field = (type *) raw; \
3104 raw += symhdr->count * sizeof (type)
3106 SET (line
, cbLine
, unsigned char);
3107 SET (external_dnr
, idnMax
, struct dnr_ext
);
3108 SET (external_pdr
, ipdMax
, struct pdr_ext
);
3109 SET (external_sym
, isymMax
, struct sym_ext
);
3110 SET (external_opt
, ioptMax
, struct opt_ext
);
3111 SET (external_aux
, iauxMax
, union aux_ext
);
3112 SET (ss
, issMax
, char);
3113 SET (ssext
, issExtMax
, char);
3114 SET (external_fdr
, ifdMax
, struct fdr_ext
);
3115 SET (external_rfd
, crfd
, struct rfd_ext
);
3116 SET (external_ext
, iextMax
, struct ext_ext
);
3119 /* Reset the counts so the second pass can use them to know how far
3121 symhdr
->ilineMax
= 0;
3125 symhdr
->isymMax
= 0;
3126 symhdr
->ioptMax
= 0;
3127 symhdr
->iauxMax
= 0;
3129 symhdr
->issExtMax
= 0;
3132 symhdr
->iextMax
= 0;
3134 /* Do the second pass: accumulate the debugging information. */
3135 ecoff_clear_output_flags (abfd
);
3136 for (ipass
= 0; ipass
< 2; ipass
++)
3138 for (o
= abfd
->sections
; o
!= (asection
*) NULL
; o
= o
->next
)
3140 if (((o
->flags
& SEC_CODE
) == 0) != ipass
)
3142 for (p
= o
->seclets_head
;
3143 p
!= (bfd_seclet_type
*) NULL
;
3146 if (p
->type
== bfd_indirect_seclet
)
3148 if (ecoff_get_debug (abfd
, p
, o
, relocateable
) == false)
3155 /* Put in the external symbols. */
3156 sym_ptr_ptr
= bfd_get_outsymbols (abfd
);
3157 if (sym_ptr_ptr
!= NULL
)
3160 struct ext_ext
*external_ext
;
3162 ssext
= ecoff_data (abfd
)->ssext
;
3163 external_ext
= ecoff_data (abfd
)->external_ext
;
3164 for (; *sym_ptr_ptr
!= NULL
; sym_ptr_ptr
++)
3169 sym_ptr
= *sym_ptr_ptr
;
3171 if ((sym_ptr
->flags
& BSF_DEBUGGING
) != 0
3172 || (sym_ptr
->flags
& BSF_LOCAL
) != 0)
3175 /* The enative pointer can be NULL for a symbol created by
3176 the linker via ecoff_make_empty_symbol. */
3177 if (bfd_asymbol_flavour (sym_ptr
) != bfd_target_ecoff_flavour
3178 || (((ecoff_symbol_type
*) sym_ptr
)->native
.enative
3179 == (struct ext_ext
*) NULL
))
3182 esym
.cobol_main
= 0;
3186 /* FIXME: we can do better than this for st and sc. */
3187 esym
.asym
.st
= stGlobal
;
3188 esym
.asym
.sc
= scAbs
;
3189 esym
.asym
.reserved
= 0;
3190 esym
.asym
.index
= indexNil
;
3194 ecoff_symbol_type
*ecoff_sym_ptr
;
3196 ecoff_sym_ptr
= (ecoff_symbol_type
*) sym_ptr
;
3197 if (ecoff_sym_ptr
->local
)
3199 ecoff_swap_ext_in (abfd
, ecoff_sym_ptr
->native
.enative
, &esym
);
3201 /* If we're producing an executable, move common symbols
3203 if (relocateable
== false)
3205 if (esym
.asym
.sc
== scCommon
)
3206 esym
.asym
.sc
= scBss
;
3207 else if (esym
.asym
.sc
== scSCommon
)
3208 esym
.asym
.sc
= scSBss
;
3211 /* Adjust the FDR index for the symbol by that used for
3213 esym
.ifd
+= ecoff_data (bfd_asymbol_bfd (sym_ptr
))->ifdbase
;
3216 esym
.asym
.iss
= symhdr
->issExtMax
;
3218 if (bfd_is_com_section (sym_ptr
->section
)
3219 || sym_ptr
->section
== &bfd_und_section
)
3220 esym
.asym
.value
= sym_ptr
->value
;
3222 esym
.asym
.value
= (sym_ptr
->value
3223 + sym_ptr
->section
->output_offset
3224 + sym_ptr
->section
->output_section
->vma
);
3226 ecoff_swap_ext_out (abfd
, &esym
, external_ext
+ symhdr
->iextMax
);
3228 ecoff_set_sym_index (sym_ptr
, symhdr
->iextMax
);
3232 strcpy (ssext
+ symhdr
->issExtMax
, sym_ptr
->name
);
3233 symhdr
->issExtMax
+= strlen (sym_ptr
->name
) + 1;
3237 /* Adjust the counts so that structures are longword aligned. */
3238 symhdr
->cbLine
= (symhdr
->cbLine
+ 3) &~ 3;
3239 symhdr
->issMax
= (symhdr
->issMax
+ 3) &~ 3;
3240 symhdr
->issExtMax
= (symhdr
->issExtMax
+ 3) &~ 3;
3245 /* Set the architecture. The only architecture we support here is
3246 mips. We set the architecture anyhow, since many callers ignore
3247 the return value. */
3250 ecoff_set_arch_mach (abfd
, arch
, machine
)
3252 enum bfd_architecture arch
;
3253 unsigned long machine
;
3255 bfd_default_set_arch_mach (abfd
, arch
, machine
);
3256 return arch
== bfd_arch_mips
;
3259 /* Get the size of the section headers. We do not output the .scommon
3260 section which we created in ecoff_mkobject. */
3263 ecoff_sizeof_headers (abfd
, reloc
)
3267 return FILHSZ
+ AOUTSZ
+ (abfd
->section_count
- 1) * SCNHSZ
;
3270 /* Calculate the file position for each section, and set
3274 ecoff_compute_section_file_positions (abfd
)
3282 if (bfd_get_start_address (abfd
))
3283 abfd
->flags
|= EXEC_P
;
3285 sofar
= ecoff_sizeof_headers (abfd
, false);
3288 for (current
= abfd
->sections
;
3289 current
!= (asection
*) NULL
;
3290 current
= current
->next
)
3292 /* Only deal with sections which have contents */
3293 if (! (current
->flags
& SEC_HAS_CONTENTS
)
3294 || strcmp (current
->name
, SCOMMON
) == 0)
3297 /* On Ultrix, the data sections in an executable file must be
3298 aligned to a page boundary within the file. This does not
3299 affect the section size, though. FIXME: Does this work for
3301 if ((abfd
->flags
& EXEC_P
) != 0
3302 && (abfd
->flags
& D_PAGED
) != 0
3303 && first_data
!= false
3304 && (current
->flags
& SEC_CODE
) == 0)
3306 sofar
= (sofar
+ ROUND_SIZE
- 1) &~ (ROUND_SIZE
- 1);
3310 /* Align the sections in the file to the same boundary on
3311 which they are aligned in virtual memory. */
3313 sofar
= BFD_ALIGN (sofar
, 1 << current
->alignment_power
);
3315 current
->filepos
= sofar
;
3317 sofar
+= current
->_raw_size
;
3319 /* make sure that this section is of the right size too */
3321 sofar
= BFD_ALIGN (sofar
, 1 << current
->alignment_power
);
3322 current
->_raw_size
+= sofar
- old_sofar
;
3325 ecoff_data (abfd
)->reloc_filepos
= sofar
;
3328 /* Set the contents of a section. */
3331 ecoff_set_section_contents (abfd
, section
, location
, offset
, count
)
3336 bfd_size_type count
;
3338 if (abfd
->output_has_begun
== false)
3339 ecoff_compute_section_file_positions (abfd
);
3341 bfd_seek (abfd
, (file_ptr
) (section
->filepos
+ offset
), SEEK_SET
);
3344 return (bfd_write (location
, 1, count
, abfd
) == count
) ? true : false;
3349 /* Write out an ECOFF file. */
3352 ecoff_write_object_contents (abfd
)
3358 file_ptr reloc_base
;
3360 unsigned long reloc_size
;
3361 unsigned long text_size
;
3362 unsigned long text_start
;
3363 unsigned long data_size
;
3364 unsigned long data_start
;
3365 unsigned long bss_size
;
3366 struct internal_filehdr internal_f
;
3367 struct internal_aouthdr internal_a
;
3370 bfd_error
= system_call_error
;
3372 if(abfd
->output_has_begun
== false)
3373 ecoff_compute_section_file_positions(abfd
);
3375 if (abfd
->sections
!= (asection
*) NULL
)
3376 scn_base
= abfd
->sections
->filepos
;
3379 reloc_base
= ecoff_data (abfd
)->reloc_filepos
;
3383 for (current
= abfd
->sections
;
3384 current
!= (asection
*)NULL
;
3385 current
= current
->next
)
3387 if (strcmp (current
->name
, SCOMMON
) == 0)
3389 current
->target_index
= count
;
3391 if (current
->reloc_count
!= 0)
3393 bfd_size_type relsize
;
3395 current
->rel_filepos
= reloc_base
;
3396 relsize
= current
->reloc_count
* RELSZ
;
3397 reloc_size
+= relsize
;
3398 reloc_base
+= relsize
;
3401 current
->rel_filepos
= 0;
3404 sym_base
= reloc_base
+ reloc_size
;
3406 /* At least on Ultrix, the symbol table of an executable file must
3407 be aligned to a page boundary. FIXME: Is this true on other
3409 if ((abfd
->flags
& EXEC_P
) != 0
3410 && (abfd
->flags
& D_PAGED
) != 0)
3411 sym_base
= (sym_base
+ ROUND_SIZE
- 1) &~ (ROUND_SIZE
- 1);
3413 ecoff_data (abfd
)->sym_filepos
= sym_base
;
3415 if ((abfd
->flags
& D_PAGED
) != 0)
3416 text_size
= ecoff_sizeof_headers (abfd
, false);
3424 /* Write section headers to the file. */
3426 internal_f
.f_nscns
= 0;
3427 if (bfd_seek (abfd
, (file_ptr
) (FILHSZ
+ AOUTSZ
), SEEK_SET
) != 0)
3429 for (current
= abfd
->sections
;
3430 current
!= (asection
*) NULL
;
3431 current
= current
->next
)
3433 struct internal_scnhdr section
;
3436 if (strcmp (current
->name
, SCOMMON
) == 0)
3438 BFD_ASSERT (bfd_get_section_size_before_reloc (current
) == 0
3439 && current
->reloc_count
== 0);
3443 ++internal_f
.f_nscns
;
3445 strncpy (section
.s_name
, current
->name
, sizeof section
.s_name
);
3447 /* FIXME: is this correct for shared libraries? I think it is
3448 but I have no platform to check. Ian Lance Taylor. */
3449 vma
= bfd_get_section_vma (abfd
, current
);
3450 if (strcmp (current
->name
, _LIB
) == 0)
3451 section
.s_vaddr
= 0;
3453 section
.s_vaddr
= vma
;
3455 section
.s_paddr
= vma
;
3456 section
.s_size
= bfd_get_section_size_before_reloc (current
);
3458 /* If this section has no size or is unloadable then the scnptr
3460 if (current
->_raw_size
== 0
3461 || (current
->flags
& (SEC_LOAD
| SEC_HAS_CONTENTS
)) == 0)
3462 section
.s_scnptr
= 0;
3464 section
.s_scnptr
= current
->filepos
;
3465 section
.s_relptr
= current
->rel_filepos
;
3467 /* FIXME: the lnnoptr of the .sbss or .sdata section of an
3468 object file produced by the assembler is supposed to point to
3469 information about how much room is required by objects of
3470 various different sizes. I think this only matters if we
3471 want the linker to compute the best size to use, or
3472 something. I don't know what happens if the information is
3474 section
.s_lnnoptr
= 0;
3476 section
.s_nreloc
= current
->reloc_count
;
3477 section
.s_nlnno
= 0;
3478 section
.s_flags
= ecoff_sec_to_styp_flags (current
->name
,
3484 ecoff_swap_scnhdr_out (abfd
, (PTR
) §ion
, (PTR
) &buff
);
3485 if (bfd_write ((PTR
) &buff
, 1, SCNHSZ
, abfd
) != SCNHSZ
)
3489 if ((section
.s_flags
& STYP_TEXT
) != 0)
3491 text_size
+= bfd_get_section_size_before_reloc (current
);
3492 if (text_start
== 0 || text_start
> vma
)
3495 else if ((section
.s_flags
& STYP_RDATA
) != 0
3496 || (section
.s_flags
& STYP_DATA
) != 0
3497 || (section
.s_flags
& STYP_LIT8
) != 0
3498 || (section
.s_flags
& STYP_LIT4
) != 0
3499 || (section
.s_flags
& STYP_SDATA
) != 0)
3501 data_size
+= bfd_get_section_size_before_reloc (current
);
3502 if (data_start
== 0 || data_start
> vma
)
3505 else if ((section
.s_flags
& STYP_BSS
) != 0
3506 || (section
.s_flags
& STYP_SBSS
) != 0)
3507 bss_size
+= bfd_get_section_size_before_reloc (current
);
3510 /* Set up the file header. */
3512 if (abfd
->xvec
->header_byteorder_big_p
!= false)
3513 internal_f
.f_magic
= MIPS_MAGIC_BIG
;
3515 internal_f
.f_magic
= MIPS_MAGIC_LITTLE
;
3518 We will NOT put a fucking timestamp in the header here. Every time you
3519 put it back, I will come in and take it out again. I'm sorry. This
3520 field does not belong here. We fill it with a 0 so it compares the
3521 same but is not a reasonable time. -- gnu@cygnus.com
3523 internal_f
.f_timdat
= 0;
3525 if (bfd_get_symcount (abfd
) != 0)
3527 /* The ECOFF f_nsyms field is not actually the number of
3528 symbols, it's the size of symbolic information header. */
3529 internal_f
.f_nsyms
= sizeof (struct hdr_ext
);
3530 internal_f
.f_symptr
= sym_base
;
3534 internal_f
.f_nsyms
= 0;
3535 internal_f
.f_symptr
= 0;
3538 internal_f
.f_opthdr
= AOUTSZ
;
3540 internal_f
.f_flags
= F_LNNO
;
3541 if (reloc_size
== 0)
3542 internal_f
.f_flags
|= F_RELFLG
;
3543 if (bfd_get_symcount (abfd
) == 0)
3544 internal_f
.f_flags
|= F_LSYMS
;
3545 if (abfd
->flags
& EXEC_P
)
3546 internal_f
.f_flags
|= F_EXEC
;
3548 if (! abfd
->xvec
->byteorder_big_p
)
3549 internal_f
.f_flags
|= F_AR32WR
;
3551 internal_f
.f_flags
|= F_AR32W
;
3553 /* Set up the ``optional'' header. */
3554 if ((abfd
->flags
& D_PAGED
) != 0)
3555 internal_a
.magic
= ZMAGIC
;
3557 internal_a
.magic
= OMAGIC
;
3559 /* FIXME: This is what Ultrix puts in, and it makes the Ultrix
3560 linker happy. But, is it right? */
3561 internal_a
.vstamp
= 0x20a;
3563 /* At least on Ultrix, these have to be rounded to page boundaries.
3564 FIXME: Is this true on other platforms? */
3565 if ((abfd
->flags
& D_PAGED
) != 0)
3567 internal_a
.tsize
= (text_size
+ ROUND_SIZE
- 1) &~ (ROUND_SIZE
- 1);
3568 internal_a
.text_start
= text_start
&~ (ROUND_SIZE
- 1);
3569 internal_a
.dsize
= (data_size
+ ROUND_SIZE
- 1) &~ (ROUND_SIZE
- 1);
3570 internal_a
.data_start
= data_start
&~ (ROUND_SIZE
- 1);
3574 internal_a
.tsize
= text_size
;
3575 internal_a
.text_start
= text_start
;
3576 internal_a
.dsize
= data_size
;
3577 internal_a
.data_start
= data_start
;
3580 /* On Ultrix, the initial portions of the .sbss and .bss segments
3581 are at the end of the data section. The bsize field in the
3582 optional header records how many bss bytes are required beyond
3583 those in the data section. The value is not rounded to a page
3585 if (bss_size
< internal_a
.dsize
- data_size
)
3588 bss_size
-= internal_a
.dsize
- data_size
;
3589 internal_a
.bsize
= bss_size
;
3590 internal_a
.bss_start
= internal_a
.data_start
+ internal_a
.dsize
;
3592 internal_a
.entry
= bfd_get_start_address (abfd
);
3594 internal_a
.gp_value
= ecoff_data (abfd
)->gp
;
3596 internal_a
.gprmask
= ecoff_data (abfd
)->gprmask
;
3597 for (i
= 0; i
< 4; i
++)
3598 internal_a
.cprmask
[i
] = ecoff_data (abfd
)->cprmask
[i
];
3600 /* Write out the file header and the optional header. */
3602 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
) != 0)
3607 ecoff_swap_filehdr_out (abfd
, (PTR
) &internal_f
, (PTR
) &buff
);
3608 if (bfd_write ((PTR
) &buff
, 1, FILHSZ
, abfd
) != FILHSZ
)
3615 ecoff_swap_aouthdr_out (abfd
, (PTR
) &internal_a
, (PTR
) &buff
);
3616 if (bfd_write ((PTR
) &buff
, 1, AOUTSZ
, abfd
) != AOUTSZ
)
3620 /* Write out the relocs. */
3621 for (current
= abfd
->sections
;
3622 current
!= (asection
*) NULL
;
3623 current
= current
->next
)
3626 arelent
**reloc_ptr_ptr
;
3627 arelent
**reloc_end
;
3630 if (current
->reloc_count
== 0)
3633 buff
= (RELOC
*) bfd_alloc (abfd
, current
->reloc_count
* RELSZ
);
3634 if (buff
== (RELOC
*) NULL
)
3636 bfd_error
= no_memory
;
3640 reloc_ptr_ptr
= current
->orelocation
;
3641 reloc_end
= reloc_ptr_ptr
+ current
->reloc_count
;
3643 for (; reloc_ptr_ptr
< reloc_end
; reloc_ptr_ptr
++, out_ptr
++)
3647 struct internal_reloc in
;
3649 memset (&in
, 0, sizeof in
);
3651 reloc
= *reloc_ptr_ptr
;
3652 sym
= *reloc
->sym_ptr_ptr
;
3654 /* This must be an ECOFF reloc. */
3655 BFD_ASSERT (reloc
->howto
!= (reloc_howto_type
*) NULL
3656 && reloc
->howto
>= ecoff_howto_table
3658 < (ecoff_howto_table
+ ECOFF_HOWTO_COUNT
)));
3660 in
.r_vaddr
= reloc
->address
+ bfd_get_section_vma (abfd
, current
);
3661 in
.r_type
= reloc
->howto
->type
;
3663 /* If this is a REFHI reloc, the next one must be a REFLO
3664 reloc for the same symbol. */
3665 BFD_ASSERT (in
.r_type
!= ECOFF_R_REFHI
3666 || (reloc_ptr_ptr
< reloc_end
3667 && (reloc_ptr_ptr
[1]->howto
3668 != (reloc_howto_type
*) NULL
)
3669 && (reloc_ptr_ptr
[1]->howto
->type
3671 && (sym
== *reloc_ptr_ptr
[1]->sym_ptr_ptr
)));
3673 if ((sym
->flags
& BSF_SECTION_SYM
) == 0)
3675 in
.r_symndx
= ecoff_get_sym_index (*reloc
->sym_ptr_ptr
);
3682 name
= bfd_get_section_name (abfd
, bfd_get_section (sym
));
3683 if (strcmp (name
, ".text") == 0)
3684 in
.r_symndx
= RELOC_SECTION_TEXT
;
3685 else if (strcmp (name
, ".rdata") == 0)
3686 in
.r_symndx
= RELOC_SECTION_RDATA
;
3687 else if (strcmp (name
, ".data") == 0)
3688 in
.r_symndx
= RELOC_SECTION_DATA
;
3689 else if (strcmp (name
, ".sdata") == 0)
3690 in
.r_symndx
= RELOC_SECTION_SDATA
;
3691 else if (strcmp (name
, ".sbss") == 0)
3692 in
.r_symndx
= RELOC_SECTION_SBSS
;
3693 else if (strcmp (name
, ".bss") == 0)
3694 in
.r_symndx
= RELOC_SECTION_BSS
;
3695 else if (strcmp (name
, ".init") == 0)
3696 in
.r_symndx
= RELOC_SECTION_INIT
;
3697 else if (strcmp (name
, ".lit8") == 0)
3698 in
.r_symndx
= RELOC_SECTION_LIT8
;
3699 else if (strcmp (name
, ".lit4") == 0)
3700 in
.r_symndx
= RELOC_SECTION_LIT4
;
3706 ecoff_swap_reloc_out (abfd
, (PTR
) &in
, (PTR
) out_ptr
);
3709 if (bfd_seek (abfd
, current
->rel_filepos
, SEEK_SET
) != 0)
3711 if (bfd_write ((PTR
) buff
, RELSZ
, current
->reloc_count
, abfd
)
3712 != RELSZ
* current
->reloc_count
)
3714 bfd_release (abfd
, (PTR
) buff
);
3717 /* Write out the symbolic debugging information. */
3718 if (bfd_get_symcount (abfd
) > 0)
3721 unsigned long sym_offset
;
3722 struct hdr_ext buff
;
3724 /* Set up the offsets in the symbolic header. */
3725 symhdr
= &ecoff_data (abfd
)->symbolic_header
;
3726 sym_offset
= ecoff_data (abfd
)->sym_filepos
+ sizeof (struct hdr_ext
);
3728 #define SET(offset, size, ptr) \
3729 if (symhdr->size == 0) \
3730 symhdr->offset = 0; \
3732 symhdr->offset = (((char *) ecoff_data (abfd)->ptr \
3733 - (char *) ecoff_data (abfd)->raw_syments) \
3736 SET (cbLineOffset
, cbLine
, line
);
3737 SET (cbDnOffset
, idnMax
, external_dnr
);
3738 SET (cbPdOffset
, ipdMax
, external_pdr
);
3739 SET (cbSymOffset
, isymMax
, external_sym
);
3740 SET (cbOptOffset
, ioptMax
, external_opt
);
3741 SET (cbAuxOffset
, iauxMax
, external_aux
);
3742 SET (cbSsOffset
, issMax
, ss
);
3743 SET (cbSsExtOffset
, issExtMax
, ssext
);
3744 SET (cbFdOffset
, ifdMax
, external_fdr
);
3745 SET (cbRfdOffset
, crfd
, external_rfd
);
3746 SET (cbExtOffset
, iextMax
, external_ext
);
3749 if (bfd_seek (abfd
, (file_ptr
) ecoff_data (abfd
)->sym_filepos
,
3752 ecoff_swap_hdr_out (abfd
, &ecoff_data (abfd
)->symbolic_header
, &buff
);
3753 if (bfd_write ((PTR
) &buff
, 1, sizeof buff
, abfd
) != sizeof buff
)
3755 if (bfd_write ((PTR
) ecoff_data (abfd
)->raw_syments
, 1,
3756 ecoff_data (abfd
)->raw_size
, abfd
)
3757 != ecoff_data (abfd
)->raw_size
)
3760 else if ((abfd
->flags
& EXEC_P
) != 0
3761 && (abfd
->flags
& D_PAGED
) != 0)
3765 /* A demand paged executable must occupy an even number of
3767 if (bfd_seek (abfd
, (file_ptr
) ecoff_data (abfd
)->sym_filepos
- 1,
3770 if (bfd_read (&c
, 1, 1, abfd
) == 0)
3772 if (bfd_seek (abfd
, (file_ptr
) ecoff_data (abfd
)->sym_filepos
- 1,
3775 if (bfd_write (&c
, 1, 1, abfd
) != 1)
3782 /* Archive handling. ECOFF uses what appears to be a unique type of
3783 archive header (which I call an armap). The byte ordering of the
3784 armap and the contents are encoded in the name of the armap itself.
3785 At least for now, we only support archives with the same byte
3786 ordering in the armap and the contents.
3788 The first four bytes in the armap are the number of symbol
3789 definitions. This is always a power of two.
3791 This is followed by the symbol definitions. Each symbol definition
3792 occupies 8 bytes. The first four bytes are the offset from the
3793 start of the armap strings to the null-terminated string naming
3794 this symbol. The second four bytes are the file offset to the
3795 archive member which defines this symbol. If the second four bytes
3796 are 0, then this is not actually a symbol definition, and it should
3799 The symbols are hashed into the armap with a closed hashing scheme.
3800 See the functions below for the details of the algorithm.
3802 We could use the hash table when looking up symbols in a library.
3803 This would require a new BFD target entry point to replace the
3804 bfd_get_next_mapent function used by the linker.
3806 After the symbol definitions comes four bytes holding the size of
3807 the string table, followed by the string table itself. */
3809 /* The name of an archive headers looks like this:
3810 __________E[BL]E[BL]_ (with a trailing space).
3811 The trailing space is changed to an X if the archive is changed to
3812 indicate that the armap is out of date. */
3814 #define ARMAP_BIG_ENDIAN 'B'
3815 #define ARMAP_LITTLE_ENDIAN 'L'
3816 #define ARMAP_MARKER 'E'
3817 #define ARMAP_START "__________"
3818 #define ARMAP_HEADER_MARKER_INDEX 10
3819 #define ARMAP_HEADER_ENDIAN_INDEX 11
3820 #define ARMAP_OBJECT_MARKER_INDEX 12
3821 #define ARMAP_OBJECT_ENDIAN_INDEX 13
3822 #define ARMAP_END_INDEX 14
3823 #define ARMAP_END "_ "
3825 /* This is a magic number used in the hashing algorithm. */
3826 #define ARMAP_HASH_MAGIC 0x9dd68ab5
3828 /* This returns the hash value to use for a string. It also sets
3829 *REHASH to the rehash adjustment if the first slot is taken. SIZE
3830 is the number of entries in the hash table, and HLOG is the log
3834 ecoff_armap_hash (s
, rehash
, size
, hlog
)
3836 unsigned int *rehash
;
3844 hash
= ((hash
>> 27) | (hash
<< 5)) + *s
++;
3845 hash
*= ARMAP_HASH_MAGIC
;
3846 *rehash
= (hash
& (size
- 1)) | 1;
3847 return hash
>> (32 - hlog
);
3850 /* Read in the armap. */
3853 ecoff_slurp_armap (abfd
)
3858 struct areltdata
*mapdata
;
3859 bfd_size_type parsed_size
;
3861 struct artdata
*ardata
;
3864 struct symdef
*symdef_ptr
;
3867 /* Get the name of the first element. */
3868 i
= bfd_read ((PTR
) nextname
, 1, 16, abfd
);
3874 bfd_seek (abfd
, (file_ptr
) -16, SEEK_CUR
);
3876 /* See if the first element is an armap. */
3877 if (strncmp (nextname
, ARMAP_START
, sizeof ARMAP_START
- 1) != 0
3878 || nextname
[ARMAP_HEADER_MARKER_INDEX
] != ARMAP_MARKER
3879 || (nextname
[ARMAP_HEADER_ENDIAN_INDEX
] != ARMAP_BIG_ENDIAN
3880 && nextname
[ARMAP_HEADER_ENDIAN_INDEX
] != ARMAP_LITTLE_ENDIAN
)
3881 || nextname
[ARMAP_OBJECT_MARKER_INDEX
] != ARMAP_MARKER
3882 || (nextname
[ARMAP_OBJECT_ENDIAN_INDEX
] != ARMAP_BIG_ENDIAN
3883 && nextname
[ARMAP_OBJECT_ENDIAN_INDEX
] != ARMAP_LITTLE_ENDIAN
)
3884 || strncmp (nextname
+ ARMAP_END_INDEX
,
3885 ARMAP_END
, sizeof ARMAP_END
- 1) != 0)
3887 bfd_has_map (abfd
) = false;
3891 /* Make sure we have the right byte ordering. */
3892 if (((nextname
[ARMAP_HEADER_ENDIAN_INDEX
] == ARMAP_BIG_ENDIAN
)
3893 ^ (abfd
->xvec
->header_byteorder_big_p
!= false))
3894 || ((nextname
[ARMAP_OBJECT_ENDIAN_INDEX
] == ARMAP_BIG_ENDIAN
)
3895 ^ (abfd
->xvec
->byteorder_big_p
!= false)))
3897 bfd_error
= wrong_format
;
3901 /* Read in the armap. */
3902 ardata
= bfd_ardata (abfd
);
3903 mapdata
= snarf_ar_hdr (abfd
);
3904 if (mapdata
== (struct areltdata
*) NULL
)
3906 parsed_size
= mapdata
->parsed_size
;
3907 bfd_release (abfd
, (PTR
) mapdata
);
3909 raw_armap
= (char *) bfd_alloc (abfd
, parsed_size
);
3910 if (raw_armap
== (char *) NULL
)
3912 bfd_error
= no_memory
;
3916 if (bfd_read ((PTR
) raw_armap
, 1, parsed_size
, abfd
) != parsed_size
)
3918 bfd_error
= malformed_archive
;
3919 bfd_release (abfd
, (PTR
) raw_armap
);
3923 count
= bfd_h_get_32 (abfd
, (PTR
) raw_armap
);
3925 ardata
->symdef_count
= 0;
3926 ardata
->cache
= (struct ar_cache
*) NULL
;
3928 /* Hack: overlay the symdefs on top of the raw archive data. This
3929 is the way do_slurp_bsd_armap works. */
3930 raw_ptr
= raw_armap
+ LONG_SIZE
;
3931 symdef_ptr
= (struct symdef
*) raw_ptr
;
3932 ardata
->symdefs
= (carsym
*) symdef_ptr
;
3933 stringbase
= raw_ptr
+ count
* (2 * LONG_SIZE
) + LONG_SIZE
;
3935 #ifdef CHECK_ARMAP_HASH
3939 /* Double check that I have the hashing algorithm right by making
3940 sure that every symbol can be looked up successfully. */
3942 for (i
= 1; i
< count
; i
<<= 1)
3944 BFD_ASSERT (i
== count
);
3946 for (i
= 0; i
< count
; i
++, raw_ptr
+= 2 * LONG_SIZE
)
3948 unsigned int name_offset
, file_offset
;
3949 unsigned int hash
, rehash
, srch
;
3951 name_offset
= bfd_h_get_32 (abfd
, (PTR
) raw_ptr
);
3952 file_offset
= bfd_h_get_32 (abfd
, (PTR
) (raw_ptr
+ LONG_SIZE
));
3953 if (file_offset
== 0)
3955 hash
= ecoff_armap_hash (stringbase
+ name_offset
, &rehash
, count
,
3960 /* See if we can rehash to this location. */
3961 for (srch
= (hash
+ rehash
) & (count
- 1);
3962 srch
!= hash
&& srch
!= i
;
3963 srch
= (srch
+ rehash
) & (count
- 1))
3964 BFD_ASSERT (bfd_h_get_32 (abfd
,
3967 + (srch
* 2 * LONG_SIZE
)
3970 BFD_ASSERT (srch
== i
);
3974 raw_ptr
= raw_armap
+ LONG_SIZE
;
3975 #endif /* CHECK_ARMAP_HASH */
3977 for (i
= 0; i
< count
; i
++, raw_ptr
+= 2 * LONG_SIZE
)
3979 unsigned int name_offset
, file_offset
;
3981 name_offset
= bfd_h_get_32 (abfd
, (PTR
) raw_ptr
);
3982 file_offset
= bfd_h_get_32 (abfd
, (PTR
) (raw_ptr
+ LONG_SIZE
));
3983 if (file_offset
== 0)
3985 symdef_ptr
->s
.name
= stringbase
+ name_offset
;
3986 symdef_ptr
->file_offset
= file_offset
;
3988 ++ardata
->symdef_count
;
3991 ardata
->first_file_filepos
= bfd_tell (abfd
);
3992 /* Pad to an even boundary. */
3993 ardata
->first_file_filepos
+= ardata
->first_file_filepos
% 2;
3995 bfd_has_map (abfd
) = true;
4000 /* Write out an armap. */
4003 ecoff_write_armap (abfd
, elength
, map
, orl_count
, stridx
)
4005 unsigned int elength
;
4007 unsigned int orl_count
;
4010 unsigned int hashsize
, hashlog
;
4011 unsigned int symdefsize
;
4013 unsigned int stringsize
;
4014 unsigned int mapsize
;
4017 struct stat statbuf
;
4019 bfd_byte temp
[LONG_SIZE
];
4020 bfd_byte
*hashtable
;
4024 /* Ultrix appears to use as a hash table size the least power of two
4025 greater than twice the number of entries. */
4026 for (hashlog
= 0; (1 << hashlog
) <= 2 * orl_count
; hashlog
++)
4028 hashsize
= 1 << hashlog
;
4030 symdefsize
= hashsize
* 2 * LONG_SIZE
;
4032 stringsize
= stridx
+ padit
;
4034 /* Include 8 bytes to store symdefsize and stringsize in output. */
4035 mapsize
= LONG_SIZE
+ symdefsize
+ stringsize
+ LONG_SIZE
;
4037 firstreal
= SARMAG
+ sizeof (struct ar_hdr
) + mapsize
+ elength
;
4039 memset ((PTR
) &hdr
, 0, sizeof hdr
);
4041 /* Work out the ECOFF armap name. */
4042 strcpy (hdr
.ar_name
, ARMAP_START
);
4043 hdr
.ar_name
[ARMAP_HEADER_MARKER_INDEX
] = ARMAP_MARKER
;
4044 hdr
.ar_name
[ARMAP_HEADER_ENDIAN_INDEX
] =
4045 (abfd
->xvec
->header_byteorder_big_p
4047 : ARMAP_LITTLE_ENDIAN
);
4048 hdr
.ar_name
[ARMAP_OBJECT_MARKER_INDEX
] = ARMAP_MARKER
;
4049 hdr
.ar_name
[ARMAP_OBJECT_ENDIAN_INDEX
] =
4050 abfd
->xvec
->byteorder_big_p
? ARMAP_BIG_ENDIAN
: ARMAP_LITTLE_ENDIAN
;
4051 memcpy (hdr
.ar_name
+ ARMAP_END_INDEX
, ARMAP_END
, sizeof ARMAP_END
- 1);
4053 /* Write the timestamp of the archive header to be just a little bit
4054 later than the timestamp of the file, otherwise the linker will
4055 complain that the index is out of date. Actually, the Ultrix
4056 linker just checks the archive name; the GNU linker may check the
4058 stat (abfd
->filename
, &statbuf
);
4059 sprintf (hdr
.ar_date
, "%ld", (long) (statbuf
.st_mtime
+ 60));
4061 /* The DECstation uses zeroes for the uid, gid and mode of the
4063 hdr
.ar_uid
[0] = '0';
4064 hdr
.ar_gid
[0] = '0';
4065 hdr
.ar_mode
[0] = '0';
4067 sprintf (hdr
.ar_size
, "%-10d", (int) mapsize
);
4069 hdr
.ar_fmag
[0] = '`';
4070 hdr
.ar_fmag
[1] = '\n';
4072 /* Turn all null bytes in the header into spaces. */
4073 for (i
= 0; i
< sizeof (struct ar_hdr
); i
++)
4074 if (((char *)(&hdr
))[i
] == '\0')
4075 (((char *)(&hdr
))[i
]) = ' ';
4077 if (bfd_write ((PTR
) &hdr
, 1, sizeof (struct ar_hdr
), abfd
)
4078 != sizeof (struct ar_hdr
))
4081 bfd_h_put_32 (abfd
, hashsize
, temp
);
4082 if (bfd_write (temp
, 1, LONG_SIZE
, abfd
) != LONG_SIZE
)
4085 hashtable
= (bfd_byte
*) bfd_zalloc (abfd
, symdefsize
);
4087 current
= abfd
->archive_head
;
4089 for (i
= 0; i
< orl_count
; i
++)
4091 unsigned int hash
, rehash
;
4093 /* Advance firstreal to the file position of this archive
4095 if (((bfd
*) map
[i
].pos
) != last_elt
)
4099 firstreal
+= arelt_size (current
) + sizeof (struct ar_hdr
);
4100 firstreal
+= firstreal
% 2;
4101 current
= current
->next
;
4103 while (current
!= (bfd
*) map
[i
].pos
);
4108 hash
= ecoff_armap_hash (*map
[i
].name
, &rehash
, hashsize
, hashlog
);
4109 if (bfd_h_get_32 (abfd
, (PTR
) (hashtable
4110 + (hash
* 2 * LONG_SIZE
)
4116 /* The desired slot is already taken. */
4117 for (srch
= (hash
+ rehash
) & (hashsize
- 1);
4119 srch
= (srch
+ rehash
) & (hashsize
- 1))
4120 if (bfd_h_get_32 (abfd
, (PTR
) (hashtable
4121 + (srch
* 2 * LONG_SIZE
)
4126 BFD_ASSERT (srch
!= hash
);
4131 bfd_h_put_32 (abfd
, map
[i
].namidx
,
4132 (PTR
) (hashtable
+ hash
* 2 * LONG_SIZE
));
4133 bfd_h_put_32 (abfd
, firstreal
,
4134 (PTR
) (hashtable
+ hash
* 2 * LONG_SIZE
+ LONG_SIZE
));
4137 if (bfd_write (hashtable
, 1, symdefsize
, abfd
) != symdefsize
)
4140 bfd_release (abfd
, hashtable
);
4142 /* Now write the strings. */
4143 bfd_h_put_32 (abfd
, stringsize
, temp
);
4144 if (bfd_write (temp
, 1, LONG_SIZE
, abfd
) != LONG_SIZE
)
4146 for (i
= 0; i
< orl_count
; i
++)
4150 len
= strlen (*map
[i
].name
) + 1;
4151 if (bfd_write ((PTR
) (*map
[i
].name
), 1, len
, abfd
) != len
)
4155 /* The spec sez this should be a newline. But in order to be
4156 bug-compatible for DECstation ar we use a null. */
4159 if (bfd_write ("\0", 1, 1, abfd
) != 1)
4166 /* We just use the generic extended name support. This is a GNU
4168 #define ecoff_slurp_extended_name_table _bfd_slurp_extended_name_table
4170 /* See whether this BFD is an archive. If it is, read in the armap
4171 and the extended name table. */
4174 ecoff_archive_p (abfd
)
4177 char armag
[SARMAG
+ 1];
4179 if (bfd_read ((PTR
) armag
, 1, SARMAG
, abfd
) != SARMAG
4180 || strncmp (armag
, ARMAG
, SARMAG
) != 0)
4182 bfd_error
= wrong_format
;
4183 return (bfd_target
*) NULL
;
4186 /* We are setting bfd_ardata(abfd) here, but since bfd_ardata
4187 involves a cast, we can't do it as the left operand of
4189 abfd
->tdata
.aout_ar_data
=
4190 (struct artdata
*) bfd_zalloc (abfd
, sizeof (struct artdata
));
4192 if (bfd_ardata (abfd
) == (struct artdata
*) NULL
)
4194 bfd_error
= no_memory
;
4195 return (bfd_target
*) NULL
;
4198 bfd_ardata (abfd
)->first_file_filepos
= SARMAG
;
4200 if (ecoff_slurp_armap (abfd
) == false
4201 || ecoff_slurp_extended_name_table (abfd
) == false)
4203 bfd_release (abfd
, bfd_ardata (abfd
));
4204 abfd
->tdata
.aout_ar_data
= (struct artdata
*) NULL
;
4205 return (bfd_target
*) NULL
;
4213 #include <core.out.h>
4215 struct sgi_core_struct
4218 char cmd
[CORE_NAMESIZE
];
4221 #define core_hdr(bfd) ((bfd)->tdata.sgi_core_data)
4222 #define core_signal(bfd) (core_hdr(bfd)->sig)
4223 #define core_command(bfd) (core_hdr(bfd)->cmd)
4226 make_bfd_asection (abfd
, name
, flags
, _raw_size
, vma
, filepos
)
4230 bfd_size_type _raw_size
;
4236 asect
= bfd_make_section (abfd
, name
);
4240 asect
->flags
= flags
;
4241 asect
->_raw_size
= _raw_size
;
4243 asect
->filepos
= filepos
;
4244 asect
->alignment_power
= 4;
4250 ecoff_core_file_p (abfd
)
4256 struct coreout coreout
;
4257 struct idesc
*idg
, *idf
, *ids
;
4259 val
= bfd_read ((PTR
)&coreout
, 1, sizeof coreout
, abfd
);
4260 if (val
!= sizeof coreout
)
4263 if (coreout
.c_magic
!= CORE_MAGIC
4264 || coreout
.c_version
!= CORE_VERSION1
)
4267 core_hdr (abfd
) = (struct sgi_core_struct
*) bfd_zalloc (abfd
, sizeof (struct sgi_core_struct
));
4268 if (!core_hdr (abfd
))
4271 strncpy (core_command (abfd
), coreout
.c_name
, CORE_NAMESIZE
);
4272 core_signal (abfd
) = coreout
.c_sigcause
;
4274 bfd_seek (abfd
, coreout
.c_vmapoffset
, SEEK_SET
);
4276 for (i
= 0; i
< coreout
.c_nvmap
; i
++)
4280 val
= bfd_read ((PTR
)&vmap
, 1, sizeof vmap
, abfd
);
4281 if (val
!= sizeof vmap
)
4284 switch (vmap
.v_type
)
4296 if (!make_bfd_asection (abfd
, secname
,
4297 SEC_ALLOC
+SEC_LOAD
+SEC_HAS_CONTENTS
,
4305 /* Make sure that the regs are contiguous within the core file. */
4307 idg
= &coreout
.c_idesc
[I_GPREGS
];
4308 idf
= &coreout
.c_idesc
[I_FPREGS
];
4309 ids
= &coreout
.c_idesc
[I_SPECREGS
];
4311 if (idg
->i_offset
+ idg
->i_len
!= idf
->i_offset
4312 || idf
->i_offset
+ idf
->i_len
!= ids
->i_offset
)
4313 return 0; /* Can't deal with non-contig regs */
4315 bfd_seek (abfd
, idg
->i_offset
, SEEK_SET
);
4317 make_bfd_asection (abfd
, ".reg",
4318 SEC_ALLOC
+SEC_HAS_CONTENTS
,
4319 idg
->i_len
+ idf
->i_len
+ ids
->i_len
,
4323 /* OK, we believe you. You're a core file (sure, sure). */
4329 ecoff_core_file_failing_command (abfd
)
4332 return core_command (abfd
);
4336 ecoff_core_file_failing_signal (abfd
)
4339 return core_signal (abfd
);
4343 ecoff_core_file_matches_executable_p (core_bfd
, exec_bfd
)
4344 bfd
*core_bfd
, *exec_bfd
;
4346 return true; /* XXX - FIXME */
4348 #else /* not def HOST_IRIX4 */
4349 #define ecoff_core_file_p _bfd_dummy_target
4350 #define ecoff_core_file_failing_command _bfd_dummy_core_file_failing_command
4351 #define ecoff_core_file_failing_signal _bfd_dummy_core_file_failing_signal
4352 #define ecoff_core_file_matches_executable_p \
4353 _bfd_dummy_core_file_matches_executable_p
4356 /* This is the COFF backend structure. The backend_data field of the
4357 bfd_target structure is set to this. The section reading code in
4358 coffgen.c uses this structure. */
4360 static CONST bfd_coff_backend_data bfd_ecoff_std_swap_table
= {
4361 (void (*) PARAMS ((bfd
*,PTR
,int,int,PTR
))) bfd_void
, /* aux_in */
4362 (void (*) PARAMS ((bfd
*,PTR
,PTR
))) bfd_void
, /* sym_in */
4363 (void (*) PARAMS ((bfd
*,PTR
,PTR
))) bfd_void
, /* lineno_in */
4364 (unsigned (*) PARAMS ((bfd
*,PTR
,int,int,PTR
))) bfd_void
, /* aux_out */
4365 (unsigned (*) PARAMS ((bfd
*,PTR
,PTR
))) bfd_void
, /* sym_out */
4366 (unsigned (*) PARAMS ((bfd
*,PTR
,PTR
))) bfd_void
, /* lineno_out */
4367 ecoff_swap_reloc_out
, ecoff_swap_filehdr_out
, ecoff_swap_aouthdr_out
,
4368 ecoff_swap_scnhdr_out
,
4369 FILHSZ
, AOUTSZ
, SCNHSZ
, 0, 0, 0, true,
4370 ecoff_swap_filehdr_in
, ecoff_swap_aouthdr_in
, ecoff_swap_scnhdr_in
,
4371 ecoff_bad_format_hook
, ecoff_set_arch_mach_hook
, ecoff_mkobject_hook
,
4372 ecoff_styp_to_sec_flags
, ecoff_make_section_hook
, ecoff_set_alignment_hook
,
4373 ecoff_slurp_symbol_table
4376 /* get_lineno could be written for ECOFF, but it would currently only
4377 be useful for linking ECOFF and COFF files together, which doesn't
4379 #define ecoff_get_lineno \
4380 ((alent *(*) PARAMS ((bfd *, asymbol *))) bfd_nullvoidptr)
4382 /* These bfd_target functions are defined in other files. */
4384 #define ecoff_truncate_arname bfd_dont_truncate_arname
4385 #define ecoff_openr_next_archived_file bfd_generic_openr_next_archived_file
4386 #define ecoff_generic_stat_arch_elt bfd_generic_stat_arch_elt
4387 #define ecoff_get_section_contents bfd_generic_get_section_contents
4388 #define ecoff_get_reloc_upper_bound coff_get_reloc_upper_bound
4389 #define ecoff_close_and_cleanup bfd_generic_close_and_cleanup
4390 #define ecoff_bfd_debug_info_start bfd_void
4391 #define ecoff_bfd_debug_info_end bfd_void
4392 #define ecoff_bfd_debug_info_accumulate \
4393 ((void (*) PARAMS ((bfd *, struct sec *))) bfd_void)
4394 #define ecoff_bfd_get_relocated_section_contents \
4395 bfd_generic_get_relocated_section_contents
4396 #define ecoff_bfd_relax_section bfd_generic_relax_section
4397 #define ecoff_bfd_make_debug_symbol \
4398 ((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr)
4400 bfd_target ecoff_little_vec
=
4402 "ecoff-littlemips", /* name */
4403 bfd_target_ecoff_flavour
,
4404 false, /* data byte order is little */
4405 false, /* header byte order is little */
4407 (HAS_RELOC
| EXEC_P
| /* object flags */
4408 HAS_LINENO
| HAS_DEBUG
|
4409 HAS_SYMS
| HAS_LOCALS
| DYNAMIC
| WP_TEXT
| D_PAGED
),
4411 (SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
), /* sect
4413 0, /* leading underscore */
4414 ' ', /* ar_pad_char */
4415 15, /* ar_max_namelen */
4416 4, /* minimum alignment power */
4417 _do_getl64
, _do_getl_signed_64
, _do_putl64
,
4418 _do_getl32
, _do_getl_signed_32
, _do_putl32
,
4419 _do_getl16
, _do_getl_signed_16
, _do_putl16
, /* data */
4420 _do_getl64
, _do_getl_signed_64
, _do_putl64
,
4421 _do_getl32
, _do_getl_signed_32
, _do_putl32
,
4422 _do_getl16
, _do_getl_signed_16
, _do_putl16
, /* hdrs */
4424 {_bfd_dummy_target
, coff_object_p
, /* bfd_check_format */
4425 ecoff_archive_p
, _bfd_dummy_target
},
4426 {bfd_false
, ecoff_mkobject
, _bfd_generic_mkarchive
, /* bfd_set_format */
4428 {bfd_false
, ecoff_write_object_contents
, /* bfd_write_contents */
4429 _bfd_write_archive_contents
, bfd_false
},
4431 (PTR
) &bfd_ecoff_std_swap_table
4434 bfd_target ecoff_big_vec
=
4436 "ecoff-bigmips", /* name */
4437 bfd_target_ecoff_flavour
,
4438 true, /* data byte order is big */
4439 true, /* header byte order is big */
4441 (HAS_RELOC
| EXEC_P
| /* object flags */
4442 HAS_LINENO
| HAS_DEBUG
|
4443 HAS_SYMS
| HAS_LOCALS
| DYNAMIC
| WP_TEXT
| D_PAGED
),
4445 (SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
), /* sect flags */
4446 0, /* leading underscore */
4447 ' ', /* ar_pad_char */
4448 15, /* ar_max_namelen */
4449 4, /* minimum alignment power */
4450 _do_getb64
, _do_getb_signed_64
, _do_putb64
,
4451 _do_getb32
, _do_getb_signed_32
, _do_putb32
,
4452 _do_getb16
, _do_getb_signed_16
, _do_putb16
,
4453 _do_getb64
, _do_getb_signed_64
, _do_putb64
,
4454 _do_getb32
, _do_getb_signed_32
, _do_putb32
,
4455 _do_getb16
, _do_getb_signed_16
, _do_putb16
,
4456 {_bfd_dummy_target
, coff_object_p
, /* bfd_check_format */
4457 ecoff_archive_p
, ecoff_core_file_p
},
4458 {bfd_false
, ecoff_mkobject
, _bfd_generic_mkarchive
, /* bfd_set_format */
4460 {bfd_false
, ecoff_write_object_contents
, /* bfd_write_contents */
4461 _bfd_write_archive_contents
, bfd_false
},
4463 (PTR
) &bfd_ecoff_std_swap_table
4464 /* Note that there is another bfd_target just above this one. If
4465 you are adding initializers here, you should be adding them there