update copyrights
[deliverable/binutils-gdb.git] / bfd / coff-rs6000.c
1 /* BFD back-end for IBM RS/6000 "XCOFF" files.
2 Copyright 1990, 91, 92, 93, 94, 95, 1996 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 /* We can use the standard get_elt_at_index routine. */
662
663 #define xcoff_get_elt_at_index _bfd_generic_get_elt_at_index
664
665 /* XCOFF archives do not have a timestamp. */
666
667 #define xcoff_update_armap_timestamp bfd_true
668
669 /* Read in the armap of an XCOFF archive. */
670
671 static boolean
672 xcoff_slurp_armap (abfd)
673 bfd *abfd;
674 {
675 file_ptr off;
676 struct xcoff_ar_hdr hdr;
677 size_t namlen;
678 bfd_size_type sz;
679 bfd_byte *contents, *cend;
680 unsigned int c, i;
681 carsym *arsym;
682 bfd_byte *p;
683
684 if (xcoff_ardata (abfd) == NULL)
685 {
686 bfd_has_map (abfd) = false;
687 return true;
688 }
689
690 off = strtol (xcoff_ardata (abfd)->symoff, (char **) NULL, 10);
691 if (off == 0)
692 {
693 bfd_has_map (abfd) = false;
694 return true;
695 }
696
697 if (bfd_seek (abfd, off, SEEK_SET) != 0)
698 return false;
699
700 /* The symbol table starts with a normal archive header. */
701 if (bfd_read ((PTR) &hdr, SIZEOF_AR_HDR, 1, abfd) != SIZEOF_AR_HDR)
702 return false;
703
704 /* Skip the name (normally empty). */
705 namlen = strtol (hdr.namlen, (char **) NULL, 10);
706 if (bfd_seek (abfd, ((namlen + 1) & ~1) + SXCOFFARFMAG, SEEK_CUR) != 0)
707 return false;
708
709 /* Read in the entire symbol table. */
710 sz = strtol (hdr.size, (char **) NULL, 10);
711 contents = (bfd_byte *) bfd_alloc (abfd, sz);
712 if (contents == NULL)
713 return false;
714 if (bfd_read ((PTR) contents, 1, sz, abfd) != sz)
715 return false;
716
717 /* The symbol table starts with a four byte count. */
718 c = bfd_h_get_32 (abfd, contents);
719
720 if (c * 4 >= sz)
721 {
722 bfd_set_error (bfd_error_bad_value);
723 return false;
724 }
725
726 bfd_ardata (abfd)->symdefs = ((carsym *)
727 bfd_alloc (abfd, c * sizeof (carsym)));
728 if (bfd_ardata (abfd)->symdefs == NULL)
729 return false;
730
731 /* After the count comes a list of four byte file offsets. */
732 for (i = 0, arsym = bfd_ardata (abfd)->symdefs, p = contents + 4;
733 i < c;
734 ++i, ++arsym, p += 4)
735 arsym->file_offset = bfd_h_get_32 (abfd, p);
736
737 /* After the file offsets come null terminated symbol names. */
738 cend = contents + sz;
739 for (i = 0, arsym = bfd_ardata (abfd)->symdefs;
740 i < c;
741 ++i, ++arsym, p += strlen ((char *) p) + 1)
742 {
743 if (p >= cend)
744 {
745 bfd_set_error (bfd_error_bad_value);
746 return false;
747 }
748 arsym->name = (char *) p;
749 }
750
751 bfd_ardata (abfd)->symdef_count = c;
752 bfd_has_map (abfd) = true;
753
754 return true;
755 }
756
757 /* See if this is an XCOFF archive. */
758
759 static const bfd_target *
760 xcoff_archive_p (abfd)
761 bfd *abfd;
762 {
763 struct xcoff_ar_file_hdr hdr;
764
765 if (bfd_read ((PTR) &hdr, SIZEOF_AR_FILE_HDR, 1, abfd)
766 != SIZEOF_AR_FILE_HDR)
767 {
768 if (bfd_get_error () != bfd_error_system_call)
769 bfd_set_error (bfd_error_wrong_format);
770 return NULL;
771 }
772
773 if (strncmp (hdr.magic, XCOFFARMAG, SXCOFFARMAG) != 0)
774 {
775 bfd_set_error (bfd_error_wrong_format);
776 return NULL;
777 }
778
779 /* We are setting bfd_ardata(abfd) here, but since bfd_ardata
780 involves a cast, we can't do it as the left operand of
781 assignment. */
782 abfd->tdata.aout_ar_data =
783 (struct artdata *) bfd_zalloc (abfd, sizeof (struct artdata));
784
785 if (bfd_ardata (abfd) == (struct artdata *) NULL)
786 return NULL;
787
788 bfd_ardata (abfd)->first_file_filepos = strtol (hdr.firstmemoff,
789 (char **) NULL, 10);
790 bfd_ardata (abfd)->cache = NULL;
791 bfd_ardata (abfd)->archive_head = NULL;
792 bfd_ardata (abfd)->symdefs = NULL;
793 bfd_ardata (abfd)->extended_names = NULL;
794
795 bfd_ardata (abfd)->tdata = bfd_zalloc (abfd, SIZEOF_AR_FILE_HDR);
796 if (bfd_ardata (abfd)->tdata == NULL)
797 return NULL;
798
799 memcpy (bfd_ardata (abfd)->tdata, &hdr, SIZEOF_AR_FILE_HDR);
800
801 if (! xcoff_slurp_armap (abfd))
802 {
803 bfd_release (abfd, bfd_ardata (abfd));
804 abfd->tdata.aout_ar_data = (struct artdata *) NULL;
805 return NULL;
806 }
807
808 return abfd->xvec;
809 }
810
811 /* Read the archive header in an XCOFF archive. */
812
813 static PTR
814 xcoff_read_ar_hdr (abfd)
815 bfd *abfd;
816 {
817 struct xcoff_ar_hdr hdr;
818 size_t namlen;
819 struct xcoff_ar_hdr *hdrp;
820 struct areltdata *ret;
821
822 if (bfd_read ((PTR) &hdr, SIZEOF_AR_HDR, 1, abfd) != SIZEOF_AR_HDR)
823 return NULL;
824
825 namlen = strtol (hdr.namlen, (char **) NULL, 10);
826 hdrp = bfd_alloc (abfd, SIZEOF_AR_HDR + namlen + 1);
827 if (hdrp == NULL)
828 return NULL;
829 memcpy (hdrp, &hdr, SIZEOF_AR_HDR);
830 if (bfd_read ((char *) hdrp + SIZEOF_AR_HDR, 1, namlen, abfd) != namlen)
831 return NULL;
832 ((char *) hdrp)[SIZEOF_AR_HDR + namlen] = '\0';
833
834 ret = (struct areltdata *) bfd_alloc (abfd, sizeof (struct areltdata));
835 if (ret == NULL)
836 return NULL;
837 ret->arch_header = (char *) hdrp;
838 ret->parsed_size = strtol (hdr.size, (char **) NULL, 10);
839 ret->filename = (char *) hdrp + SIZEOF_AR_HDR;
840
841 /* Skip over the XCOFFARFMAG at the end of the file name. */
842 if (bfd_seek (abfd, (namlen & 1) + SXCOFFARFMAG, SEEK_CUR) != 0)
843 return NULL;
844
845 return (PTR) ret;
846 }
847
848 /* Open the next element in an XCOFF archive. */
849
850 static bfd *
851 xcoff_openr_next_archived_file (archive, last_file)
852 bfd *archive;
853 bfd *last_file;
854 {
855 file_ptr filestart;
856
857 if (xcoff_ardata (archive) == NULL)
858 {
859 bfd_set_error (bfd_error_invalid_operation);
860 return NULL;
861 }
862
863 if (last_file == NULL)
864 filestart = bfd_ardata (archive)->first_file_filepos;
865 else
866 filestart = strtol (arch_xhdr (last_file)->nextoff, (char **) NULL, 10);
867
868 if (filestart == 0
869 || filestart == strtol (xcoff_ardata (archive)->memoff,
870 (char **) NULL, 10)
871 || filestart == strtol (xcoff_ardata (archive)->symoff,
872 (char **) NULL, 10))
873 {
874 bfd_set_error (bfd_error_no_more_archived_files);
875 return NULL;
876 }
877
878 return _bfd_get_elt_at_filepos (archive, filestart);
879 }
880
881 /* Stat an element in an XCOFF archive. */
882
883 static int
884 xcoff_generic_stat_arch_elt (abfd, s)
885 bfd *abfd;
886 struct stat *s;
887 {
888 struct xcoff_ar_hdr *hdrp;
889
890 if (abfd->arelt_data == NULL)
891 {
892 bfd_set_error (bfd_error_invalid_operation);
893 return -1;
894 }
895
896 hdrp = arch_xhdr (abfd);
897
898 s->st_mtime = strtol (hdrp->date, (char **) NULL, 10);
899 s->st_uid = strtol (hdrp->uid, (char **) NULL, 10);
900 s->st_gid = strtol (hdrp->gid, (char **) NULL, 10);
901 s->st_mode = strtol (hdrp->mode, (char **) NULL, 8);
902 s->st_size = arch_eltdata (abfd)->parsed_size;
903
904 return 0;
905 }
906
907 /* Normalize a file name for inclusion in an archive. */
908
909 static const char *
910 normalize_filename (abfd)
911 bfd *abfd;
912 {
913 const char *file;
914 const char *filename;
915
916 file = bfd_get_filename (abfd);
917 filename = strrchr (file, '/');
918 if (filename != NULL)
919 filename++;
920 else
921 filename = file;
922 return filename;
923 }
924
925 /* Write out an XCOFF armap. */
926
927 /*ARGSUSED*/
928 static boolean
929 xcoff_write_armap (abfd, elength, map, orl_count, stridx)
930 bfd *abfd;
931 unsigned int elength;
932 struct orl *map;
933 unsigned int orl_count;
934 int stridx;
935 {
936 struct xcoff_ar_hdr hdr;
937 char *p;
938 unsigned char buf[4];
939 bfd *sub;
940 file_ptr fileoff;
941 unsigned int i;
942
943 memset (&hdr, 0, sizeof hdr);
944 sprintf (hdr.size, "%ld", (long) (4 + orl_count * 4 + stridx));
945 sprintf (hdr.nextoff, "%d", 0);
946 memcpy (hdr.prevoff, xcoff_ardata (abfd)->memoff, 12);
947 sprintf (hdr.date, "%d", 0);
948 sprintf (hdr.uid, "%d", 0);
949 sprintf (hdr.gid, "%d", 0);
950 sprintf (hdr.mode, "%d", 0);
951 sprintf (hdr.namlen, "%d", 0);
952
953 /* We need spaces, not null bytes, in the header. */
954 for (p = (char *) &hdr; p < (char *) &hdr + SIZEOF_AR_HDR; p++)
955 if (*p == '\0')
956 *p = ' ';
957
958 if (bfd_write ((PTR) &hdr, SIZEOF_AR_HDR, 1, abfd) != SIZEOF_AR_HDR
959 || bfd_write (XCOFFARFMAG, 1, SXCOFFARFMAG, abfd) != SXCOFFARFMAG)
960 return false;
961
962 bfd_h_put_32 (abfd, orl_count, buf);
963 if (bfd_write (buf, 1, 4, abfd) != 4)
964 return false;
965
966 sub = abfd->archive_head;
967 fileoff = SIZEOF_AR_FILE_HDR;
968 i = 0;
969 while (sub != NULL && i < orl_count)
970 {
971 size_t namlen;
972
973 while (((bfd *) (map[i]).pos) == sub)
974 {
975 bfd_h_put_32 (abfd, fileoff, buf);
976 if (bfd_write (buf, 1, 4, abfd) != 4)
977 return false;
978 ++i;
979 }
980 namlen = strlen (normalize_filename (sub));
981 namlen = (namlen + 1) &~ 1;
982 fileoff += (SIZEOF_AR_HDR
983 + namlen
984 + SXCOFFARFMAG
985 + arelt_size (sub));
986 fileoff = (fileoff + 1) &~ 1;
987 sub = sub->next;
988 }
989
990 for (i = 0; i < orl_count; i++)
991 {
992 const char *name;
993 size_t namlen;
994
995 name = *map[i].name;
996 namlen = strlen (name);
997 if (bfd_write (name, 1, namlen + 1, abfd) != namlen + 1)
998 return false;
999 }
1000
1001 if ((stridx & 1) != 0)
1002 {
1003 char b;
1004
1005 b = '\0';
1006 if (bfd_write (&b, 1, 1, abfd) != 1)
1007 return false;
1008 }
1009
1010 return true;
1011 }
1012
1013 /* Write out an XCOFF archive. We always write an entire archive,
1014 rather than fussing with the freelist and so forth. */
1015
1016 static boolean
1017 xcoff_write_archive_contents (abfd)
1018 bfd *abfd;
1019 {
1020 struct xcoff_ar_file_hdr fhdr;
1021 size_t count;
1022 size_t total_namlen;
1023 file_ptr *offsets;
1024 boolean makemap;
1025 boolean hasobjects;
1026 file_ptr prevoff, nextoff;
1027 bfd *sub;
1028 unsigned int i;
1029 struct xcoff_ar_hdr ahdr;
1030 bfd_size_type size;
1031 char *p;
1032 char decbuf[13];
1033
1034 memset (&fhdr, 0, sizeof fhdr);
1035 strncpy (fhdr.magic, XCOFFARMAG, SXCOFFARMAG);
1036 sprintf (fhdr.firstmemoff, "%d", SIZEOF_AR_FILE_HDR);
1037 sprintf (fhdr.freeoff, "%d", 0);
1038
1039 count = 0;
1040 total_namlen = 0;
1041 for (sub = abfd->archive_head; sub != NULL; sub = sub->next)
1042 {
1043 ++count;
1044 total_namlen += strlen (normalize_filename (sub)) + 1;
1045 }
1046 offsets = (file_ptr *) bfd_alloc (abfd, count * sizeof (file_ptr));
1047 if (offsets == NULL)
1048 return false;
1049
1050 if (bfd_seek (abfd, SIZEOF_AR_FILE_HDR, SEEK_SET) != 0)
1051 return false;
1052
1053 makemap = bfd_has_map (abfd);
1054 hasobjects = false;
1055 prevoff = 0;
1056 nextoff = SIZEOF_AR_FILE_HDR;
1057 for (sub = abfd->archive_head, i = 0; sub != NULL; sub = sub->next, i++)
1058 {
1059 const char *name;
1060 size_t namlen;
1061 struct xcoff_ar_hdr *ahdrp;
1062 bfd_size_type remaining;
1063
1064 if (makemap && ! hasobjects)
1065 {
1066 if (bfd_check_format (sub, bfd_object))
1067 hasobjects = true;
1068 }
1069
1070 name = normalize_filename (sub);
1071 namlen = strlen (name);
1072
1073 if (sub->arelt_data != NULL)
1074 ahdrp = arch_xhdr (sub);
1075 else
1076 ahdrp = NULL;
1077
1078 if (ahdrp == NULL)
1079 {
1080 struct stat s;
1081
1082 memset (&ahdr, 0, sizeof ahdr);
1083 ahdrp = &ahdr;
1084 if (stat (bfd_get_filename (sub), &s) != 0)
1085 {
1086 bfd_set_error (bfd_error_system_call);
1087 return false;
1088 }
1089
1090 sprintf (ahdrp->size, "%ld", (long) s.st_size);
1091 sprintf (ahdrp->date, "%ld", (long) s.st_mtime);
1092 sprintf (ahdrp->uid, "%ld", (long) s.st_uid);
1093 sprintf (ahdrp->gid, "%ld", (long) s.st_gid);
1094 sprintf (ahdrp->mode, "%o", (unsigned int) s.st_mode);
1095
1096 if (sub->arelt_data == NULL)
1097 {
1098 sub->arelt_data = ((struct areltdata *)
1099 bfd_alloc (sub, sizeof (struct areltdata)));
1100 if (sub->arelt_data == NULL)
1101 return false;
1102 }
1103
1104 arch_eltdata (sub)->parsed_size = s.st_size;
1105 }
1106
1107 sprintf (ahdrp->prevoff, "%ld", (long) prevoff);
1108 sprintf (ahdrp->namlen, "%ld", (long) namlen);
1109
1110 /* If the length of the name is odd, we write out the null byte
1111 after the name as well. */
1112 namlen = (namlen + 1) &~ 1;
1113
1114 remaining = arelt_size (sub);
1115 size = (SIZEOF_AR_HDR
1116 + namlen
1117 + SXCOFFARFMAG
1118 + remaining);
1119
1120 BFD_ASSERT (nextoff == bfd_tell (abfd));
1121
1122 offsets[i] = nextoff;
1123
1124 prevoff = nextoff;
1125 nextoff += size + (size & 1);
1126
1127 sprintf (ahdrp->nextoff, "%ld", (long) nextoff);
1128
1129 /* We need spaces, not null bytes, in the header. */
1130 for (p = (char *) ahdrp; p < (char *) ahdrp + SIZEOF_AR_HDR; p++)
1131 if (*p == '\0')
1132 *p = ' ';
1133
1134 if (bfd_write ((PTR) ahdrp, 1, SIZEOF_AR_HDR, abfd) != SIZEOF_AR_HDR
1135 || bfd_write ((PTR) name, 1, namlen, abfd) != namlen
1136 || (bfd_write ((PTR) XCOFFARFMAG, 1, SXCOFFARFMAG, abfd)
1137 != SXCOFFARFMAG))
1138 return false;
1139
1140 if (bfd_seek (sub, (file_ptr) 0, SEEK_SET) != 0)
1141 return false;
1142 while (remaining != 0)
1143 {
1144 bfd_size_type amt;
1145 bfd_byte buffer[DEFAULT_BUFFERSIZE];
1146
1147 amt = sizeof buffer;
1148 if (amt > remaining)
1149 amt = remaining;
1150 if (bfd_read (buffer, 1, amt, sub) != amt
1151 || bfd_write (buffer, 1, amt, abfd) != amt)
1152 return false;
1153 remaining -= amt;
1154 }
1155
1156 if ((size & 1) != 0)
1157 {
1158 bfd_byte b;
1159
1160 b = '\0';
1161 if (bfd_write (&b, 1, 1, abfd) != 1)
1162 return false;
1163 }
1164 }
1165
1166 sprintf (fhdr.lastmemoff, "%ld", (long) prevoff);
1167
1168 /* Write out the member table. */
1169
1170 BFD_ASSERT (nextoff == bfd_tell (abfd));
1171 sprintf (fhdr.memoff, "%ld", (long) nextoff);
1172
1173 memset (&ahdr, 0, sizeof ahdr);
1174 sprintf (ahdr.size, "%ld", (long) (12 + count * 12 + total_namlen));
1175 sprintf (ahdr.prevoff, "%ld", (long) prevoff);
1176 sprintf (ahdr.date, "%d", 0);
1177 sprintf (ahdr.uid, "%d", 0);
1178 sprintf (ahdr.gid, "%d", 0);
1179 sprintf (ahdr.mode, "%d", 0);
1180 sprintf (ahdr.namlen, "%d", 0);
1181
1182 size = (SIZEOF_AR_HDR
1183 + 12
1184 + count * 12
1185 + total_namlen
1186 + SXCOFFARFMAG);
1187
1188 prevoff = nextoff;
1189 nextoff += size + (size & 1);
1190
1191 if (makemap && hasobjects)
1192 sprintf (ahdr.nextoff, "%ld", (long) nextoff);
1193 else
1194 sprintf (ahdr.nextoff, "%d", 0);
1195
1196 /* We need spaces, not null bytes, in the header. */
1197 for (p = (char *) &ahdr; p < (char *) &ahdr + SIZEOF_AR_HDR; p++)
1198 if (*p == '\0')
1199 *p = ' ';
1200
1201 if (bfd_write ((PTR) &ahdr, 1, SIZEOF_AR_HDR, abfd) != SIZEOF_AR_HDR
1202 || (bfd_write ((PTR) XCOFFARFMAG, 1, SXCOFFARFMAG, abfd)
1203 != SXCOFFARFMAG))
1204 return false;
1205
1206 sprintf (decbuf, "%-12ld", (long) count);
1207 if (bfd_write ((PTR) decbuf, 1, 12, abfd) != 12)
1208 return false;
1209 for (i = 0; i < count; i++)
1210 {
1211 sprintf (decbuf, "%-12ld", (long) offsets[i]);
1212 if (bfd_write ((PTR) decbuf, 1, 12, abfd) != 12)
1213 return false;
1214 }
1215 for (sub = abfd->archive_head; sub != NULL; sub = sub->next)
1216 {
1217 const char *name;
1218 size_t namlen;
1219
1220 name = normalize_filename (sub);
1221 namlen = strlen (name);
1222 if (bfd_write ((PTR) name, 1, namlen + 1, abfd) != namlen + 1)
1223 return false;
1224 }
1225 if ((size & 1) != 0)
1226 {
1227 bfd_byte b;
1228
1229 b = '\0';
1230 if (bfd_write ((PTR) &b, 1, 1, abfd) != 1)
1231 return false;
1232 }
1233
1234 /* Write out the armap, if appropriate. */
1235
1236 if (! makemap || ! hasobjects)
1237 sprintf (fhdr.symoff, "%d", 0);
1238 else
1239 {
1240 BFD_ASSERT (nextoff == bfd_tell (abfd));
1241 sprintf (fhdr.symoff, "%ld", (long) nextoff);
1242 bfd_ardata (abfd)->tdata = (PTR) &fhdr;
1243 if (! _bfd_compute_and_write_armap (abfd, 0))
1244 return false;
1245 }
1246
1247 /* Write out the archive file header. */
1248
1249 /* We need spaces, not null bytes, in the header. */
1250 for (p = (char *) &fhdr; p < (char *) &fhdr + SIZEOF_AR_FILE_HDR; p++)
1251 if (*p == '\0')
1252 *p = ' ';
1253
1254 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
1255 || (bfd_write ((PTR) &fhdr, SIZEOF_AR_FILE_HDR, 1, abfd) !=
1256 SIZEOF_AR_FILE_HDR))
1257 return false;
1258
1259 return true;
1260 }
1261 \f
1262 /* We can't use the usual coff_sizeof_headers routine, because AIX
1263 always uses an a.out header. */
1264
1265 /*ARGSUSED*/
1266 static int
1267 _bfd_xcoff_sizeof_headers (abfd, reloc)
1268 bfd *abfd;
1269 boolean reloc;
1270 {
1271 int size;
1272
1273 size = FILHSZ;
1274 if (xcoff_data (abfd)->full_aouthdr)
1275 size += AOUTSZ;
1276 else
1277 size += SMALL_AOUTSZ;
1278 size += abfd->section_count * SCNHSZ;
1279 return size;
1280 }
1281 \f
1282 #define CORE_FILE_P _bfd_dummy_target
1283
1284 #define coff_core_file_failing_command _bfd_nocore_core_file_failing_command
1285 #define coff_core_file_failing_signal _bfd_nocore_core_file_failing_signal
1286 #define coff_core_file_matches_executable_p \
1287 _bfd_nocore_core_file_matches_executable_p
1288
1289 #ifdef AIX_CORE
1290 #undef CORE_FILE_P
1291 #define CORE_FILE_P rs6000coff_core_p
1292 extern const bfd_target * rs6000coff_core_p ();
1293 extern boolean rs6000coff_get_section_contents ();
1294 extern boolean rs6000coff_core_file_matches_executable_p ();
1295
1296 #undef coff_core_file_matches_executable_p
1297 #define coff_core_file_matches_executable_p \
1298 rs6000coff_core_file_matches_executable_p
1299
1300 extern char *rs6000coff_core_file_failing_command PARAMS ((bfd *abfd));
1301 #undef coff_core_file_failing_command
1302 #define coff_core_file_failing_command rs6000coff_core_file_failing_command
1303
1304 extern int rs6000coff_core_file_failing_signal PARAMS ((bfd *abfd));
1305 #undef coff_core_file_failing_signal
1306 #define coff_core_file_failing_signal rs6000coff_core_file_failing_signal
1307
1308 #undef coff_get_section_contents
1309 #define coff_get_section_contents rs6000coff_get_section_contents
1310 #endif /* AIX_CORE */
1311
1312 #ifdef LYNX_CORE
1313
1314 #undef CORE_FILE_P
1315 #define CORE_FILE_P lynx_core_file_p
1316 extern const bfd_target *lynx_core_file_p PARAMS ((bfd *abfd));
1317
1318 extern boolean lynx_core_file_matches_executable_p PARAMS ((bfd *core_bfd,
1319 bfd *exec_bfd));
1320 #undef coff_core_file_matches_executable_p
1321 #define coff_core_file_matches_executable_p lynx_core_file_matches_executable_p
1322
1323 extern char *lynx_core_file_failing_command PARAMS ((bfd *abfd));
1324 #undef coff_core_file_failing_command
1325 #define coff_core_file_failing_command lynx_core_file_failing_command
1326
1327 extern int lynx_core_file_failing_signal PARAMS ((bfd *abfd));
1328 #undef coff_core_file_failing_signal
1329 #define coff_core_file_failing_signal lynx_core_file_failing_signal
1330
1331 #endif /* LYNX_CORE */
1332
1333 #define _bfd_xcoff_bfd_get_relocated_section_contents \
1334 coff_bfd_get_relocated_section_contents
1335 #define _bfd_xcoff_bfd_relax_section coff_bfd_relax_section
1336 #define _bfd_xcoff_bfd_link_split_section coff_bfd_link_split_section
1337
1338 /* The transfer vector that leads the outside world to all of the above. */
1339
1340 const bfd_target
1341 #ifdef TARGET_SYM
1342 TARGET_SYM =
1343 #else
1344 rs6000coff_vec =
1345 #endif
1346 {
1347 #ifdef TARGET_NAME
1348 TARGET_NAME,
1349 #else
1350 "aixcoff-rs6000", /* name */
1351 #endif
1352 bfd_target_coff_flavour,
1353 BFD_ENDIAN_BIG, /* data byte order is big */
1354 BFD_ENDIAN_BIG, /* header byte order is big */
1355
1356 (HAS_RELOC | EXEC_P | /* object flags */
1357 HAS_LINENO | HAS_DEBUG | DYNAMIC |
1358 HAS_SYMS | HAS_LOCALS | WP_TEXT),
1359
1360 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
1361 0, /* leading char */
1362 '/', /* ar_pad_char */
1363 15, /* ar_max_namelen??? FIXMEmgo */
1364
1365 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
1366 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
1367 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
1368 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
1369 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
1370 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
1371
1372 {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
1373 xcoff_archive_p, CORE_FILE_P},
1374 {bfd_false, coff_mkobject, /* bfd_set_format */
1375 _bfd_generic_mkarchive, bfd_false},
1376 {bfd_false, coff_write_object_contents, /* bfd_write_contents */
1377 xcoff_write_archive_contents, bfd_false},
1378
1379 BFD_JUMP_TABLE_GENERIC (coff),
1380 BFD_JUMP_TABLE_COPY (coff),
1381 BFD_JUMP_TABLE_CORE (coff),
1382 BFD_JUMP_TABLE_ARCHIVE (xcoff),
1383 BFD_JUMP_TABLE_SYMBOLS (coff),
1384 BFD_JUMP_TABLE_RELOCS (coff),
1385 BFD_JUMP_TABLE_WRITE (coff),
1386 BFD_JUMP_TABLE_LINK (_bfd_xcoff),
1387 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
1388
1389 COFF_SWAP_TABLE,
1390 };
This page took 0.065275 seconds and 5 git commands to generate.