1 /* BFD back-end for IBM RS/6000 "XCOFF" files.
2 Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999
3 Free Software Foundation, Inc.
4 FIXME: Can someone provide a transliteration of this name into ASCII?
5 Using the following chars caused a compiler warning on HIUX (so I replaced
6 them with octal escapes), and isn't useful without an understanding of what
8 Written by Metin G. Ozisik, Mimi Ph\373\364ng-Th\345o V\365,
10 Archive support from Damon A. Permezel.
11 Contributed by IBM Corporation and Cygnus Support.
13 This file is part of BFD, the Binary File Descriptor library.
15 This program is free software; you can redistribute it and/or modify
16 it under the terms of the GNU General Public License as published by
17 the Free Software Foundation; either version 2 of the License, or
18 (at your option) any later version.
20 This program is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
25 You should have received a copy of the GNU General Public License
26 along with this program; if not, write to the Free Software
27 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
29 /* Internalcoff.h and coffcode.h modify themselves based on this flag. */
30 #define RS6000COFF_C 1
35 #include "coff/internal.h"
36 #include "coff/rs6000.h"
39 /* The main body of code is in coffcode.h. */
41 boolean _bfd_xcoff_mkobject PARAMS ((bfd *));
42 boolean _bfd_xcoff_copy_private_bfd_data PARAMS ((bfd *, bfd *));
43 boolean _bfd_xcoff_is_local_label_name PARAMS ((bfd *, const char *));
44 void _bfd_xcoff_rtype2howto
45 PARAMS ((arelent *, struct internal_reloc *));
46 reloc_howto_type *_bfd_xcoff_reloc_type_lookup
47 PARAMS ((bfd *, bfd_reloc_code_real_type));
48 boolean _bfd_xcoff_slurp_armap PARAMS ((bfd *));
49 const bfd_target *_bfd_xcoff_archive_p PARAMS ((bfd *));
50 PTR _bfd_xcoff_read_ar_hdr PARAMS ((bfd *));
51 bfd *_bfd_xcoff_openr_next_archived_file PARAMS ((bfd *, bfd *));
52 int _bfd_xcoff_generic_stat_arch_elt PARAMS ((bfd *, struct stat *));
53 static const char *normalize_filename PARAMS ((bfd *));
54 boolean _bfd_xcoff_write_armap
55 PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int));
56 boolean _bfd_xcoff_write_archive_contents PARAMS ((bfd *));
57 int _bfd_xcoff_sizeof_headers PARAMS ((bfd *, boolean));
59 /* We use our own tdata type. Its first field is the COFF tdata type,
60 so the COFF routines are compatible. */
63 _bfd_xcoff_mkobject (abfd)
68 abfd->tdata.xcoff_obj_data =
69 ((struct xcoff_tdata *)
70 bfd_zalloc (abfd, sizeof (struct xcoff_tdata)));
71 if (abfd->tdata.xcoff_obj_data == NULL)
73 coff = coff_data (abfd);
74 coff->symbols = (coff_symbol_type *) NULL;
75 coff->conversion_table = (unsigned int *) NULL;
76 coff->raw_syments = (struct coff_ptr_struct *) NULL;
79 xcoff_data (abfd)->modtype = ('1' << 8) | 'L';
81 /* We set cputype to -1 to indicate that it has not been
83 xcoff_data (abfd)->cputype = -1;
85 xcoff_data (abfd)->csects = NULL;
86 xcoff_data (abfd)->debug_indices = NULL;
91 /* Copy XCOFF data from one BFD to another. */
94 _bfd_xcoff_copy_private_bfd_data (ibfd, obfd)
98 struct xcoff_tdata *ix, *ox;
101 if (ibfd->xvec != obfd->xvec)
103 ix = xcoff_data (ibfd);
104 ox = xcoff_data (obfd);
105 ox->full_aouthdr = ix->full_aouthdr;
111 sec = coff_section_from_bfd_index (ibfd, ix->sntoc);
115 ox->sntoc = sec->output_section->target_index;
117 if (ix->snentry == 0)
121 sec = coff_section_from_bfd_index (ibfd, ix->snentry);
125 ox->snentry = sec->output_section->target_index;
127 ox->text_align_power = ix->text_align_power;
128 ox->data_align_power = ix->data_align_power;
129 ox->modtype = ix->modtype;
130 ox->cputype = ix->cputype;
131 ox->maxdata = ix->maxdata;
132 ox->maxstack = ix->maxstack;
136 /* I don't think XCOFF really has a notion of local labels based on
137 name. This will mean that ld -X doesn't actually strip anything.
138 The AIX native linker does not have a -X option, and it ignores the
142 _bfd_xcoff_is_local_label_name (abfd, name)
143 bfd *abfd ATTRIBUTE_UNUSED;
144 const char *name ATTRIBUTE_UNUSED;
150 #define NO_COFF_SYMBOLS
152 static void xcoff_swap_sym_in PARAMS ((bfd *, PTR, PTR));
153 static unsigned int xcoff_swap_sym_out PARAMS ((bfd *, PTR, PTR));
154 static void xcoff_swap_aux_in PARAMS ((bfd *, PTR, int, int, int, int, PTR));
155 static unsigned int xcoff_swap_aux_out PARAMS ((bfd *, PTR, int, int, int, int, PTR));
158 xcoff_swap_sym_in (abfd, ext1, in1)
163 SYMENT *ext = (SYMENT *)ext1;
164 struct internal_syment *in = (struct internal_syment *)in1;
167 if(ext->e.e_name[0] != 0)
169 memcpy(in->_n._n_name, ext->e.e_name, SYMNMLEN);
173 in->_n._n_n._n_zeroes = 0;
174 in->_n._n_n._n_offset =
175 bfd_h_get_32(abfd, (bfd_byte *) ext->e.e.e_offset);
178 in->n_value = bfd_h_get_32(abfd, (bfd_byte *) ext->e_value);
179 in->n_scnum = bfd_h_get_16(abfd, (bfd_byte *) ext->e_scnum);
180 in->n_type = bfd_h_get_16(abfd, (bfd_byte *) ext->e_type);
181 in->n_sclass = bfd_h_get_8(abfd, ext->e_sclass);
182 in->n_numaux = bfd_h_get_8(abfd, ext->e_numaux);
186 xcoff_swap_sym_out (abfd, inp, extp)
191 struct internal_syment *in = (struct internal_syment *)inp;
192 SYMENT *ext =(SYMENT *)extp;
194 if(in->_n._n_name[0] != 0)
196 memcpy(ext->e.e_name, in->_n._n_name, SYMNMLEN);
200 bfd_h_put_32(abfd, 0, (bfd_byte *) ext->e.e.e_zeroes);
201 bfd_h_put_32(abfd, in->_n._n_n._n_offset,
202 (bfd_byte *) ext->e.e.e_offset);
205 bfd_h_put_32(abfd, in->n_value , (bfd_byte *) ext->e_value);
206 bfd_h_put_16(abfd, in->n_scnum , (bfd_byte *) ext->e_scnum);
207 bfd_h_put_16(abfd, in->n_type , (bfd_byte *) ext->e_type);
208 bfd_h_put_8(abfd, in->n_sclass , ext->e_sclass);
209 bfd_h_put_8(abfd, in->n_numaux , ext->e_numaux);
210 return bfd_coff_symesz (abfd);
213 #define PUTWORD bfd_h_put_32
214 #define PUTHALF bfd_h_put_16
215 #define PUTBYTE bfd_h_put_8
216 #define GETWORD bfd_h_get_32
217 #define GETHALF bfd_h_get_16
218 #define GETBYTE bfd_h_get_8
221 xcoff_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1)
230 AUXENT *ext = (AUXENT *)ext1;
231 union internal_auxent *in = (union internal_auxent *)in1;
235 if (ext->x_file.x_fname[0] == 0) {
236 in->x_file.x_n.x_zeroes = 0;
237 in->x_file.x_n.x_offset =
238 bfd_h_get_32(abfd, (bfd_byte *) ext->x_file.x_n.x_offset);
243 memcpy (in->x_file.x_fname, ext->x_file.x_fname,
244 numaux * sizeof (AUXENT));
248 memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN);
253 /* RS/6000 "csect" auxents */
256 if (indx + 1 == numaux)
258 in->x_csect.x_scnlen.l =
259 bfd_h_get_32 (abfd, ext->x_csect.x_scnlen);
260 in->x_csect.x_parmhash = bfd_h_get_32 (abfd,
261 ext->x_csect.x_parmhash);
262 in->x_csect.x_snhash = bfd_h_get_16 (abfd, ext->x_csect.x_snhash);
263 /* We don't have to hack bitfields in x_smtyp because it's
264 defined by shifts-and-ands, which are equivalent on all
266 in->x_csect.x_smtyp = bfd_h_get_8 (abfd, ext->x_csect.x_smtyp);
267 in->x_csect.x_smclas = bfd_h_get_8 (abfd, ext->x_csect.x_smclas);
268 in->x_csect.x_stab = bfd_h_get_32 (abfd, ext->x_csect.x_stab);
269 in->x_csect.x_snstab = bfd_h_get_16 (abfd, ext->x_csect.x_snstab);
277 if (type == T_NULL) {
278 in->x_scn.x_scnlen = bfd_h_get_32(abfd,
279 (bfd_byte *) ext->x_scn.x_scnlen);
280 in->x_scn.x_nreloc = bfd_h_get_16(abfd,
281 (bfd_byte *) ext->x_scn.x_nreloc);
282 in->x_scn.x_nlinno = bfd_h_get_16(abfd,
283 (bfd_byte *) ext->x_scn.x_nlinno);
284 /* PE defines some extra fields; we zero them out for
286 in->x_scn.x_checksum = 0;
287 in->x_scn.x_associated = 0;
288 in->x_scn.x_comdat = 0;
295 in->x_sym.x_tagndx.l = bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_tagndx);
296 in->x_sym.x_tvndx = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_tvndx);
298 if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
300 in->x_sym.x_fcnary.x_fcn.x_lnnoptr = bfd_h_get_32(abfd, (bfd_byte *)
301 ext->x_sym.x_fcnary.x_fcn.x_lnnoptr);
302 in->x_sym.x_fcnary.x_fcn.x_endndx.l = bfd_h_get_32(abfd, (bfd_byte *)
303 ext->x_sym.x_fcnary.x_fcn.x_endndx);
307 in->x_sym.x_fcnary.x_ary.x_dimen[0] =
308 bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
309 in->x_sym.x_fcnary.x_ary.x_dimen[1] =
310 bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
311 in->x_sym.x_fcnary.x_ary.x_dimen[2] =
312 bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
313 in->x_sym.x_fcnary.x_ary.x_dimen[3] =
314 bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
317 in->x_sym.x_misc.x_fsize = bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_misc.x_fsize);
320 in->x_sym.x_misc.x_lnsz.x_lnno = bfd_h_get_16(abfd, (bfd_byte *)
321 ext->x_sym.x_misc.x_lnsz.x_lnno);
322 in->x_sym.x_misc.x_lnsz.x_size = bfd_h_get_16(abfd, (bfd_byte *)
323 ext->x_sym.x_misc.x_lnsz.x_size);
327 /* the semicolon is because MSVC doesn't like labels at
335 xcoff_swap_aux_out (abfd, inp, type, class, indx, numaux, extp)
340 int indx ATTRIBUTE_UNUSED;
341 int numaux ATTRIBUTE_UNUSED;
344 union internal_auxent *in = (union internal_auxent *)inp;
345 AUXENT *ext = (AUXENT *)extp;
347 memset((PTR)ext, 0, bfd_coff_auxesz (abfd));
351 if (in->x_file.x_fname[0] == 0)
353 PUTWORD(abfd, 0, (bfd_byte *) ext->x_file.x_n.x_zeroes);
355 in->x_file.x_n.x_offset,
356 (bfd_byte *) ext->x_file.x_n.x_offset);
360 memcpy (ext->x_file.x_fname, in->x_file.x_fname, FILNMLEN);
364 /* RS/6000 "csect" auxents */
367 if (indx + 1 == numaux)
369 PUTWORD (abfd, in->x_csect.x_scnlen.l,ext->x_csect.x_scnlen);
370 PUTWORD (abfd, in->x_csect.x_parmhash, ext->x_csect.x_parmhash);
371 PUTHALF (abfd, in->x_csect.x_snhash, ext->x_csect.x_snhash);
372 /* We don't have to hack bitfields in x_smtyp because it's
373 defined by shifts-and-ands, which are equivalent on all
375 PUTBYTE (abfd, in->x_csect.x_smtyp, ext->x_csect.x_smtyp);
376 PUTBYTE (abfd, in->x_csect.x_smclas, ext->x_csect.x_smclas);
377 PUTWORD (abfd, in->x_csect.x_stab, ext->x_csect.x_stab);
378 PUTHALF (abfd, in->x_csect.x_snstab, ext->x_csect.x_snstab);
386 if (type == T_NULL) {
387 bfd_h_put_32(abfd, in->x_scn.x_scnlen, (bfd_byte *) ext->x_scn.x_scnlen);
388 bfd_h_put_16(abfd, in->x_scn.x_nreloc, (bfd_byte *) ext->x_scn.x_nreloc);
389 bfd_h_put_16(abfd, in->x_scn.x_nlinno, (bfd_byte *) ext->x_scn.x_nlinno);
395 PUTWORD(abfd, in->x_sym.x_tagndx.l, (bfd_byte *) ext->x_sym.x_tagndx);
396 PUTWORD(abfd, in->x_sym.x_tvndx , (bfd_byte *) ext->x_sym.x_tvndx);
398 if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
400 bfd_h_put_32(abfd, in->x_sym.x_fcnary.x_fcn.x_lnnoptr,
401 (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_lnnoptr);
402 PUTWORD(abfd, in->x_sym.x_fcnary.x_fcn.x_endndx.l,
403 (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_endndx);
407 bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[0],
408 (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
409 bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[1],
410 (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
411 bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[2],
412 (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
413 bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[3],
414 (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
418 PUTWORD (abfd, in->x_sym.x_misc.x_fsize,
419 (bfd_byte *) ext->x_sym.x_misc.x_fsize);
422 bfd_h_put_16(abfd, in->x_sym.x_misc.x_lnsz.x_lnno,
423 (bfd_byte *)ext->x_sym.x_misc.x_lnsz.x_lnno);
424 bfd_h_put_16(abfd, in->x_sym.x_misc.x_lnsz.x_size,
425 (bfd_byte *)ext->x_sym.x_misc.x_lnsz.x_size);
429 return bfd_coff_auxesz (abfd);
434 /* The XCOFF reloc table. Actually, XCOFF relocations specify the
435 bitsize and whether they are signed or not, along with a
436 conventional type. This table is for the types, which are used for
437 different algorithms for putting in the reloc. Many of these
438 relocs need special_function entries, which I have not written. */
440 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
441 from smaller values. Start with zero, widen, *then* decrement. */
442 #define MINUS_ONE (((bfd_vma)0) - 1)
444 reloc_howto_type xcoff_howto_table[] =
446 /* Standard 32 bit relocation. */
449 2, /* size (0 = byte, 1 = short, 2 = long) */
451 false, /* pc_relative */
453 complain_overflow_bitfield, /* complain_on_overflow */
454 0, /* special_function */
456 true, /* partial_inplace */
457 0xffffffff, /* src_mask */
458 0xffffffff, /* dst_mask */
459 false), /* pcrel_offset */
461 /* 32 bit relocation, but store negative value. */
464 -2, /* size (0 = byte, 1 = short, 2 = long) */
466 false, /* pc_relative */
468 complain_overflow_bitfield, /* complain_on_overflow */
469 0, /* special_function */
471 true, /* partial_inplace */
472 0xffffffff, /* src_mask */
473 0xffffffff, /* dst_mask */
474 false), /* pcrel_offset */
476 /* 32 bit PC relative relocation. */
479 2, /* size (0 = byte, 1 = short, 2 = long) */
481 true, /* pc_relative */
483 complain_overflow_signed, /* complain_on_overflow */
484 0, /* special_function */
486 true, /* partial_inplace */
487 0xffffffff, /* src_mask */
488 0xffffffff, /* dst_mask */
489 false), /* pcrel_offset */
491 /* 16 bit TOC relative relocation. */
494 1, /* size (0 = byte, 1 = short, 2 = long) */
496 false, /* pc_relative */
498 complain_overflow_bitfield, /* complain_on_overflow */
499 0, /* special_function */
501 true, /* partial_inplace */
502 0xffff, /* src_mask */
503 0xffff, /* dst_mask */
504 false), /* pcrel_offset */
506 /* I don't really know what this is. */
509 2, /* size (0 = byte, 1 = short, 2 = long) */
511 false, /* pc_relative */
513 complain_overflow_bitfield, /* complain_on_overflow */
514 0, /* special_function */
516 true, /* partial_inplace */
517 0xffffffff, /* src_mask */
518 0xffffffff, /* dst_mask */
519 false), /* pcrel_offset */
521 /* External TOC relative symbol. */
524 2, /* size (0 = byte, 1 = short, 2 = long) */
526 false, /* pc_relative */
528 complain_overflow_bitfield, /* complain_on_overflow */
529 0, /* special_function */
531 true, /* partial_inplace */
532 0xffff, /* src_mask */
533 0xffff, /* dst_mask */
534 false), /* pcrel_offset */
536 /* Local TOC relative symbol. */
539 2, /* size (0 = byte, 1 = short, 2 = long) */
541 false, /* pc_relative */
543 complain_overflow_bitfield, /* complain_on_overflow */
544 0, /* special_function */
546 true, /* partial_inplace */
547 0xffff, /* src_mask */
548 0xffff, /* dst_mask */
549 false), /* pcrel_offset */
553 /* Non modifiable absolute branch. */
556 2, /* size (0 = byte, 1 = short, 2 = long) */
558 false, /* pc_relative */
560 complain_overflow_bitfield, /* complain_on_overflow */
561 0, /* special_function */
563 true, /* partial_inplace */
564 0x3fffffc, /* src_mask */
565 0x3fffffc, /* dst_mask */
566 false), /* pcrel_offset */
570 /* Non modifiable relative branch. */
571 HOWTO (0xa, /* type */
573 2, /* size (0 = byte, 1 = short, 2 = long) */
575 true, /* pc_relative */
577 complain_overflow_signed, /* complain_on_overflow */
578 0, /* special_function */
580 true, /* partial_inplace */
581 0x3fffffc, /* src_mask */
582 0x3fffffc, /* dst_mask */
583 false), /* pcrel_offset */
588 HOWTO (0xc, /* type */
590 2, /* size (0 = byte, 1 = short, 2 = long) */
592 false, /* pc_relative */
594 complain_overflow_bitfield, /* complain_on_overflow */
595 0, /* special_function */
597 true, /* partial_inplace */
598 0xffff, /* src_mask */
599 0xffff, /* dst_mask */
600 false), /* pcrel_offset */
603 HOWTO (0xd, /* type */
605 2, /* size (0 = byte, 1 = short, 2 = long) */
607 false, /* pc_relative */
609 complain_overflow_bitfield, /* complain_on_overflow */
610 0, /* special_function */
612 true, /* partial_inplace */
613 0xffff, /* src_mask */
614 0xffff, /* dst_mask */
615 false), /* pcrel_offset */
619 /* Non-relocating reference. */
620 HOWTO (0xf, /* type */
622 2, /* size (0 = byte, 1 = short, 2 = long) */
624 false, /* pc_relative */
626 complain_overflow_bitfield, /* complain_on_overflow */
627 0, /* special_function */
629 false, /* partial_inplace */
632 false), /* pcrel_offset */
637 /* TOC relative indirect load. */
638 HOWTO (0x12, /* type */
640 2, /* size (0 = byte, 1 = short, 2 = long) */
642 false, /* pc_relative */
644 complain_overflow_bitfield, /* complain_on_overflow */
645 0, /* special_function */
647 true, /* partial_inplace */
648 0xffff, /* src_mask */
649 0xffff, /* dst_mask */
650 false), /* pcrel_offset */
652 /* TOC relative load address. */
653 HOWTO (0x13, /* type */
655 2, /* size (0 = byte, 1 = short, 2 = long) */
657 false, /* pc_relative */
659 complain_overflow_bitfield, /* complain_on_overflow */
660 0, /* special_function */
662 true, /* partial_inplace */
663 0xffff, /* src_mask */
664 0xffff, /* dst_mask */
665 false), /* pcrel_offset */
667 /* Modifiable relative branch. */
668 HOWTO (0x14, /* type */
670 2, /* size (0 = byte, 1 = short, 2 = long) */
672 false, /* pc_relative */
674 complain_overflow_bitfield, /* complain_on_overflow */
675 0, /* special_function */
676 "R_RRTBI", /* name */
677 true, /* partial_inplace */
678 0xffffffff, /* src_mask */
679 0xffffffff, /* dst_mask */
680 false), /* pcrel_offset */
682 /* Modifiable absolute branch. */
683 HOWTO (0x15, /* type */
685 2, /* size (0 = byte, 1 = short, 2 = long) */
687 false, /* pc_relative */
689 complain_overflow_bitfield, /* complain_on_overflow */
690 0, /* special_function */
691 "R_RRTBA", /* name */
692 true, /* partial_inplace */
693 0xffffffff, /* src_mask */
694 0xffffffff, /* dst_mask */
695 false), /* pcrel_offset */
697 /* Modifiable call absolute indirect. */
698 HOWTO (0x16, /* type */
700 2, /* size (0 = byte, 1 = short, 2 = long) */
702 false, /* pc_relative */
704 complain_overflow_bitfield, /* complain_on_overflow */
705 0, /* special_function */
707 true, /* partial_inplace */
708 0xffff, /* src_mask */
709 0xffff, /* dst_mask */
710 false), /* pcrel_offset */
712 /* Modifiable call relative. */
713 HOWTO (0x17, /* type */
715 2, /* size (0 = byte, 1 = short, 2 = long) */
717 false, /* pc_relative */
719 complain_overflow_bitfield, /* complain_on_overflow */
720 0, /* special_function */
722 true, /* partial_inplace */
723 0xffff, /* src_mask */
724 0xffff, /* dst_mask */
725 false), /* pcrel_offset */
727 /* Modifiable branch absolute. */
728 HOWTO (0x18, /* type */
730 2, /* size (0 = byte, 1 = short, 2 = long) */
732 false, /* pc_relative */
734 complain_overflow_bitfield, /* complain_on_overflow */
735 0, /* special_function */
737 true, /* partial_inplace */
738 0xffff, /* src_mask */
739 0xffff, /* dst_mask */
740 false), /* pcrel_offset */
742 /* Modifiable branch absolute. */
743 HOWTO (0x19, /* type */
745 2, /* size (0 = byte, 1 = short, 2 = long) */
747 false, /* pc_relative */
749 complain_overflow_bitfield, /* complain_on_overflow */
750 0, /* special_function */
752 true, /* partial_inplace */
753 0xffff, /* src_mask */
754 0xffff, /* dst_mask */
755 false), /* pcrel_offset */
757 /* Modifiable branch relative. */
758 HOWTO (0x1a, /* type */
760 2, /* size (0 = byte, 1 = short, 2 = long) */
762 false, /* pc_relative */
764 complain_overflow_signed, /* complain_on_overflow */
765 0, /* special_function */
767 true, /* partial_inplace */
768 0xffff, /* src_mask */
769 0xffff, /* dst_mask */
770 false), /* pcrel_offset */
772 /* Modifiable branch absolute. */
773 HOWTO (0x1b, /* type */
775 2, /* size (0 = byte, 1 = short, 2 = long) */
777 false, /* pc_relative */
779 complain_overflow_bitfield, /* complain_on_overflow */
780 0, /* special_function */
782 true, /* partial_inplace */
783 0xffff, /* src_mask */
784 0xffff, /* dst_mask */
785 false), /* pcrel_offset */
788 4, /* size (0 = byte, 1 = short, 2 = long) */
790 false, /* pc_relative */
792 complain_overflow_bitfield, /* complain_on_overflow */
793 0, /* special_function */
795 true, /* partial_inplace */
796 MINUS_ONE, /* src_mask */
797 MINUS_ONE, /* dst_mask */
798 false) /* pcrel_offset */
802 /* These are the first two like the above but for 16-bit relocs. */
803 static reloc_howto_type xcoff_howto_table_16[] =
805 /* Standard 16 bit relocation. */
808 2, /* size (0 = byte, 1 = short, 2 = long) */
810 false, /* pc_relative */
812 complain_overflow_bitfield, /* complain_on_overflow */
813 0, /* special_function */
814 "R_POS_16", /* name */
815 true, /* partial_inplace */
816 0xffffffff, /* src_mask */
817 0xffffffff, /* dst_mask */
818 false), /* pcrel_offset */
820 /* 16 bit relocation, but store negative value. */
823 -2, /* size (0 = byte, 1 = short, 2 = long) */
825 false, /* pc_relative */
827 complain_overflow_bitfield, /* complain_on_overflow */
828 0, /* special_function */
829 "R_NEG_16", /* name */
830 true, /* partial_inplace */
831 0xffffffff, /* src_mask */
832 0xffffffff, /* dst_mask */
833 false), /* pcrel_offset */
835 /* 16 bit PC relative relocation. */
838 2, /* size (0 = byte, 1 = short, 2 = long) */
840 true, /* pc_relative */
842 complain_overflow_signed, /* complain_on_overflow */
843 0, /* special_function */
844 "R_REL_16", /* name */
845 true, /* partial_inplace */
846 0xffffffff, /* src_mask */
847 0xffffffff, /* dst_mask */
848 false) /* pcrel_offset */
852 _bfd_xcoff_rtype2howto (relent, internal)
854 struct internal_reloc *internal;
856 relent->howto = xcoff_howto_table + internal->r_type;
858 if (relent->howto->bitsize != ((unsigned int) internal->r_size & 0x1f) + 1
860 < sizeof(xcoff_howto_table_16)/sizeof(xcoff_howto_table_16[0])))
861 relent->howto = xcoff_howto_table_16 + internal->r_type;
863 /* The r_size field of an XCOFF reloc encodes the bitsize of the
864 relocation, as well as indicating whether it is signed or not.
865 Doublecheck that the relocation information gathered from the
866 type matches this information. */
867 if (relent->howto->bitsize != ((unsigned int) internal->r_size & 0x1f) + 1)
870 if ((internal->r_size & 0x80) != 0
871 ? (relent->howto->complain_on_overflow != complain_overflow_signed)
872 : (relent->howto->complain_on_overflow != complain_overflow_bitfield))
878 _bfd_xcoff_reloc_type_lookup (abfd, code)
879 bfd *abfd ATTRIBUTE_UNUSED;
880 bfd_reloc_code_real_type code;
884 case BFD_RELOC_PPC_B26:
885 return &xcoff_howto_table[0xa];
886 case BFD_RELOC_PPC_BA26:
887 return &xcoff_howto_table[8];
888 case BFD_RELOC_PPC_TOC16:
889 return &xcoff_howto_table[3];
892 return &xcoff_howto_table[0];
894 return &xcoff_howto_table[0x1c];
900 #define SELECT_RELOC(internal, howto) \
902 internal.r_type = howto->type; \
904 ((howto->complain_on_overflow == complain_overflow_signed \
907 | (howto->bitsize - 1)); \
910 #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
912 #define COFF_LONG_FILENAMES
914 #define RTYPE2HOWTO(cache_ptr, dst) _bfd_xcoff_rtype2howto (cache_ptr, dst)
916 #define coff_SWAP_sym_in xcoff_swap_sym_in
917 #define coff_SWAP_sym_out xcoff_swap_sym_out
918 #define coff_SWAP_aux_in xcoff_swap_aux_in
919 #define coff_SWAP_aux_out xcoff_swap_aux_out
920 #define coff_mkobject _bfd_xcoff_mkobject
921 #define coff_bfd_copy_private_bfd_data _bfd_xcoff_copy_private_bfd_data
922 #define coff_bfd_is_local_label_name _bfd_xcoff_is_local_label_name
923 #define coff_bfd_reloc_type_lookup _bfd_xcoff_reloc_type_lookup
924 #define coff_relocate_section _bfd_ppc_xcoff_relocate_section
926 #include "coffcode.h"
928 /* XCOFF archive support. The original version of this code was by
929 Damon A. Permezel. It was enhanced to permit cross support, and
930 writing archive files, by Ian Lance Taylor, Cygnus Support.
932 XCOFF uses its own archive format. Everything is hooked together
933 with file offset links, so it is possible to rapidly update an
934 archive in place. Of course, we don't do that. An XCOFF archive
935 has a real file header, not just an ARMAG string. The structure of
936 the file header and of each archive header appear below.
938 An XCOFF archive also has a member table, which is a list of
939 elements in the archive (you can get that by looking through the
940 linked list, but you have to read a lot more of the file). The
941 member table has a normal archive header with an empty name. It is
942 normally (and perhaps must be) the second to last entry in the
943 archive. The member table data is almost printable ASCII. It
944 starts with a 12 character decimal string which is the number of
945 entries in the table. For each entry it has a 12 character decimal
946 string which is the offset in the archive of that member. These
947 entries are followed by a series of null terminated strings which
948 are the member names for each entry.
950 Finally, an XCOFF archive has a global symbol table, which is what
951 we call the armap. The global symbol table has a normal archive
952 header with an empty name. It is normally (and perhaps must be)
953 the last entry in the archive. The contents start with a four byte
954 binary number which is the number of entries. This is followed by
955 a that many four byte binary numbers; each is the file offset of an
956 entry in the archive. These numbers are followed by a series of
957 null terminated strings, which are symbol names.
959 AIX 4.3 introduced a new archive format which can handle larger
960 files and also 32- and 64-bit objects in the same archive. The
961 things said above remain true except that there is now more than
962 one global symbol table. The one is used to index 32-bit objects,
963 the other for 64-bit objects.
965 The new archives (recognizable by the new ARMAG string) has larger
966 field lengths so that we cannot really share any code. Also we have
967 to take care that we are not generating the new form of archives
968 on AIX 4.2 or earlier systems. */
970 /* XCOFF archives use this as a magic string. Note that both strings
971 have the same length. */
973 #define XCOFFARMAG "<aiaff>\012"
974 #define XCOFFARMAGBIG "<bigaf>\012"
975 #define SXCOFFARMAG 8
977 /* This terminates an XCOFF archive member name. */
979 #define XCOFFARFMAG "`\012"
980 #define SXCOFFARFMAG 2
982 /* XCOFF archives start with this (printable) structure. */
984 struct xcoff_ar_file_hdr
987 char magic[SXCOFFARMAG];
989 /* Offset of the member table (decimal ASCII string). */
992 /* Offset of the global symbol table (decimal ASCII string). */
995 /* Offset of the first member in the archive (decimal ASCII string). */
996 char firstmemoff[12];
998 /* Offset of the last member in the archive (decimal ASCII string). */
1001 /* Offset of the first member on the free list (decimal ASCII
1006 #define SIZEOF_AR_FILE_HDR (5 * 12 + SXCOFFARMAG)
1008 /* This is the equivalent data structure for the big archive format. */
1010 struct xcoff_ar_file_hdr_big
1013 char magic[SXCOFFARMAG];
1015 /* Offset of the member table (decimal ASCII string). */
1018 /* Offset of the global symbol table for 32-bit objects (decimal ASCII
1022 /* Offset of the global symbol table for 64-bit objects (decimal ASCII
1026 /* Offset of the first member in the archive (decimal ASCII string). */
1027 char firstmemoff[20];
1029 /* Offset of the last member in the archive (decimal ASCII string). */
1030 char lastmemoff[20];
1032 /* Offset of the first member on the free list (decimal ASCII
1037 #define SIZEOF_AR_FILE_HDR_BIG (6 * 20 + SXCOFFARMAG)
1040 /* Each XCOFF archive member starts with this (printable) structure. */
1044 /* File size not including the header (decimal ASCII string). */
1047 /* File offset of next archive member (decimal ASCII string). */
1050 /* File offset of previous archive member (decimal ASCII string). */
1053 /* File mtime (decimal ASCII string). */
1056 /* File UID (decimal ASCII string). */
1059 /* File GID (decimal ASCII string). */
1062 /* File mode (octal ASCII string). */
1065 /* Length of file name (decimal ASCII string). */
1068 /* This structure is followed by the file name. The length of the
1069 name is given in the namlen field. If the length of the name is
1070 odd, the name is followed by a null byte. The name and optional
1071 null byte are followed by XCOFFARFMAG, which is not included in
1072 namlen. The contents of the archive member follow; the number of
1073 bytes is given in the size field. */
1076 #define SIZEOF_AR_HDR (7 * 12 + 4)
1078 /* The equivalent for the big archive format. */
1080 struct xcoff_ar_hdr_big
1082 /* File size not including the header (decimal ASCII string). */
1085 /* File offset of next archive member (decimal ASCII string). */
1088 /* File offset of previous archive member (decimal ASCII string). */
1091 /* File mtime (decimal ASCII string). */
1094 /* File UID (decimal ASCII string). */
1097 /* File GID (decimal ASCII string). */
1100 /* File mode (octal ASCII string). */
1103 /* Length of file name (decimal ASCII string). */
1106 /* This structure is followed by the file name. The length of the
1107 name is given in the namlen field. If the length of the name is
1108 odd, the name is followed by a null byte. The name and optional
1109 null byte are followed by XCOFFARFMAG, which is not included in
1110 namlen. The contents of the archive member follow; the number of
1111 bytes is given in the size field. */
1114 #define SIZEOF_AR_HDR_BIG (3 * 20 + 4 * 12 + 4)
1117 /* We often have to distinguish between the old and big file format.
1118 Make it a bit cleaner. We can use `xcoff_ardata' here because the
1119 `hdr' member has the same size and position in both formats. */
1120 #define xcoff_big_format_p(abfd) \
1121 (xcoff_ardata (abfd)->magic[1] == 'b')
1123 /* We store a copy of the xcoff_ar_file_hdr in the tdata field of the
1124 artdata structure. Similar for the big archive. */
1125 #define xcoff_ardata(abfd) \
1126 ((struct xcoff_ar_file_hdr *) bfd_ardata (abfd)->tdata)
1127 #define xcoff_ardata_big(abfd) \
1128 ((struct xcoff_ar_file_hdr_big *) bfd_ardata (abfd)->tdata)
1130 /* We store a copy of the xcoff_ar_hdr in the arelt_data field of an
1131 archive element. Similar for the big archive. */
1132 #define arch_eltdata(bfd) ((struct areltdata *) ((bfd)->arelt_data))
1133 #define arch_xhdr(bfd) \
1134 ((struct xcoff_ar_hdr *) arch_eltdata (bfd)->arch_header)
1135 #define arch_xhdr_big(bfd) \
1136 ((struct xcoff_ar_hdr_big *) arch_eltdata (bfd)->arch_header)
1138 /* XCOFF archives do not have anything which corresponds to an
1139 extended name table. */
1141 #define _bfd_xcoff_slurp_extended_name_table bfd_false
1142 #define _bfd_xcoff_construct_extended_name_table \
1143 ((boolean (*) PARAMS ((bfd *, char **, bfd_size_type *, const char **))) \
1145 #define _bfd_xcoff_truncate_arname bfd_dont_truncate_arname
1147 /* We can use the standard get_elt_at_index routine. */
1149 #define _bfd_xcoff_get_elt_at_index _bfd_generic_get_elt_at_index
1151 /* XCOFF archives do not have a timestamp. */
1153 #define _bfd_xcoff_update_armap_timestamp bfd_true
1155 /* Read in the armap of an XCOFF archive. */
1158 _bfd_xcoff_slurp_armap (abfd)
1164 bfd_byte *contents, *cend;
1169 if (xcoff_ardata (abfd) == NULL)
1171 bfd_has_map (abfd) = false;
1175 if (! xcoff_big_format_p (abfd))
1177 /* This is for the old format. */
1178 struct xcoff_ar_hdr hdr;
1180 off = strtol (xcoff_ardata (abfd)->symoff, (char **) NULL, 10);
1183 bfd_has_map (abfd) = false;
1187 if (bfd_seek (abfd, off, SEEK_SET) != 0)
1190 /* The symbol table starts with a normal archive header. */
1191 if (bfd_read ((PTR) &hdr, SIZEOF_AR_HDR, 1, abfd) != SIZEOF_AR_HDR)
1194 /* Skip the name (normally empty). */
1195 namlen = strtol (hdr.namlen, (char **) NULL, 10);
1196 if (bfd_seek (abfd, ((namlen + 1) & ~1) + SXCOFFARFMAG, SEEK_CUR) != 0)
1199 sz = strtol (hdr.size, (char **) NULL, 10);
1203 /* This is for the new format. */
1204 struct xcoff_ar_hdr_big hdr;
1206 off = strtol (xcoff_ardata_big (abfd)->symoff, (char **) NULL, 10);
1209 bfd_has_map (abfd) = false;
1213 if (bfd_seek (abfd, off, SEEK_SET) != 0)
1216 /* The symbol table starts with a normal archive header. */
1217 if (bfd_read ((PTR) &hdr, SIZEOF_AR_HDR_BIG, 1, abfd)
1218 != SIZEOF_AR_HDR_BIG)
1221 /* Skip the name (normally empty). */
1222 namlen = strtol (hdr.namlen, (char **) NULL, 10);
1223 if (bfd_seek (abfd, ((namlen + 1) & ~1) + SXCOFFARFMAG, SEEK_CUR) != 0)
1226 /* XXX This actually has to be a call to strtoll (at least on 32-bit
1227 machines) since the field width is 20 and there numbers with more
1228 than 32 bits can be represented. */
1229 sz = strtol (hdr.size, (char **) NULL, 10);
1232 /* Read in the entire symbol table. */
1233 contents = (bfd_byte *) bfd_alloc (abfd, sz);
1234 if (contents == NULL)
1236 if (bfd_read ((PTR) contents, 1, sz, abfd) != sz)
1239 /* The symbol table starts with a four byte count. */
1240 c = bfd_h_get_32 (abfd, contents);
1244 bfd_set_error (bfd_error_bad_value);
1248 bfd_ardata (abfd)->symdefs = ((carsym *)
1249 bfd_alloc (abfd, c * sizeof (carsym)));
1250 if (bfd_ardata (abfd)->symdefs == NULL)
1253 /* After the count comes a list of four byte file offsets. */
1254 for (i = 0, arsym = bfd_ardata (abfd)->symdefs, p = contents + 4;
1256 ++i, ++arsym, p += 4)
1257 arsym->file_offset = bfd_h_get_32 (abfd, p);
1259 /* After the file offsets come null terminated symbol names. */
1260 cend = contents + sz;
1261 for (i = 0, arsym = bfd_ardata (abfd)->symdefs;
1263 ++i, ++arsym, p += strlen ((char *) p) + 1)
1267 bfd_set_error (bfd_error_bad_value);
1270 arsym->name = (char *) p;
1273 bfd_ardata (abfd)->symdef_count = c;
1274 bfd_has_map (abfd) = true;
1279 /* See if this is an XCOFF archive. */
1282 _bfd_xcoff_archive_p (abfd)
1285 char magic[SXCOFFARMAG];
1287 if (bfd_read ((PTR) magic, SXCOFFARMAG, 1, abfd) != SXCOFFARMAG)
1289 if (bfd_get_error () != bfd_error_system_call)
1290 bfd_set_error (bfd_error_wrong_format);
1294 if (strncmp (magic, XCOFFARMAG, SXCOFFARMAG) != 0
1295 && strncmp (magic, XCOFFARMAGBIG, SXCOFFARMAG) != 0)
1297 bfd_set_error (bfd_error_wrong_format);
1301 /* We are setting bfd_ardata(abfd) here, but since bfd_ardata
1302 involves a cast, we can't do it as the left operand of
1304 abfd->tdata.aout_ar_data =
1305 (struct artdata *) bfd_zalloc (abfd, sizeof (struct artdata));
1307 if (bfd_ardata (abfd) == (struct artdata *) NULL)
1310 bfd_ardata (abfd)->cache = NULL;
1311 bfd_ardata (abfd)->archive_head = NULL;
1312 bfd_ardata (abfd)->symdefs = NULL;
1313 bfd_ardata (abfd)->extended_names = NULL;
1315 /* Now handle the two formats. */
1316 if (magic[1] != 'b')
1318 /* This is the old format. */
1319 struct xcoff_ar_file_hdr hdr;
1321 /* Copy over the magic string. */
1322 memcpy (hdr.magic, magic, SXCOFFARMAG);
1324 /* Now read the rest of the file header. */
1325 if (bfd_read ((PTR) &hdr.memoff, SIZEOF_AR_FILE_HDR - SXCOFFARMAG, 1,
1326 abfd) != SIZEOF_AR_FILE_HDR - SXCOFFARMAG)
1328 if (bfd_get_error () != bfd_error_system_call)
1329 bfd_set_error (bfd_error_wrong_format);
1333 bfd_ardata (abfd)->first_file_filepos = strtol (hdr.firstmemoff,
1334 (char **) NULL, 10);
1336 bfd_ardata (abfd)->tdata = bfd_zalloc (abfd, SIZEOF_AR_FILE_HDR);
1337 if (bfd_ardata (abfd)->tdata == NULL)
1340 memcpy (bfd_ardata (abfd)->tdata, &hdr, SIZEOF_AR_FILE_HDR);
1344 /* This is the new format. */
1345 struct xcoff_ar_file_hdr_big hdr;
1347 /* Copy over the magic string. */
1348 memcpy (hdr.magic, magic, SXCOFFARMAG);
1350 /* Now read the rest of the file header. */
1351 if (bfd_read ((PTR) &hdr.memoff, SIZEOF_AR_FILE_HDR_BIG - SXCOFFARMAG, 1,
1352 abfd) != SIZEOF_AR_FILE_HDR_BIG - SXCOFFARMAG)
1354 if (bfd_get_error () != bfd_error_system_call)
1355 bfd_set_error (bfd_error_wrong_format);
1359 /* XXX This actually has to be a call to strtoll (at least on 32-bit
1360 machines) since the field width is 20 and there numbers with more
1361 than 32 bits can be represented. */
1362 bfd_ardata (abfd)->first_file_filepos = strtol (hdr.firstmemoff,
1363 (char **) NULL, 10);
1365 bfd_ardata (abfd)->tdata = bfd_zalloc (abfd, SIZEOF_AR_FILE_HDR_BIG);
1366 if (bfd_ardata (abfd)->tdata == NULL)
1369 memcpy (bfd_ardata (abfd)->tdata, &hdr, SIZEOF_AR_FILE_HDR_BIG);
1372 if (! _bfd_xcoff_slurp_armap (abfd))
1374 bfd_release (abfd, bfd_ardata (abfd));
1375 abfd->tdata.aout_ar_data = (struct artdata *) NULL;
1382 /* Read the archive header in an XCOFF archive. */
1385 _bfd_xcoff_read_ar_hdr (abfd)
1389 struct areltdata *ret;
1391 ret = (struct areltdata *) bfd_alloc (abfd, sizeof (struct areltdata));
1395 if (! xcoff_big_format_p (abfd))
1397 struct xcoff_ar_hdr hdr;
1398 struct xcoff_ar_hdr *hdrp;
1400 if (bfd_read ((PTR) &hdr, SIZEOF_AR_HDR, 1, abfd) != SIZEOF_AR_HDR)
1406 namlen = strtol (hdr.namlen, (char **) NULL, 10);
1407 hdrp = (struct xcoff_ar_hdr *) bfd_alloc (abfd,
1408 SIZEOF_AR_HDR + namlen + 1);
1414 memcpy (hdrp, &hdr, SIZEOF_AR_HDR);
1415 if (bfd_read ((char *) hdrp + SIZEOF_AR_HDR, 1, namlen, abfd) != namlen)
1420 ((char *) hdrp)[SIZEOF_AR_HDR + namlen] = '\0';
1422 ret->arch_header = (char *) hdrp;
1423 ret->parsed_size = strtol (hdr.size, (char **) NULL, 10);
1424 ret->filename = (char *) hdrp + SIZEOF_AR_HDR;
1428 struct xcoff_ar_hdr_big hdr;
1429 struct xcoff_ar_hdr_big *hdrp;
1431 if (bfd_read ((PTR) &hdr, SIZEOF_AR_HDR_BIG, 1, abfd)
1432 != SIZEOF_AR_HDR_BIG)
1438 namlen = strtol (hdr.namlen, (char **) NULL, 10);
1439 hdrp = (struct xcoff_ar_hdr_big *) bfd_alloc (abfd,
1447 memcpy (hdrp, &hdr, SIZEOF_AR_HDR_BIG);
1448 if (bfd_read ((char *) hdrp + SIZEOF_AR_HDR_BIG, 1, namlen, abfd) != namlen)
1453 ((char *) hdrp)[SIZEOF_AR_HDR_BIG + namlen] = '\0';
1455 ret->arch_header = (char *) hdrp;
1456 /* XXX This actually has to be a call to strtoll (at least on 32-bit
1457 machines) since the field width is 20 and there numbers with more
1458 than 32 bits can be represented. */
1459 ret->parsed_size = strtol (hdr.size, (char **) NULL, 10);
1460 ret->filename = (char *) hdrp + SIZEOF_AR_HDR_BIG;
1463 /* Skip over the XCOFFARFMAG at the end of the file name. */
1464 if (bfd_seek (abfd, (namlen & 1) + SXCOFFARFMAG, SEEK_CUR) != 0)
1470 /* Open the next element in an XCOFF archive. */
1473 _bfd_xcoff_openr_next_archived_file (archive, last_file)
1479 if (xcoff_ardata (archive) == NULL)
1481 bfd_set_error (bfd_error_invalid_operation);
1485 if (! xcoff_big_format_p (archive))
1487 if (last_file == NULL)
1488 filestart = bfd_ardata (archive)->first_file_filepos;
1490 filestart = strtol (arch_xhdr (last_file)->nextoff, (char **) NULL,
1494 || filestart == strtol (xcoff_ardata (archive)->memoff,
1496 || filestart == strtol (xcoff_ardata (archive)->symoff,
1497 (char **) NULL, 10))
1499 bfd_set_error (bfd_error_no_more_archived_files);
1505 if (last_file == NULL)
1506 filestart = bfd_ardata (archive)->first_file_filepos;
1508 /* XXX These actually have to be a calls to strtoll (at least
1509 on 32-bit machines) since the fields's width is 20 and
1510 there numbers with more than 32 bits can be represented. */
1511 filestart = strtol (arch_xhdr_big (last_file)->nextoff, (char **) NULL,
1514 /* XXX These actually have to be calls to strtoll (at least on 32-bit
1515 machines) since the fields's width is 20 and there numbers with more
1516 than 32 bits can be represented. */
1518 || filestart == strtol (xcoff_ardata_big (archive)->memoff,
1520 || filestart == strtol (xcoff_ardata_big (archive)->symoff,
1521 (char **) NULL, 10))
1523 bfd_set_error (bfd_error_no_more_archived_files);
1528 return _bfd_get_elt_at_filepos (archive, filestart);
1531 /* Stat an element in an XCOFF archive. */
1534 _bfd_xcoff_generic_stat_arch_elt (abfd, s)
1538 if (abfd->arelt_data == NULL)
1540 bfd_set_error (bfd_error_invalid_operation);
1544 if (! xcoff_big_format_p (abfd))
1546 struct xcoff_ar_hdr *hdrp = arch_xhdr (abfd);
1548 s->st_mtime = strtol (hdrp->date, (char **) NULL, 10);
1549 s->st_uid = strtol (hdrp->uid, (char **) NULL, 10);
1550 s->st_gid = strtol (hdrp->gid, (char **) NULL, 10);
1551 s->st_mode = strtol (hdrp->mode, (char **) NULL, 8);
1552 s->st_size = arch_eltdata (abfd)->parsed_size;
1556 struct xcoff_ar_hdr_big *hdrp = arch_xhdr_big (abfd);
1558 s->st_mtime = strtol (hdrp->date, (char **) NULL, 10);
1559 s->st_uid = strtol (hdrp->uid, (char **) NULL, 10);
1560 s->st_gid = strtol (hdrp->gid, (char **) NULL, 10);
1561 s->st_mode = strtol (hdrp->mode, (char **) NULL, 8);
1562 s->st_size = arch_eltdata (abfd)->parsed_size;
1568 /* Normalize a file name for inclusion in an archive. */
1571 normalize_filename (abfd)
1575 const char *filename;
1577 file = bfd_get_filename (abfd);
1578 filename = strrchr (file, '/');
1579 if (filename != NULL)
1586 /* Write out an XCOFF armap. */
1590 xcoff_write_armap_old (abfd, elength, map, orl_count, stridx)
1592 unsigned int elength ATTRIBUTE_UNUSED;
1594 unsigned int orl_count;
1597 struct xcoff_ar_hdr hdr;
1599 unsigned char buf[4];
1604 memset (&hdr, 0, sizeof hdr);
1605 sprintf (hdr.size, "%ld", (long) (4 + orl_count * 4 + stridx));
1606 sprintf (hdr.nextoff, "%d", 0);
1607 memcpy (hdr.prevoff, xcoff_ardata (abfd)->memoff, 12);
1608 sprintf (hdr.date, "%d", 0);
1609 sprintf (hdr.uid, "%d", 0);
1610 sprintf (hdr.gid, "%d", 0);
1611 sprintf (hdr.mode, "%d", 0);
1612 sprintf (hdr.namlen, "%d", 0);
1614 /* We need spaces, not null bytes, in the header. */
1615 for (p = (char *) &hdr; p < (char *) &hdr + SIZEOF_AR_HDR; p++)
1619 if (bfd_write ((PTR) &hdr, SIZEOF_AR_HDR, 1, abfd) != SIZEOF_AR_HDR
1620 || bfd_write (XCOFFARFMAG, 1, SXCOFFARFMAG, abfd) != SXCOFFARFMAG)
1623 bfd_h_put_32 (abfd, orl_count, buf);
1624 if (bfd_write (buf, 1, 4, abfd) != 4)
1627 sub = abfd->archive_head;
1628 fileoff = SIZEOF_AR_FILE_HDR;
1630 while (sub != NULL && i < orl_count)
1634 while (((bfd *) (map[i]).pos) == sub)
1636 bfd_h_put_32 (abfd, fileoff, buf);
1637 if (bfd_write (buf, 1, 4, abfd) != 4)
1641 namlen = strlen (normalize_filename (sub));
1642 namlen = (namlen + 1) &~ 1;
1643 fileoff += (SIZEOF_AR_HDR
1646 + arelt_size (sub));
1647 fileoff = (fileoff + 1) &~ 1;
1651 for (i = 0; i < orl_count; i++)
1656 name = *map[i].name;
1657 namlen = strlen (name);
1658 if (bfd_write (name, 1, namlen + 1, abfd) != namlen + 1)
1662 if ((stridx & 1) != 0)
1667 if (bfd_write (&b, 1, 1, abfd) != 1)
1676 xcoff_write_armap_big (abfd, elength, map, orl_count, stridx)
1678 unsigned int elength ATTRIBUTE_UNUSED;
1680 unsigned int orl_count;
1683 struct xcoff_ar_hdr_big hdr;
1685 unsigned char buf[4];
1690 memset (&hdr, 0, sizeof hdr);
1691 /* XXX This call actually should use %lld (at least on 32-bit
1692 machines) since the fields's width is 20 and there numbers with
1693 more than 32 bits can be represented. */
1694 sprintf (hdr.size, "%ld", (long) (4 + orl_count * 4 + stridx));
1695 sprintf (hdr.nextoff, "%d", 0);
1696 memcpy (hdr.prevoff, xcoff_ardata (abfd)->memoff, 12);
1697 sprintf (hdr.date, "%d", 0);
1698 sprintf (hdr.uid, "%d", 0);
1699 sprintf (hdr.gid, "%d", 0);
1700 sprintf (hdr.mode, "%d", 0);
1701 sprintf (hdr.namlen, "%d", 0);
1703 /* We need spaces, not null bytes, in the header. */
1704 for (p = (char *) &hdr; p < (char *) &hdr + SIZEOF_AR_HDR_BIG; p++)
1708 if (bfd_write ((PTR) &hdr, SIZEOF_AR_HDR_BIG, 1, abfd) != SIZEOF_AR_HDR_BIG
1709 || bfd_write (XCOFFARFMAG, 1, SXCOFFARFMAG, abfd) != SXCOFFARFMAG)
1712 bfd_h_put_32 (abfd, orl_count, buf);
1713 if (bfd_write (buf, 1, 4, abfd) != 4)
1716 sub = abfd->archive_head;
1717 fileoff = SIZEOF_AR_FILE_HDR_BIG;
1719 while (sub != NULL && i < orl_count)
1723 while (((bfd *) (map[i]).pos) == sub)
1725 bfd_h_put_32 (abfd, fileoff, buf);
1726 if (bfd_write (buf, 1, 4, abfd) != 4)
1730 namlen = strlen (normalize_filename (sub));
1731 namlen = (namlen + 1) &~ 1;
1732 fileoff += (SIZEOF_AR_HDR_BIG
1735 + arelt_size (sub));
1736 fileoff = (fileoff + 1) &~ 1;
1740 for (i = 0; i < orl_count; i++)
1745 name = *map[i].name;
1746 namlen = strlen (name);
1747 if (bfd_write (name, 1, namlen + 1, abfd) != namlen + 1)
1751 if ((stridx & 1) != 0)
1756 if (bfd_write (&b, 1, 1, abfd) != 1)
1765 _bfd_xcoff_write_armap (abfd, elength, map, orl_count, stridx)
1767 unsigned int elength ATTRIBUTE_UNUSED;
1769 unsigned int orl_count;
1772 if (! xcoff_big_format_p (abfd))
1773 return xcoff_write_armap_old (abfd, elength, map, orl_count, stridx);
1775 return xcoff_write_armap_big (abfd, elength, map, orl_count, stridx);
1778 /* Write out an XCOFF archive. We always write an entire archive,
1779 rather than fussing with the freelist and so forth. */
1782 xcoff_write_archive_contents_old (abfd)
1785 struct xcoff_ar_file_hdr fhdr;
1787 size_t total_namlen;
1791 file_ptr prevoff, nextoff;
1794 struct xcoff_ar_hdr ahdr;
1799 memset (&fhdr, 0, sizeof fhdr);
1800 strncpy (fhdr.magic, XCOFFARMAG, SXCOFFARMAG);
1801 sprintf (fhdr.firstmemoff, "%d", SIZEOF_AR_FILE_HDR);
1802 sprintf (fhdr.freeoff, "%d", 0);
1806 for (sub = abfd->archive_head; sub != NULL; sub = sub->next)
1809 total_namlen += strlen (normalize_filename (sub)) + 1;
1811 offsets = (file_ptr *) bfd_alloc (abfd, count * sizeof (file_ptr));
1812 if (offsets == NULL)
1815 if (bfd_seek (abfd, SIZEOF_AR_FILE_HDR, SEEK_SET) != 0)
1818 makemap = bfd_has_map (abfd);
1821 nextoff = SIZEOF_AR_FILE_HDR;
1822 for (sub = abfd->archive_head, i = 0; sub != NULL; sub = sub->next, i++)
1826 struct xcoff_ar_hdr *ahdrp;
1827 bfd_size_type remaining;
1829 if (makemap && ! hasobjects)
1831 if (bfd_check_format (sub, bfd_object))
1835 name = normalize_filename (sub);
1836 namlen = strlen (name);
1838 if (sub->arelt_data != NULL)
1839 ahdrp = arch_xhdr (sub);
1847 memset (&ahdr, 0, sizeof ahdr);
1849 if (stat (bfd_get_filename (sub), &s) != 0)
1851 bfd_set_error (bfd_error_system_call);
1855 sprintf (ahdrp->size, "%ld", (long) s.st_size);
1856 sprintf (ahdrp->date, "%ld", (long) s.st_mtime);
1857 sprintf (ahdrp->uid, "%ld", (long) s.st_uid);
1858 sprintf (ahdrp->gid, "%ld", (long) s.st_gid);
1859 sprintf (ahdrp->mode, "%o", (unsigned int) s.st_mode);
1861 if (sub->arelt_data == NULL)
1863 sub->arelt_data = bfd_alloc (sub, sizeof (struct areltdata));
1864 if (sub->arelt_data == NULL)
1868 arch_eltdata (sub)->parsed_size = s.st_size;
1871 sprintf (ahdrp->prevoff, "%ld", (long) prevoff);
1872 sprintf (ahdrp->namlen, "%ld", (long) namlen);
1874 /* If the length of the name is odd, we write out the null byte
1875 after the name as well. */
1876 namlen = (namlen + 1) &~ 1;
1878 remaining = arelt_size (sub);
1879 size = (SIZEOF_AR_HDR
1884 BFD_ASSERT (nextoff == bfd_tell (abfd));
1886 offsets[i] = nextoff;
1889 nextoff += size + (size & 1);
1891 sprintf (ahdrp->nextoff, "%ld", (long) nextoff);
1893 /* We need spaces, not null bytes, in the header. */
1894 for (p = (char *) ahdrp; p < (char *) ahdrp + SIZEOF_AR_HDR; p++)
1898 if (bfd_write ((PTR) ahdrp, 1, SIZEOF_AR_HDR, abfd) != SIZEOF_AR_HDR
1899 || bfd_write ((PTR) name, 1, namlen, abfd) != namlen
1900 || (bfd_write ((PTR) XCOFFARFMAG, 1, SXCOFFARFMAG, abfd)
1904 if (bfd_seek (sub, (file_ptr) 0, SEEK_SET) != 0)
1906 while (remaining != 0)
1909 bfd_byte buffer[DEFAULT_BUFFERSIZE];
1911 amt = sizeof buffer;
1912 if (amt > remaining)
1914 if (bfd_read (buffer, 1, amt, sub) != amt
1915 || bfd_write (buffer, 1, amt, abfd) != amt)
1920 if ((size & 1) != 0)
1925 if (bfd_write (&b, 1, 1, abfd) != 1)
1930 sprintf (fhdr.lastmemoff, "%ld", (long) prevoff);
1932 /* Write out the member table. */
1934 BFD_ASSERT (nextoff == bfd_tell (abfd));
1935 sprintf (fhdr.memoff, "%ld", (long) nextoff);
1937 memset (&ahdr, 0, sizeof ahdr);
1938 sprintf (ahdr.size, "%ld", (long) (12 + count * 12 + total_namlen));
1939 sprintf (ahdr.prevoff, "%ld", (long) prevoff);
1940 sprintf (ahdr.date, "%d", 0);
1941 sprintf (ahdr.uid, "%d", 0);
1942 sprintf (ahdr.gid, "%d", 0);
1943 sprintf (ahdr.mode, "%d", 0);
1944 sprintf (ahdr.namlen, "%d", 0);
1946 size = (SIZEOF_AR_HDR
1953 nextoff += size + (size & 1);
1955 if (makemap && hasobjects)
1956 sprintf (ahdr.nextoff, "%ld", (long) nextoff);
1958 sprintf (ahdr.nextoff, "%d", 0);
1960 /* We need spaces, not null bytes, in the header. */
1961 for (p = (char *) &ahdr; p < (char *) &ahdr + SIZEOF_AR_HDR; p++)
1965 if (bfd_write ((PTR) &ahdr, 1, SIZEOF_AR_HDR, abfd) != SIZEOF_AR_HDR
1966 || (bfd_write ((PTR) XCOFFARFMAG, 1, SXCOFFARFMAG, abfd)
1970 sprintf (decbuf, "%-12ld", (long) count);
1971 if (bfd_write ((PTR) decbuf, 1, 12, abfd) != 12)
1973 for (i = 0; i < count; i++)
1975 sprintf (decbuf, "%-12ld", (long) offsets[i]);
1976 if (bfd_write ((PTR) decbuf, 1, 12, abfd) != 12)
1979 for (sub = abfd->archive_head; sub != NULL; sub = sub->next)
1984 name = normalize_filename (sub);
1985 namlen = strlen (name);
1986 if (bfd_write ((PTR) name, 1, namlen + 1, abfd) != namlen + 1)
1989 if ((size & 1) != 0)
1994 if (bfd_write ((PTR) &b, 1, 1, abfd) != 1)
1998 /* Write out the armap, if appropriate. */
2000 if (! makemap || ! hasobjects)
2001 sprintf (fhdr.symoff, "%d", 0);
2004 BFD_ASSERT (nextoff == bfd_tell (abfd));
2005 sprintf (fhdr.symoff, "%ld", (long) nextoff);
2006 bfd_ardata (abfd)->tdata = (PTR) &fhdr;
2007 if (! _bfd_compute_and_write_armap (abfd, 0))
2011 /* Write out the archive file header. */
2013 /* We need spaces, not null bytes, in the header. */
2014 for (p = (char *) &fhdr; p < (char *) &fhdr + SIZEOF_AR_FILE_HDR; p++)
2018 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
2019 || (bfd_write ((PTR) &fhdr, SIZEOF_AR_FILE_HDR, 1, abfd) !=
2020 SIZEOF_AR_FILE_HDR))
2027 xcoff_write_archive_contents_big (abfd)
2030 struct xcoff_ar_file_hdr_big fhdr;
2032 size_t total_namlen;
2036 file_ptr prevoff, nextoff;
2039 struct xcoff_ar_hdr_big ahdr;
2044 memset (&fhdr, 0, sizeof fhdr);
2045 strncpy (fhdr.magic, XCOFFARMAGBIG, SXCOFFARMAG);
2046 sprintf (fhdr.firstmemoff, "%d", SIZEOF_AR_FILE_HDR_BIG);
2047 sprintf (fhdr.freeoff, "%d", 0);
2051 for (sub = abfd->archive_head; sub != NULL; sub = sub->next)
2054 total_namlen += strlen (normalize_filename (sub)) + 1;
2056 offsets = (file_ptr *) bfd_alloc (abfd, count * sizeof (file_ptr));
2057 if (offsets == NULL)
2060 if (bfd_seek (abfd, SIZEOF_AR_FILE_HDR_BIG, SEEK_SET) != 0)
2063 makemap = bfd_has_map (abfd);
2066 nextoff = SIZEOF_AR_FILE_HDR_BIG;
2067 for (sub = abfd->archive_head, i = 0; sub != NULL; sub = sub->next, i++)
2071 struct xcoff_ar_hdr_big *ahdrp;
2072 bfd_size_type remaining;
2074 if (makemap && ! hasobjects)
2076 if (bfd_check_format (sub, bfd_object))
2080 name = normalize_filename (sub);
2081 namlen = strlen (name);
2083 if (sub->arelt_data != NULL)
2084 ahdrp = arch_xhdr_big (sub);
2092 memset (&ahdr, 0, sizeof ahdr);
2094 /* XXX This should actually be a call to stat64 (at least on
2095 32-bit machines). */
2096 if (stat (bfd_get_filename (sub), &s) != 0)
2098 bfd_set_error (bfd_error_system_call);
2102 /* XXX This call actually should use %lld (at least on 32-bit
2103 machines) since the fields's width is 20 and there numbers with
2104 more than 32 bits can be represented. */
2105 sprintf (ahdrp->size, "%ld", (long) s.st_size);
2106 sprintf (ahdrp->date, "%ld", (long) s.st_mtime);
2107 sprintf (ahdrp->uid, "%ld", (long) s.st_uid);
2108 sprintf (ahdrp->gid, "%ld", (long) s.st_gid);
2109 sprintf (ahdrp->mode, "%o", (unsigned int) s.st_mode);
2111 if (sub->arelt_data == NULL)
2113 sub->arelt_data = bfd_alloc (sub, sizeof (struct areltdata));
2114 if (sub->arelt_data == NULL)
2118 arch_eltdata (sub)->parsed_size = s.st_size;
2121 /* XXX These calls actually should use %lld (at least on 32-bit
2122 machines) since the fields's width is 20 and there numbers with
2123 more than 32 bits can be represented. */
2124 sprintf (ahdrp->prevoff, "%ld", (long) prevoff);
2125 sprintf (ahdrp->namlen, "%ld", (long) namlen);
2127 /* If the length of the name is odd, we write out the null byte
2128 after the name as well. */
2129 namlen = (namlen + 1) &~ 1;
2131 remaining = arelt_size (sub);
2132 size = (SIZEOF_AR_HDR_BIG
2137 BFD_ASSERT (nextoff == bfd_tell (abfd));
2139 offsets[i] = nextoff;
2142 nextoff += size + (size & 1);
2144 sprintf (ahdrp->nextoff, "%ld", (long) nextoff);
2146 /* We need spaces, not null bytes, in the header. */
2147 for (p = (char *) ahdrp; p < (char *) ahdrp + SIZEOF_AR_HDR_BIG; p++)
2151 if (bfd_write ((PTR) ahdrp, 1, SIZEOF_AR_HDR_BIG, abfd)
2152 != SIZEOF_AR_HDR_BIG
2153 || bfd_write ((PTR) name, 1, namlen, abfd) != namlen
2154 || (bfd_write ((PTR) XCOFFARFMAG, 1, SXCOFFARFMAG, abfd)
2158 if (bfd_seek (sub, (file_ptr) 0, SEEK_SET) != 0)
2160 while (remaining != 0)
2163 bfd_byte buffer[DEFAULT_BUFFERSIZE];
2165 amt = sizeof buffer;
2166 if (amt > remaining)
2168 if (bfd_read (buffer, 1, amt, sub) != amt
2169 || bfd_write (buffer, 1, amt, abfd) != amt)
2174 if ((size & 1) != 0)
2179 if (bfd_write (&b, 1, 1, abfd) != 1)
2184 /* XXX This call actually should use %lld (at least on 32-bit
2185 machines) since the fields's width is 20 and there numbers with
2186 more than 32 bits can be represented. */
2187 sprintf (fhdr.lastmemoff, "%ld", (long) prevoff);
2189 /* Write out the member table. */
2191 BFD_ASSERT (nextoff == bfd_tell (abfd));
2192 /* XXX This call actually should use %lld (at least on 32-bit
2193 machines) since the fields's width is 20 and there numbers with
2194 more than 32 bits can be represented. */
2195 sprintf (fhdr.memoff, "%ld", (long) nextoff);
2197 memset (&ahdr, 0, sizeof ahdr);
2198 /* XXX The next two calls actually should use %lld (at least on 32-bit
2199 machines) since the fields's width is 20 and there numbers with
2200 more than 32 bits can be represented. */
2201 sprintf (ahdr.size, "%ld", (long) (12 + count * 12 + total_namlen));
2202 sprintf (ahdr.prevoff, "%ld", (long) prevoff);
2203 sprintf (ahdr.date, "%d", 0);
2204 sprintf (ahdr.uid, "%d", 0);
2205 sprintf (ahdr.gid, "%d", 0);
2206 sprintf (ahdr.mode, "%d", 0);
2207 sprintf (ahdr.namlen, "%d", 0);
2209 size = (SIZEOF_AR_HDR_BIG
2216 nextoff += size + (size & 1);
2218 if (makemap && hasobjects)
2219 /* XXX This call actually should use %lld (at least on 32-bit
2220 machines) since the fields's width is 20 and there numbers with
2221 more than 32 bits can be represented. */
2222 sprintf (ahdr.nextoff, "%ld", (long) nextoff);
2224 sprintf (ahdr.nextoff, "%d", 0);
2226 /* We need spaces, not null bytes, in the header. */
2227 for (p = (char *) &ahdr; p < (char *) &ahdr + SIZEOF_AR_HDR_BIG; p++)
2231 if (bfd_write ((PTR) &ahdr, 1, SIZEOF_AR_HDR_BIG, abfd) != SIZEOF_AR_HDR_BIG
2232 || (bfd_write ((PTR) XCOFFARFMAG, 1, SXCOFFARFMAG, abfd)
2236 sprintf (decbuf, "%-12ld", (long) count);
2237 if (bfd_write ((PTR) decbuf, 1, 12, abfd) != 12)
2239 for (i = 0; i < count; i++)
2241 sprintf (decbuf, "%-12ld", (long) offsets[i]);
2242 if (bfd_write ((PTR) decbuf, 1, 12, abfd) != 12)
2245 for (sub = abfd->archive_head; sub != NULL; sub = sub->next)
2250 name = normalize_filename (sub);
2251 namlen = strlen (name);
2252 if (bfd_write ((PTR) name, 1, namlen + 1, abfd) != namlen + 1)
2255 if ((size & 1) != 0)
2260 if (bfd_write ((PTR) &b, 1, 1, abfd) != 1)
2264 /* Write out the armap, if appropriate. */
2266 if (! makemap || ! hasobjects)
2267 sprintf (fhdr.symoff, "%d", 0);
2270 BFD_ASSERT (nextoff == bfd_tell (abfd));
2271 /* XXX This call actually should use %lld (at least on 32-bit
2272 machines) since the fields's width is 20 and there numbers with
2273 more than 32 bits can be represented. */
2274 sprintf (fhdr.symoff, "%ld", (long) nextoff);
2275 bfd_ardata (abfd)->tdata = (PTR) &fhdr;
2276 if (! _bfd_compute_and_write_armap (abfd, 0))
2280 /* Write out the archive file header. */
2282 /* We need spaces, not null bytes, in the header. */
2283 for (p = (char *) &fhdr; p < (char *) &fhdr + SIZEOF_AR_FILE_HDR_BIG; p++)
2287 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
2288 || (bfd_write ((PTR) &fhdr, SIZEOF_AR_FILE_HDR_BIG, 1, abfd) !=
2289 SIZEOF_AR_FILE_HDR_BIG))
2296 _bfd_xcoff_write_archive_contents (abfd)
2299 if (! xcoff_big_format_p (abfd))
2300 return xcoff_write_archive_contents_old (abfd);
2302 return xcoff_write_archive_contents_big (abfd);
2305 /* We can't use the usual coff_sizeof_headers routine, because AIX
2306 always uses an a.out header. */
2310 _bfd_xcoff_sizeof_headers (abfd, reloc)
2312 boolean reloc ATTRIBUTE_UNUSED;
2317 if (xcoff_data (abfd)->full_aouthdr)
2320 size += SMALL_AOUTSZ;
2321 size += abfd->section_count * SCNHSZ;
2325 #define CORE_FILE_P _bfd_dummy_target
2327 #define coff_core_file_failing_command _bfd_nocore_core_file_failing_command
2328 #define coff_core_file_failing_signal _bfd_nocore_core_file_failing_signal
2329 #define coff_core_file_matches_executable_p \
2330 _bfd_nocore_core_file_matches_executable_p
2334 #define CORE_FILE_P rs6000coff_core_p
2335 extern const bfd_target * rs6000coff_core_p ();
2336 extern boolean rs6000coff_get_section_contents ();
2337 extern boolean rs6000coff_core_file_matches_executable_p ();
2339 #undef coff_core_file_matches_executable_p
2340 #define coff_core_file_matches_executable_p \
2341 rs6000coff_core_file_matches_executable_p
2343 extern char *rs6000coff_core_file_failing_command PARAMS ((bfd *abfd));
2344 #undef coff_core_file_failing_command
2345 #define coff_core_file_failing_command rs6000coff_core_file_failing_command
2347 extern int rs6000coff_core_file_failing_signal PARAMS ((bfd *abfd));
2348 #undef coff_core_file_failing_signal
2349 #define coff_core_file_failing_signal rs6000coff_core_file_failing_signal
2351 #undef coff_get_section_contents
2352 #define coff_get_section_contents rs6000coff_get_section_contents
2353 #endif /* AIX_CORE */
2358 #define CORE_FILE_P lynx_core_file_p
2359 extern const bfd_target *lynx_core_file_p PARAMS ((bfd *abfd));
2361 extern boolean lynx_core_file_matches_executable_p PARAMS ((bfd *core_bfd,
2363 #undef coff_core_file_matches_executable_p
2364 #define coff_core_file_matches_executable_p lynx_core_file_matches_executable_p
2366 extern char *lynx_core_file_failing_command PARAMS ((bfd *abfd));
2367 #undef coff_core_file_failing_command
2368 #define coff_core_file_failing_command lynx_core_file_failing_command
2370 extern int lynx_core_file_failing_signal PARAMS ((bfd *abfd));
2371 #undef coff_core_file_failing_signal
2372 #define coff_core_file_failing_signal lynx_core_file_failing_signal
2374 #endif /* LYNX_CORE */
2376 #define _bfd_xcoff_bfd_get_relocated_section_contents \
2377 coff_bfd_get_relocated_section_contents
2378 #define _bfd_xcoff_bfd_relax_section coff_bfd_relax_section
2379 #define _bfd_xcoff_bfd_gc_sections coff_bfd_gc_sections
2380 #define _bfd_xcoff_bfd_link_split_section coff_bfd_link_split_section
2382 /* The transfer vector that leads the outside world to all of the above. */
2394 "aixcoff-rs6000", /* name */
2396 bfd_target_coff_flavour,
2397 BFD_ENDIAN_BIG, /* data byte order is big */
2398 BFD_ENDIAN_BIG, /* header byte order is big */
2400 (HAS_RELOC | EXEC_P | /* object flags */
2401 HAS_LINENO | HAS_DEBUG | DYNAMIC |
2402 HAS_SYMS | HAS_LOCALS | WP_TEXT),
2404 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
2405 0, /* leading char */
2406 '/', /* ar_pad_char */
2407 15, /* ar_max_namelen??? FIXMEmgo */
2409 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
2410 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
2411 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
2412 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
2413 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
2414 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
2416 {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
2417 _bfd_xcoff_archive_p, CORE_FILE_P},
2418 {bfd_false, coff_mkobject, /* bfd_set_format */
2419 _bfd_generic_mkarchive, bfd_false},
2420 {bfd_false, coff_write_object_contents, /* bfd_write_contents */
2421 _bfd_xcoff_write_archive_contents, bfd_false},
2423 BFD_JUMP_TABLE_GENERIC (coff),
2424 BFD_JUMP_TABLE_COPY (coff),
2425 BFD_JUMP_TABLE_CORE (coff),
2426 BFD_JUMP_TABLE_ARCHIVE (_bfd_xcoff),
2427 BFD_JUMP_TABLE_SYMBOLS (coff),
2428 BFD_JUMP_TABLE_RELOCS (coff),
2429 BFD_JUMP_TABLE_WRITE (coff),
2430 BFD_JUMP_TABLE_LINK (_bfd_xcoff),
2431 BFD_JUMP_TABLE_DYNAMIC (_bfd_xcoff),