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"
36 #undef obj_sym_filepos
38 #include "coff/mips.h"
39 #include "coff/internal.h"
41 #include "coff/symconst.h"
42 #include "coff/ecoff-ext.h"
46 /* Each canonical asymbol really looks like this. */
48 typedef struct ecoff_symbol_struct
50 /* The actual symbol which the rest of BFD works with */
53 /* The fdr for this symbol. */
56 /* true if this is a local symbol rather than an external one. */
59 /* A pointer to the unswapped hidden information for this symbol */
62 struct sym_ext
*lnative
;
63 struct ext_ext
*enative
;
68 /* We take the address of the first element of a asymbol to ensure that the
69 macro is only ever applied to an asymbol. */
70 #define ecoffsymbol(asymbol) ((ecoff_symbol_type *) (&((asymbol)->the_bfd)))
72 /* The page boundary used to align sections in the executable file. */
73 #define ROUND_SIZE 0x1000
75 /* The linker needs a section to hold small common variables while
76 linking. There is no convenient way to create it when the linker
77 needs it, so we always create one for each BFD. We then avoid
79 #define SCOMMON ".scommon"
81 /* MIPS ECOFF has COFF sections, but the debugging information is
82 stored in a completely different format. This files uses the some
83 of the swapping routines from coffswap.h, and some of the generic
84 COFF routines in coffgen.c, but, unlike the real COFF targets, does
85 not use coffcode.h itself. */
87 /* Prototypes for static functions. */
89 static boolean ecoff_bad_format_hook
PARAMS ((bfd
*abfd
, PTR filehdr
));
90 static asection
*ecoff_make_section_hook
PARAMS ((bfd
*abfd
, char *name
));
91 static boolean ecoff_new_section_hook
PARAMS ((bfd
*abfd
, asection
*section
));
92 static boolean ecoff_mkobject
PARAMS ((bfd
*abfd
));
93 static PTR ecoff_mkobject_hook
PARAMS ((bfd
*abfd
, PTR filehdr
, PTR aouthdr
));
94 static boolean ecoff_set_arch_mach_hook
PARAMS ((bfd
*abfd
, PTR filehdr
));
95 static long ecoff_sec_to_styp_flags
PARAMS ((CONST
char *name
,
97 static flagword ecoff_styp_to_sec_flags
PARAMS ((bfd
*abfd
, PTR hdr
));
98 static asymbol
*ecoff_make_empty_symbol
PARAMS ((bfd
*abfd
));
99 static void ecoff_set_symbol_info
PARAMS ((bfd
*abfd
, SYMR
*ecoff_sym
,
100 asymbol
*asym
, int ext
,
101 asymbol
**indirect_ptr_ptr
));
102 static boolean ecoff_slurp_symbol_table
PARAMS ((bfd
*abfd
));
103 static unsigned int ecoff_get_symtab_upper_bound
PARAMS ((bfd
*abfd
));
104 static unsigned int ecoff_get_symtab
PARAMS ((bfd
*abfd
,
105 asymbol
**alocation
));
106 static void ecoff_emit_aggregate
PARAMS ((bfd
*abfd
, char *string
,
107 RNDXR
*rndx
, long isym
,
109 static char *ecoff_type_to_string
PARAMS ((bfd
*abfd
, union aux_ext
*aux_ptr
,
110 int indx
, int bigendian
));
111 static void ecoff_print_symbol
PARAMS ((bfd
*abfd
, PTR filep
,
113 bfd_print_symbol_type how
));
114 static void ecoff_get_symbol_info
PARAMS ((bfd
*abfd
,
117 static void ecoff_swap_reloc_in
PARAMS ((bfd
*abfd
, RELOC
*ext
,
118 struct internal_reloc
*intern
));
119 static unsigned int ecoff_swap_reloc_out
PARAMS ((bfd
*abfd
, PTR src
,
121 static bfd_reloc_status_type ecoff_generic_reloc
PARAMS ((bfd
*abfd
,
127 static bfd_reloc_status_type ecoff_refhi_reloc
PARAMS ((bfd
*abfd
,
133 static bfd_reloc_status_type ecoff_reflo_reloc
PARAMS ((bfd
*abfd
,
139 static bfd_reloc_status_type ecoff_gprel_reloc
PARAMS ((bfd
*abfd
,
145 static boolean ecoff_slurp_reloc_table
PARAMS ((bfd
*abfd
, asection
*section
,
147 static unsigned int ecoff_canonicalize_reloc
PARAMS ((bfd
*abfd
,
151 static CONST
struct reloc_howto_struct
*ecoff_bfd_reloc_type_lookup
152 PARAMS ((bfd
*abfd
, bfd_reloc_code_real_type code
));
153 static boolean ecoff_find_nearest_line
PARAMS ((bfd
*abfd
,
157 CONST
char **filename_ptr
,
158 CONST
char **fnname_ptr
,
159 unsigned int *retline_ptr
));
160 static void ecoff_clear_output_flags
PARAMS ((bfd
*abfd
));
161 static boolean ecoff_rel
PARAMS ((bfd
*output_bfd
, bfd_seclet_type
*seclet
,
162 asection
*output_section
, PTR data
,
163 boolean relocateable
));
164 static boolean ecoff_dump_seclet
PARAMS ((bfd
*abfd
, bfd_seclet_type
*seclet
,
165 asection
*section
, PTR data
,
166 boolean relocateable
));
167 static long ecoff_add_string
PARAMS ((bfd
*output_bfd
, FDR
*fdr
,
168 CONST
char *string
, boolean external
));
169 static boolean ecoff_get_debug
PARAMS ((bfd
*output_bfd
,
170 bfd_seclet_type
*seclet
,
172 boolean relocateable
));
173 static boolean ecoff_bfd_seclet_link
PARAMS ((bfd
*abfd
, PTR data
,
174 boolean relocateable
));
175 static boolean ecoff_set_arch_mach
PARAMS ((bfd
*abfd
,
176 enum bfd_architecture arch
,
177 unsigned long machine
));
178 static int ecoff_sizeof_headers
PARAMS ((bfd
*abfd
, boolean reloc
));
179 static void ecoff_compute_section_file_positions
PARAMS ((bfd
*abfd
));
180 static boolean ecoff_set_section_contents
PARAMS ((bfd
*abfd
,
184 bfd_size_type count
));
185 static boolean ecoff_write_object_contents
PARAMS ((bfd
*abfd
));
186 static unsigned int ecoff_armap_hash
PARAMS ((CONST
char *s
,
187 unsigned int *rehash
,
190 static boolean ecoff_slurp_armap
PARAMS ((bfd
*abfd
));
191 static boolean ecoff_write_armap
PARAMS ((bfd
*abfd
, unsigned int elength
,
193 unsigned int orl_count
,
195 static bfd_target
*ecoff_archive_p
PARAMS ((bfd
*abfd
));
197 /* Get the generic COFF swapping routines, except for the reloc,
198 symbol, and lineno ones. Give them ecoff names. */
200 #define NO_COFF_RELOCS
201 #define NO_COFF_SYMBOLS
202 #define NO_COFF_LINENOS
203 #define coff_swap_filehdr_in ecoff_swap_filehdr_in
204 #define coff_swap_filehdr_out ecoff_swap_filehdr_out
205 #define coff_swap_aouthdr_in ecoff_swap_aouthdr_in
206 #define coff_swap_aouthdr_out ecoff_swap_aouthdr_out
207 #define coff_swap_scnhdr_in ecoff_swap_scnhdr_in
208 #define coff_swap_scnhdr_out ecoff_swap_scnhdr_out
209 #include "coffswap.h"
211 /* How to process the various relocs types. */
213 static reloc_howto_type ecoff_howto_table
[] =
215 /* Reloc type 0 is ignored. The reloc reading code ensures that
216 this is a reference to the .abs section, which will cause
217 bfd_perform_relocation to do nothing. */
218 HOWTO (ECOFF_R_IGNORE
, /* type */
220 0, /* size (0 = byte, 1 = short, 2 = long) */
221 8, /* bitsize (obsolete) */
222 false, /* pc_relative */
224 false, /* absolute (obsolete) */
225 false, /* complain_on_overflow */
226 0, /* special_function */
228 false, /* partial_inplace */
231 false), /* pcrel_offset */
233 /* A 16 bit reference to a symbol, normally from a data section. */
234 HOWTO (ECOFF_R_REFHALF
, /* type */
236 1, /* size (0 = byte, 1 = short, 2 = long) */
237 16, /* bitsize (obsolete) */
238 false, /* pc_relative */
240 false, /* absolute (obsolete) */
241 true, /* complain_on_overflow */
242 ecoff_generic_reloc
, /* special_function */
243 "REFHALF", /* name */
244 true, /* partial_inplace */
245 0xffff, /* src_mask */
246 0xffff, /* dst_mask */
247 false), /* pcrel_offset */
249 /* A 32 bit reference to a symbol, normally from a data section. */
250 HOWTO (ECOFF_R_REFWORD
, /* type */
252 2, /* size (0 = byte, 1 = short, 2 = long) */
253 32, /* bitsize (obsolete) */
254 false, /* pc_relative */
256 false, /* absolute (obsolete) */
257 true, /* complain_on_overflow */
258 ecoff_generic_reloc
, /* special_function */
259 "REFWORD", /* name */
260 true, /* partial_inplace */
261 0xffffffff, /* src_mask */
262 0xffffffff, /* dst_mask */
263 false), /* pcrel_offset */
265 /* A 26 bit absolute jump address. */
266 HOWTO (ECOFF_R_JMPADDR
, /* type */
268 2, /* size (0 = byte, 1 = short, 2 = long) */
269 32, /* bitsize (obsolete) */
270 false, /* pc_relative */
272 false, /* absolute (obsolete) */
273 true, /* complain_on_overflow */
274 ecoff_generic_reloc
, /* special_function */
275 "JMPADDR", /* name */
276 true, /* partial_inplace */
277 0x3ffffff, /* src_mask */
278 0x3ffffff, /* dst_mask */
279 false), /* pcrel_offset */
281 /* The high 16 bits of a symbol value. Handled by the function
282 ecoff_refhi_reloc. */
283 HOWTO (ECOFF_R_REFHI
, /* type */
285 2, /* size (0 = byte, 1 = short, 2 = long) */
286 32, /* bitsize (obsolete) */
287 false, /* pc_relative */
289 false, /* absolute (obsolete) */
290 true, /* complain_on_overflow */
291 ecoff_refhi_reloc
, /* special_function */
293 true, /* partial_inplace */
294 0xffff, /* src_mask */
295 0xffff, /* dst_mask */
296 false), /* pcrel_offset */
298 /* The low 16 bits of a symbol value. */
299 HOWTO (ECOFF_R_REFLO
, /* type */
301 2, /* size (0 = byte, 1 = short, 2 = long) */
302 32, /* bitsize (obsolete) */
303 false, /* pc_relative */
305 false, /* absolute (obsolete) */
306 true, /* complain_on_overflow */
307 ecoff_reflo_reloc
, /* special_function */
309 true, /* partial_inplace */
310 0xffff, /* src_mask */
311 0xffff, /* dst_mask */
312 false), /* pcrel_offset */
314 /* A reference to an offset from the gp register. Handled by the
315 function ecoff_gprel_reloc. */
316 HOWTO (ECOFF_R_GPREL
, /* type */
318 2, /* size (0 = byte, 1 = short, 2 = long) */
319 32, /* bitsize (obsolete) */
320 false, /* pc_relative */
322 false, /* absolute (obsolete) */
323 true, /* complain_on_overflow */
324 ecoff_gprel_reloc
, /* special_function */
326 true, /* partial_inplace */
327 0xffff, /* src_mask */
328 0xffff, /* dst_mask */
329 false), /* pcrel_offset */
331 /* A reference to a literal using an offset from the gp register.
332 Handled by the function ecoff_gprel_reloc. */
333 HOWTO (ECOFF_R_LITERAL
, /* type */
335 2, /* size (0 = byte, 1 = short, 2 = long) */
336 32, /* bitsize (obsolete) */
337 false, /* pc_relative */
339 false, /* absolute (obsolete) */
340 true, /* complain_on_overflow */
341 ecoff_gprel_reloc
, /* special_function */
342 "LITERAL", /* name */
343 true, /* partial_inplace */
344 0xffff, /* src_mask */
345 0xffff, /* dst_mask */
346 false) /* pcrel_offset */
349 #define ECOFF_HOWTO_COUNT \
350 (sizeof ecoff_howto_table / sizeof ecoff_howto_table[0])
352 /* This stuff is somewhat copied from coffcode.h. */
354 static asection bfd_debug_section
= { "*DEBUG*" };
356 /* See whether the magic number matches. */
359 ecoff_bad_format_hook (abfd
, filehdr
)
363 struct internal_filehdr
*internal_f
= (struct internal_filehdr
*) filehdr
;
365 if (ECOFFBADMAG (*internal_f
))
371 /* This is a hook needed by SCO COFF, but we have nothing to do. */
374 ecoff_make_section_hook (abfd
, name
)
378 return (asection
*) NULL
;
381 /* Initialize a new section. */
384 ecoff_new_section_hook (abfd
, section
)
388 section
->alignment_power
= abfd
->xvec
->align_power_min
;
390 if (strcmp (section
->name
, _TEXT
) == 0)
391 section
->flags
|= SEC_CODE
| SEC_LOAD
| SEC_ALLOC
;
392 else if (strcmp (section
->name
, _DATA
) == 0
393 || strcmp (section
->name
, _SDATA
) == 0)
394 section
->flags
|= SEC_DATA
| SEC_LOAD
| SEC_ALLOC
;
395 else if (strcmp (section
->name
, _RDATA
) == 0
396 || strcmp (section
->name
, _LIT8
) == 0
397 || strcmp (section
->name
, _LIT4
) == 0)
398 section
->flags
|= SEC_DATA
| SEC_LOAD
| SEC_ALLOC
| SEC_READONLY
;
399 else if (strcmp (section
->name
, _BSS
) == 0
400 || strcmp (section
->name
, _SBSS
) == 0)
401 section
->flags
|= SEC_ALLOC
;
403 /* Probably any other section name is SEC_NEVER_LOAD, but I'm
404 uncertain about .init on some systems and I don't know how shared
410 /* Set the alignment of a section; we have nothing to do. */
412 #define ecoff_set_alignment_hook \
413 ((void (*) PARAMS ((bfd *, asection *, PTR))) bfd_void)
415 /* Create an ECOFF object. */
418 ecoff_mkobject (abfd
)
421 abfd
->tdata
.ecoff_obj_data
= ((struct ecoff_tdata
*)
422 bfd_zalloc (abfd
, sizeof (ecoff_data_type
)));
423 if (abfd
->tdata
.ecoff_obj_data
== NULL
)
425 bfd_error
= no_memory
;
429 /* Always create a .scommon section for every BFD. This is a hack so
430 that the linker has something to attach scSCommon symbols to. */
431 bfd_make_section (abfd
, SCOMMON
);
436 /* Create the ECOFF backend specific information. */
439 ecoff_mkobject_hook (abfd
, filehdr
, aouthdr
)
444 struct internal_filehdr
*internal_f
= (struct internal_filehdr
*) filehdr
;
445 struct internal_aouthdr
*internal_a
= (struct internal_aouthdr
*) aouthdr
;
446 ecoff_data_type
*ecoff
;
448 if (ecoff_mkobject (abfd
) == false)
451 ecoff
= ecoff_data (abfd
);
453 ecoff
->sym_filepos
= internal_f
->f_symptr
;
455 if (internal_a
!= (struct internal_aouthdr
*) NULL
)
459 ecoff
->text_start
= internal_a
->text_start
;
460 ecoff
->text_end
= internal_a
->text_start
+ internal_a
->tsize
;
461 ecoff
->gp
= internal_a
->gp_value
;
462 ecoff
->gprmask
= internal_a
->gprmask
;
463 for (i
= 0; i
< 4; i
++)
464 ecoff
->cprmask
[i
] = internal_a
->cprmask
[i
];
465 if (internal_a
->magic
== MIPS_AOUT_ZMAGIC
)
466 abfd
->flags
|= D_PAGED
;
472 /* Determine the machine architecture and type. */
475 ecoff_set_arch_mach_hook (abfd
, filehdr
)
479 struct internal_filehdr
*internal_f
= (struct internal_filehdr
*) filehdr
;
480 enum bfd_architecture arch
;
482 switch (internal_f
->f_magic
)
485 case MIPS_MAGIC_LITTLE
:
487 arch
= bfd_arch_mips
;
491 arch
= bfd_arch_obscure
;
495 bfd_default_set_arch_mach (abfd
, arch
, (unsigned long) 0);
500 /* Get the section s_flags to use for a section. */
503 ecoff_sec_to_styp_flags (name
, flags
)
511 if (strcmp (name
, _TEXT
) == 0)
513 else if (strcmp (name
, _DATA
) == 0)
515 else if (strcmp (name
, _SDATA
) == 0)
517 else if (strcmp (name
, _RDATA
) == 0)
519 else if (strcmp (name
, _LIT8
) == 0)
521 else if (strcmp (name
, _LIT4
) == 0)
523 else if (strcmp (name
, _BSS
) == 0)
525 else if (strcmp (name
, _SBSS
) == 0)
527 else if (strcmp (name
, _INIT
) == 0)
528 styp
= STYP_MIPS_INIT
;
529 else if (flags
& SEC_CODE
)
531 else if (flags
& SEC_DATA
)
533 else if (flags
& SEC_READONLY
)
535 else if (flags
& SEC_LOAD
)
540 if (flags
& SEC_NEVER_LOAD
)
546 /* Get the BFD flags to use for a section. */
549 ecoff_styp_to_sec_flags (abfd
, hdr
)
553 struct internal_scnhdr
*internal_s
= (struct internal_scnhdr
*) hdr
;
554 long styp_flags
= internal_s
->s_flags
;
555 flagword sec_flags
=0;
557 if (styp_flags
& STYP_NOLOAD
)
558 sec_flags
|= SEC_NEVER_LOAD
;
560 /* For 386 COFF, at least, an unloadable text or data section is
561 actually a shared library section. */
562 if ((styp_flags
& STYP_TEXT
)
563 || (styp_flags
& STYP_MIPS_INIT
))
565 if (sec_flags
& SEC_NEVER_LOAD
)
566 sec_flags
|= SEC_CODE
| SEC_SHARED_LIBRARY
;
568 sec_flags
|= SEC_CODE
| SEC_LOAD
| SEC_ALLOC
;
570 else if ((styp_flags
& STYP_DATA
)
571 || (styp_flags
& STYP_RDATA
)
572 || (styp_flags
& STYP_SDATA
))
574 if (sec_flags
& SEC_NEVER_LOAD
)
575 sec_flags
|= SEC_DATA
| SEC_SHARED_LIBRARY
;
577 sec_flags
|= SEC_DATA
| SEC_LOAD
| SEC_ALLOC
;
578 if (styp_flags
& STYP_RDATA
)
579 sec_flags
|= SEC_READONLY
;
581 else if ((styp_flags
& STYP_BSS
)
582 || (styp_flags
& STYP_SBSS
))
584 sec_flags
|= SEC_ALLOC
;
586 else if (styp_flags
& STYP_INFO
)
588 sec_flags
|= SEC_NEVER_LOAD
;
590 else if ((styp_flags
& STYP_LIT8
)
591 || (styp_flags
& STYP_LIT4
))
593 sec_flags
|= SEC_DATA
| SEC_LOAD
| SEC_ALLOC
| SEC_READONLY
;
597 sec_flags
|= SEC_ALLOC
| SEC_LOAD
;
603 /* Read in and swap the important symbolic information for an ECOFF
604 object file. FIXME: This is called by gdb. If there is ever
605 another ECOFF target, it should be moved into some sort of target
606 specific structure. */
609 ecoff_slurp_symbolic_info (abfd
)
612 struct hdr_ext external_symhdr
;
613 HDRR
*internal_symhdr
;
614 bfd_size_type raw_base
;
615 bfd_size_type raw_size
;
617 struct fdr_ext
*fraw_src
;
618 struct fdr_ext
*fraw_end
;
621 /* Check whether we've already gotten it, and whether there's any to
623 if (ecoff_data (abfd
)->raw_syments
!= (PTR
) NULL
)
625 if (ecoff_data (abfd
)->sym_filepos
== 0)
627 bfd_get_symcount (abfd
) = 0;
631 /* At this point bfd_get_symcount (abfd) holds the number of symbols
632 as read from the file header, but on ECOFF this is always the
633 size of the symbolic information header. It would be cleaner to
634 handle this when we first read the file in coffgen.c. */
635 if (bfd_get_symcount (abfd
) != sizeof (external_symhdr
))
637 bfd_error
= bad_value
;
641 /* Read the symbolic information header. */
642 if (bfd_seek (abfd
, ecoff_data (abfd
)->sym_filepos
, SEEK_SET
) == -1
643 || (bfd_read ((PTR
) &external_symhdr
, sizeof (external_symhdr
), 1, abfd
)
644 != sizeof (external_symhdr
)))
646 bfd_error
= system_call_error
;
649 internal_symhdr
= &ecoff_data (abfd
)->symbolic_header
;
650 ecoff_swap_hdr_in (abfd
, &external_symhdr
, internal_symhdr
);
652 if (internal_symhdr
->magic
!= magicSym
)
654 bfd_error
= bad_value
;
658 /* Now we can get the correct number of symbols. */
659 bfd_get_symcount (abfd
) = (internal_symhdr
->isymMax
660 + internal_symhdr
->iextMax
);
662 /* Read all the symbolic information at once. */
663 raw_base
= ecoff_data (abfd
)->sym_filepos
+ sizeof (struct hdr_ext
);
665 if (internal_symhdr
->cbExtOffset
!= 0)
666 raw_size
= (internal_symhdr
->cbExtOffset
668 + internal_symhdr
->iextMax
* sizeof (struct ext_ext
));
671 long cbline
, issmax
, issextmax
;
673 cbline
= (internal_symhdr
->cbLine
+ 3) &~ 3;
674 issmax
= (internal_symhdr
->issMax
+ 3) &~ 3;
675 issextmax
= (internal_symhdr
->issExtMax
+ 3) &~ 3;
676 raw_size
= (cbline
* sizeof (unsigned char)
677 + internal_symhdr
->idnMax
* sizeof (struct dnr_ext
)
678 + internal_symhdr
->ipdMax
* sizeof (struct pdr_ext
)
679 + internal_symhdr
->isymMax
* sizeof (struct sym_ext
)
680 + internal_symhdr
->ioptMax
* sizeof (struct opt_ext
)
681 + internal_symhdr
->iauxMax
* sizeof (union aux_ext
)
682 + issmax
* sizeof (char)
683 + issextmax
* sizeof (char)
684 + internal_symhdr
->ifdMax
* sizeof (struct fdr_ext
)
685 + internal_symhdr
->crfd
* sizeof (struct rfd_ext
)
686 + internal_symhdr
->iextMax
* sizeof (struct ext_ext
));
691 ecoff_data (abfd
)->sym_filepos
= 0;
694 raw
= (PTR
) bfd_alloc (abfd
, raw_size
);
697 bfd_error
= no_memory
;
700 if (bfd_read (raw
, raw_size
, 1, abfd
) != raw_size
)
702 bfd_error
= system_call_error
;
703 bfd_release (abfd
, raw
);
707 ecoff_data (abfd
)->raw_size
= raw_size
;
708 ecoff_data (abfd
)->raw_syments
= raw
;
710 /* Get pointers for the numeric offsets in the HDRR structure. */
711 #define FIX(off1, off2, type) \
712 if (internal_symhdr->off1 == 0) \
713 ecoff_data (abfd)->off2 = (type *) NULL; \
715 ecoff_data (abfd)->off2 = (type *) ((char *) raw \
716 + internal_symhdr->off1 \
718 FIX (cbLineOffset
, line
, unsigned char);
719 FIX (cbDnOffset
, external_dnr
, struct dnr_ext
);
720 FIX (cbPdOffset
, external_pdr
, struct pdr_ext
);
721 FIX (cbSymOffset
, external_sym
, struct sym_ext
);
722 FIX (cbOptOffset
, external_opt
, struct opt_ext
);
723 FIX (cbAuxOffset
, external_aux
, union aux_ext
);
724 FIX (cbSsOffset
, ss
, char);
725 FIX (cbSsExtOffset
, ssext
, char);
726 FIX (cbFdOffset
, external_fdr
, struct fdr_ext
);
727 FIX (cbRfdOffset
, external_rfd
, struct rfd_ext
);
728 FIX (cbExtOffset
, external_ext
, struct ext_ext
);
731 /* I don't want to always swap all the data, because it will just
732 waste time and most programs will never look at it. The only
733 time the linker needs most of the debugging information swapped
734 is when linking big-endian and little-endian MIPS object files
735 together, which is not a common occurrence.
737 We need to look at the fdr to deal with a lot of information in
738 the symbols, so we swap them here. */
739 ecoff_data (abfd
)->fdr
= (struct fdr
*) bfd_alloc (abfd
,
740 (internal_symhdr
->ifdMax
*
741 sizeof (struct fdr
)));
742 if (ecoff_data (abfd
)->fdr
== NULL
)
744 bfd_error
= no_memory
;
747 fdr_ptr
= ecoff_data (abfd
)->fdr
;
748 fraw_src
= ecoff_data (abfd
)->external_fdr
;
749 fraw_end
= fraw_src
+ internal_symhdr
->ifdMax
;
750 for (; fraw_src
< fraw_end
; fraw_src
++, fdr_ptr
++)
751 ecoff_swap_fdr_in (abfd
, fraw_src
, fdr_ptr
);
756 /* ECOFF symbol table routines. The ECOFF symbol table is described
757 in gcc/mips-tfile.c. */
759 /* ECOFF uses two common sections. One is the usual one, and the
760 other is for small objects. All the small objects are kept
761 together, and then referenced via the gp pointer, which yields
762 faster assembler code. This is what we use for the small common
764 static asection ecoff_scom_section
;
765 static asymbol ecoff_scom_symbol
;
766 static asymbol
*ecoff_scom_symbol_ptr
;
768 /* Create an empty symbol. */
771 ecoff_make_empty_symbol (abfd
)
774 ecoff_symbol_type
*new;
776 new = (ecoff_symbol_type
*) bfd_alloc (abfd
, sizeof (ecoff_symbol_type
));
777 if (new == (ecoff_symbol_type
*) NULL
)
779 bfd_error
= no_memory
;
780 return (asymbol
*) NULL
;
782 memset (new, 0, sizeof *new);
783 new->symbol
.section
= (asection
*) NULL
;
784 new->fdr
= (FDR
*) NULL
;
786 new->native
.lnative
= (struct sym_ext
*) NULL
;
787 new->symbol
.the_bfd
= abfd
;
791 /* Set the BFD flags and section for an ECOFF symbol. */
794 ecoff_set_symbol_info (abfd
, ecoff_sym
, asym
, ext
, indirect_ptr_ptr
)
799 asymbol
**indirect_ptr_ptr
;
801 asym
->the_bfd
= abfd
;
802 asym
->value
= ecoff_sym
->value
;
803 asym
->section
= &bfd_debug_section
;
806 /* An indirect symbol requires two consecutive stabs symbols. */
807 if (*indirect_ptr_ptr
!= (asymbol
*) NULL
)
809 BFD_ASSERT (MIPS_IS_STAB (ecoff_sym
));
811 /* @@ Stuffing pointers into integers is a no-no.
812 We can usually get away with it if the integer is
813 large enough though. */
814 if (sizeof (asym
) > sizeof (bfd_vma
))
816 (*indirect_ptr_ptr
)->value
= (bfd_vma
) asym
;
818 asym
->flags
= BSF_DEBUGGING
;
819 asym
->section
= &bfd_und_section
;
820 *indirect_ptr_ptr
= NULL
;
824 if (MIPS_IS_STAB (ecoff_sym
)
825 && (MIPS_UNMARK_STAB (ecoff_sym
->index
) | N_EXT
) == (N_INDR
| N_EXT
))
827 asym
->flags
= BSF_DEBUGGING
| BSF_INDIRECT
;
828 asym
->section
= &bfd_ind_section
;
829 /* Pass this symbol on to the next call to this function. */
830 *indirect_ptr_ptr
= asym
;
834 /* Most symbol types are just for debugging. */
835 switch (ecoff_sym
->st
)
844 if (MIPS_IS_STAB (ecoff_sym
))
846 asym
->flags
= BSF_DEBUGGING
;
851 asym
->flags
= BSF_DEBUGGING
;
856 asym
->flags
= BSF_EXPORT
| BSF_GLOBAL
;
858 asym
->flags
= BSF_LOCAL
;
859 switch (ecoff_sym
->sc
)
862 /* Used for compiler generated labels. Leave them in the
863 debugging section, and mark them as local. If BSF_DEBUGGING
864 is set, then nm does not display them for some reason. If no
865 flags are set then the linker whines about them. */
866 asym
->flags
= BSF_LOCAL
;
869 asym
->section
= bfd_make_section_old_way (abfd
, ".text");
870 asym
->value
-= asym
->section
->vma
;
873 asym
->section
= bfd_make_section_old_way (abfd
, ".data");
874 asym
->value
-= asym
->section
->vma
;
879 asym
->section
= &bfd_com_section
;
884 asym
->section
= bfd_make_section_old_way (abfd
, ".bss");
885 asym
->value
-= asym
->section
->vma
;
889 asym
->flags
= BSF_DEBUGGING
;
892 asym
->section
= &bfd_abs_section
;
895 asym
->section
= &bfd_und_section
;
905 asym
->flags
= BSF_DEBUGGING
;
908 asym
->section
= bfd_make_section_old_way (abfd
, ".sdata");
909 asym
->value
-= asym
->section
->vma
;
912 asym
->section
= bfd_make_section_old_way (abfd
, ".sbss");
914 asym
->value
-= asym
->section
->vma
;
917 asym
->section
= bfd_make_section_old_way (abfd
, ".rdata");
918 asym
->value
-= asym
->section
->vma
;
921 asym
->flags
= BSF_DEBUGGING
;
924 if (asym
->value
> ecoff_data (abfd
)->gp_size
)
926 asym
->section
= &bfd_com_section
;
932 if (ecoff_scom_section
.name
== NULL
)
934 /* Initialize the small common section. */
935 ecoff_scom_section
.name
= SCOMMON
;
936 ecoff_scom_section
.flags
= SEC_IS_COMMON
;
937 ecoff_scom_section
.output_section
= &ecoff_scom_section
;
938 ecoff_scom_section
.symbol
= &ecoff_scom_symbol
;
939 ecoff_scom_section
.symbol_ptr_ptr
= &ecoff_scom_symbol_ptr
;
940 ecoff_scom_symbol
.name
= SCOMMON
;
941 ecoff_scom_symbol
.flags
= BSF_SECTION_SYM
;
942 ecoff_scom_symbol
.section
= &ecoff_scom_section
;
943 ecoff_scom_symbol_ptr
= &ecoff_scom_symbol
;
945 asym
->section
= &ecoff_scom_section
;
950 asym
->flags
= BSF_DEBUGGING
;
953 asym
->section
= &bfd_und_section
;
958 asym
->section
= bfd_make_section_old_way (abfd
, ".init");
959 asym
->value
-= asym
->section
->vma
;
964 asym
->flags
= BSF_DEBUGGING
;
967 asym
->section
= bfd_make_section_old_way (abfd
, ".fini");
968 asym
->value
-= asym
->section
->vma
;
974 /* Look for special constructors symbols and make relocation entries
975 in a special construction section. These are produced by the
976 -fgnu-linker argument to g++. */
977 if (MIPS_IS_STAB (ecoff_sym
))
979 switch (MIPS_UNMARK_STAB (ecoff_sym
->index
))
991 arelent_chain
*reloc_chain
;
993 /* Get a section with the same name as the symbol (usually
994 __CTOR_LIST__ or __DTOR_LIST__). FIXME: gcc uses the
995 name ___CTOR_LIST (three underscores). We need
996 __CTOR_LIST (two underscores), since ECOFF doesn't use
997 a leading underscore. This should be handled by gcc,
998 but instead we do it here. Actually, this should all
999 be done differently anyhow. */
1000 name
= bfd_asymbol_name (asym
);
1001 if (name
[0] == '_' && name
[1] == '_' && name
[2] == '_')
1006 section
= bfd_get_section_by_name (abfd
, name
);
1007 if (section
== (asection
*) NULL
)
1011 copy
= (char *) bfd_alloc (abfd
, strlen (name
) + 1);
1012 strcpy (copy
, name
);
1013 section
= bfd_make_section (abfd
, copy
);
1016 /* Build a reloc pointing to this constructor. */
1017 reloc_chain
= (arelent_chain
*) bfd_alloc (abfd
,
1018 sizeof (arelent_chain
));
1019 reloc_chain
->relent
.sym_ptr_ptr
=
1020 bfd_get_section (asym
)->symbol_ptr_ptr
;
1021 reloc_chain
->relent
.address
= section
->_raw_size
;
1022 reloc_chain
->relent
.addend
= asym
->value
;
1024 /* FIXME: Assumes 32 bit __CTOR_LIST__ entries. */
1025 reloc_chain
->relent
.howto
= ecoff_howto_table
+ ECOFF_R_REFWORD
;
1027 /* Set up the constructor section to hold the reloc. */
1028 section
->flags
= SEC_CONSTRUCTOR
;
1029 ++section
->reloc_count
;
1031 /* Constructor sections must be rounded to a four byte
1032 boundary (FIXME: assuming 32 bit entries). These are
1033 not real sections--they are handled specially by the
1034 linker--so the ECOFF 16 byte alignment restriction does
1036 section
->alignment_power
= 2;
1038 reloc_chain
->next
= section
->constructor_chain
;
1039 section
->constructor_chain
= reloc_chain
;
1041 /* FIXME: Assumes 32 bit __CTOR_LIST__ entries. */
1042 section
->_raw_size
+= 4;
1044 /* Mark the symbol as a constructor. */
1045 asym
->flags
|= BSF_CONSTRUCTOR
;
1052 /* Read an ECOFF symbol table. */
1055 ecoff_slurp_symbol_table (abfd
)
1058 bfd_size_type internal_size
;
1059 ecoff_symbol_type
*internal
;
1060 ecoff_symbol_type
*internal_ptr
;
1061 asymbol
*indirect_ptr
;
1062 struct ext_ext
*eraw_src
;
1063 struct ext_ext
*eraw_end
;
1067 /* If we've already read in the symbol table, do nothing. */
1068 if (ecoff_data (abfd
)->canonical_symbols
!= NULL
)
1071 /* Get the symbolic information. */
1072 if (ecoff_slurp_symbolic_info (abfd
) == false)
1074 if (bfd_get_symcount (abfd
) == 0)
1077 internal_size
= bfd_get_symcount (abfd
) * sizeof (ecoff_symbol_type
);
1078 internal
= (ecoff_symbol_type
*) bfd_alloc (abfd
, internal_size
);
1079 if (internal
== NULL
)
1081 bfd_error
= no_memory
;
1085 internal_ptr
= internal
;
1086 indirect_ptr
= NULL
;
1087 eraw_src
= ecoff_data (abfd
)->external_ext
;
1088 eraw_end
= eraw_src
+ ecoff_data (abfd
)->symbolic_header
.iextMax
;
1089 for (; eraw_src
< eraw_end
; eraw_src
++, internal_ptr
++)
1093 ecoff_swap_ext_in (abfd
, eraw_src
, &internal_esym
);
1094 internal_ptr
->symbol
.name
= (ecoff_data (abfd
)->ssext
1095 + internal_esym
.asym
.iss
);
1096 ecoff_set_symbol_info (abfd
, &internal_esym
.asym
,
1097 &internal_ptr
->symbol
, 1, &indirect_ptr
);
1098 internal_ptr
->fdr
= ecoff_data (abfd
)->fdr
+ internal_esym
.ifd
;
1099 internal_ptr
->local
= false;
1100 internal_ptr
->native
.enative
= eraw_src
;
1102 BFD_ASSERT (indirect_ptr
== (asymbol
*) NULL
);
1104 /* The local symbols must be accessed via the fdr's, because the
1105 string and aux indices are relative to the fdr information. */
1106 fdr_ptr
= ecoff_data (abfd
)->fdr
;
1107 fdr_end
= fdr_ptr
+ ecoff_data (abfd
)->symbolic_header
.ifdMax
;
1108 for (; fdr_ptr
< fdr_end
; fdr_ptr
++)
1110 struct sym_ext
*lraw_src
;
1111 struct sym_ext
*lraw_end
;
1113 lraw_src
= ecoff_data (abfd
)->external_sym
+ fdr_ptr
->isymBase
;
1114 lraw_end
= lraw_src
+ fdr_ptr
->csym
;
1115 for (; lraw_src
< lraw_end
; lraw_src
++, internal_ptr
++)
1119 ecoff_swap_sym_in (abfd
, lraw_src
, &internal_sym
);
1120 internal_ptr
->symbol
.name
= (ecoff_data (abfd
)->ss
1122 + internal_sym
.iss
);
1123 ecoff_set_symbol_info (abfd
, &internal_sym
,
1124 &internal_ptr
->symbol
, 0, &indirect_ptr
);
1125 internal_ptr
->fdr
= fdr_ptr
;
1126 internal_ptr
->local
= true;
1127 internal_ptr
->native
.lnative
= lraw_src
;
1130 BFD_ASSERT (indirect_ptr
== (asymbol
*) NULL
);
1132 ecoff_data (abfd
)->canonical_symbols
= internal
;
1138 ecoff_get_symtab_upper_bound (abfd
)
1141 if (ecoff_slurp_symbolic_info (abfd
) == false
1142 || bfd_get_symcount (abfd
) == 0)
1145 return (bfd_get_symcount (abfd
) + 1) * (sizeof (ecoff_symbol_type
*));
1149 ecoff_get_symtab (abfd
, alocation
)
1151 asymbol
**alocation
;
1153 unsigned int counter
= 0;
1154 ecoff_symbol_type
*symbase
;
1155 ecoff_symbol_type
**location
= (ecoff_symbol_type
**) alocation
;
1157 if (ecoff_slurp_symbol_table (abfd
) == false
1158 || bfd_get_symcount (abfd
) == 0)
1161 symbase
= ecoff_data (abfd
)->canonical_symbols
;
1162 while (counter
< bfd_get_symcount (abfd
))
1164 *(location
++) = symbase
++;
1167 *location
++ = (ecoff_symbol_type
*) NULL
;
1168 return bfd_get_symcount (abfd
);
1171 /* Turn ECOFF type information into a printable string.
1172 ecoff_emit_aggregate and ecoff_type_to_string are from
1173 gcc/mips-tdump.c, with swapping added and used_ptr removed. */
1175 /* Write aggregate information to a string. */
1178 ecoff_emit_aggregate (abfd
, string
, rndx
, isym
, which
)
1185 int ifd
= rndx
->rfd
;
1186 int indx
= rndx
->index
;
1187 int sym_base
, ss_base
;
1193 sym_base
= ecoff_data (abfd
)->fdr
[ifd
].isymBase
;
1194 ss_base
= ecoff_data (abfd
)->fdr
[ifd
].issBase
;
1196 if (indx
== indexNil
)
1197 name
= "/* no name */";
1203 ecoff_swap_sym_in (abfd
,
1204 ecoff_data (abfd
)->external_sym
+ indx
,
1206 name
= ecoff_data (abfd
)->ss
+ ss_base
+ sym
.iss
;
1210 "%s %s { ifd = %d, index = %d }",
1212 indx
+ ecoff_data (abfd
)->symbolic_header
.iextMax
);
1215 /* Convert the type information to string format. */
1218 ecoff_type_to_string (abfd
, aux_ptr
, indx
, bigendian
)
1220 union aux_ext
*aux_ptr
;
1232 unsigned int basic_type
;
1234 static char buffer1
[1024];
1235 static char buffer2
[1024];
1240 for (i
= 0; i
< 7; i
++)
1242 qualifiers
[i
].low_bound
= 0;
1243 qualifiers
[i
].high_bound
= 0;
1244 qualifiers
[i
].stride
= 0;
1247 if (AUX_GET_ISYM (bigendian
, &aux_ptr
[indx
]) == -1)
1248 return "-1 (no type)";
1249 ecoff_swap_tir_in (bigendian
, &aux_ptr
[indx
++].a_ti
, &u
.ti
);
1251 basic_type
= u
.ti
.bt
;
1252 qualifiers
[0].type
= u
.ti
.tq0
;
1253 qualifiers
[1].type
= u
.ti
.tq1
;
1254 qualifiers
[2].type
= u
.ti
.tq2
;
1255 qualifiers
[3].type
= u
.ti
.tq3
;
1256 qualifiers
[4].type
= u
.ti
.tq4
;
1257 qualifiers
[5].type
= u
.ti
.tq5
;
1258 qualifiers
[6].type
= tqNil
;
1261 * Go get the basic type.
1265 case btNil
: /* undefined */
1269 case btAdr
: /* address - integer same size as pointer */
1270 strcpy (p1
, "address");
1273 case btChar
: /* character */
1274 strcpy (p1
, "char");
1277 case btUChar
: /* unsigned character */
1278 strcpy (p1
, "unsigned char");
1281 case btShort
: /* short */
1282 strcpy (p1
, "short");
1285 case btUShort
: /* unsigned short */
1286 strcpy (p1
, "unsigned short");
1289 case btInt
: /* int */
1293 case btUInt
: /* unsigned int */
1294 strcpy (p1
, "unsigned int");
1297 case btLong
: /* long */
1298 strcpy (p1
, "long");
1301 case btULong
: /* unsigned long */
1302 strcpy (p1
, "unsigned long");
1305 case btFloat
: /* float (real) */
1306 strcpy (p1
, "float");
1309 case btDouble
: /* Double (real) */
1310 strcpy (p1
, "double");
1313 /* Structures add 1-2 aux words:
1314 1st word is [ST_RFDESCAPE, offset] pointer to struct def;
1315 2nd word is file index if 1st word rfd is ST_RFDESCAPE. */
1317 case btStruct
: /* Structure (Record) */
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 /* Unions add 1-2 aux words:
1326 1st word is [ST_RFDESCAPE, offset] pointer to union def;
1327 2nd word is file index if 1st word rfd is ST_RFDESCAPE. */
1329 case btUnion
: /* Union */
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 /* Enumerations add 1-2 aux words:
1338 1st word is [ST_RFDESCAPE, offset] pointer to enum def;
1339 2nd word is file index if 1st word rfd is ST_RFDESCAPE. */
1341 case btEnum
: /* Enumeration */
1342 ecoff_swap_rndx_in (bigendian
, &aux_ptr
[indx
].a_rndx
, &rndx
);
1343 ecoff_emit_aggregate (abfd
, p1
, &rndx
,
1344 AUX_GET_ISYM (bigendian
, &aux_ptr
[indx
+1]),
1346 indx
++; /* skip aux words */
1349 case btTypedef
: /* defined via a typedef, isymRef points */
1350 strcpy (p1
, "typedef");
1353 case btRange
: /* subrange of int */
1354 strcpy (p1
, "subrange");
1357 case btSet
: /* pascal sets */
1361 case btComplex
: /* fortran complex */
1362 strcpy (p1
, "complex");
1365 case btDComplex
: /* fortran double complex */
1366 strcpy (p1
, "double complex");
1369 case btIndirect
: /* forward or unnamed typedef */
1370 strcpy (p1
, "forward/unamed typedef");
1373 case btFixedDec
: /* Fixed Decimal */
1374 strcpy (p1
, "fixed decimal");
1377 case btFloatDec
: /* Float Decimal */
1378 strcpy (p1
, "float decimal");
1381 case btString
: /* Varying Length Character String */
1382 strcpy (p1
, "string");
1385 case btBit
: /* Aligned Bit String */
1389 case btPicture
: /* Picture */
1390 strcpy (p1
, "picture");
1393 case btVoid
: /* Void */
1394 strcpy (p1
, "void");
1398 sprintf (p1
, "Unknown basic type %d", (int) basic_type
);
1402 p1
+= strlen (buffer1
);
1405 * If this is a bitfield, get the bitsize.
1411 bitsize
= AUX_GET_WIDTH (bigendian
, &aux_ptr
[indx
++]);
1412 sprintf (p1
, " : %d", bitsize
);
1413 p1
+= strlen (buffer1
);
1418 * Deal with any qualifiers.
1420 if (qualifiers
[0].type
!= tqNil
)
1423 * Snarf up any array bounds in the correct order. Arrays
1424 * store 5 successive words in the aux. table:
1425 * word 0 RNDXR to type of the bounds (ie, int)
1426 * word 1 Current file descriptor index
1428 * word 3 high bound (or -1 if [])
1429 * word 4 stride size in bits
1431 for (i
= 0; i
< 7; i
++)
1433 if (qualifiers
[i
].type
== tqArray
)
1435 qualifiers
[i
].low_bound
=
1436 AUX_GET_DNLOW (bigendian
, &aux_ptr
[indx
+2]);
1437 qualifiers
[i
].high_bound
=
1438 AUX_GET_DNHIGH (bigendian
, &aux_ptr
[indx
+3]);
1439 qualifiers
[i
].stride
=
1440 AUX_GET_WIDTH (bigendian
, &aux_ptr
[indx
+4]);
1446 * Now print out the qualifiers.
1448 for (i
= 0; i
< 6; i
++)
1450 switch (qualifiers
[i
].type
)
1457 strcpy (p2
, "ptr to ");
1458 p2
+= sizeof ("ptr to ")-1;
1462 strcpy (p2
, "volatile ");
1463 p2
+= sizeof ("volatile ")-1;
1467 strcpy (p2
, "far ");
1468 p2
+= sizeof ("far ")-1;
1472 strcpy (p2
, "func. ret. ");
1473 p2
+= sizeof ("func. ret. ");
1478 int first_array
= i
;
1481 /* Print array bounds reversed (ie, in the order the C
1482 programmer writes them). C is such a fun language.... */
1484 while (i
< 5 && qualifiers
[i
+1].type
== tqArray
)
1487 for (j
= i
; j
>= first_array
; j
--)
1489 strcpy (p2
, "array [");
1490 p2
+= sizeof ("array [")-1;
1491 if (qualifiers
[j
].low_bound
!= 0)
1493 "%ld:%ld {%ld bits}",
1494 (long) qualifiers
[j
].low_bound
,
1495 (long) qualifiers
[j
].high_bound
,
1496 (long) qualifiers
[j
].stride
);
1498 else if (qualifiers
[j
].high_bound
!= -1)
1501 (long) (qualifiers
[j
].high_bound
+ 1),
1502 (long) (qualifiers
[j
].stride
));
1505 sprintf (p2
, " {%ld bits}", (long) (qualifiers
[j
].stride
));
1508 strcpy (p2
, "] of ");
1509 p2
+= sizeof ("] of ")-1;
1517 strcpy (p2
, buffer1
);
1521 /* Return information about ECOFF symbol SYMBOL in RET. */
1524 ecoff_get_symbol_info (abfd
, symbol
, ret
)
1525 bfd
*abfd
; /* Ignored. */
1529 bfd_symbol_info (symbol
, ret
);
1532 /* Print information about an ECOFF symbol. */
1535 ecoff_print_symbol (abfd
, filep
, symbol
, how
)
1539 bfd_print_symbol_type how
;
1541 FILE *file
= (FILE *)filep
;
1545 case bfd_print_symbol_name
:
1546 fprintf (file
, "%s", symbol
->name
);
1548 case bfd_print_symbol_more
:
1549 if (ecoffsymbol (symbol
)->local
)
1553 ecoff_swap_sym_in (abfd
, ecoffsymbol (symbol
)->native
.lnative
,
1555 fprintf (file
, "ecoff local %lx %x %x",
1556 (unsigned long) ecoff_sym
.value
,
1557 (unsigned) ecoff_sym
.st
, (unsigned) ecoff_sym
.sc
);
1563 ecoff_swap_ext_in (abfd
, ecoffsymbol (symbol
)->native
.enative
,
1565 fprintf (file
, "ecoff extern %lx %x %x",
1566 (unsigned long) ecoff_ext
.asym
.value
,
1567 (unsigned) ecoff_ext
.asym
.st
,
1568 (unsigned) ecoff_ext
.asym
.sc
);
1571 case bfd_print_symbol_all
:
1572 /* Print out the symbols in a reasonable way */
1581 if (ecoffsymbol (symbol
)->local
)
1583 ecoff_swap_sym_in (abfd
, ecoffsymbol (symbol
)->native
.lnative
,
1586 pos
= (ecoffsymbol (symbol
)->native
.lnative
1587 - ecoff_data (abfd
)->external_sym
1588 + ecoff_data (abfd
)->symbolic_header
.iextMax
);
1595 ecoff_swap_ext_in (abfd
, ecoffsymbol (symbol
)->native
.enative
,
1598 pos
= (ecoffsymbol (symbol
)->native
.enative
1599 - ecoff_data (abfd
)->external_ext
);
1600 jmptbl
= ecoff_ext
.jmptbl
? 'j' : ' ';
1601 cobol_main
= ecoff_ext
.cobol_main
? 'c' : ' ';
1602 weakext
= ecoff_ext
.weakext
? 'w' : ' ';
1605 fprintf (file
, "[%3d] %c %lx st %x sc %x indx %x %c%c%c %s",
1606 pos
, type
, (unsigned long) ecoff_ext
.asym
.value
,
1607 (unsigned) ecoff_ext
.asym
.st
,
1608 (unsigned) ecoff_ext
.asym
.sc
,
1609 (unsigned) ecoff_ext
.asym
.index
,
1610 jmptbl
, cobol_main
, weakext
,
1613 if (ecoffsymbol (symbol
)->fdr
!= NULL
1614 && ecoff_ext
.asym
.index
!= indexNil
)
1619 union aux_ext
*aux_base
;
1621 indx
= ecoff_ext
.asym
.index
;
1623 /* sym_base is used to map the fdr relative indices which
1624 appear in the file to the position number which we are
1626 sym_base
= ecoffsymbol (symbol
)->fdr
->isymBase
;
1627 if (ecoffsymbol (symbol
)->local
)
1628 sym_base
+= ecoff_data (abfd
)->symbolic_header
.iextMax
;
1630 /* aux_base is the start of the aux entries for this file;
1631 asym.index is an offset from this. */
1632 aux_base
= (ecoff_data (abfd
)->external_aux
1633 + ecoffsymbol (symbol
)->fdr
->iauxBase
);
1635 /* The aux entries are stored in host byte order; the
1636 order is indicated by a bit in the fdr. */
1637 bigendian
= ecoffsymbol (symbol
)->fdr
->fBigendian
;
1639 /* This switch is basically from gcc/mips-tdump.c */
1640 switch (ecoff_ext
.asym
.st
)
1648 printf ("\n End+1 symbol: %ld", indx
+ sym_base
);
1652 if (ecoff_ext
.asym
.sc
== scText
1653 || ecoff_ext
.asym
.sc
== scInfo
)
1654 printf ("\n First symbol: %ld", indx
+ sym_base
);
1656 printf ("\n First symbol: %ld",
1657 (long) (AUX_GET_ISYM (bigendian
,
1658 &aux_base
[ecoff_ext
.asym
.index
])
1664 if (MIPS_IS_STAB (&ecoff_ext
.asym
))
1666 else if (ecoffsymbol (symbol
)->local
)
1667 printf ("\n End+1 symbol: %-7ld Type: %s",
1668 (long) (AUX_GET_ISYM (bigendian
,
1669 &aux_base
[ecoff_ext
.asym
.index
])
1671 ecoff_type_to_string (abfd
, aux_base
, indx
+ 1,
1674 printf ("\n Local symbol: %d",
1677 + ecoff_data (abfd
)->symbolic_header
.iextMax
));
1681 if (!MIPS_IS_STAB (&ecoff_ext
.asym
))
1682 printf ("\n Type: %s",
1683 ecoff_type_to_string (abfd
, aux_base
, indx
,
1693 /* Reloc handling. MIPS ECOFF relocs are packed into 8 bytes in
1694 external form. They use a bit which indicates whether the symbol
1697 /* Swap a reloc in. */
1700 ecoff_swap_reloc_in (abfd
, ext
, intern
)
1703 struct internal_reloc
*intern
;
1705 intern
->r_vaddr
= bfd_h_get_32 (abfd
, (bfd_byte
*) ext
->r_vaddr
);
1706 if (abfd
->xvec
->header_byteorder_big_p
!= false)
1708 intern
->r_symndx
= (((int) ext
->r_bits
[0]
1709 << RELOC_BITS0_SYMNDX_SH_LEFT_BIG
)
1710 | ((int) ext
->r_bits
[1]
1711 << RELOC_BITS1_SYMNDX_SH_LEFT_BIG
)
1712 | ((int) ext
->r_bits
[2]
1713 << RELOC_BITS2_SYMNDX_SH_LEFT_BIG
));
1714 intern
->r_type
= ((ext
->r_bits
[3] & RELOC_BITS3_TYPE_BIG
)
1715 >> RELOC_BITS3_TYPE_SH_BIG
);
1716 intern
->r_extern
= (ext
->r_bits
[3] & RELOC_BITS3_EXTERN_BIG
) != 0;
1720 intern
->r_symndx
= (((int) ext
->r_bits
[0]
1721 << RELOC_BITS0_SYMNDX_SH_LEFT_LITTLE
)
1722 | ((int) ext
->r_bits
[1]
1723 << RELOC_BITS1_SYMNDX_SH_LEFT_LITTLE
)
1724 | ((int) ext
->r_bits
[2]
1725 << RELOC_BITS2_SYMNDX_SH_LEFT_LITTLE
));
1726 intern
->r_type
= ((ext
->r_bits
[3] & RELOC_BITS3_TYPE_LITTLE
)
1727 >> RELOC_BITS3_TYPE_SH_LITTLE
);
1728 intern
->r_extern
= (ext
->r_bits
[3] & RELOC_BITS3_EXTERN_LITTLE
) != 0;
1732 /* Swap a reloc out. */
1735 ecoff_swap_reloc_out (abfd
, src
, dst
)
1740 struct internal_reloc
*intern
= (struct internal_reloc
*) src
;
1741 RELOC
*ext
= (RELOC
*) dst
;
1743 bfd_h_put_32 (abfd
, intern
->r_vaddr
, (bfd_byte
*) ext
->r_vaddr
);
1744 if (abfd
->xvec
->header_byteorder_big_p
!= false)
1746 ext
->r_bits
[0] = intern
->r_symndx
>> RELOC_BITS0_SYMNDX_SH_LEFT_BIG
;
1747 ext
->r_bits
[1] = intern
->r_symndx
>> RELOC_BITS1_SYMNDX_SH_LEFT_BIG
;
1748 ext
->r_bits
[2] = intern
->r_symndx
>> RELOC_BITS2_SYMNDX_SH_LEFT_BIG
;
1749 ext
->r_bits
[3] = (((intern
->r_type
<< RELOC_BITS3_TYPE_SH_BIG
)
1750 & RELOC_BITS3_TYPE_BIG
)
1751 | (intern
->r_extern
? RELOC_BITS3_EXTERN_BIG
: 0));
1755 ext
->r_bits
[0] = intern
->r_symndx
>> RELOC_BITS0_SYMNDX_SH_LEFT_LITTLE
;
1756 ext
->r_bits
[1] = intern
->r_symndx
>> RELOC_BITS1_SYMNDX_SH_LEFT_LITTLE
;
1757 ext
->r_bits
[2] = intern
->r_symndx
>> RELOC_BITS2_SYMNDX_SH_LEFT_LITTLE
;
1758 ext
->r_bits
[3] = (((intern
->r_type
<< RELOC_BITS3_TYPE_SH_LITTLE
)
1759 & RELOC_BITS3_TYPE_LITTLE
)
1760 | (intern
->r_extern
? RELOC_BITS3_EXTERN_LITTLE
: 0));
1766 /* ECOFF relocs are either against external symbols, or against
1767 sections. If we are producing relocateable output, and the reloc
1768 is against an external symbol, and nothing has given us any
1769 additional addend, the resulting reloc will also be against the
1770 same symbol. In such a case, we don't want to change anything
1771 about the way the reloc is handled, since it will all be done at
1772 final link time. Rather than put special case code into
1773 bfd_perform_relocation, all the reloc types use this howto
1774 function. It just short circuits the reloc if producing
1775 relocateable output against an external symbol. */
1777 static bfd_reloc_status_type
1778 ecoff_generic_reloc (abfd
,
1785 arelent
*reloc_entry
;
1788 asection
*input_section
;
1791 if (output_bfd
!= (bfd
*) NULL
1792 && (symbol
->flags
& BSF_SECTION_SYM
) == 0
1793 && reloc_entry
->addend
== 0)
1795 reloc_entry
->address
+= input_section
->output_offset
;
1796 return bfd_reloc_ok
;
1799 return bfd_reloc_continue
;
1802 /* Do a REFHI relocation. This has to be done in combination with a
1803 REFLO reloc, because there is a carry from the REFLO to the REFHI.
1804 Here we just save the information we need; we do the actual
1805 relocation when we see the REFLO. ECOFF requires that the REFLO
1806 immediately follow the REFHI, so this ought to work. */
1808 static bfd_byte
*ecoff_refhi_addr
;
1809 static bfd_vma ecoff_refhi_addend
;
1811 static bfd_reloc_status_type
1812 ecoff_refhi_reloc (abfd
,
1819 arelent
*reloc_entry
;
1822 asection
*input_section
;
1825 bfd_reloc_status_type ret
;
1828 /* If we're relocating, and this an external symbol, we don't want
1829 to change anything. */
1830 if (output_bfd
!= (bfd
*) NULL
1831 && (symbol
->flags
& BSF_SECTION_SYM
) == 0
1832 && reloc_entry
->addend
== 0)
1834 reloc_entry
->address
+= input_section
->output_offset
;
1835 return bfd_reloc_ok
;
1839 if (symbol
->section
== &bfd_und_section
1840 && output_bfd
== (bfd
*) NULL
)
1841 ret
= bfd_reloc_undefined
;
1843 if (bfd_is_com_section (symbol
->section
))
1846 relocation
= symbol
->value
;
1848 relocation
+= symbol
->section
->output_section
->vma
;
1849 relocation
+= symbol
->section
->output_offset
;
1850 relocation
+= reloc_entry
->addend
;
1852 if (reloc_entry
->address
> input_section
->_cooked_size
)
1853 return bfd_reloc_outofrange
;
1855 /* Save the information, and let REFLO do the actual relocation. */
1856 ecoff_refhi_addr
= (bfd_byte
*) data
+ reloc_entry
->address
;
1857 ecoff_refhi_addend
= relocation
;
1859 if (output_bfd
!= (bfd
*) NULL
)
1860 reloc_entry
->address
+= input_section
->output_offset
;
1865 /* Do a REFLO relocation. This is a straightforward 16 bit inplace
1866 relocation; this function exists in order to do the REFHI
1867 relocation described above. */
1869 static bfd_reloc_status_type
1870 ecoff_reflo_reloc (abfd
,
1877 arelent
*reloc_entry
;
1880 asection
*input_section
;
1883 if (ecoff_refhi_addr
!= (bfd_byte
*) NULL
)
1887 unsigned long vallo
;
1889 /* Do the REFHI relocation. Note that we actually don't need to
1890 know anything about the REFLO itself, except where to find
1891 the low 16 bits of the addend needed by the REFHI. */
1892 insn
= bfd_get_32 (abfd
, ecoff_refhi_addr
);
1893 vallo
= (bfd_get_32 (abfd
, (bfd_byte
*) data
+ reloc_entry
->address
)
1895 val
= ((insn
& 0xffff) << 16) + vallo
;
1896 val
+= ecoff_refhi_addend
;
1898 /* The low order 16 bits are always treated as a signed value.
1899 Therefore, a negative value in the low order bits requires an
1900 adjustment in the high order bits. We need to make this
1901 adjustment in two ways: once for the bits we took from the
1902 data, and once for the bits we are putting back in to the
1904 if ((vallo
& 0x8000) != 0)
1906 if ((val
& 0x8000) != 0)
1909 insn
= (insn
&~ 0xffff) | ((val
>> 16) & 0xffff);
1910 bfd_put_32 (abfd
, insn
, ecoff_refhi_addr
);
1912 ecoff_refhi_addr
= (bfd_byte
*) NULL
;
1915 /* Now do the REFLO reloc in the usual way. */
1916 return ecoff_generic_reloc (abfd
, reloc_entry
, symbol
, data
,
1917 input_section
, output_bfd
);
1920 /* Do a GPREL relocation. This is a 16 bit value which must become
1921 the offset from the gp register. */
1923 static bfd_reloc_status_type
1924 ecoff_gprel_reloc (abfd
,
1931 arelent
*reloc_entry
;
1934 asection
*input_section
;
1937 boolean relocateable
;
1942 /* If we're relocating, and this is an external symbol with no
1943 addend, we don't want to change anything. We will only have an
1944 addend if this is a newly created reloc, not read from an ECOFF
1946 if (output_bfd
!= (bfd
*) NULL
1947 && (symbol
->flags
& BSF_SECTION_SYM
) == 0
1948 && reloc_entry
->addend
== 0)
1950 reloc_entry
->address
+= input_section
->output_offset
;
1951 return bfd_reloc_ok
;
1954 if (output_bfd
!= (bfd
*) NULL
)
1955 relocateable
= true;
1958 relocateable
= false;
1959 output_bfd
= symbol
->section
->output_section
->owner
;
1962 if (symbol
->section
== &bfd_und_section
1963 && relocateable
== false)
1964 return bfd_reloc_undefined
;
1966 /* We have to figure out the gp value, so that we can adjust the
1967 symbol value correctly. We look up the symbol _gp in the output
1968 BFD. If we can't find it, we're stuck. We cache it in the ECOFF
1969 target data. We don't need to adjust the symbol value for an
1970 external symbol if we are producing relocateable output. */
1971 if (ecoff_data (output_bfd
)->gp
== 0
1972 && (relocateable
== false
1973 || (symbol
->flags
& BSF_SECTION_SYM
) != 0))
1975 if (relocateable
!= false)
1977 /* Make up a value. */
1978 ecoff_data (output_bfd
)->gp
=
1979 symbol
->section
->output_section
->vma
+ 0x4000;
1987 count
= bfd_get_symcount (output_bfd
);
1988 sym
= bfd_get_outsymbols (output_bfd
);
1990 /* We should do something more friendly here, but we don't
1991 have a good reloc status to return. */
1992 if (sym
== (asymbol
**) NULL
)
1995 for (i
= 0; i
< count
; i
++, sym
++)
1997 register CONST
char *name
;
1999 name
= bfd_asymbol_name (*sym
);
2000 if (*name
== '_' && strcmp (name
, "_gp") == 0)
2002 ecoff_data (output_bfd
)->gp
= bfd_asymbol_value (*sym
);
2007 /* We should do something more friendly here, but we don't have
2008 a good reloc status to return. */
2014 if (bfd_is_com_section (symbol
->section
))
2017 relocation
= symbol
->value
;
2019 relocation
+= symbol
->section
->output_section
->vma
;
2020 relocation
+= symbol
->section
->output_offset
;
2022 if (reloc_entry
->address
> input_section
->_cooked_size
)
2023 return bfd_reloc_outofrange
;
2025 insn
= bfd_get_32 (abfd
, (bfd_byte
*) data
+ reloc_entry
->address
);
2027 /* Set val to the offset into the section or symbol. */
2028 val
= ((insn
& 0xffff) + reloc_entry
->addend
) & 0xffff;
2032 /* Adjust val for the final section location and GP value. If we
2033 are producing relocateable output, we don't want to do this for
2034 an external symbol. */
2035 if (relocateable
== false
2036 || (symbol
->flags
& BSF_SECTION_SYM
) != 0)
2037 val
+= relocation
- ecoff_data (output_bfd
)->gp
;
2039 insn
= (insn
&~ 0xffff) | (val
& 0xffff);
2040 bfd_put_32 (abfd
, insn
, (bfd_byte
*) data
+ reloc_entry
->address
);
2042 if (relocateable
!= false)
2043 reloc_entry
->address
+= input_section
->output_offset
;
2045 /* Make sure it fit in 16 bits. */
2046 if (val
>= 0x8000 && val
< 0xffff8000)
2047 return bfd_reloc_outofrange
;
2049 return bfd_reloc_ok
;
2052 /* Read in the relocs for a section. */
2055 ecoff_slurp_reloc_table (abfd
, section
, symbols
)
2060 RELOC
*external_relocs
;
2061 arelent
*internal_relocs
;
2065 if (section
->relocation
!= (arelent
*) NULL
2066 || section
->reloc_count
== 0
2067 || (section
->flags
& SEC_CONSTRUCTOR
) != 0)
2070 if (ecoff_slurp_symbol_table (abfd
) == false)
2073 internal_relocs
= (arelent
*) bfd_alloc (abfd
,
2075 * section
->reloc_count
));
2076 external_relocs
= (RELOC
*) bfd_alloc (abfd
, RELSZ
* section
->reloc_count
);
2077 if (internal_relocs
== (arelent
*) NULL
2078 || external_relocs
== (RELOC
*) NULL
)
2080 bfd_error
= no_memory
;
2083 if (bfd_seek (abfd
, section
->rel_filepos
, SEEK_SET
) != 0)
2085 if (bfd_read (external_relocs
, 1, RELSZ
* section
->reloc_count
, abfd
)
2086 != RELSZ
* section
->reloc_count
)
2088 bfd_error
= system_call_error
;
2092 for (i
= 0, rptr
= internal_relocs
; i
< section
->reloc_count
; i
++, rptr
++)
2094 struct internal_reloc intern
;
2096 ecoff_swap_reloc_in (abfd
, external_relocs
+ i
, &intern
);
2098 if (intern
.r_type
> ECOFF_R_LITERAL
)
2101 if (intern
.r_extern
)
2103 /* r_symndx is an index into the external symbols. */
2104 BFD_ASSERT (intern
.r_symndx
>= 0
2106 < ecoff_data (abfd
)->symbolic_header
.iextMax
));
2107 rptr
->sym_ptr_ptr
= symbols
+ intern
.r_symndx
;
2112 CONST
char *sec_name
;
2115 /* r_symndx is a section key. */
2116 switch (intern
.r_symndx
)
2118 case RELOC_SECTION_TEXT
: sec_name
= ".text"; break;
2119 case RELOC_SECTION_RDATA
: sec_name
= ".rdata"; break;
2120 case RELOC_SECTION_DATA
: sec_name
= ".data"; break;
2121 case RELOC_SECTION_SDATA
: sec_name
= ".sdata"; break;
2122 case RELOC_SECTION_SBSS
: sec_name
= ".sbss"; break;
2123 case RELOC_SECTION_BSS
: sec_name
= ".bss"; break;
2124 case RELOC_SECTION_INIT
: sec_name
= ".init"; break;
2125 case RELOC_SECTION_LIT8
: sec_name
= ".lit8"; break;
2126 case RELOC_SECTION_LIT4
: sec_name
= ".lit4"; break;
2130 sec
= bfd_get_section_by_name (abfd
, sec_name
);
2131 if (sec
== (asection
*) NULL
)
2133 rptr
->sym_ptr_ptr
= sec
->symbol_ptr_ptr
;
2135 rptr
->addend
= - bfd_get_section_vma (abfd
, sec
);
2136 if (intern
.r_type
== ECOFF_R_GPREL
2137 || intern
.r_type
== ECOFF_R_LITERAL
)
2138 rptr
->addend
+= ecoff_data (abfd
)->gp
;
2141 rptr
->address
= intern
.r_vaddr
- bfd_get_section_vma (abfd
, section
);
2142 rptr
->howto
= &ecoff_howto_table
[intern
.r_type
];
2144 /* If the type is ECOFF_R_IGNORE, make sure this is a reference
2145 to the absolute section so that the reloc is ignored. */
2146 if (intern
.r_type
== ECOFF_R_IGNORE
)
2147 rptr
->sym_ptr_ptr
= bfd_abs_section
.symbol_ptr_ptr
;
2150 bfd_release (abfd
, external_relocs
);
2152 section
->relocation
= internal_relocs
;
2157 /* Get a canonical list of relocs. */
2160 ecoff_canonicalize_reloc (abfd
, section
, relptr
, symbols
)
2168 if (section
->flags
& SEC_CONSTRUCTOR
)
2170 arelent_chain
*chain
;
2172 /* This section has relocs made up by us, not the file, so take
2173 them out of their chain and place them into the data area
2175 for (count
= 0, chain
= section
->constructor_chain
;
2176 count
< section
->reloc_count
;
2177 count
++, chain
= chain
->next
)
2178 *relptr
++ = &chain
->relent
;
2184 if (ecoff_slurp_reloc_table (abfd
, section
, symbols
) == false)
2187 tblptr
= section
->relocation
;
2188 if (tblptr
== (arelent
*) NULL
)
2191 for (count
= 0; count
< section
->reloc_count
; count
++)
2192 *relptr
++ = tblptr
++;
2195 *relptr
= (arelent
*) NULL
;
2197 return section
->reloc_count
;
2200 /* Get the howto structure for a generic reloc type. */
2202 static CONST
struct reloc_howto_struct
*
2203 ecoff_bfd_reloc_type_lookup (abfd
, code
)
2205 bfd_reloc_code_real_type code
;
2212 ecoff_type
= ECOFF_R_REFHALF
;
2215 ecoff_type
= ECOFF_R_REFWORD
;
2217 case BFD_RELOC_MIPS_JMP
:
2218 ecoff_type
= ECOFF_R_JMPADDR
;
2220 case BFD_RELOC_HI16_S
:
2221 ecoff_type
= ECOFF_R_REFHI
;
2223 case BFD_RELOC_LO16
:
2224 ecoff_type
= ECOFF_R_REFLO
;
2226 case BFD_RELOC_MIPS_GPREL
:
2227 ecoff_type
= ECOFF_R_GPREL
;
2230 return (CONST
struct reloc_howto_struct
*) NULL
;
2233 return &ecoff_howto_table
[ecoff_type
];
2236 /* Provided a BFD, a section and an offset into the section, calculate
2237 and return the name of the source file and the line nearest to the
2241 ecoff_find_nearest_line (abfd
,
2250 asymbol
**ignore_symbols
;
2252 CONST
char **filename_ptr
;
2253 CONST
char **functionname_ptr
;
2254 unsigned int *retline_ptr
;
2260 struct pdr_ext
*pdr_ptr
;
2261 struct pdr_ext
*pdr_end
;
2263 unsigned char *line_ptr
;
2264 unsigned char *line_end
;
2267 /* If we're not in the .text section, we don't have any line
2269 if (strcmp (section
->name
, _TEXT
) != 0
2270 || offset
< ecoff_data (abfd
)->text_start
2271 || offset
>= ecoff_data (abfd
)->text_end
)
2274 /* Make sure we have the FDR's. */
2275 if (ecoff_slurp_symbolic_info (abfd
) == false
2276 || bfd_get_symcount (abfd
) == 0)
2279 /* Each file descriptor (FDR) has a memory address. Here we track
2280 down which FDR we want. The FDR's are stored in increasing
2281 memory order. If speed is ever important, this can become a
2282 binary search. We must ignore FDR's with no PDR entries; they
2283 will have the adr of the FDR before or after them. */
2284 fdr_start
= ecoff_data (abfd
)->fdr
;
2285 fdr_end
= fdr_start
+ ecoff_data (abfd
)->symbolic_header
.ifdMax
;
2286 fdr_hold
= (FDR
*) NULL
;
2287 for (fdr_ptr
= fdr_start
; fdr_ptr
< fdr_end
; fdr_ptr
++)
2289 if (fdr_ptr
->cpd
== 0)
2291 if (offset
< fdr_ptr
->adr
)
2295 if (fdr_hold
== (FDR
*) NULL
)
2299 /* Each FDR has a list of procedure descriptors (PDR). PDR's also
2300 have an address, which is relative to the FDR address, and are
2301 also stored in increasing memory order. */
2302 offset
-= fdr_ptr
->adr
;
2303 pdr_ptr
= ecoff_data (abfd
)->external_pdr
+ fdr_ptr
->ipdFirst
;
2304 pdr_end
= pdr_ptr
+ fdr_ptr
->cpd
;
2305 ecoff_swap_pdr_in (abfd
, pdr_ptr
, &pdr
);
2307 /* The address of the first PDR is an offset which applies to the
2308 addresses of all the PDR's. */
2311 for (pdr_ptr
++; pdr_ptr
< pdr_end
; pdr_ptr
++)
2313 ecoff_swap_pdr_in (abfd
, pdr_ptr
, &pdr
);
2314 if (offset
< pdr
.adr
)
2318 /* Now we can look for the actual line number. The line numbers are
2319 stored in a very funky format, which I won't try to describe.
2320 Note that right here pdr_ptr and pdr hold the PDR *after* the one
2321 we want; we need this to compute line_end. */
2322 line_end
= ecoff_data (abfd
)->line
;
2323 if (pdr_ptr
== pdr_end
)
2324 line_end
+= fdr_ptr
->cbLineOffset
+ fdr_ptr
->cbLine
;
2326 line_end
+= fdr_ptr
->cbLineOffset
+ pdr
.cbLineOffset
;
2328 /* Now change pdr and pdr_ptr to the one we want. */
2330 ecoff_swap_pdr_in (abfd
, pdr_ptr
, &pdr
);
2334 line_ptr
= (ecoff_data (abfd
)->line
2335 + fdr_ptr
->cbLineOffset
2336 + pdr
.cbLineOffset
);
2337 while (line_ptr
< line_end
)
2342 delta
= *line_ptr
>> 4;
2345 count
= (*line_ptr
& 0xf) + 1;
2349 delta
= (((line_ptr
[0]) & 0xff) << 8) + ((line_ptr
[1]) & 0xff);
2350 if (delta
>= 0x8000)
2355 if (offset
< count
* 4)
2357 offset
-= count
* 4;
2360 /* If fdr_ptr->rss is -1, then this file does not have full symbols,
2361 at least according to gdb/mipsread.c. */
2362 if (fdr_ptr
->rss
== -1)
2364 *filename_ptr
= NULL
;
2366 *functionname_ptr
= NULL
;
2371 ecoff_swap_ext_in (abfd
,
2372 (ecoff_data (abfd
)->external_ext
2375 *functionname_ptr
= ecoff_data (abfd
)->ssext
+ proc_ext
.asym
.iss
;
2382 *filename_ptr
= ecoff_data (abfd
)->ss
+ fdr_ptr
->issBase
+ fdr_ptr
->rss
;
2383 ecoff_swap_sym_in (abfd
,
2384 (ecoff_data (abfd
)->external_sym
2388 *functionname_ptr
= (ecoff_data (abfd
)->ss
2392 if (lineno
== ilineNil
)
2394 *retline_ptr
= lineno
;
2398 /* We can't use the generic linking routines for ECOFF, because we
2399 have to handle all the debugging information. The generic link
2400 routine just works out the section contents and attaches a list of
2403 We link by looping over all the seclets. We make two passes. On
2404 the first we set the actual section contents and determine the size
2405 of the debugging information. On the second we accumulate the
2406 debugging information and write it out.
2408 This currently always accumulates the debugging information, which
2409 is incorrect, because it ignores the -s and -S options of the
2410 linker. The linker needs to be modified to give us that
2411 information in a more useful format (currently it just provides a
2412 list of symbols which should appear in the output file). */
2414 /* Clear the output_has_begun flag for all the input BFD's. We use it
2415 to avoid linking in the debugging information for a BFD more than
2419 ecoff_clear_output_flags (abfd
)
2422 register asection
*o
;
2423 register bfd_seclet_type
*p
;
2425 for (o
= abfd
->sections
; o
!= (asection
*) NULL
; o
= o
->next
)
2426 for (p
= o
->seclets_head
;
2427 p
!= (bfd_seclet_type
*) NULL
;
2429 if (p
->type
== bfd_indirect_seclet
)
2430 p
->u
.indirect
.section
->owner
->output_has_begun
= false;
2433 /* Handle an indirect seclet on the first pass. Set the contents of
2434 the output section, and accumulate the debugging information if
2438 ecoff_rel (output_bfd
, seclet
, output_section
, data
, relocateable
)
2440 bfd_seclet_type
*seclet
;
2441 asection
*output_section
;
2443 boolean relocateable
;
2446 HDRR
*output_symhdr
;
2449 if ((output_section
->flags
& SEC_HAS_CONTENTS
)
2450 && !(output_section
->flags
& SEC_NEVER_LOAD
)
2451 && (output_section
->flags
& SEC_LOAD
)
2454 data
= (PTR
) bfd_get_relocated_section_contents (output_bfd
,
2458 if (bfd_set_section_contents (output_bfd
,
2469 input_bfd
= seclet
->u
.indirect
.section
->owner
;
2471 /* We want to figure out how much space will be required to
2472 incorporate all the debugging information from input_bfd. We use
2473 the output_has_begun field to avoid adding it in more than once.
2474 The actual incorporation is done in the second pass, in
2475 ecoff_get_debug. The code has to parallel that code in its
2476 manipulations of output_symhdr. */
2478 if (input_bfd
->output_has_begun
)
2480 input_bfd
->output_has_begun
= true;
2482 output_symhdr
= &ecoff_data (output_bfd
)->symbolic_header
;
2484 if (input_bfd
->xvec
->flavour
!= bfd_target_ecoff_flavour
)
2490 /* We just accumulate local symbols from a non-ECOFF BFD. The
2491 external symbols are handled separately. */
2493 symbols
= (asymbol
**) bfd_alloc (output_bfd
,
2494 get_symtab_upper_bound (input_bfd
));
2495 if (symbols
== (asymbol
**) NULL
)
2497 bfd_error
= no_memory
;
2500 sym_end
= symbols
+ bfd_canonicalize_symtab (input_bfd
, symbols
);
2502 for (sym_ptr
= symbols
; sym_ptr
< sym_end
; sym_ptr
++)
2506 len
= strlen ((*sym_ptr
)->name
);
2507 if (((*sym_ptr
)->flags
& BSF_EXPORT
) == 0)
2509 ++output_symhdr
->isymMax
;
2510 output_symhdr
->issMax
+= len
+ 1;
2514 bfd_release (output_bfd
, (PTR
) symbols
);
2516 ++output_symhdr
->ifdMax
;
2521 /* We simply add in the information from another ECOFF BFD. First
2522 we make sure we have the symbolic information. */
2523 if (ecoff_slurp_symbol_table (input_bfd
) == false)
2525 if (bfd_get_symcount (input_bfd
) == 0)
2528 input_symhdr
= &ecoff_data (input_bfd
)->symbolic_header
;
2530 /* Figure out how much information we are going to be putting in.
2531 The external symbols are handled separately. */
2532 output_symhdr
->ilineMax
+= input_symhdr
->ilineMax
;
2533 output_symhdr
->cbLine
+= input_symhdr
->cbLine
;
2534 output_symhdr
->idnMax
+= input_symhdr
->idnMax
;
2535 output_symhdr
->ipdMax
+= input_symhdr
->ipdMax
;
2536 output_symhdr
->isymMax
+= input_symhdr
->isymMax
;
2537 output_symhdr
->ioptMax
+= input_symhdr
->ioptMax
;
2538 output_symhdr
->iauxMax
+= input_symhdr
->iauxMax
;
2539 output_symhdr
->issMax
+= input_symhdr
->issMax
;
2540 output_symhdr
->ifdMax
+= input_symhdr
->ifdMax
;
2542 /* The RFD's are special, since we create them if needed. */
2543 if (input_symhdr
->crfd
> 0)
2544 output_symhdr
->crfd
+= input_symhdr
->crfd
;
2546 output_symhdr
->crfd
+= input_symhdr
->ifdMax
;
2551 /* Handle an arbitrary seclet on the first pass. */
2554 ecoff_dump_seclet (abfd
, seclet
, section
, data
, relocateable
)
2556 bfd_seclet_type
*seclet
;
2559 boolean relocateable
;
2561 switch (seclet
->type
)
2563 case bfd_indirect_seclet
:
2564 /* The contents of this section come from another one somewhere
2566 return ecoff_rel (abfd
, seclet
, section
, data
, relocateable
);
2568 case bfd_fill_seclet
:
2569 /* Fill in the section with fill.value. This is used to pad out
2570 sections, but we must avoid padding the .bss section. */
2571 if ((section
->flags
& SEC_HAS_CONTENTS
) == 0)
2573 if (seclet
->u
.fill
.value
!= 0)
2578 char *d
= (char *) bfd_alloc (abfd
, seclet
->size
);
2582 for (i
= 0; i
< seclet
->size
; i
+=2)
2583 d
[i
] = seclet
->u
.fill
.value
>> 8;
2584 for (i
= 1; i
< seclet
->size
; i
+=2)
2585 d
[i
] = seclet
->u
.fill
.value
;
2586 ret
= bfd_set_section_contents (abfd
, section
, d
, seclet
->offset
,
2588 bfd_release (abfd
, (PTR
) d
);
2600 /* Add a string to the debugging information we are accumulating for a
2601 file. Return the offset from the fdr string base or from the
2602 external string base. */
2605 ecoff_add_string (output_bfd
, fdr
, string
, external
)
2615 symhdr
= &ecoff_data (output_bfd
)->symbolic_header
;
2616 len
= strlen (string
);
2619 strcpy (ecoff_data (output_bfd
)->ssext
+ symhdr
->issExtMax
, string
);
2620 ret
= symhdr
->issExtMax
;
2621 symhdr
->issExtMax
+= len
+ 1;
2625 strcpy (ecoff_data (output_bfd
)->ss
+ symhdr
->issMax
, string
);
2627 symhdr
->issMax
+= len
+ 1;
2628 fdr
->cbSs
+= len
+ 1;
2633 /* Accumulate the debugging information from an input section. */
2636 ecoff_get_debug (output_bfd
, seclet
, section
, relocateable
)
2638 bfd_seclet_type
*seclet
;
2640 boolean relocateable
;
2643 HDRR
*output_symhdr
;
2645 ecoff_data_type
*output_ecoff
;
2646 ecoff_data_type
*input_ecoff
;
2648 struct sym_ext
*sym_out
;
2649 ecoff_symbol_type
*esym_ptr
;
2650 ecoff_symbol_type
*esym_end
;
2653 struct fdr_ext
*fdr_out
;
2655 input_bfd
= seclet
->u
.indirect
.section
->owner
;
2657 /* Don't get the information more than once. */
2658 if (input_bfd
->output_has_begun
)
2660 input_bfd
->output_has_begun
= true;
2662 output_ecoff
= ecoff_data (output_bfd
);
2663 output_symhdr
= &output_ecoff
->symbolic_header
;
2665 if (input_bfd
->xvec
->flavour
!= bfd_target_ecoff_flavour
)
2672 /* This is not an ECOFF BFD. Just gather the symbols. */
2674 memset (&fdr
, 0, sizeof fdr
);
2676 fdr
.adr
= bfd_get_section_vma (output_bfd
, section
) + seclet
->offset
;
2677 fdr
.issBase
= output_symhdr
->issMax
;
2679 fdr
.rss
= ecoff_add_string (output_bfd
,
2681 bfd_get_filename (input_bfd
),
2683 fdr
.isymBase
= output_symhdr
->isymMax
;
2685 /* Get the local symbols from the input BFD. */
2686 symbols
= (asymbol
**) bfd_alloc (output_bfd
,
2687 get_symtab_upper_bound (input_bfd
));
2688 if (symbols
== (asymbol
**) NULL
)
2690 bfd_error
= no_memory
;
2693 sym_end
= symbols
+ bfd_canonicalize_symtab (input_bfd
, symbols
);
2695 /* Handle the local symbols. Any external symbols are handled
2698 for (sym_ptr
= symbols
; sym_ptr
!= sym_end
; sym_ptr
++)
2702 if (((*sym_ptr
)->flags
& BSF_EXPORT
) != 0)
2704 memset (&internal_sym
, 0, sizeof internal_sym
);
2705 internal_sym
.iss
= ecoff_add_string (output_bfd
,
2710 if (bfd_is_com_section ((*sym_ptr
)->section
)
2711 || (*sym_ptr
)->section
== &bfd_und_section
)
2712 internal_sym
.value
= (*sym_ptr
)->value
;
2714 internal_sym
.value
= ((*sym_ptr
)->value
2715 + (*sym_ptr
)->section
->output_offset
2716 + (*sym_ptr
)->section
->output_section
->vma
);
2717 internal_sym
.st
= stNil
;
2718 internal_sym
.sc
= scUndefined
;
2719 internal_sym
.index
= indexNil
;
2720 ecoff_swap_sym_out (output_bfd
, &internal_sym
,
2721 (output_ecoff
->external_sym
2722 + output_symhdr
->isymMax
));
2724 ++output_symhdr
->isymMax
;
2727 bfd_release (output_bfd
, (PTR
) symbols
);
2729 /* Leave everything else in the FDR zeroed out. This will cause
2730 the lang field to be langC. The fBigendian field will
2731 indicate little endian format, but it doesn't matter because
2732 it only applies to aux fields and there are none. */
2734 ecoff_swap_fdr_out (output_bfd
, &fdr
,
2735 (output_ecoff
->external_fdr
2736 + output_symhdr
->ifdMax
));
2737 ++output_symhdr
->ifdMax
;
2741 /* This is an ECOFF BFD. We want to grab the information from
2742 input_bfd and attach it to output_bfd. */
2743 count
= bfd_get_symcount (input_bfd
);
2746 input_ecoff
= ecoff_data (input_bfd
);
2747 input_symhdr
= &input_ecoff
->symbolic_header
;
2749 /* I think that it is more efficient to simply copy the debugging
2750 information from the input BFD to the output BFD. Because ECOFF
2751 uses relative pointers for most of the debugging information,
2752 only a little of it has to be changed at all. */
2754 /* Swap in the local symbols, adjust their values, and swap them out
2755 again. The external symbols are handled separately. */
2756 sym_out
= output_ecoff
->external_sym
+ output_symhdr
->isymMax
;
2758 esym_ptr
= ecoff_data (input_bfd
)->canonical_symbols
;
2759 esym_end
= esym_ptr
+ count
;
2760 for (; esym_ptr
< esym_end
; esym_ptr
++)
2762 if (esym_ptr
->local
)
2766 ecoff_swap_sym_in (input_bfd
, esym_ptr
->native
.lnative
, &sym
);
2768 /* If we're producing an executable, move common symbols
2770 if (relocateable
== false)
2772 if (sym
.sc
== scCommon
)
2774 else if (sym
.sc
== scSCommon
)
2778 if (! bfd_is_com_section (esym_ptr
->symbol
.section
)
2779 && (esym_ptr
->symbol
.flags
& BSF_DEBUGGING
) == 0
2780 && esym_ptr
->symbol
.section
!= &bfd_und_section
)
2781 sym
.value
= (esym_ptr
->symbol
.value
2782 + esym_ptr
->symbol
.section
->output_offset
2783 + esym_ptr
->symbol
.section
->output_section
->vma
);
2784 ecoff_swap_sym_out (output_bfd
, &sym
, sym_out
);
2789 /* That should have accounted for all the local symbols in
2791 BFD_ASSERT ((sym_out
- output_ecoff
->external_sym
) - output_symhdr
->isymMax
2792 == input_symhdr
->isymMax
);
2794 /* Copy the information that does not need swapping. */
2795 memcpy (output_ecoff
->line
+ output_symhdr
->cbLine
,
2797 input_symhdr
->cbLine
* sizeof (unsigned char));
2798 memcpy (output_ecoff
->external_aux
+ output_symhdr
->iauxMax
,
2799 input_ecoff
->external_aux
,
2800 input_symhdr
->iauxMax
* sizeof (union aux_ext
));
2801 memcpy (output_ecoff
->ss
+ output_symhdr
->issMax
,
2803 input_symhdr
->issMax
* sizeof (char));
2805 /* Some of the information may need to be swapped. */
2806 if (output_bfd
->xvec
->header_byteorder_big_p
2807 == input_bfd
->xvec
->header_byteorder_big_p
)
2809 /* The two BFD's have the same endianness, so memcpy will
2811 memcpy (output_ecoff
->external_dnr
+ output_symhdr
->idnMax
,
2812 input_ecoff
->external_dnr
,
2813 input_symhdr
->idnMax
* sizeof (struct dnr_ext
));
2814 memcpy (output_ecoff
->external_pdr
+ output_symhdr
->ipdMax
,
2815 input_ecoff
->external_pdr
,
2816 input_symhdr
->ipdMax
* sizeof (struct pdr_ext
));
2817 memcpy (output_ecoff
->external_opt
+ output_symhdr
->ioptMax
,
2818 input_ecoff
->external_opt
,
2819 input_symhdr
->ioptMax
* sizeof (struct opt_ext
));
2823 struct dnr_ext
*dnr_in
;
2824 struct dnr_ext
*dnr_end
;
2825 struct dnr_ext
*dnr_out
;
2826 struct pdr_ext
*pdr_in
;
2827 struct pdr_ext
*pdr_end
;
2828 struct pdr_ext
*pdr_out
;
2829 struct opt_ext
*opt_in
;
2830 struct opt_ext
*opt_end
;
2831 struct opt_ext
*opt_out
;
2833 /* The two BFD's have different endianness, so we must swap
2834 everything in and out. This code would always work, but it
2835 would be slow in the normal case. */
2836 dnr_in
= input_ecoff
->external_dnr
;
2837 dnr_end
= dnr_in
+ input_symhdr
->idnMax
;
2838 dnr_out
= output_ecoff
->external_dnr
+ output_symhdr
->idnMax
;
2839 for (; dnr_in
< dnr_end
; dnr_in
++, dnr_out
++)
2843 ecoff_swap_dnr_in (input_bfd
, dnr_in
, &dnr
);
2844 ecoff_swap_dnr_out (output_bfd
, &dnr
, dnr_out
);
2846 pdr_in
= input_ecoff
->external_pdr
;
2847 pdr_end
= pdr_in
+ input_symhdr
->ipdMax
;
2848 pdr_out
= output_ecoff
->external_pdr
+ output_symhdr
->ipdMax
;
2849 for (; pdr_in
< pdr_end
; pdr_in
++, pdr_out
++)
2853 ecoff_swap_pdr_in (input_bfd
, pdr_in
, &pdr
);
2854 ecoff_swap_pdr_out (output_bfd
, &pdr
, pdr_out
);
2856 opt_in
= input_ecoff
->external_opt
;
2857 opt_end
= opt_in
+ input_symhdr
->ioptMax
;
2858 opt_out
= output_ecoff
->external_opt
+ output_symhdr
->ioptMax
;
2859 for (; opt_in
< opt_end
; opt_in
++, opt_out
++)
2863 ecoff_swap_opt_in (input_bfd
, opt_in
, &opt
);
2864 ecoff_swap_opt_out (output_bfd
, &opt
, opt_out
);
2868 /* Set ifdbase so that the external symbols know how to adjust their
2870 input_ecoff
->ifdbase
= output_symhdr
->ifdMax
;
2872 fdr_ptr
= input_ecoff
->fdr
;
2873 fdr_end
= fdr_ptr
+ input_symhdr
->ifdMax
;
2874 fdr_out
= output_ecoff
->external_fdr
+ output_symhdr
->ifdMax
;
2875 for (; fdr_ptr
< fdr_end
; fdr_ptr
++, fdr_out
++)
2878 unsigned long pdr_off
;
2882 /* The memory address for this fdr is the address for the seclet
2883 plus the offset to this fdr within input_bfd. For some
2884 reason the offset of the first procedure pointer is also
2892 ecoff_swap_pdr_in (input_bfd
,
2893 input_ecoff
->external_pdr
+ fdr
.ipdFirst
,
2897 fdr
.adr
= (bfd_get_section_vma (output_bfd
, section
)
2899 + (fdr_ptr
->adr
- input_ecoff
->fdr
->adr
)
2902 fdr
.issBase
+= output_symhdr
->issMax
;
2903 fdr
.isymBase
+= output_symhdr
->isymMax
;
2904 fdr
.ilineBase
+= output_symhdr
->ilineMax
;
2905 fdr
.ioptBase
+= output_symhdr
->ioptMax
;
2906 fdr
.ipdFirst
+= output_symhdr
->ipdMax
;
2907 fdr
.iauxBase
+= output_symhdr
->iauxMax
;
2908 fdr
.rfdBase
+= output_symhdr
->crfd
;
2910 /* If there are no RFD's, we are going to add some. We don't
2911 want to adjust irfd for this, so that all the FDR's can share
2913 if (input_symhdr
->crfd
== 0)
2914 fdr
.crfd
= input_symhdr
->ifdMax
;
2916 if (fdr
.cbLine
!= 0)
2917 fdr
.cbLineOffset
+= output_symhdr
->cbLine
;
2919 ecoff_swap_fdr_out (output_bfd
, &fdr
, fdr_out
);
2922 if (input_symhdr
->crfd
> 0)
2924 struct rfd_ext
*rfd_in
;
2925 struct rfd_ext
*rfd_end
;
2926 struct rfd_ext
*rfd_out
;
2928 /* Swap and adjust the RFD's. RFD's are only created by the
2929 linker, so this will only be necessary if one of the input
2930 files is the result of a partial link. Presumably all
2931 necessary RFD's are present. */
2932 rfd_in
= input_ecoff
->external_rfd
;
2933 rfd_end
= rfd_in
+ input_symhdr
->crfd
;
2934 rfd_out
= output_ecoff
->external_rfd
+ output_symhdr
->crfd
;
2935 for (; rfd_in
< rfd_end
; rfd_in
++, rfd_out
++)
2939 ecoff_swap_rfd_in (input_bfd
, rfd_in
, &rfd
);
2940 rfd
+= output_symhdr
->ifdMax
;
2941 ecoff_swap_rfd_out (output_bfd
, &rfd
, rfd_out
);
2943 output_symhdr
->crfd
+= input_symhdr
->crfd
;
2947 struct rfd_ext
*rfd_out
;
2948 struct rfd_ext
*rfd_end
;
2951 /* Create RFD's. Some of the debugging information includes
2952 relative file indices. These indices are taken as indices to
2953 the RFD table if there is one, or to the global table if
2954 there is not. If we did not create RFD's, we would have to
2955 parse and adjust all the debugging information which contains
2957 rfd
= output_symhdr
->ifdMax
;
2958 rfd_out
= output_ecoff
->external_rfd
+ output_symhdr
->crfd
;
2959 rfd_end
= rfd_out
+ input_symhdr
->ifdMax
;
2960 for (; rfd_out
< rfd_end
; rfd_out
++, rfd
++)
2961 ecoff_swap_rfd_out (output_bfd
, &rfd
, rfd_out
);
2962 output_symhdr
->crfd
+= input_symhdr
->ifdMax
;
2965 /* Combine the register masks. */
2969 output_ecoff
->gprmask
|= input_ecoff
->gprmask
;
2970 for (i
= 0; i
< 4; i
++)
2971 output_ecoff
->cprmask
[i
] |= input_ecoff
->cprmask
[i
];
2974 /* Update the counts. */
2975 output_symhdr
->ilineMax
+= input_symhdr
->ilineMax
;
2976 output_symhdr
->cbLine
+= input_symhdr
->cbLine
;
2977 output_symhdr
->idnMax
+= input_symhdr
->idnMax
;
2978 output_symhdr
->ipdMax
+= input_symhdr
->ipdMax
;
2979 output_symhdr
->isymMax
+= input_symhdr
->isymMax
;
2980 output_symhdr
->ioptMax
+= input_symhdr
->ioptMax
;
2981 output_symhdr
->iauxMax
+= input_symhdr
->iauxMax
;
2982 output_symhdr
->issMax
+= input_symhdr
->issMax
;
2983 output_symhdr
->ifdMax
+= input_symhdr
->ifdMax
;
2988 /* This is the actual link routine. It makes two passes over all the
2992 ecoff_bfd_seclet_link (abfd
, data
, relocateable
)
2995 boolean relocateable
;
2999 register asection
*o
;
3000 register bfd_seclet_type
*p
;
3001 asymbol
**sym_ptr_ptr
;
3005 /* We accumulate the debugging information counts in the symbolic
3007 symhdr
= &ecoff_data (abfd
)->symbolic_header
;
3008 symhdr
->magic
= magicSym
;
3009 /* FIXME: What should the version stamp be? */
3011 symhdr
->ilineMax
= 0;
3015 symhdr
->isymMax
= 0;
3016 symhdr
->ioptMax
= 0;
3017 symhdr
->iauxMax
= 0;
3019 symhdr
->issExtMax
= 0;
3022 symhdr
->iextMax
= 0;
3024 /* We need to copy over the debugging symbols from each input BFD.
3025 When we do this copying, we have to adjust the text address in
3026 the FDR structures, so we have to know the text address used for
3027 the input BFD. Since we only want to copy the symbols once per
3028 input BFD, but we are going to look at each input BFD multiple
3029 times (once for each section it provides), we arrange to always
3030 look at the text section first. That means that when we copy the
3031 debugging information, we always know the text address. So we
3032 actually do each pass in two sub passes; first the text sections,
3033 then the non-text sections. We use the output_has_begun flag to
3034 determine whether we have copied over the debugging information
3037 /* Do the first pass: set the output section contents and count the
3038 debugging information. */
3039 ecoff_clear_output_flags (abfd
);
3040 for (ipass
= 0; ipass
< 2; ipass
++)
3042 for (o
= abfd
->sections
; o
!= (asection
*) NULL
; o
= o
->next
)
3044 /* For SEC_CODE sections, (flags & SEC_CODE) == 0 is false,
3045 so they are done on pass 0. For other sections the
3046 expression is true, so they are done on pass 1. */
3047 if (((o
->flags
& SEC_CODE
) == 0) != ipass
)
3050 for (p
= o
->seclets_head
;
3051 p
!= (bfd_seclet_type
*) NULL
;
3054 if (ecoff_dump_seclet (abfd
, p
, o
, data
, relocateable
)
3061 /* We handle the external symbols differently. We use the ones
3062 attached to the output_bfd. The linker will have already
3063 determined which symbols are to be attached. Here we just
3064 determine how much space we will need for them. */
3065 sym_ptr_ptr
= bfd_get_outsymbols (abfd
);
3066 if (sym_ptr_ptr
!= NULL
)
3070 sym_end
= sym_ptr_ptr
+ bfd_get_symcount (abfd
);
3071 for (; sym_ptr_ptr
< sym_end
; sym_ptr_ptr
++)
3073 if (((*sym_ptr_ptr
)->flags
& BSF_DEBUGGING
) == 0
3074 && ((*sym_ptr_ptr
)->flags
& BSF_LOCAL
) == 0)
3077 symhdr
->issExtMax
+= strlen ((*sym_ptr_ptr
)->name
) + 1;
3082 /* Adjust the counts so that structures are longword aligned. */
3083 symhdr
->cbLine
= (symhdr
->cbLine
+ 3) &~ 3;
3084 symhdr
->issMax
= (symhdr
->issMax
+ 3) &~ 3;
3085 symhdr
->issExtMax
= (symhdr
->issExtMax
+ 3) &~ 3;
3087 /* Now the counts in symhdr are the correct size for the debugging
3088 information. We allocate the right amount of space, and reset
3089 the counts so that the second pass can use them as indices. It
3090 would be possible to output the debugging information directly to
3091 the file in pass 2, rather than to build it in memory and then
3092 write it out. Outputting to the file would require a lot of
3093 seeks and small writes, though, and I think this approach is
3095 size
= (symhdr
->cbLine
* sizeof (unsigned char)
3096 + symhdr
->idnMax
* sizeof (struct dnr_ext
)
3097 + symhdr
->ipdMax
* sizeof (struct pdr_ext
)
3098 + symhdr
->isymMax
* sizeof (struct sym_ext
)
3099 + symhdr
->ioptMax
* sizeof (struct opt_ext
)
3100 + symhdr
->iauxMax
* sizeof (union aux_ext
)
3101 + symhdr
->issMax
* sizeof (char)
3102 + symhdr
->issExtMax
* sizeof (char)
3103 + symhdr
->ifdMax
* sizeof (struct fdr_ext
)
3104 + symhdr
->crfd
* sizeof (struct rfd_ext
)
3105 + symhdr
->iextMax
* sizeof (struct ext_ext
));
3106 raw
= (char *) bfd_alloc (abfd
, size
);
3107 if (raw
== (char *) NULL
)
3109 bfd_error
= no_memory
;
3112 ecoff_data (abfd
)->raw_size
= size
;
3113 ecoff_data (abfd
)->raw_syments
= (PTR
) raw
;
3115 /* Initialize the raw pointers. */
3116 #define SET(field, count, type) \
3117 ecoff_data (abfd)->field = (type *) raw; \
3118 raw += symhdr->count * sizeof (type)
3120 SET (line
, cbLine
, unsigned char);
3121 SET (external_dnr
, idnMax
, struct dnr_ext
);
3122 SET (external_pdr
, ipdMax
, struct pdr_ext
);
3123 SET (external_sym
, isymMax
, struct sym_ext
);
3124 SET (external_opt
, ioptMax
, struct opt_ext
);
3125 SET (external_aux
, iauxMax
, union aux_ext
);
3126 SET (ss
, issMax
, char);
3127 SET (ssext
, issExtMax
, char);
3128 SET (external_fdr
, ifdMax
, struct fdr_ext
);
3129 SET (external_rfd
, crfd
, struct rfd_ext
);
3130 SET (external_ext
, iextMax
, struct ext_ext
);
3133 /* Reset the counts so the second pass can use them to know how far
3135 symhdr
->ilineMax
= 0;
3139 symhdr
->isymMax
= 0;
3140 symhdr
->ioptMax
= 0;
3141 symhdr
->iauxMax
= 0;
3143 symhdr
->issExtMax
= 0;
3146 symhdr
->iextMax
= 0;
3148 /* Do the second pass: accumulate the debugging information. */
3149 ecoff_clear_output_flags (abfd
);
3150 for (ipass
= 0; ipass
< 2; ipass
++)
3152 for (o
= abfd
->sections
; o
!= (asection
*) NULL
; o
= o
->next
)
3154 if (((o
->flags
& SEC_CODE
) == 0) != ipass
)
3156 for (p
= o
->seclets_head
;
3157 p
!= (bfd_seclet_type
*) NULL
;
3160 if (p
->type
== bfd_indirect_seclet
)
3162 if (ecoff_get_debug (abfd
, p
, o
, relocateable
) == false)
3169 /* Put in the external symbols. */
3170 sym_ptr_ptr
= bfd_get_outsymbols (abfd
);
3171 if (sym_ptr_ptr
!= NULL
)
3174 struct ext_ext
*external_ext
;
3176 ssext
= ecoff_data (abfd
)->ssext
;
3177 external_ext
= ecoff_data (abfd
)->external_ext
;
3178 for (; *sym_ptr_ptr
!= NULL
; sym_ptr_ptr
++)
3183 sym_ptr
= *sym_ptr_ptr
;
3185 if ((sym_ptr
->flags
& BSF_DEBUGGING
) != 0
3186 || (sym_ptr
->flags
& BSF_LOCAL
) != 0)
3189 /* The enative pointer can be NULL for a symbol created by
3190 the linker via ecoff_make_empty_symbol. */
3191 if (bfd_asymbol_flavour (sym_ptr
) != bfd_target_ecoff_flavour
3192 || (((ecoff_symbol_type
*) sym_ptr
)->native
.enative
3193 == (struct ext_ext
*) NULL
))
3196 esym
.cobol_main
= 0;
3200 /* FIXME: we can do better than this for st and sc. */
3201 esym
.asym
.st
= stGlobal
;
3202 esym
.asym
.sc
= scAbs
;
3203 esym
.asym
.reserved
= 0;
3204 esym
.asym
.index
= indexNil
;
3208 ecoff_symbol_type
*ecoff_sym_ptr
;
3210 ecoff_sym_ptr
= (ecoff_symbol_type
*) sym_ptr
;
3211 if (ecoff_sym_ptr
->local
)
3213 ecoff_swap_ext_in (abfd
, ecoff_sym_ptr
->native
.enative
, &esym
);
3215 /* If we're producing an executable, move common symbols
3217 if (relocateable
== false)
3219 if (esym
.asym
.sc
== scCommon
)
3220 esym
.asym
.sc
= scBss
;
3221 else if (esym
.asym
.sc
== scSCommon
)
3222 esym
.asym
.sc
= scSBss
;
3225 /* Adjust the FDR index for the symbol by that used for
3227 esym
.ifd
+= ecoff_data (bfd_asymbol_bfd (sym_ptr
))->ifdbase
;
3230 esym
.asym
.iss
= symhdr
->issExtMax
;
3232 if (bfd_is_com_section (sym_ptr
->section
)
3233 || sym_ptr
->section
== &bfd_und_section
)
3234 esym
.asym
.value
= sym_ptr
->value
;
3236 esym
.asym
.value
= (sym_ptr
->value
3237 + sym_ptr
->section
->output_offset
3238 + sym_ptr
->section
->output_section
->vma
);
3240 ecoff_swap_ext_out (abfd
, &esym
, external_ext
+ symhdr
->iextMax
);
3242 ecoff_set_sym_index (sym_ptr
, symhdr
->iextMax
);
3246 strcpy (ssext
+ symhdr
->issExtMax
, sym_ptr
->name
);
3247 symhdr
->issExtMax
+= strlen (sym_ptr
->name
) + 1;
3251 /* Adjust the counts so that structures are longword aligned. */
3252 symhdr
->cbLine
= (symhdr
->cbLine
+ 3) &~ 3;
3253 symhdr
->issMax
= (symhdr
->issMax
+ 3) &~ 3;
3254 symhdr
->issExtMax
= (symhdr
->issExtMax
+ 3) &~ 3;
3259 /* Set the architecture. The only architecture we support here is
3260 mips. We set the architecture anyhow, since many callers ignore
3261 the return value. */
3264 ecoff_set_arch_mach (abfd
, arch
, machine
)
3266 enum bfd_architecture arch
;
3267 unsigned long machine
;
3269 bfd_default_set_arch_mach (abfd
, arch
, machine
);
3270 return arch
== bfd_arch_mips
;
3273 /* Get the size of the section headers. We do not output the .scommon
3274 section which we created in ecoff_mkobject. */
3277 ecoff_sizeof_headers (abfd
, reloc
)
3281 return FILHSZ
+ AOUTSZ
+ (abfd
->section_count
- 1) * SCNHSZ
;
3284 /* Calculate the file position for each section, and set
3288 ecoff_compute_section_file_positions (abfd
)
3296 if (bfd_get_start_address (abfd
))
3297 abfd
->flags
|= EXEC_P
;
3299 sofar
= ecoff_sizeof_headers (abfd
, false);
3302 for (current
= abfd
->sections
;
3303 current
!= (asection
*) NULL
;
3304 current
= current
->next
)
3306 /* Only deal with sections which have contents */
3307 if (! (current
->flags
& SEC_HAS_CONTENTS
)
3308 || strcmp (current
->name
, SCOMMON
) == 0)
3311 /* On Ultrix, the data sections in an executable file must be
3312 aligned to a page boundary within the file. This does not
3313 affect the section size, though. FIXME: Does this work for
3315 if ((abfd
->flags
& EXEC_P
) != 0
3316 && (abfd
->flags
& D_PAGED
) != 0
3317 && first_data
!= false
3318 && (current
->flags
& SEC_CODE
) == 0)
3320 sofar
= (sofar
+ ROUND_SIZE
- 1) &~ (ROUND_SIZE
- 1);
3324 /* Align the sections in the file to the same boundary on
3325 which they are aligned in virtual memory. */
3327 sofar
= BFD_ALIGN (sofar
, 1 << current
->alignment_power
);
3329 current
->filepos
= sofar
;
3331 sofar
+= current
->_raw_size
;
3333 /* make sure that this section is of the right size too */
3335 sofar
= BFD_ALIGN (sofar
, 1 << current
->alignment_power
);
3336 current
->_raw_size
+= sofar
- old_sofar
;
3339 ecoff_data (abfd
)->reloc_filepos
= sofar
;
3342 /* Set the contents of a section. */
3345 ecoff_set_section_contents (abfd
, section
, location
, offset
, count
)
3350 bfd_size_type count
;
3352 if (abfd
->output_has_begun
== false)
3353 ecoff_compute_section_file_positions (abfd
);
3355 bfd_seek (abfd
, (file_ptr
) (section
->filepos
+ offset
), SEEK_SET
);
3358 return (bfd_write (location
, 1, count
, abfd
) == count
) ? true : false;
3363 /* Write out an ECOFF file. */
3366 ecoff_write_object_contents (abfd
)
3372 file_ptr reloc_base
;
3374 unsigned long reloc_size
;
3375 unsigned long text_size
;
3376 unsigned long text_start
;
3377 unsigned long data_size
;
3378 unsigned long data_start
;
3379 unsigned long bss_size
;
3380 struct internal_filehdr internal_f
;
3381 struct internal_aouthdr internal_a
;
3384 bfd_error
= system_call_error
;
3386 if(abfd
->output_has_begun
== false)
3387 ecoff_compute_section_file_positions(abfd
);
3389 if (abfd
->sections
!= (asection
*) NULL
)
3390 scn_base
= abfd
->sections
->filepos
;
3393 reloc_base
= ecoff_data (abfd
)->reloc_filepos
;
3397 for (current
= abfd
->sections
;
3398 current
!= (asection
*)NULL
;
3399 current
= current
->next
)
3401 if (strcmp (current
->name
, SCOMMON
) == 0)
3403 current
->target_index
= count
;
3405 if (current
->reloc_count
!= 0)
3407 bfd_size_type relsize
;
3409 current
->rel_filepos
= reloc_base
;
3410 relsize
= current
->reloc_count
* RELSZ
;
3411 reloc_size
+= relsize
;
3412 reloc_base
+= relsize
;
3415 current
->rel_filepos
= 0;
3418 sym_base
= reloc_base
+ reloc_size
;
3420 /* At least on Ultrix, the symbol table of an executable file must
3421 be aligned to a page boundary. FIXME: Is this true on other
3423 if ((abfd
->flags
& EXEC_P
) != 0
3424 && (abfd
->flags
& D_PAGED
) != 0)
3425 sym_base
= (sym_base
+ ROUND_SIZE
- 1) &~ (ROUND_SIZE
- 1);
3427 ecoff_data (abfd
)->sym_filepos
= sym_base
;
3429 if ((abfd
->flags
& D_PAGED
) != 0)
3430 text_size
= ecoff_sizeof_headers (abfd
, false);
3438 /* Write section headers to the file. */
3440 internal_f
.f_nscns
= 0;
3441 if (bfd_seek (abfd
, (file_ptr
) (FILHSZ
+ AOUTSZ
), SEEK_SET
) != 0)
3443 for (current
= abfd
->sections
;
3444 current
!= (asection
*) NULL
;
3445 current
= current
->next
)
3447 struct internal_scnhdr section
;
3450 if (strcmp (current
->name
, SCOMMON
) == 0)
3452 BFD_ASSERT (bfd_get_section_size_before_reloc (current
) == 0
3453 && current
->reloc_count
== 0);
3457 ++internal_f
.f_nscns
;
3459 strncpy (section
.s_name
, current
->name
, sizeof section
.s_name
);
3461 /* FIXME: is this correct for shared libraries? I think it is
3462 but I have no platform to check. Ian Lance Taylor. */
3463 vma
= bfd_get_section_vma (abfd
, current
);
3464 if (strcmp (current
->name
, _LIB
) == 0)
3465 section
.s_vaddr
= 0;
3467 section
.s_vaddr
= vma
;
3469 section
.s_paddr
= vma
;
3470 section
.s_size
= bfd_get_section_size_before_reloc (current
);
3472 /* If this section has no size or is unloadable then the scnptr
3474 if (current
->_raw_size
== 0
3475 || (current
->flags
& (SEC_LOAD
| SEC_HAS_CONTENTS
)) == 0)
3476 section
.s_scnptr
= 0;
3478 section
.s_scnptr
= current
->filepos
;
3479 section
.s_relptr
= current
->rel_filepos
;
3481 /* FIXME: the lnnoptr of the .sbss or .sdata section of an
3482 object file produced by the assembler is supposed to point to
3483 information about how much room is required by objects of
3484 various different sizes. I think this only matters if we
3485 want the linker to compute the best size to use, or
3486 something. I don't know what happens if the information is
3488 section
.s_lnnoptr
= 0;
3490 section
.s_nreloc
= current
->reloc_count
;
3491 section
.s_nlnno
= 0;
3492 section
.s_flags
= ecoff_sec_to_styp_flags (current
->name
,
3498 ecoff_swap_scnhdr_out (abfd
, (PTR
) §ion
, (PTR
) &buff
);
3499 if (bfd_write ((PTR
) &buff
, 1, SCNHSZ
, abfd
) != SCNHSZ
)
3503 if ((section
.s_flags
& STYP_TEXT
) != 0)
3505 text_size
+= bfd_get_section_size_before_reloc (current
);
3506 if (text_start
== 0 || text_start
> vma
)
3509 else if ((section
.s_flags
& STYP_RDATA
) != 0
3510 || (section
.s_flags
& STYP_DATA
) != 0
3511 || (section
.s_flags
& STYP_LIT8
) != 0
3512 || (section
.s_flags
& STYP_LIT4
) != 0
3513 || (section
.s_flags
& STYP_SDATA
) != 0)
3515 data_size
+= bfd_get_section_size_before_reloc (current
);
3516 if (data_start
== 0 || data_start
> vma
)
3519 else if ((section
.s_flags
& STYP_BSS
) != 0
3520 || (section
.s_flags
& STYP_SBSS
) != 0)
3521 bss_size
+= bfd_get_section_size_before_reloc (current
);
3524 /* Set up the file header. */
3526 if (abfd
->xvec
->header_byteorder_big_p
!= false)
3527 internal_f
.f_magic
= MIPS_MAGIC_BIG
;
3529 internal_f
.f_magic
= MIPS_MAGIC_LITTLE
;
3532 We will NOT put a fucking timestamp in the header here. Every time you
3533 put it back, I will come in and take it out again. I'm sorry. This
3534 field does not belong here. We fill it with a 0 so it compares the
3535 same but is not a reasonable time. -- gnu@cygnus.com
3537 internal_f
.f_timdat
= 0;
3539 if (bfd_get_symcount (abfd
) != 0)
3541 /* The ECOFF f_nsyms field is not actually the number of
3542 symbols, it's the size of symbolic information header. */
3543 internal_f
.f_nsyms
= sizeof (struct hdr_ext
);
3544 internal_f
.f_symptr
= sym_base
;
3548 internal_f
.f_nsyms
= 0;
3549 internal_f
.f_symptr
= 0;
3552 internal_f
.f_opthdr
= AOUTSZ
;
3554 internal_f
.f_flags
= F_LNNO
;
3555 if (reloc_size
== 0)
3556 internal_f
.f_flags
|= F_RELFLG
;
3557 if (bfd_get_symcount (abfd
) == 0)
3558 internal_f
.f_flags
|= F_LSYMS
;
3559 if (abfd
->flags
& EXEC_P
)
3560 internal_f
.f_flags
|= F_EXEC
;
3562 if (! abfd
->xvec
->byteorder_big_p
)
3563 internal_f
.f_flags
|= F_AR32WR
;
3565 internal_f
.f_flags
|= F_AR32W
;
3567 /* Set up the ``optional'' header. */
3568 if ((abfd
->flags
& D_PAGED
) != 0)
3569 internal_a
.magic
= MIPS_AOUT_ZMAGIC
;
3571 internal_a
.magic
= MIPS_AOUT_OMAGIC
;
3573 /* FIXME: This is what Ultrix puts in, and it makes the Ultrix
3574 linker happy. But, is it right? */
3575 internal_a
.vstamp
= 0x20a;
3577 /* At least on Ultrix, these have to be rounded to page boundaries.
3578 FIXME: Is this true on other platforms? */
3579 if ((abfd
->flags
& D_PAGED
) != 0)
3581 internal_a
.tsize
= (text_size
+ ROUND_SIZE
- 1) &~ (ROUND_SIZE
- 1);
3582 internal_a
.text_start
= text_start
&~ (ROUND_SIZE
- 1);
3583 internal_a
.dsize
= (data_size
+ ROUND_SIZE
- 1) &~ (ROUND_SIZE
- 1);
3584 internal_a
.data_start
= data_start
&~ (ROUND_SIZE
- 1);
3588 internal_a
.tsize
= text_size
;
3589 internal_a
.text_start
= text_start
;
3590 internal_a
.dsize
= data_size
;
3591 internal_a
.data_start
= data_start
;
3594 /* On Ultrix, the initial portions of the .sbss and .bss segments
3595 are at the end of the data section. The bsize field in the
3596 optional header records how many bss bytes are required beyond
3597 those in the data section. The value is not rounded to a page
3599 if (bss_size
< internal_a
.dsize
- data_size
)
3602 bss_size
-= internal_a
.dsize
- data_size
;
3603 internal_a
.bsize
= bss_size
;
3604 internal_a
.bss_start
= internal_a
.data_start
+ internal_a
.dsize
;
3606 internal_a
.entry
= bfd_get_start_address (abfd
);
3608 internal_a
.gp_value
= ecoff_data (abfd
)->gp
;
3610 internal_a
.gprmask
= ecoff_data (abfd
)->gprmask
;
3611 for (i
= 0; i
< 4; i
++)
3612 internal_a
.cprmask
[i
] = ecoff_data (abfd
)->cprmask
[i
];
3614 /* Write out the file header and the optional header. */
3616 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
) != 0)
3621 ecoff_swap_filehdr_out (abfd
, (PTR
) &internal_f
, (PTR
) &buff
);
3622 if (bfd_write ((PTR
) &buff
, 1, FILHSZ
, abfd
) != FILHSZ
)
3629 ecoff_swap_aouthdr_out (abfd
, (PTR
) &internal_a
, (PTR
) &buff
);
3630 if (bfd_write ((PTR
) &buff
, 1, AOUTSZ
, abfd
) != AOUTSZ
)
3634 /* Write out the relocs. */
3635 for (current
= abfd
->sections
;
3636 current
!= (asection
*) NULL
;
3637 current
= current
->next
)
3640 arelent
**reloc_ptr_ptr
;
3641 arelent
**reloc_end
;
3644 if (current
->reloc_count
== 0)
3647 buff
= (RELOC
*) bfd_alloc (abfd
, current
->reloc_count
* RELSZ
);
3648 if (buff
== (RELOC
*) NULL
)
3650 bfd_error
= no_memory
;
3654 reloc_ptr_ptr
= current
->orelocation
;
3655 reloc_end
= reloc_ptr_ptr
+ current
->reloc_count
;
3657 for (; reloc_ptr_ptr
< reloc_end
; reloc_ptr_ptr
++, out_ptr
++)
3661 struct internal_reloc in
;
3663 memset (&in
, 0, sizeof in
);
3665 reloc
= *reloc_ptr_ptr
;
3666 sym
= *reloc
->sym_ptr_ptr
;
3668 /* This must be an ECOFF reloc. */
3669 BFD_ASSERT (reloc
->howto
!= (reloc_howto_type
*) NULL
3670 && reloc
->howto
>= ecoff_howto_table
3672 < (ecoff_howto_table
+ ECOFF_HOWTO_COUNT
)));
3674 in
.r_vaddr
= reloc
->address
+ bfd_get_section_vma (abfd
, current
);
3675 in
.r_type
= reloc
->howto
->type
;
3677 /* If this is a REFHI reloc, the next one must be a REFLO
3678 reloc for the same symbol. */
3679 BFD_ASSERT (in
.r_type
!= ECOFF_R_REFHI
3680 || (reloc_ptr_ptr
< reloc_end
3681 && (reloc_ptr_ptr
[1]->howto
3682 != (reloc_howto_type
*) NULL
)
3683 && (reloc_ptr_ptr
[1]->howto
->type
3685 && (sym
== *reloc_ptr_ptr
[1]->sym_ptr_ptr
)));
3687 if ((sym
->flags
& BSF_SECTION_SYM
) == 0)
3689 in
.r_symndx
= ecoff_get_sym_index (*reloc
->sym_ptr_ptr
);
3696 name
= bfd_get_section_name (abfd
, bfd_get_section (sym
));
3697 if (strcmp (name
, ".text") == 0)
3698 in
.r_symndx
= RELOC_SECTION_TEXT
;
3699 else if (strcmp (name
, ".rdata") == 0)
3700 in
.r_symndx
= RELOC_SECTION_RDATA
;
3701 else if (strcmp (name
, ".data") == 0)
3702 in
.r_symndx
= RELOC_SECTION_DATA
;
3703 else if (strcmp (name
, ".sdata") == 0)
3704 in
.r_symndx
= RELOC_SECTION_SDATA
;
3705 else if (strcmp (name
, ".sbss") == 0)
3706 in
.r_symndx
= RELOC_SECTION_SBSS
;
3707 else if (strcmp (name
, ".bss") == 0)
3708 in
.r_symndx
= RELOC_SECTION_BSS
;
3709 else if (strcmp (name
, ".init") == 0)
3710 in
.r_symndx
= RELOC_SECTION_INIT
;
3711 else if (strcmp (name
, ".lit8") == 0)
3712 in
.r_symndx
= RELOC_SECTION_LIT8
;
3713 else if (strcmp (name
, ".lit4") == 0)
3714 in
.r_symndx
= RELOC_SECTION_LIT4
;
3720 ecoff_swap_reloc_out (abfd
, (PTR
) &in
, (PTR
) out_ptr
);
3723 if (bfd_seek (abfd
, current
->rel_filepos
, SEEK_SET
) != 0)
3725 if (bfd_write ((PTR
) buff
, RELSZ
, current
->reloc_count
, abfd
)
3726 != RELSZ
* current
->reloc_count
)
3728 bfd_release (abfd
, (PTR
) buff
);
3731 /* Write out the symbolic debugging information. */
3732 if (bfd_get_symcount (abfd
) > 0)
3735 unsigned long sym_offset
;
3736 struct hdr_ext buff
;
3738 /* Set up the offsets in the symbolic header. */
3739 symhdr
= &ecoff_data (abfd
)->symbolic_header
;
3740 sym_offset
= ecoff_data (abfd
)->sym_filepos
+ sizeof (struct hdr_ext
);
3742 #define SET(offset, size, ptr) \
3743 if (symhdr->size == 0) \
3744 symhdr->offset = 0; \
3746 symhdr->offset = (((char *) ecoff_data (abfd)->ptr \
3747 - (char *) ecoff_data (abfd)->raw_syments) \
3750 SET (cbLineOffset
, cbLine
, line
);
3751 SET (cbDnOffset
, idnMax
, external_dnr
);
3752 SET (cbPdOffset
, ipdMax
, external_pdr
);
3753 SET (cbSymOffset
, isymMax
, external_sym
);
3754 SET (cbOptOffset
, ioptMax
, external_opt
);
3755 SET (cbAuxOffset
, iauxMax
, external_aux
);
3756 SET (cbSsOffset
, issMax
, ss
);
3757 SET (cbSsExtOffset
, issExtMax
, ssext
);
3758 SET (cbFdOffset
, ifdMax
, external_fdr
);
3759 SET (cbRfdOffset
, crfd
, external_rfd
);
3760 SET (cbExtOffset
, iextMax
, external_ext
);
3763 if (bfd_seek (abfd
, (file_ptr
) ecoff_data (abfd
)->sym_filepos
,
3766 ecoff_swap_hdr_out (abfd
, &ecoff_data (abfd
)->symbolic_header
, &buff
);
3767 if (bfd_write ((PTR
) &buff
, 1, sizeof buff
, abfd
) != sizeof buff
)
3769 if (bfd_write ((PTR
) ecoff_data (abfd
)->raw_syments
, 1,
3770 ecoff_data (abfd
)->raw_size
, abfd
)
3771 != ecoff_data (abfd
)->raw_size
)
3774 else if ((abfd
->flags
& EXEC_P
) != 0
3775 && (abfd
->flags
& D_PAGED
) != 0)
3779 /* A demand paged executable must occupy an even number of
3781 if (bfd_seek (abfd
, (file_ptr
) ecoff_data (abfd
)->sym_filepos
- 1,
3784 if (bfd_read (&c
, 1, 1, abfd
) == 0)
3786 if (bfd_seek (abfd
, (file_ptr
) ecoff_data (abfd
)->sym_filepos
- 1,
3789 if (bfd_write (&c
, 1, 1, abfd
) != 1)
3796 /* Archive handling. ECOFF uses what appears to be a unique type of
3797 archive header (which I call an armap). The byte ordering of the
3798 armap and the contents are encoded in the name of the armap itself.
3799 At least for now, we only support archives with the same byte
3800 ordering in the armap and the contents.
3802 The first four bytes in the armap are the number of symbol
3803 definitions. This is always a power of two.
3805 This is followed by the symbol definitions. Each symbol definition
3806 occupies 8 bytes. The first four bytes are the offset from the
3807 start of the armap strings to the null-terminated string naming
3808 this symbol. The second four bytes are the file offset to the
3809 archive member which defines this symbol. If the second four bytes
3810 are 0, then this is not actually a symbol definition, and it should
3813 The symbols are hashed into the armap with a closed hashing scheme.
3814 See the functions below for the details of the algorithm.
3816 We could use the hash table when looking up symbols in a library.
3817 This would require a new BFD target entry point to replace the
3818 bfd_get_next_mapent function used by the linker.
3820 After the symbol definitions comes four bytes holding the size of
3821 the string table, followed by the string table itself. */
3823 /* The name of an archive headers looks like this:
3824 __________E[BL]E[BL]_ (with a trailing space).
3825 The trailing space is changed to an X if the archive is changed to
3826 indicate that the armap is out of date. */
3828 #define ARMAP_BIG_ENDIAN 'B'
3829 #define ARMAP_LITTLE_ENDIAN 'L'
3830 #define ARMAP_MARKER 'E'
3831 #define ARMAP_START "__________"
3832 #define ARMAP_HEADER_MARKER_INDEX 10
3833 #define ARMAP_HEADER_ENDIAN_INDEX 11
3834 #define ARMAP_OBJECT_MARKER_INDEX 12
3835 #define ARMAP_OBJECT_ENDIAN_INDEX 13
3836 #define ARMAP_END_INDEX 14
3837 #define ARMAP_END "_ "
3839 /* This is a magic number used in the hashing algorithm. */
3840 #define ARMAP_HASH_MAGIC 0x9dd68ab5
3842 /* This returns the hash value to use for a string. It also sets
3843 *REHASH to the rehash adjustment if the first slot is taken. SIZE
3844 is the number of entries in the hash table, and HLOG is the log
3848 ecoff_armap_hash (s
, rehash
, size
, hlog
)
3850 unsigned int *rehash
;
3858 hash
= ((hash
>> 27) | (hash
<< 5)) + *s
++;
3859 hash
*= ARMAP_HASH_MAGIC
;
3860 *rehash
= (hash
& (size
- 1)) | 1;
3861 return hash
>> (32 - hlog
);
3864 /* Read in the armap. */
3867 ecoff_slurp_armap (abfd
)
3872 struct areltdata
*mapdata
;
3873 bfd_size_type parsed_size
;
3875 struct artdata
*ardata
;
3878 struct symdef
*symdef_ptr
;
3881 /* Get the name of the first element. */
3882 i
= bfd_read ((PTR
) nextname
, 1, 16, abfd
);
3888 bfd_seek (abfd
, (file_ptr
) -16, SEEK_CUR
);
3890 /* See if the first element is an armap. */
3891 if (strncmp (nextname
, ARMAP_START
, sizeof ARMAP_START
- 1) != 0
3892 || nextname
[ARMAP_HEADER_MARKER_INDEX
] != ARMAP_MARKER
3893 || (nextname
[ARMAP_HEADER_ENDIAN_INDEX
] != ARMAP_BIG_ENDIAN
3894 && nextname
[ARMAP_HEADER_ENDIAN_INDEX
] != ARMAP_LITTLE_ENDIAN
)
3895 || nextname
[ARMAP_OBJECT_MARKER_INDEX
] != ARMAP_MARKER
3896 || (nextname
[ARMAP_OBJECT_ENDIAN_INDEX
] != ARMAP_BIG_ENDIAN
3897 && nextname
[ARMAP_OBJECT_ENDIAN_INDEX
] != ARMAP_LITTLE_ENDIAN
)
3898 || strncmp (nextname
+ ARMAP_END_INDEX
,
3899 ARMAP_END
, sizeof ARMAP_END
- 1) != 0)
3901 bfd_has_map (abfd
) = false;
3905 /* Make sure we have the right byte ordering. */
3906 if (((nextname
[ARMAP_HEADER_ENDIAN_INDEX
] == ARMAP_BIG_ENDIAN
)
3907 ^ (abfd
->xvec
->header_byteorder_big_p
!= false))
3908 || ((nextname
[ARMAP_OBJECT_ENDIAN_INDEX
] == ARMAP_BIG_ENDIAN
)
3909 ^ (abfd
->xvec
->byteorder_big_p
!= false)))
3911 bfd_error
= wrong_format
;
3915 /* Read in the armap. */
3916 ardata
= bfd_ardata (abfd
);
3917 mapdata
= snarf_ar_hdr (abfd
);
3918 if (mapdata
== (struct areltdata
*) NULL
)
3920 parsed_size
= mapdata
->parsed_size
;
3921 bfd_release (abfd
, (PTR
) mapdata
);
3923 raw_armap
= (char *) bfd_alloc (abfd
, parsed_size
);
3924 if (raw_armap
== (char *) NULL
)
3926 bfd_error
= no_memory
;
3930 if (bfd_read ((PTR
) raw_armap
, 1, parsed_size
, abfd
) != parsed_size
)
3932 bfd_error
= malformed_archive
;
3933 bfd_release (abfd
, (PTR
) raw_armap
);
3937 count
= bfd_h_get_32 (abfd
, (PTR
) raw_armap
);
3939 ardata
->symdef_count
= 0;
3940 ardata
->cache
= (struct ar_cache
*) NULL
;
3942 /* Hack: overlay the symdefs on top of the raw archive data. This
3943 is the way do_slurp_bsd_armap works. */
3944 raw_ptr
= raw_armap
+ LONG_SIZE
;
3945 symdef_ptr
= (struct symdef
*) raw_ptr
;
3946 ardata
->symdefs
= (carsym
*) symdef_ptr
;
3947 stringbase
= raw_ptr
+ count
* (2 * LONG_SIZE
) + LONG_SIZE
;
3949 #ifdef CHECK_ARMAP_HASH
3953 /* Double check that I have the hashing algorithm right by making
3954 sure that every symbol can be looked up successfully. */
3956 for (i
= 1; i
< count
; i
<<= 1)
3958 BFD_ASSERT (i
== count
);
3960 for (i
= 0; i
< count
; i
++, raw_ptr
+= 2 * LONG_SIZE
)
3962 unsigned int name_offset
, file_offset
;
3963 unsigned int hash
, rehash
, srch
;
3965 name_offset
= bfd_h_get_32 (abfd
, (PTR
) raw_ptr
);
3966 file_offset
= bfd_h_get_32 (abfd
, (PTR
) (raw_ptr
+ LONG_SIZE
));
3967 if (file_offset
== 0)
3969 hash
= ecoff_armap_hash (stringbase
+ name_offset
, &rehash
, count
,
3974 /* See if we can rehash to this location. */
3975 for (srch
= (hash
+ rehash
) & (count
- 1);
3976 srch
!= hash
&& srch
!= i
;
3977 srch
= (srch
+ rehash
) & (count
- 1))
3978 BFD_ASSERT (bfd_h_get_32 (abfd
,
3981 + (srch
* 2 * LONG_SIZE
)
3984 BFD_ASSERT (srch
== i
);
3988 raw_ptr
= raw_armap
+ LONG_SIZE
;
3989 #endif /* CHECK_ARMAP_HASH */
3991 for (i
= 0; i
< count
; i
++, raw_ptr
+= 2 * LONG_SIZE
)
3993 unsigned int name_offset
, file_offset
;
3995 name_offset
= bfd_h_get_32 (abfd
, (PTR
) raw_ptr
);
3996 file_offset
= bfd_h_get_32 (abfd
, (PTR
) (raw_ptr
+ LONG_SIZE
));
3997 if (file_offset
== 0)
3999 symdef_ptr
->s
.name
= stringbase
+ name_offset
;
4000 symdef_ptr
->file_offset
= file_offset
;
4002 ++ardata
->symdef_count
;
4005 ardata
->first_file_filepos
= bfd_tell (abfd
);
4006 /* Pad to an even boundary. */
4007 ardata
->first_file_filepos
+= ardata
->first_file_filepos
% 2;
4009 bfd_has_map (abfd
) = true;
4014 /* Write out an armap. */
4017 ecoff_write_armap (abfd
, elength
, map
, orl_count
, stridx
)
4019 unsigned int elength
;
4021 unsigned int orl_count
;
4024 unsigned int hashsize
, hashlog
;
4025 unsigned int symdefsize
;
4027 unsigned int stringsize
;
4028 unsigned int mapsize
;
4031 struct stat statbuf
;
4033 bfd_byte temp
[LONG_SIZE
];
4034 bfd_byte
*hashtable
;
4038 /* Ultrix appears to use as a hash table size the least power of two
4039 greater than twice the number of entries. */
4040 for (hashlog
= 0; (1 << hashlog
) <= 2 * orl_count
; hashlog
++)
4042 hashsize
= 1 << hashlog
;
4044 symdefsize
= hashsize
* 2 * LONG_SIZE
;
4046 stringsize
= stridx
+ padit
;
4048 /* Include 8 bytes to store symdefsize and stringsize in output. */
4049 mapsize
= LONG_SIZE
+ symdefsize
+ stringsize
+ LONG_SIZE
;
4051 firstreal
= SARMAG
+ sizeof (struct ar_hdr
) + mapsize
+ elength
;
4053 memset ((PTR
) &hdr
, 0, sizeof hdr
);
4055 /* Work out the ECOFF armap name. */
4056 strcpy (hdr
.ar_name
, ARMAP_START
);
4057 hdr
.ar_name
[ARMAP_HEADER_MARKER_INDEX
] = ARMAP_MARKER
;
4058 hdr
.ar_name
[ARMAP_HEADER_ENDIAN_INDEX
] =
4059 (abfd
->xvec
->header_byteorder_big_p
4061 : ARMAP_LITTLE_ENDIAN
);
4062 hdr
.ar_name
[ARMAP_OBJECT_MARKER_INDEX
] = ARMAP_MARKER
;
4063 hdr
.ar_name
[ARMAP_OBJECT_ENDIAN_INDEX
] =
4064 abfd
->xvec
->byteorder_big_p
? ARMAP_BIG_ENDIAN
: ARMAP_LITTLE_ENDIAN
;
4065 memcpy (hdr
.ar_name
+ ARMAP_END_INDEX
, ARMAP_END
, sizeof ARMAP_END
- 1);
4067 /* Write the timestamp of the archive header to be just a little bit
4068 later than the timestamp of the file, otherwise the linker will
4069 complain that the index is out of date. Actually, the Ultrix
4070 linker just checks the archive name; the GNU linker may check the
4072 stat (abfd
->filename
, &statbuf
);
4073 sprintf (hdr
.ar_date
, "%ld", (long) (statbuf
.st_mtime
+ 60));
4075 /* The DECstation uses zeroes for the uid, gid and mode of the
4077 hdr
.ar_uid
[0] = '0';
4078 hdr
.ar_gid
[0] = '0';
4079 hdr
.ar_mode
[0] = '0';
4081 sprintf (hdr
.ar_size
, "%-10d", (int) mapsize
);
4083 hdr
.ar_fmag
[0] = '`';
4084 hdr
.ar_fmag
[1] = '\n';
4086 /* Turn all null bytes in the header into spaces. */
4087 for (i
= 0; i
< sizeof (struct ar_hdr
); i
++)
4088 if (((char *)(&hdr
))[i
] == '\0')
4089 (((char *)(&hdr
))[i
]) = ' ';
4091 if (bfd_write ((PTR
) &hdr
, 1, sizeof (struct ar_hdr
), abfd
)
4092 != sizeof (struct ar_hdr
))
4095 bfd_h_put_32 (abfd
, hashsize
, temp
);
4096 if (bfd_write (temp
, 1, LONG_SIZE
, abfd
) != LONG_SIZE
)
4099 hashtable
= (bfd_byte
*) bfd_zalloc (abfd
, symdefsize
);
4101 current
= abfd
->archive_head
;
4103 for (i
= 0; i
< orl_count
; i
++)
4105 unsigned int hash
, rehash
;
4107 /* Advance firstreal to the file position of this archive
4109 if (((bfd
*) map
[i
].pos
) != last_elt
)
4113 firstreal
+= arelt_size (current
) + sizeof (struct ar_hdr
);
4114 firstreal
+= firstreal
% 2;
4115 current
= current
->next
;
4117 while (current
!= (bfd
*) map
[i
].pos
);
4122 hash
= ecoff_armap_hash (*map
[i
].name
, &rehash
, hashsize
, hashlog
);
4123 if (bfd_h_get_32 (abfd
, (PTR
) (hashtable
4124 + (hash
* 2 * LONG_SIZE
)
4130 /* The desired slot is already taken. */
4131 for (srch
= (hash
+ rehash
) & (hashsize
- 1);
4133 srch
= (srch
+ rehash
) & (hashsize
- 1))
4134 if (bfd_h_get_32 (abfd
, (PTR
) (hashtable
4135 + (srch
* 2 * LONG_SIZE
)
4140 BFD_ASSERT (srch
!= hash
);
4145 bfd_h_put_32 (abfd
, map
[i
].namidx
,
4146 (PTR
) (hashtable
+ hash
* 2 * LONG_SIZE
));
4147 bfd_h_put_32 (abfd
, firstreal
,
4148 (PTR
) (hashtable
+ hash
* 2 * LONG_SIZE
+ LONG_SIZE
));
4151 if (bfd_write (hashtable
, 1, symdefsize
, abfd
) != symdefsize
)
4154 bfd_release (abfd
, hashtable
);
4156 /* Now write the strings. */
4157 bfd_h_put_32 (abfd
, stringsize
, temp
);
4158 if (bfd_write (temp
, 1, LONG_SIZE
, abfd
) != LONG_SIZE
)
4160 for (i
= 0; i
< orl_count
; i
++)
4164 len
= strlen (*map
[i
].name
) + 1;
4165 if (bfd_write ((PTR
) (*map
[i
].name
), 1, len
, abfd
) != len
)
4169 /* The spec sez this should be a newline. But in order to be
4170 bug-compatible for DECstation ar we use a null. */
4173 if (bfd_write ("\0", 1, 1, abfd
) != 1)
4180 /* We just use the generic extended name support. This is a GNU
4182 #define ecoff_slurp_extended_name_table _bfd_slurp_extended_name_table
4184 /* See whether this BFD is an archive. If it is, read in the armap
4185 and the extended name table. */
4188 ecoff_archive_p (abfd
)
4191 char armag
[SARMAG
+ 1];
4193 if (bfd_read ((PTR
) armag
, 1, SARMAG
, abfd
) != SARMAG
4194 || strncmp (armag
, ARMAG
, SARMAG
) != 0)
4196 bfd_error
= wrong_format
;
4197 return (bfd_target
*) NULL
;
4200 /* We are setting bfd_ardata(abfd) here, but since bfd_ardata
4201 involves a cast, we can't do it as the left operand of
4203 abfd
->tdata
.aout_ar_data
=
4204 (struct artdata
*) bfd_zalloc (abfd
, sizeof (struct artdata
));
4206 if (bfd_ardata (abfd
) == (struct artdata
*) NULL
)
4208 bfd_error
= no_memory
;
4209 return (bfd_target
*) NULL
;
4212 bfd_ardata (abfd
)->first_file_filepos
= SARMAG
;
4214 if (ecoff_slurp_armap (abfd
) == false
4215 || ecoff_slurp_extended_name_table (abfd
) == false)
4217 bfd_release (abfd
, bfd_ardata (abfd
));
4218 abfd
->tdata
.aout_ar_data
= (struct artdata
*) NULL
;
4219 return (bfd_target
*) NULL
;
4227 #include <core.out.h>
4229 struct sgi_core_struct
4232 char cmd
[CORE_NAMESIZE
];
4235 #define core_hdr(bfd) ((bfd)->tdata.sgi_core_data)
4236 #define core_signal(bfd) (core_hdr(bfd)->sig)
4237 #define core_command(bfd) (core_hdr(bfd)->cmd)
4240 make_bfd_asection (abfd
, name
, flags
, _raw_size
, vma
, filepos
)
4244 bfd_size_type _raw_size
;
4250 asect
= bfd_make_section (abfd
, name
);
4254 asect
->flags
= flags
;
4255 asect
->_raw_size
= _raw_size
;
4257 asect
->filepos
= filepos
;
4258 asect
->alignment_power
= 4;
4264 ecoff_core_file_p (abfd
)
4270 struct coreout coreout
;
4271 struct idesc
*idg
, *idf
, *ids
;
4273 val
= bfd_read ((PTR
)&coreout
, 1, sizeof coreout
, abfd
);
4274 if (val
!= sizeof coreout
)
4277 if (coreout
.c_magic
!= CORE_MAGIC
4278 || coreout
.c_version
!= CORE_VERSION1
)
4281 core_hdr (abfd
) = (struct sgi_core_struct
*) bfd_zalloc (abfd
, sizeof (struct sgi_core_struct
));
4282 if (!core_hdr (abfd
))
4285 strncpy (core_command (abfd
), coreout
.c_name
, CORE_NAMESIZE
);
4286 core_signal (abfd
) = coreout
.c_sigcause
;
4288 bfd_seek (abfd
, coreout
.c_vmapoffset
, SEEK_SET
);
4290 for (i
= 0; i
< coreout
.c_nvmap
; i
++)
4294 val
= bfd_read ((PTR
)&vmap
, 1, sizeof vmap
, abfd
);
4295 if (val
!= sizeof vmap
)
4298 switch (vmap
.v_type
)
4310 if (!make_bfd_asection (abfd
, secname
,
4311 SEC_ALLOC
+SEC_LOAD
+SEC_HAS_CONTENTS
,
4319 /* Make sure that the regs are contiguous within the core file. */
4321 idg
= &coreout
.c_idesc
[I_GPREGS
];
4322 idf
= &coreout
.c_idesc
[I_FPREGS
];
4323 ids
= &coreout
.c_idesc
[I_SPECREGS
];
4325 if (idg
->i_offset
+ idg
->i_len
!= idf
->i_offset
4326 || idf
->i_offset
+ idf
->i_len
!= ids
->i_offset
)
4327 return 0; /* Can't deal with non-contig regs */
4329 bfd_seek (abfd
, idg
->i_offset
, SEEK_SET
);
4331 make_bfd_asection (abfd
, ".reg",
4332 SEC_ALLOC
+SEC_HAS_CONTENTS
,
4333 idg
->i_len
+ idf
->i_len
+ ids
->i_len
,
4337 /* OK, we believe you. You're a core file (sure, sure). */
4343 ecoff_core_file_failing_command (abfd
)
4346 return core_command (abfd
);
4350 ecoff_core_file_failing_signal (abfd
)
4353 return core_signal (abfd
);
4357 ecoff_core_file_matches_executable_p (core_bfd
, exec_bfd
)
4358 bfd
*core_bfd
, *exec_bfd
;
4360 return true; /* XXX - FIXME */
4362 #else /* not def HOST_IRIX4 */
4363 #define ecoff_core_file_p _bfd_dummy_target
4364 #define ecoff_core_file_failing_command _bfd_dummy_core_file_failing_command
4365 #define ecoff_core_file_failing_signal _bfd_dummy_core_file_failing_signal
4366 #define ecoff_core_file_matches_executable_p \
4367 _bfd_dummy_core_file_matches_executable_p
4370 /* This is the COFF backend structure. The backend_data field of the
4371 bfd_target structure is set to this. The section reading code in
4372 coffgen.c uses this structure. */
4374 static CONST bfd_coff_backend_data bfd_ecoff_std_swap_table
= {
4375 (void (*) PARAMS ((bfd
*,PTR
,int,int,PTR
))) bfd_void
, /* aux_in */
4376 (void (*) PARAMS ((bfd
*,PTR
,PTR
))) bfd_void
, /* sym_in */
4377 (void (*) PARAMS ((bfd
*,PTR
,PTR
))) bfd_void
, /* lineno_in */
4378 (unsigned (*) PARAMS ((bfd
*,PTR
,int,int,PTR
))) bfd_void
, /* aux_out */
4379 (unsigned (*) PARAMS ((bfd
*,PTR
,PTR
))) bfd_void
, /* sym_out */
4380 (unsigned (*) PARAMS ((bfd
*,PTR
,PTR
))) bfd_void
, /* lineno_out */
4381 ecoff_swap_reloc_out
, ecoff_swap_filehdr_out
, ecoff_swap_aouthdr_out
,
4382 ecoff_swap_scnhdr_out
,
4383 FILHSZ
, AOUTSZ
, SCNHSZ
, 0, 0, 0, true,
4384 ecoff_swap_filehdr_in
, ecoff_swap_aouthdr_in
, ecoff_swap_scnhdr_in
,
4385 ecoff_bad_format_hook
, ecoff_set_arch_mach_hook
, ecoff_mkobject_hook
,
4386 ecoff_styp_to_sec_flags
, ecoff_make_section_hook
, ecoff_set_alignment_hook
,
4387 ecoff_slurp_symbol_table
4390 /* get_lineno could be written for ECOFF, but it would currently only
4391 be useful for linking ECOFF and COFF files together, which doesn't
4393 #define ecoff_get_lineno \
4394 ((alent *(*) PARAMS ((bfd *, asymbol *))) bfd_nullvoidptr)
4396 /* These bfd_target functions are defined in other files. */
4398 #define ecoff_truncate_arname bfd_dont_truncate_arname
4399 #define ecoff_openr_next_archived_file bfd_generic_openr_next_archived_file
4400 #define ecoff_generic_stat_arch_elt bfd_generic_stat_arch_elt
4401 #define ecoff_get_section_contents bfd_generic_get_section_contents
4402 #define ecoff_get_reloc_upper_bound coff_get_reloc_upper_bound
4403 #define ecoff_close_and_cleanup bfd_generic_close_and_cleanup
4404 #define ecoff_bfd_debug_info_start bfd_void
4405 #define ecoff_bfd_debug_info_end bfd_void
4406 #define ecoff_bfd_debug_info_accumulate \
4407 ((void (*) PARAMS ((bfd *, struct sec *))) bfd_void)
4408 #define ecoff_bfd_get_relocated_section_contents \
4409 bfd_generic_get_relocated_section_contents
4410 #define ecoff_bfd_relax_section bfd_generic_relax_section
4411 #define ecoff_bfd_make_debug_symbol \
4412 ((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr)
4414 bfd_target ecoff_little_vec
=
4416 "ecoff-littlemips", /* name */
4417 bfd_target_ecoff_flavour
,
4418 false, /* data byte order is little */
4419 false, /* header byte order is little */
4421 (HAS_RELOC
| EXEC_P
| /* object flags */
4422 HAS_LINENO
| HAS_DEBUG
|
4423 HAS_SYMS
| HAS_LOCALS
| DYNAMIC
| WP_TEXT
| D_PAGED
),
4425 (SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
), /* sect
4427 0, /* leading underscore */
4428 ' ', /* ar_pad_char */
4429 15, /* ar_max_namelen */
4430 4, /* minimum alignment power */
4431 _do_getl64
, _do_getl_signed_64
, _do_putl64
,
4432 _do_getl32
, _do_getl_signed_32
, _do_putl32
,
4433 _do_getl16
, _do_getl_signed_16
, _do_putl16
, /* data */
4434 _do_getl64
, _do_getl_signed_64
, _do_putl64
,
4435 _do_getl32
, _do_getl_signed_32
, _do_putl32
,
4436 _do_getl16
, _do_getl_signed_16
, _do_putl16
, /* hdrs */
4438 {_bfd_dummy_target
, coff_object_p
, /* bfd_check_format */
4439 ecoff_archive_p
, _bfd_dummy_target
},
4440 {bfd_false
, ecoff_mkobject
, _bfd_generic_mkarchive
, /* bfd_set_format */
4442 {bfd_false
, ecoff_write_object_contents
, /* bfd_write_contents */
4443 _bfd_write_archive_contents
, bfd_false
},
4445 (PTR
) &bfd_ecoff_std_swap_table
4448 bfd_target ecoff_big_vec
=
4450 "ecoff-bigmips", /* name */
4451 bfd_target_ecoff_flavour
,
4452 true, /* data byte order is big */
4453 true, /* header byte order is big */
4455 (HAS_RELOC
| EXEC_P
| /* object flags */
4456 HAS_LINENO
| HAS_DEBUG
|
4457 HAS_SYMS
| HAS_LOCALS
| DYNAMIC
| WP_TEXT
| D_PAGED
),
4459 (SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
), /* sect flags */
4460 0, /* leading underscore */
4461 ' ', /* ar_pad_char */
4462 15, /* ar_max_namelen */
4463 4, /* minimum alignment power */
4464 _do_getb64
, _do_getb_signed_64
, _do_putb64
,
4465 _do_getb32
, _do_getb_signed_32
, _do_putb32
,
4466 _do_getb16
, _do_getb_signed_16
, _do_putb16
,
4467 _do_getb64
, _do_getb_signed_64
, _do_putb64
,
4468 _do_getb32
, _do_getb_signed_32
, _do_putb32
,
4469 _do_getb16
, _do_getb_signed_16
, _do_putb16
,
4470 {_bfd_dummy_target
, coff_object_p
, /* bfd_check_format */
4471 ecoff_archive_p
, ecoff_core_file_p
},
4472 {bfd_false
, ecoff_mkobject
, _bfd_generic_mkarchive
, /* bfd_set_format */
4474 {bfd_false
, ecoff_write_object_contents
, /* bfd_write_contents */
4475 _bfd_write_archive_contents
, bfd_false
},
4477 (PTR
) &bfd_ecoff_std_swap_table
4478 /* Note that there is another bfd_target just above this one. If
4479 you are adding initializers here, you should be adding them there