* opncls.c (bfd_alloc_by_size_t): Set bfd_error_no_memory if
[deliverable/binutils-gdb.git] / bfd / coff-rs6000.c
1 /* BFD back-end for IBM RS/6000 "XCOFF" files.
2 Copyright 1990, 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
3 FIXME: Can someone provide a transliteration of this name into ASCII?
4 Using the following chars caused a compiler warning on HIUX (so I replaced
5 them with octal escapes), and isn't useful without an understanding of what
6 character set it is.
7 Written by Metin G. Ozisik, Mimi Ph\373\364ng-Th\345o V\365,
8 and John Gilmore.
9 Archive support from Damon A. Permezel.
10 Contributed by IBM Corporation and Cygnus Support.
11
12 This file is part of BFD, the Binary File Descriptor library.
13
14 This program is free software; you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by
16 the Free Software Foundation; either version 2 of the License, or
17 (at your option) any later version.
18
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, write to the Free Software
26 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
27
28 /* Internalcoff.h and coffcode.h modify themselves based on this flag. */
29 #define RS6000COFF_C 1
30
31 #include "bfd.h"
32 #include "sysdep.h"
33 #include "libbfd.h"
34 #include "obstack.h"
35 #include "coff/internal.h"
36 #include "coff/rs6000.h"
37 #include "libcoff.h"
38
39 /* The main body of code is in coffcode.h. */
40
41 static boolean xcoff_mkobject PARAMS ((bfd *));
42 static boolean xcoff_copy_private_bfd_data PARAMS ((bfd *, bfd *));
43 static void xcoff_rtype2howto
44 PARAMS ((arelent *, struct internal_reloc *));
45 static reloc_howto_type *xcoff_reloc_type_lookup
46 PARAMS ((bfd *, bfd_reloc_code_real_type));
47 static boolean xcoff_slurp_armap PARAMS ((bfd *));
48 static const bfd_target *xcoff_archive_p PARAMS ((bfd *));
49 static PTR xcoff_read_ar_hdr PARAMS ((bfd *));
50 static bfd *xcoff_openr_next_archived_file PARAMS ((bfd *, bfd *));
51 static int xcoff_generic_stat_arch_elt PARAMS ((bfd *, struct stat *));
52 static const char *normalize_filename PARAMS ((bfd *));
53 static boolean xcoff_write_armap
54 PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int));
55 static boolean xcoff_write_archive_contents PARAMS ((bfd *));
56 \f
57 /* We use our own tdata type. Its first field is the COFF tdata type,
58 so the COFF routines are compatible. */
59
60 static boolean
61 xcoff_mkobject (abfd)
62 bfd *abfd;
63 {
64 coff_data_type *coff;
65
66 abfd->tdata.xcoff_obj_data =
67 ((struct xcoff_tdata *)
68 bfd_zalloc (abfd, sizeof (struct xcoff_tdata)));
69 if (abfd->tdata.xcoff_obj_data == NULL)
70 return false;
71 coff = coff_data (abfd);
72 coff->symbols = (coff_symbol_type *) NULL;
73 coff->conversion_table = (unsigned int *) NULL;
74 coff->raw_syments = (struct coff_ptr_struct *) NULL;
75 coff->relocbase = 0;
76
77 xcoff_data (abfd)->modtype = ('1' << 8) | 'L';
78
79 /* We set cputype to -1 to indicate that it has not been
80 initialized. */
81 xcoff_data (abfd)->cputype = -1;
82
83 xcoff_data (abfd)->csects = NULL;
84 xcoff_data (abfd)->debug_indices = NULL;
85
86 return true;
87 }
88
89 /* Copy XCOFF data from one BFD to another. */
90
91 static boolean
92 xcoff_copy_private_bfd_data (ibfd, obfd)
93 bfd *ibfd;
94 bfd *obfd;
95 {
96 struct xcoff_tdata *ix, *ox;
97
98 if (ibfd->xvec != obfd->xvec)
99 return true;
100 ix = xcoff_data (ibfd);
101 ox = xcoff_data (obfd);
102 ox->full_aouthdr = ix->full_aouthdr;
103 ox->toc = ix->toc;
104 if (ix->toc_section == NULL)
105 ox->toc_section = NULL;
106 else
107 ox->toc_section = ix->toc_section->output_section;
108 if (ix->entry_section == NULL)
109 ox->entry_section = NULL;
110 else
111 ox->entry_section = ix->entry_section->output_section;
112 ox->text_align_power = ix->text_align_power;
113 ox->data_align_power = ix->data_align_power;
114 ox->modtype = ix->modtype;
115 ox->cputype = ix->cputype;
116 ox->maxdata = ix->maxdata;
117 ox->maxstack = ix->maxstack;
118 return true;
119 }
120 \f
121 /* The XCOFF reloc table. Actually, XCOFF relocations specify the
122 bitsize and whether they are signed or not, along with a
123 conventional type. This table is for the types, which are used for
124 different algorithms for putting in the reloc. Many of these
125 relocs need special_function entries, which I have not written. */
126
127 static reloc_howto_type xcoff_howto_table[] =
128 {
129 /* Standard 32 bit relocation. */
130 HOWTO (0, /* type */
131 0, /* rightshift */
132 2, /* size (0 = byte, 1 = short, 2 = long) */
133 32, /* bitsize */
134 false, /* pc_relative */
135 0, /* bitpos */
136 complain_overflow_bitfield, /* complain_on_overflow */
137 0, /* special_function */
138 "R_POS", /* name */
139 true, /* partial_inplace */
140 0xffffffff, /* src_mask */
141 0xffffffff, /* dst_mask */
142 false), /* pcrel_offset */
143
144 /* 32 bit relocation, but store negative value. */
145 HOWTO (1, /* type */
146 0, /* rightshift */
147 -2, /* size (0 = byte, 1 = short, 2 = long) */
148 32, /* bitsize */
149 false, /* pc_relative */
150 0, /* bitpos */
151 complain_overflow_bitfield, /* complain_on_overflow */
152 0, /* special_function */
153 "R_NEG", /* name */
154 true, /* partial_inplace */
155 0xffffffff, /* src_mask */
156 0xffffffff, /* dst_mask */
157 false), /* pcrel_offset */
158
159 /* 32 bit PC relative relocation. */
160 HOWTO (2, /* type */
161 0, /* rightshift */
162 2, /* size (0 = byte, 1 = short, 2 = long) */
163 32, /* bitsize */
164 true, /* pc_relative */
165 0, /* bitpos */
166 complain_overflow_signed, /* complain_on_overflow */
167 0, /* special_function */
168 "R_REL", /* name */
169 true, /* partial_inplace */
170 0xffffffff, /* src_mask */
171 0xffffffff, /* dst_mask */
172 false), /* pcrel_offset */
173
174 /* 16 bit TOC relative relocation. */
175 HOWTO (3, /* type */
176 0, /* rightshift */
177 1, /* size (0 = byte, 1 = short, 2 = long) */
178 16, /* bitsize */
179 false, /* pc_relative */
180 0, /* bitpos */
181 complain_overflow_bitfield, /* complain_on_overflow */
182 0, /* special_function */
183 "R_TOC", /* name */
184 true, /* partial_inplace */
185 0xffff, /* src_mask */
186 0xffff, /* dst_mask */
187 false), /* pcrel_offset */
188
189 /* I don't really know what this is. */
190 HOWTO (4, /* type */
191 1, /* rightshift */
192 2, /* size (0 = byte, 1 = short, 2 = long) */
193 32, /* bitsize */
194 false, /* pc_relative */
195 0, /* bitpos */
196 complain_overflow_bitfield, /* complain_on_overflow */
197 0, /* special_function */
198 "R_RTB", /* name */
199 true, /* partial_inplace */
200 0xffffffff, /* src_mask */
201 0xffffffff, /* dst_mask */
202 false), /* pcrel_offset */
203
204 /* External TOC relative symbol. */
205 HOWTO (5, /* type */
206 0, /* rightshift */
207 2, /* size (0 = byte, 1 = short, 2 = long) */
208 16, /* bitsize */
209 false, /* pc_relative */
210 0, /* bitpos */
211 complain_overflow_bitfield, /* complain_on_overflow */
212 0, /* special_function */
213 "R_GL", /* name */
214 true, /* partial_inplace */
215 0xffff, /* src_mask */
216 0xffff, /* dst_mask */
217 false), /* pcrel_offset */
218
219 /* Local TOC relative symbol. */
220 HOWTO (6, /* type */
221 0, /* rightshift */
222 2, /* size (0 = byte, 1 = short, 2 = long) */
223 16, /* bitsize */
224 false, /* pc_relative */
225 0, /* bitpos */
226 complain_overflow_bitfield, /* complain_on_overflow */
227 0, /* special_function */
228 "R_TCL", /* name */
229 true, /* partial_inplace */
230 0xffff, /* src_mask */
231 0xffff, /* dst_mask */
232 false), /* pcrel_offset */
233
234 { 7 },
235
236 /* Non modifiable absolute branch. */
237 HOWTO (8, /* type */
238 0, /* rightshift */
239 2, /* size (0 = byte, 1 = short, 2 = long) */
240 26, /* bitsize */
241 false, /* pc_relative */
242 0, /* bitpos */
243 complain_overflow_bitfield, /* complain_on_overflow */
244 0, /* special_function */
245 "R_BA", /* name */
246 true, /* partial_inplace */
247 0x3fffffc, /* src_mask */
248 0x3fffffc, /* dst_mask */
249 false), /* pcrel_offset */
250
251 { 9 },
252
253 /* Non modifiable relative branch. */
254 HOWTO (0xa, /* type */
255 0, /* rightshift */
256 2, /* size (0 = byte, 1 = short, 2 = long) */
257 26, /* bitsize */
258 true, /* pc_relative */
259 0, /* bitpos */
260 complain_overflow_signed, /* complain_on_overflow */
261 0, /* special_function */
262 "R_BR", /* name */
263 true, /* partial_inplace */
264 0x3fffffc, /* src_mask */
265 0x3fffffc, /* dst_mask */
266 false), /* pcrel_offset */
267
268 { 0xb },
269
270 /* Indirect load. */
271 HOWTO (0xc, /* type */
272 0, /* rightshift */
273 2, /* size (0 = byte, 1 = short, 2 = long) */
274 16, /* bitsize */
275 false, /* pc_relative */
276 0, /* bitpos */
277 complain_overflow_bitfield, /* complain_on_overflow */
278 0, /* special_function */
279 "R_RL", /* name */
280 true, /* partial_inplace */
281 0xffff, /* src_mask */
282 0xffff, /* dst_mask */
283 false), /* pcrel_offset */
284
285 /* Load address. */
286 HOWTO (0xd, /* type */
287 0, /* rightshift */
288 2, /* size (0 = byte, 1 = short, 2 = long) */
289 16, /* bitsize */
290 false, /* pc_relative */
291 0, /* bitpos */
292 complain_overflow_bitfield, /* complain_on_overflow */
293 0, /* special_function */
294 "R_RLA", /* name */
295 true, /* partial_inplace */
296 0xffff, /* src_mask */
297 0xffff, /* dst_mask */
298 false), /* pcrel_offset */
299
300 { 0xe },
301
302 /* Non-relocating reference. */
303 HOWTO (0xf, /* type */
304 0, /* rightshift */
305 2, /* size (0 = byte, 1 = short, 2 = long) */
306 32, /* bitsize */
307 false, /* pc_relative */
308 0, /* bitpos */
309 complain_overflow_bitfield, /* complain_on_overflow */
310 0, /* special_function */
311 "R_REF", /* name */
312 false, /* partial_inplace */
313 0, /* src_mask */
314 0, /* dst_mask */
315 false), /* pcrel_offset */
316
317 { 0x10 },
318 { 0x11 },
319
320 /* TOC relative indirect load. */
321 HOWTO (0x12, /* type */
322 0, /* rightshift */
323 2, /* size (0 = byte, 1 = short, 2 = long) */
324 16, /* bitsize */
325 false, /* pc_relative */
326 0, /* bitpos */
327 complain_overflow_bitfield, /* complain_on_overflow */
328 0, /* special_function */
329 "R_TRL", /* name */
330 true, /* partial_inplace */
331 0xffff, /* src_mask */
332 0xffff, /* dst_mask */
333 false), /* pcrel_offset */
334
335 /* TOC relative load address. */
336 HOWTO (0x13, /* type */
337 0, /* rightshift */
338 2, /* size (0 = byte, 1 = short, 2 = long) */
339 16, /* bitsize */
340 false, /* pc_relative */
341 0, /* bitpos */
342 complain_overflow_bitfield, /* complain_on_overflow */
343 0, /* special_function */
344 "R_TRLA", /* name */
345 true, /* partial_inplace */
346 0xffff, /* src_mask */
347 0xffff, /* dst_mask */
348 false), /* pcrel_offset */
349
350 /* Modifiable relative branch. */
351 HOWTO (0x14, /* type */
352 1, /* rightshift */
353 2, /* size (0 = byte, 1 = short, 2 = long) */
354 32, /* bitsize */
355 false, /* pc_relative */
356 0, /* bitpos */
357 complain_overflow_bitfield, /* complain_on_overflow */
358 0, /* special_function */
359 "R_RRTBI", /* name */
360 true, /* partial_inplace */
361 0xffffffff, /* src_mask */
362 0xffffffff, /* dst_mask */
363 false), /* pcrel_offset */
364
365 /* Modifiable absolute branch. */
366 HOWTO (0x15, /* type */
367 1, /* rightshift */
368 2, /* size (0 = byte, 1 = short, 2 = long) */
369 32, /* bitsize */
370 false, /* pc_relative */
371 0, /* bitpos */
372 complain_overflow_bitfield, /* complain_on_overflow */
373 0, /* special_function */
374 "R_RRTBA", /* name */
375 true, /* partial_inplace */
376 0xffffffff, /* src_mask */
377 0xffffffff, /* dst_mask */
378 false), /* pcrel_offset */
379
380 /* Modifiable call absolute indirect. */
381 HOWTO (0x16, /* type */
382 0, /* rightshift */
383 2, /* size (0 = byte, 1 = short, 2 = long) */
384 16, /* bitsize */
385 false, /* pc_relative */
386 0, /* bitpos */
387 complain_overflow_bitfield, /* complain_on_overflow */
388 0, /* special_function */
389 "R_CAI", /* name */
390 true, /* partial_inplace */
391 0xffff, /* src_mask */
392 0xffff, /* dst_mask */
393 false), /* pcrel_offset */
394
395 /* Modifiable call relative. */
396 HOWTO (0x17, /* type */
397 0, /* rightshift */
398 2, /* size (0 = byte, 1 = short, 2 = long) */
399 16, /* bitsize */
400 false, /* pc_relative */
401 0, /* bitpos */
402 complain_overflow_bitfield, /* complain_on_overflow */
403 0, /* special_function */
404 "R_CREL", /* name */
405 true, /* partial_inplace */
406 0xffff, /* src_mask */
407 0xffff, /* dst_mask */
408 false), /* pcrel_offset */
409
410 /* Modifiable branch absolute. */
411 HOWTO (0x18, /* type */
412 0, /* rightshift */
413 2, /* size (0 = byte, 1 = short, 2 = long) */
414 16, /* bitsize */
415 false, /* pc_relative */
416 0, /* bitpos */
417 complain_overflow_bitfield, /* complain_on_overflow */
418 0, /* special_function */
419 "R_RBA", /* name */
420 true, /* partial_inplace */
421 0xffff, /* src_mask */
422 0xffff, /* dst_mask */
423 false), /* pcrel_offset */
424
425 /* Modifiable branch absolute. */
426 HOWTO (0x19, /* type */
427 0, /* rightshift */
428 2, /* size (0 = byte, 1 = short, 2 = long) */
429 16, /* bitsize */
430 false, /* pc_relative */
431 0, /* bitpos */
432 complain_overflow_bitfield, /* complain_on_overflow */
433 0, /* special_function */
434 "R_RBAC", /* name */
435 true, /* partial_inplace */
436 0xffff, /* src_mask */
437 0xffff, /* dst_mask */
438 false), /* pcrel_offset */
439
440 /* Modifiable branch relative. */
441 HOWTO (0x1a, /* type */
442 0, /* rightshift */
443 2, /* size (0 = byte, 1 = short, 2 = long) */
444 26, /* bitsize */
445 false, /* pc_relative */
446 0, /* bitpos */
447 complain_overflow_signed, /* complain_on_overflow */
448 0, /* special_function */
449 "R_RBR", /* name */
450 true, /* partial_inplace */
451 0xffff, /* src_mask */
452 0xffff, /* dst_mask */
453 false), /* pcrel_offset */
454
455 /* Modifiable branch absolute. */
456 HOWTO (0x1b, /* type */
457 0, /* rightshift */
458 2, /* size (0 = byte, 1 = short, 2 = long) */
459 16, /* bitsize */
460 false, /* pc_relative */
461 0, /* bitpos */
462 complain_overflow_bitfield, /* complain_on_overflow */
463 0, /* special_function */
464 "R_RBRC", /* name */
465 true, /* partial_inplace */
466 0xffff, /* src_mask */
467 0xffff, /* dst_mask */
468 false) /* pcrel_offset */
469 };
470
471 static void
472 xcoff_rtype2howto (relent, internal)
473 arelent *relent;
474 struct internal_reloc *internal;
475 {
476 relent->howto = xcoff_howto_table + internal->r_type;
477
478 /* The r_size field of an XCOFF reloc encodes the bitsize of the
479 relocation, as well as indicating whether it is signed or not.
480 Doublecheck that the relocation information gathered from the
481 type matches this information. */
482 if (relent->howto->bitsize != ((unsigned int) internal->r_size & 0x1f) + 1)
483 abort ();
484 #if 0
485 if ((internal->r_size & 0x80) != 0
486 ? (relent->howto->complain_on_overflow != complain_overflow_signed)
487 : (relent->howto->complain_on_overflow != complain_overflow_bitfield))
488 abort ();
489 #endif
490 }
491
492 static reloc_howto_type *
493 xcoff_reloc_type_lookup (abfd, code)
494 bfd *abfd;
495 bfd_reloc_code_real_type code;
496 {
497 switch (code)
498 {
499 case BFD_RELOC_PPC_B26:
500 return &xcoff_howto_table[0xa];
501 case BFD_RELOC_PPC_BA26:
502 return &xcoff_howto_table[8];
503 case BFD_RELOC_PPC_TOC16:
504 return &xcoff_howto_table[3];
505 case BFD_RELOC_32:
506 case BFD_RELOC_CTOR:
507 return &xcoff_howto_table[0];
508 default:
509 return NULL;
510 }
511 }
512
513 #define SELECT_RELOC(internal, howto) \
514 { \
515 internal.r_type = howto->type; \
516 internal.r_size = \
517 ((howto->complain_on_overflow == complain_overflow_signed \
518 ? 0x80 \
519 : 0) \
520 | (howto->bitsize - 1)); \
521 }
522 \f
523 #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
524
525 #define COFF_LONG_FILENAMES
526
527 #define RTYPE2HOWTO(cache_ptr, dst) xcoff_rtype2howto (cache_ptr, dst)
528
529 #define coff_mkobject xcoff_mkobject
530 #define coff_bfd_copy_private_bfd_data xcoff_copy_private_bfd_data
531 #define coff_bfd_reloc_type_lookup xcoff_reloc_type_lookup
532 #define coff_relocate_section _bfd_ppc_xcoff_relocate_section
533
534 #include "coffcode.h"
535 \f
536 /* XCOFF archive support. The original version of this code was by
537 Damon A. Permezel. It was enhanced to permit cross support, and
538 writing archive files, by Ian Lance Taylor, Cygnus Support.
539
540 XCOFF uses its own archive format. Everything is hooked together
541 with file offset links, so it is possible to rapidly update an
542 archive in place. Of course, we don't do that. An XCOFF archive
543 has a real file header, not just an ARMAG string. The structure of
544 the file header and of each archive header appear below.
545
546 An XCOFF archive also has a member table, which is a list of
547 elements in the archive (you can get that by looking through the
548 linked list, but you have to read a lot more of the file). The
549 member table has a normal archive header with an empty name. It is
550 normally (and perhaps must be) the second to last entry in the
551 archive. The member table data is almost printable ASCII. It
552 starts with a 12 character decimal string which is the number of
553 entries in the table. For each entry it has a 12 character decimal
554 string which is the offset in the archive of that member. These
555 entries are followed by a series of null terminated strings which
556 are the member names for each entry.
557
558 Finally, an XCOFF archive has a global symbol table, which is what
559 we call the armap. The global symbol table has a normal archive
560 header with an empty name. It is normally (and perhaps must be)
561 the last entry in the archive. The contents start with a four byte
562 binary number which is the number of entries. This is followed by
563 a that many four byte binary numbers; each is the file offset of an
564 entry in the archive. These numbers are followed by a series of
565 null terminated strings, which are symbol names. */
566
567 /* XCOFF archives use this as a magic string. */
568
569 #define XCOFFARMAG "<aiaff>\012"
570 #define SXCOFFARMAG 8
571
572 /* This terminates an XCOFF archive member name. */
573
574 #define XCOFFARFMAG "`\012"
575 #define SXCOFFARFMAG 2
576
577 /* XCOFF archives start with this (printable) structure. */
578
579 struct xcoff_ar_file_hdr
580 {
581 /* Magic string. */
582 char magic[SXCOFFARMAG];
583
584 /* Offset of the member table (decimal ASCII string). */
585 char memoff[12];
586
587 /* Offset of the global symbol table (decimal ASCII string). */
588 char symoff[12];
589
590 /* Offset of the first member in the archive (decimal ASCII string). */
591 char firstmemoff[12];
592
593 /* Offset of the last member in the archive (decimal ASCII string). */
594 char lastmemoff[12];
595
596 /* Offset of the first member on the free list (decimal ASCII
597 string). */
598 char freeoff[12];
599 };
600
601 #define SIZEOF_AR_FILE_HDR (5 * 12 + SXCOFFARMAG)
602
603 /* Each XCOFF archive member starts with this (printable) structure. */
604
605 struct xcoff_ar_hdr
606 {
607 /* File size not including the header (decimal ASCII string). */
608 char size[12];
609
610 /* File offset of next archive member (decimal ASCII string). */
611 char nextoff[12];
612
613 /* File offset of previous archive member (decimal ASCII string). */
614 char prevoff[12];
615
616 /* File mtime (decimal ASCII string). */
617 char date[12];
618
619 /* File UID (decimal ASCII string). */
620 char uid[12];
621
622 /* File GID (decimal ASCII string). */
623 char gid[12];
624
625 /* File mode (octal ASCII string). */
626 char mode[12];
627
628 /* Length of file name (decimal ASCII string). */
629 char namlen[4];
630
631 /* This structure is followed by the file name. The length of the
632 name is given in the namlen field. If the length of the name is
633 odd, the name is followed by a null byte. The name and optional
634 null byte are followed by XCOFFARFMAG, which is not included in
635 namlen. The contents of the archive member follow; the number of
636 bytes is given in the size field. */
637 };
638
639 #define SIZEOF_AR_HDR (7 * 12 + 4)
640
641 /* We store a copy of the xcoff_ar_file_hdr in the tdata field of the
642 artdata structure. */
643 #define xcoff_ardata(abfd) \
644 ((struct xcoff_ar_file_hdr *) bfd_ardata (abfd)->tdata)
645
646 /* We store a copy of the xcoff_ar_hdr in the arelt_data field of an
647 archive element. */
648 #define arch_eltdata(bfd) ((struct areltdata *) ((bfd)->arelt_data))
649 #define arch_xhdr(bfd) \
650 ((struct xcoff_ar_hdr *) arch_eltdata (bfd)->arch_header)
651
652 /* XCOFF archives do not have anything which corresponds to an
653 extended name table. */
654
655 #define xcoff_slurp_extended_name_table bfd_false
656 #define xcoff_construct_extended_name_table \
657 ((boolean (*) PARAMS ((bfd *, char **, bfd_size_type *, const char **))) \
658 bfd_false)
659 #define xcoff_truncate_arname bfd_dont_truncate_arname
660
661 /* XCOFF archives do not have a timestamp. */
662
663 #define xcoff_update_armap_timestamp bfd_true
664
665 /* Read in the armap of an XCOFF archive. */
666
667 static boolean
668 xcoff_slurp_armap (abfd)
669 bfd *abfd;
670 {
671 file_ptr off;
672 struct xcoff_ar_hdr hdr;
673 size_t namlen;
674 bfd_size_type sz;
675 bfd_byte *contents, *cend;
676 unsigned int c, i;
677 carsym *arsym;
678 bfd_byte *p;
679
680 if (xcoff_ardata (abfd) == NULL)
681 {
682 bfd_has_map (abfd) = false;
683 return true;
684 }
685
686 off = strtol (xcoff_ardata (abfd)->symoff, (char **) NULL, 10);
687 if (off == 0)
688 {
689 bfd_has_map (abfd) = false;
690 return true;
691 }
692
693 if (bfd_seek (abfd, off, SEEK_SET) != 0)
694 return false;
695
696 /* The symbol table starts with a normal archive header. */
697 if (bfd_read ((PTR) &hdr, SIZEOF_AR_HDR, 1, abfd) != SIZEOF_AR_HDR)
698 return false;
699
700 /* Skip the name (normally empty). */
701 namlen = strtol (hdr.namlen, (char **) NULL, 10);
702 if (bfd_seek (abfd, ((namlen + 1) & ~1) + SXCOFFARFMAG, SEEK_CUR) != 0)
703 return false;
704
705 /* Read in the entire symbol table. */
706 sz = strtol (hdr.size, (char **) NULL, 10);
707 contents = (bfd_byte *) bfd_alloc (abfd, sz);
708 if (contents == NULL)
709 return false;
710 if (bfd_read ((PTR) contents, 1, sz, abfd) != sz)
711 return false;
712
713 /* The symbol table starts with a four byte count. */
714 c = bfd_h_get_32 (abfd, contents);
715
716 if (c * 4 >= sz)
717 {
718 bfd_set_error (bfd_error_bad_value);
719 return false;
720 }
721
722 bfd_ardata (abfd)->symdefs = ((carsym *)
723 bfd_alloc (abfd, c * sizeof (carsym)));
724 if (bfd_ardata (abfd)->symdefs == NULL)
725 return false;
726
727 /* After the count comes a list of four byte file offsets. */
728 for (i = 0, arsym = bfd_ardata (abfd)->symdefs, p = contents + 4;
729 i < c;
730 ++i, ++arsym, p += 4)
731 arsym->file_offset = bfd_h_get_32 (abfd, p);
732
733 /* After the file offsets come null terminated symbol names. */
734 cend = contents + sz;
735 for (i = 0, arsym = bfd_ardata (abfd)->symdefs;
736 i < c;
737 ++i, ++arsym, p += strlen ((char *) p) + 1)
738 {
739 if (p >= cend)
740 {
741 bfd_set_error (bfd_error_bad_value);
742 return false;
743 }
744 arsym->name = (char *) p;
745 }
746
747 bfd_ardata (abfd)->symdef_count = c;
748 bfd_has_map (abfd) = true;
749
750 return true;
751 }
752
753 /* See if this is an XCOFF archive. */
754
755 static const bfd_target *
756 xcoff_archive_p (abfd)
757 bfd *abfd;
758 {
759 struct xcoff_ar_file_hdr hdr;
760
761 if (bfd_read ((PTR) &hdr, SIZEOF_AR_FILE_HDR, 1, abfd)
762 != SIZEOF_AR_FILE_HDR)
763 {
764 if (bfd_get_error () != bfd_error_system_call)
765 bfd_set_error (bfd_error_wrong_format);
766 return NULL;
767 }
768
769 if (strncmp (hdr.magic, XCOFFARMAG, SXCOFFARMAG) != 0)
770 {
771 bfd_set_error (bfd_error_wrong_format);
772 return NULL;
773 }
774
775 /* We are setting bfd_ardata(abfd) here, but since bfd_ardata
776 involves a cast, we can't do it as the left operand of
777 assignment. */
778 abfd->tdata.aout_ar_data =
779 (struct artdata *) bfd_zalloc (abfd, sizeof (struct artdata));
780
781 if (bfd_ardata (abfd) == (struct artdata *) NULL)
782 return NULL;
783
784 bfd_ardata (abfd)->first_file_filepos = strtol (hdr.firstmemoff,
785 (char **) NULL, 10);
786 bfd_ardata (abfd)->cache = NULL;
787 bfd_ardata (abfd)->archive_head = NULL;
788 bfd_ardata (abfd)->symdefs = NULL;
789 bfd_ardata (abfd)->extended_names = NULL;
790
791 bfd_ardata (abfd)->tdata = bfd_zalloc (abfd, SIZEOF_AR_FILE_HDR);
792 if (bfd_ardata (abfd)->tdata == NULL)
793 return NULL;
794
795 memcpy (bfd_ardata (abfd)->tdata, &hdr, SIZEOF_AR_FILE_HDR);
796
797 if (! xcoff_slurp_armap (abfd))
798 {
799 bfd_release (abfd, bfd_ardata (abfd));
800 abfd->tdata.aout_ar_data = (struct artdata *) NULL;
801 return NULL;
802 }
803
804 return abfd->xvec;
805 }
806
807 /* Read the archive header in an XCOFF archive. */
808
809 static PTR
810 xcoff_read_ar_hdr (abfd)
811 bfd *abfd;
812 {
813 struct xcoff_ar_hdr hdr;
814 size_t namlen;
815 struct xcoff_ar_hdr *hdrp;
816 struct areltdata *ret;
817
818 if (bfd_read ((PTR) &hdr, SIZEOF_AR_HDR, 1, abfd) != SIZEOF_AR_HDR)
819 return NULL;
820
821 namlen = strtol (hdr.namlen, (char **) NULL, 10);
822 hdrp = bfd_alloc (abfd, SIZEOF_AR_HDR + namlen + 1);
823 if (hdrp == NULL)
824 return NULL;
825 memcpy (hdrp, &hdr, SIZEOF_AR_HDR);
826 if (bfd_read ((char *) hdrp + SIZEOF_AR_HDR, 1, namlen, abfd) != namlen)
827 return NULL;
828 ((char *) hdrp)[SIZEOF_AR_HDR + namlen] = '\0';
829
830 ret = (struct areltdata *) bfd_alloc (abfd, sizeof (struct areltdata));
831 if (ret == NULL)
832 return NULL;
833 ret->arch_header = (char *) hdrp;
834 ret->parsed_size = strtol (hdr.size, (char **) NULL, 10);
835 ret->filename = (char *) hdrp + SIZEOF_AR_HDR;
836
837 /* Skip over the XCOFFARFMAG at the end of the file name. */
838 if (bfd_seek (abfd, (namlen & 1) + SXCOFFARFMAG, SEEK_CUR) != 0)
839 return NULL;
840
841 return (PTR) ret;
842 }
843
844 /* Open the next element in an XCOFF archive. */
845
846 static bfd *
847 xcoff_openr_next_archived_file (archive, last_file)
848 bfd *archive;
849 bfd *last_file;
850 {
851 file_ptr filestart;
852
853 if (xcoff_ardata (archive) == NULL)
854 {
855 bfd_set_error (bfd_error_invalid_operation);
856 return NULL;
857 }
858
859 if (last_file == NULL)
860 filestart = bfd_ardata (archive)->first_file_filepos;
861 else
862 filestart = strtol (arch_xhdr (last_file)->nextoff, (char **) NULL, 10);
863
864 if (filestart == 0
865 || filestart == strtol (xcoff_ardata (archive)->memoff,
866 (char **) NULL, 10)
867 || filestart == strtol (xcoff_ardata (archive)->symoff,
868 (char **) NULL, 10))
869 {
870 bfd_set_error (bfd_error_no_more_archived_files);
871 return NULL;
872 }
873
874 return _bfd_get_elt_at_filepos (archive, filestart);
875 }
876
877 /* Stat an element in an XCOFF archive. */
878
879 static int
880 xcoff_generic_stat_arch_elt (abfd, s)
881 bfd *abfd;
882 struct stat *s;
883 {
884 struct xcoff_ar_hdr *hdrp;
885
886 if (abfd->arelt_data == NULL)
887 {
888 bfd_set_error (bfd_error_invalid_operation);
889 return -1;
890 }
891
892 hdrp = arch_xhdr (abfd);
893
894 s->st_mtime = strtol (hdrp->date, (char **) NULL, 10);
895 s->st_uid = strtol (hdrp->uid, (char **) NULL, 10);
896 s->st_gid = strtol (hdrp->gid, (char **) NULL, 10);
897 s->st_mode = strtol (hdrp->mode, (char **) NULL, 8);
898 s->st_size = arch_eltdata (abfd)->parsed_size;
899
900 return 0;
901 }
902
903 /* Normalize a file name for inclusion in an archive. */
904
905 static const char *
906 normalize_filename (abfd)
907 bfd *abfd;
908 {
909 const char *file;
910 const char *filename;
911
912 file = bfd_get_filename (abfd);
913 filename = strrchr (file, '/');
914 if (filename != NULL)
915 filename++;
916 else
917 filename = file;
918 return filename;
919 }
920
921 /* Write out an XCOFF armap. */
922
923 /*ARGSUSED*/
924 static boolean
925 xcoff_write_armap (abfd, elength, map, orl_count, stridx)
926 bfd *abfd;
927 unsigned int elength;
928 struct orl *map;
929 unsigned int orl_count;
930 int stridx;
931 {
932 struct xcoff_ar_hdr hdr;
933 char *p;
934 unsigned char buf[4];
935 bfd *sub;
936 file_ptr fileoff;
937 unsigned int i;
938
939 memset (&hdr, 0, sizeof hdr);
940 sprintf (hdr.size, "%ld", (long) (4 + orl_count * 4 + stridx));
941 sprintf (hdr.nextoff, "%d", 0);
942 memcpy (hdr.prevoff, xcoff_ardata (abfd)->memoff, 12);
943 sprintf (hdr.date, "%d", 0);
944 sprintf (hdr.uid, "%d", 0);
945 sprintf (hdr.gid, "%d", 0);
946 sprintf (hdr.mode, "%d", 0);
947 sprintf (hdr.namlen, "%d", 0);
948
949 /* We need spaces, not null bytes, in the header. */
950 for (p = (char *) &hdr; p < (char *) &hdr + SIZEOF_AR_HDR; p++)
951 if (*p == '\0')
952 *p = ' ';
953
954 if (bfd_write ((PTR) &hdr, SIZEOF_AR_HDR, 1, abfd) != SIZEOF_AR_HDR
955 || bfd_write (XCOFFARFMAG, 1, SXCOFFARFMAG, abfd) != SXCOFFARFMAG)
956 return false;
957
958 bfd_h_put_32 (abfd, orl_count, buf);
959 if (bfd_write (buf, 1, 4, abfd) != 4)
960 return false;
961
962 sub = abfd->archive_head;
963 fileoff = SIZEOF_AR_FILE_HDR;
964 i = 0;
965 while (sub != NULL && i < orl_count)
966 {
967 size_t namlen;
968
969 while (((bfd *) (map[i]).pos) == sub)
970 {
971 bfd_h_put_32 (abfd, fileoff, buf);
972 if (bfd_write (buf, 1, 4, abfd) != 4)
973 return false;
974 ++i;
975 }
976 namlen = strlen (normalize_filename (sub));
977 namlen = (namlen + 1) &~ 1;
978 fileoff += (SIZEOF_AR_HDR
979 + namlen
980 + SXCOFFARFMAG
981 + arelt_size (sub));
982 fileoff = (fileoff + 1) &~ 1;
983 sub = sub->next;
984 }
985
986 for (i = 0; i < orl_count; i++)
987 {
988 const char *name;
989 size_t namlen;
990
991 name = *map[i].name;
992 namlen = strlen (name);
993 if (bfd_write (name, 1, namlen + 1, abfd) != namlen + 1)
994 return false;
995 }
996
997 if ((stridx & 1) != 0)
998 {
999 char b;
1000
1001 b = '\0';
1002 if (bfd_write (&b, 1, 1, abfd) != 1)
1003 return false;
1004 }
1005
1006 return true;
1007 }
1008
1009 /* Write out an XCOFF archive. We always write an entire archive,
1010 rather than fussing with the freelist and so forth. */
1011
1012 static boolean
1013 xcoff_write_archive_contents (abfd)
1014 bfd *abfd;
1015 {
1016 struct xcoff_ar_file_hdr fhdr;
1017 size_t count;
1018 size_t total_namlen;
1019 file_ptr *offsets;
1020 boolean makemap;
1021 boolean hasobjects;
1022 file_ptr prevoff, nextoff;
1023 bfd *sub;
1024 unsigned int i;
1025 struct xcoff_ar_hdr ahdr;
1026 bfd_size_type size;
1027 char *p;
1028 char decbuf[13];
1029
1030 memset (&fhdr, 0, sizeof fhdr);
1031 strncpy (fhdr.magic, XCOFFARMAG, SXCOFFARMAG);
1032 sprintf (fhdr.firstmemoff, "%d", SIZEOF_AR_FILE_HDR);
1033 sprintf (fhdr.freeoff, "%d", 0);
1034
1035 count = 0;
1036 total_namlen = 0;
1037 for (sub = abfd->archive_head; sub != NULL; sub = sub->next)
1038 {
1039 ++count;
1040 total_namlen += strlen (normalize_filename (sub)) + 1;
1041 }
1042 offsets = (file_ptr *) bfd_alloc (abfd, count * sizeof (file_ptr));
1043 if (offsets == NULL)
1044 return false;
1045
1046 if (bfd_seek (abfd, SIZEOF_AR_FILE_HDR, SEEK_SET) != 0)
1047 return false;
1048
1049 makemap = bfd_has_map (abfd);
1050 hasobjects = false;
1051 prevoff = 0;
1052 nextoff = SIZEOF_AR_FILE_HDR;
1053 for (sub = abfd->archive_head, i = 0; sub != NULL; sub = sub->next, i++)
1054 {
1055 const char *name;
1056 size_t namlen;
1057 struct xcoff_ar_hdr *ahdrp;
1058 bfd_size_type remaining;
1059
1060 if (makemap && ! hasobjects)
1061 {
1062 if (bfd_check_format (sub, bfd_object))
1063 hasobjects = true;
1064 }
1065
1066 name = normalize_filename (sub);
1067 namlen = strlen (name);
1068
1069 if (sub->arelt_data != NULL)
1070 ahdrp = arch_xhdr (sub);
1071 else
1072 ahdrp = NULL;
1073
1074 if (ahdrp == NULL)
1075 {
1076 struct stat s;
1077
1078 memset (&ahdr, 0, sizeof ahdr);
1079 ahdrp = &ahdr;
1080 if (stat (bfd_get_filename (sub), &s) != 0)
1081 {
1082 bfd_set_error (bfd_error_system_call);
1083 return false;
1084 }
1085
1086 sprintf (ahdrp->size, "%ld", (long) s.st_size);
1087 sprintf (ahdrp->date, "%ld", (long) s.st_mtime);
1088 sprintf (ahdrp->uid, "%ld", (long) s.st_uid);
1089 sprintf (ahdrp->gid, "%ld", (long) s.st_gid);
1090 sprintf (ahdrp->mode, "%o", (unsigned int) s.st_mode);
1091
1092 if (sub->arelt_data == NULL)
1093 {
1094 sub->arelt_data = ((struct areltdata *)
1095 bfd_alloc (sub, sizeof (struct areltdata)));
1096 if (sub->arelt_data == NULL)
1097 return false;
1098 }
1099
1100 arch_eltdata (sub)->parsed_size = s.st_size;
1101 }
1102
1103 sprintf (ahdrp->prevoff, "%ld", (long) prevoff);
1104 sprintf (ahdrp->namlen, "%ld", (long) namlen);
1105
1106 /* If the length of the name is odd, we write out the null byte
1107 after the name as well. */
1108 namlen = (namlen + 1) &~ 1;
1109
1110 remaining = arelt_size (sub);
1111 size = (SIZEOF_AR_HDR
1112 + namlen
1113 + SXCOFFARFMAG
1114 + remaining);
1115
1116 BFD_ASSERT (nextoff == bfd_tell (abfd));
1117
1118 offsets[i] = nextoff;
1119
1120 prevoff = nextoff;
1121 nextoff += size + (size & 1);
1122
1123 sprintf (ahdrp->nextoff, "%ld", (long) nextoff);
1124
1125 /* We need spaces, not null bytes, in the header. */
1126 for (p = (char *) ahdrp; p < (char *) ahdrp + SIZEOF_AR_HDR; p++)
1127 if (*p == '\0')
1128 *p = ' ';
1129
1130 if (bfd_write ((PTR) ahdrp, 1, SIZEOF_AR_HDR, abfd) != SIZEOF_AR_HDR
1131 || bfd_write ((PTR) name, 1, namlen, abfd) != namlen
1132 || (bfd_write ((PTR) XCOFFARFMAG, 1, SXCOFFARFMAG, abfd)
1133 != SXCOFFARFMAG))
1134 return false;
1135
1136 if (bfd_seek (sub, (file_ptr) 0, SEEK_SET) != 0)
1137 return false;
1138 while (remaining != 0)
1139 {
1140 bfd_size_type amt;
1141 bfd_byte buffer[DEFAULT_BUFFERSIZE];
1142
1143 amt = sizeof buffer;
1144 if (amt > remaining)
1145 amt = remaining;
1146 if (bfd_read (buffer, 1, amt, sub) != amt
1147 || bfd_write (buffer, 1, amt, abfd) != amt)
1148 return false;
1149 remaining -= amt;
1150 }
1151
1152 if ((size & 1) != 0)
1153 {
1154 bfd_byte b;
1155
1156 b = '\0';
1157 if (bfd_write (&b, 1, 1, abfd) != 1)
1158 return false;
1159 }
1160 }
1161
1162 sprintf (fhdr.lastmemoff, "%ld", (long) prevoff);
1163
1164 /* Write out the member table. */
1165
1166 BFD_ASSERT (nextoff == bfd_tell (abfd));
1167 sprintf (fhdr.memoff, "%ld", (long) nextoff);
1168
1169 memset (&ahdr, 0, sizeof ahdr);
1170 sprintf (ahdr.size, "%ld", (long) (12 + count * 12 + total_namlen));
1171 sprintf (ahdr.prevoff, "%ld", (long) prevoff);
1172 sprintf (ahdr.date, "%d", 0);
1173 sprintf (ahdr.uid, "%d", 0);
1174 sprintf (ahdr.gid, "%d", 0);
1175 sprintf (ahdr.mode, "%d", 0);
1176 sprintf (ahdr.namlen, "%d", 0);
1177
1178 size = (SIZEOF_AR_HDR
1179 + 12
1180 + count * 12
1181 + total_namlen
1182 + SXCOFFARFMAG);
1183
1184 prevoff = nextoff;
1185 nextoff += size + (size & 1);
1186
1187 if (makemap && hasobjects)
1188 sprintf (ahdr.nextoff, "%ld", (long) nextoff);
1189 else
1190 sprintf (ahdr.nextoff, "%d", 0);
1191
1192 /* We need spaces, not null bytes, in the header. */
1193 for (p = (char *) &ahdr; p < (char *) &ahdr + SIZEOF_AR_HDR; p++)
1194 if (*p == '\0')
1195 *p = ' ';
1196
1197 if (bfd_write ((PTR) &ahdr, 1, SIZEOF_AR_HDR, abfd) != SIZEOF_AR_HDR
1198 || (bfd_write ((PTR) XCOFFARFMAG, 1, SXCOFFARFMAG, abfd)
1199 != SXCOFFARFMAG))
1200 return false;
1201
1202 sprintf (decbuf, "%-12ld", (long) count);
1203 if (bfd_write ((PTR) decbuf, 1, 12, abfd) != 12)
1204 return false;
1205 for (i = 0; i < count; i++)
1206 {
1207 sprintf (decbuf, "%-12ld", (long) offsets[i]);
1208 if (bfd_write ((PTR) decbuf, 1, 12, abfd) != 12)
1209 return false;
1210 }
1211 for (sub = abfd->archive_head; sub != NULL; sub = sub->next)
1212 {
1213 const char *name;
1214 size_t namlen;
1215
1216 name = normalize_filename (sub);
1217 namlen = strlen (name);
1218 if (bfd_write ((PTR) name, 1, namlen + 1, abfd) != namlen + 1)
1219 return false;
1220 }
1221 if ((size & 1) != 0)
1222 {
1223 bfd_byte b;
1224
1225 b = '\0';
1226 if (bfd_write ((PTR) &b, 1, 1, abfd) != 1)
1227 return false;
1228 }
1229
1230 /* Write out the armap, if appropriate. */
1231
1232 if (! makemap || ! hasobjects)
1233 sprintf (fhdr.symoff, "%d", 0);
1234 else
1235 {
1236 BFD_ASSERT (nextoff == bfd_tell (abfd));
1237 sprintf (fhdr.symoff, "%ld", (long) nextoff);
1238 bfd_ardata (abfd)->tdata = (PTR) &fhdr;
1239 if (! _bfd_compute_and_write_armap (abfd, 0))
1240 return false;
1241 }
1242
1243 /* Write out the archive file header. */
1244
1245 /* We need spaces, not null bytes, in the header. */
1246 for (p = (char *) &fhdr; p < (char *) &fhdr + SIZEOF_AR_FILE_HDR; p++)
1247 if (*p == '\0')
1248 *p = ' ';
1249
1250 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
1251 || (bfd_write ((PTR) &fhdr, SIZEOF_AR_FILE_HDR, 1, abfd) !=
1252 SIZEOF_AR_FILE_HDR))
1253 return false;
1254
1255 return true;
1256 }
1257 \f
1258 /* We can't use the usual coff_sizeof_headers routine, because AIX
1259 always uses an a.out header. */
1260
1261 /*ARGSUSED*/
1262 static int
1263 _bfd_xcoff_sizeof_headers (abfd, reloc)
1264 bfd *abfd;
1265 boolean reloc;
1266 {
1267 int size;
1268
1269 size = FILHSZ;
1270 if (xcoff_data (abfd)->full_aouthdr)
1271 size += AOUTSZ;
1272 else
1273 size += SMALL_AOUTSZ;
1274 size += abfd->section_count * SCNHSZ;
1275 return size;
1276 }
1277 \f
1278 #define CORE_FILE_P _bfd_dummy_target
1279
1280 #define coff_core_file_failing_command _bfd_nocore_core_file_failing_command
1281 #define coff_core_file_failing_signal _bfd_nocore_core_file_failing_signal
1282 #define coff_core_file_matches_executable_p \
1283 _bfd_nocore_core_file_matches_executable_p
1284
1285 #ifdef AIX_CORE
1286 #undef CORE_FILE_P
1287 #define CORE_FILE_P rs6000coff_core_p
1288 extern const bfd_target * rs6000coff_core_p ();
1289 extern boolean rs6000coff_get_section_contents ();
1290 extern boolean rs6000coff_core_file_matches_executable_p ();
1291
1292 #undef coff_core_file_matches_executable_p
1293 #define coff_core_file_matches_executable_p \
1294 rs6000coff_core_file_matches_executable_p
1295
1296 extern char *rs6000coff_core_file_failing_command PARAMS ((bfd *abfd));
1297 #undef coff_core_file_failing_command
1298 #define coff_core_file_failing_command rs6000coff_core_file_failing_command
1299
1300 extern int rs6000coff_core_file_failing_signal PARAMS ((bfd *abfd));
1301 #undef coff_core_file_failing_signal
1302 #define coff_core_file_failing_signal rs6000coff_core_file_failing_signal
1303
1304 #undef coff_get_section_contents
1305 #define coff_get_section_contents rs6000coff_get_section_contents
1306 #endif /* AIX_CORE */
1307
1308 #ifdef LYNX_CORE
1309
1310 #undef CORE_FILE_P
1311 #define CORE_FILE_P lynx_core_file_p
1312 extern const bfd_target *lynx_core_file_p PARAMS ((bfd *abfd));
1313
1314 extern boolean lynx_core_file_matches_executable_p PARAMS ((bfd *core_bfd,
1315 bfd *exec_bfd));
1316 #undef coff_core_file_matches_executable_p
1317 #define coff_core_file_matches_executable_p lynx_core_file_matches_executable_p
1318
1319 extern char *lynx_core_file_failing_command PARAMS ((bfd *abfd));
1320 #undef coff_core_file_failing_command
1321 #define coff_core_file_failing_command lynx_core_file_failing_command
1322
1323 extern int lynx_core_file_failing_signal PARAMS ((bfd *abfd));
1324 #undef coff_core_file_failing_signal
1325 #define coff_core_file_failing_signal lynx_core_file_failing_signal
1326
1327 #endif /* LYNX_CORE */
1328
1329 #define _bfd_xcoff_bfd_get_relocated_section_contents \
1330 coff_bfd_get_relocated_section_contents
1331 #define _bfd_xcoff_bfd_relax_section coff_bfd_relax_section
1332 #define _bfd_xcoff_bfd_link_split_section coff_bfd_link_split_section
1333
1334 /* The transfer vector that leads the outside world to all of the above. */
1335
1336 const bfd_target
1337 #ifdef TARGET_SYM
1338 TARGET_SYM =
1339 #else
1340 rs6000coff_vec =
1341 #endif
1342 {
1343 #ifdef TARGET_NAME
1344 TARGET_NAME,
1345 #else
1346 "aixcoff-rs6000", /* name */
1347 #endif
1348 bfd_target_coff_flavour,
1349 true, /* data byte order is big */
1350 true, /* header byte order is big */
1351
1352 (HAS_RELOC | EXEC_P | /* object flags */
1353 HAS_LINENO | HAS_DEBUG | DYNAMIC |
1354 HAS_SYMS | HAS_LOCALS | WP_TEXT),
1355
1356 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
1357 0, /* leading char */
1358 '/', /* ar_pad_char */
1359 15, /* ar_max_namelen??? FIXMEmgo */
1360
1361 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
1362 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
1363 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
1364 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
1365 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
1366 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
1367
1368 {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
1369 xcoff_archive_p, CORE_FILE_P},
1370 {bfd_false, coff_mkobject, /* bfd_set_format */
1371 _bfd_generic_mkarchive, bfd_false},
1372 {bfd_false, coff_write_object_contents, /* bfd_write_contents */
1373 xcoff_write_archive_contents, bfd_false},
1374
1375 BFD_JUMP_TABLE_GENERIC (coff),
1376 BFD_JUMP_TABLE_COPY (coff),
1377 BFD_JUMP_TABLE_CORE (coff),
1378 BFD_JUMP_TABLE_ARCHIVE (xcoff),
1379 BFD_JUMP_TABLE_SYMBOLS (coff),
1380 BFD_JUMP_TABLE_RELOCS (coff),
1381 BFD_JUMP_TABLE_WRITE (coff),
1382 BFD_JUMP_TABLE_LINK (_bfd_xcoff),
1383 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
1384
1385 COFF_SWAP_TABLE,
1386 };
This page took 0.058003 seconds and 4 git commands to generate.