1 /* Internal format of XCOFF object file data structures for BFD.
2 
3    Copyright (C) 1995-2021 Free Software Foundation, Inc.
4    Written by Ian Lance Taylor <ian@cygnus.com>, Cygnus Support.
5 
6    This file is part of BFD, the Binary File Descriptor library.
7 
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 3 of the License, or
11    (at your option) any later version.
12 
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17 
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21    MA 02110-1301, USA.  */
22 
23 #ifndef _INTERNAL_XCOFF_H
24 #define _INTERNAL_XCOFF_H
25 
26 /* XCOFF specific f_flags.  */
27 
28 /* File was profiled with fdpr.  */
29 #define F_FDPR_PROF 0x0010
30 
31 /* File was reordered with fdpr.  */
32 #define F_FDPR_OPTI 0x0020
33 
34 /* File use very large program support.  */
35 #define F_DSA       0x0040
36 
37 /* One aux header specifying medium page sizes is non-zero.  */
38 #define F_VARPG     0x0100
39 
40 /* Read/write sections are non-executable.  */
41 #define F_NONEXEC   0x8000
42 
43 /* Linker */
44 
45 /* Names of "special" sections.  */
46 #define _TEXT	".text"
47 #define _DATA	".data"
48 #define _BSS	".bss"
49 #define _TDATA	".tdata"
50 #define _TBSS	".tbss"
51 #define _PAD	".pad"
52 #define _LOADER	".loader"
53 #define _EXCEPT ".except"
54 #define _TYPCHK ".typchk"
55 
56 /* XCOFF uses special .dwXXX sections with the type STYP_DWARF.  */
57 #define STYP_DWARF  0x0010
58 
59 /* High-order 16-bits dwarf subtypes.  */
60 #define SSUBTYP_DWINFO  0x10000
61 #define SSUBTYP_DWLINE  0x20000
62 #define SSUBTYP_DWPBNMS 0x30000
63 #define SSUBTYP_DWPBTYP 0x40000
64 #define SSUBTYP_DWARNGE 0x50000
65 #define SSUBTYP_DWABREV 0x60000
66 #define SSUBTYP_DWSTR   0x70000
67 #define SSUBTYP_DWRNGES 0x80000
68 #define SSUBTYP_DWLOC   0x90000
69 #define SSUBTYP_DWFRAME 0xA0000
70 #define SSUBTYP_DWMAC   0xB0000
71 
72 /* XCOFF uses a special .loader section with type STYP_LOADER.  */
73 #define STYP_LOADER 0x1000
74 
75 /* Specifies an exception section.  A section of this type provides
76    information to identify the reason that a trap or ececptin occured within
77    and executable object program */
78 #define STYP_EXCEPT 0x0100
79 
80 /* Specifies an initialized thread-local data section.  */
81 #define STYP_TDATA  0x0400
82 
83 /* Specifies an uninitialized thread-local data section.  */
84 #define STYP_TBSS   0x0800
85 
86 /* XCOFF uses a special .debug section with type STYP_DEBUG.  */
87 #define STYP_DEBUG  0x2000
88 
89 /* Specifies a type check section.  A section of this type contains parameter
90    argument type check strings used by the AIX binder.  */
91 #define STYP_TYPCHK 0x4000
92 
93 /* XCOFF handles line number or relocation overflow by creating
94    another section header with STYP_OVRFLO set.  */
95 #define STYP_OVRFLO 0x8000
96 
97 #define	RS6K_AOUTHDR_OMAGIC 0x0107 /* old: text & data writeable */
98 #define	RS6K_AOUTHDR_NMAGIC 0x0108 /* new: text r/o, data r/w */
99 #define	RS6K_AOUTHDR_ZMAGIC 0x010B /* paged: text r/o, both page-aligned */
100 
101 /* Flags for aouthdr o_flags */
102 #define RS6K_AOUTHDR_TLS_LE    0x80  /* TLS local-exec code was generated */
103 #define RS6K_AOUTHDR_RAS       0x40  /* kernel module is key & recovery safe */
104 #define RS6K_AOUTHDR_ALGNTDATA 0xf   /* TLS alignment */
105 
106 /* Flags for aouthdr o_x64flags */
107 #define RS6K_AOUTHDR_SHR_SYMTAB  0x8000
108 #define RS6K_AOUTHDR_FORK_POLICY 0x4000
109 #define RS6K_AOUTHDR_FORK_COR    0x2000
110 
111 
112 /* XCOFF relocation types.
113    The relocations are described in the function
114    xcoff[64]_ppc_relocate_section in coff64-rs6000.c and coff-rs6000.c  */
115 
116 #define R_POS    (0x00)
117 #define R_NEG    (0x01)
118 #define R_REL    (0x02)
119 #define R_TOC    (0x03)
120 #define R_TRL    (0x04)
121 #define R_GL     (0x05)
122 #define R_TCL    (0x06)
123 #define R_BA     (0x08)
124 #define R_BR     (0x0a)
125 #define R_RL     (0x0c)
126 #define R_RLA    (0x0d)
127 #define R_REF    (0x0f)
128 #define R_TRLA   (0x13)
129 #define R_RRTBI  (0x14)
130 #define R_RRTBA  (0x15)
131 #define R_CAI    (0x16)
132 #define R_CREL   (0x17)
133 #define R_RBA    (0x18)
134 #define R_RBAC   (0x19)
135 #define R_RBR    (0x1a)
136 #define R_RBRC   (0x1b)
137 #define R_TLS    (0x20)
138 #define R_TLS_IE (0x21)
139 #define R_TLS_LD (0x22)
140 #define R_TLS_LE (0x23)
141 #define R_TLSM   (0x24)
142 #define R_TLSML  (0x25)
143 #define R_TOCU   (0x30)
144 #define R_TOCL   (0x31)
145 
146 /* Storage class #defines, from /usr/include/storclass.h that are not already
147    defined in internal.h */
148 
149 /* Comment string in .info section */
150 #define	C_INFO		110
151 
152 /* Dwarf symbol.  */
153 #define C_DWARF		112
154 
155 /* Auxillary Symbol Entries  */
156 
157 /* x_smtyp values:  */
158 #define	SMTYP_ALIGN(x)	((x) >> 3)	/* log2 of alignment */
159 #define	SMTYP_SMTYP(x)	((x) & 0x7)	/* symbol type */
160 /* Symbol type values:  */
161 #define	XTY_ER	0		/* External reference */
162 #define	XTY_SD	1		/* Csect definition */
163 #define	XTY_LD	2		/* Label definition */
164 #define XTY_CM	3		/* .BSS */
165 #define	XTY_EM	4		/* Error message */
166 #define	XTY_US	5		/* "Reserved for internal use" */
167 
168 /* x_smclas values:  */
169 #define	XMC_PR	0		/* Read-only program code */
170 #define	XMC_RO	1		/* Read-only constant */
171 #define	XMC_DB	2		/* Read-only debug dictionary table */
172 #define	XMC_TC	3		/* Read-write general TOC entry */
173 #define	XMC_UA	4		/* Read-write unclassified */
174 #define	XMC_RW	5		/* Read-write data */
175 #define	XMC_GL	6		/* Read-only global linkage */
176 #define	XMC_XO	7		/* Read-only extended operation */
177 #define	XMC_SV	8		/* Read-only supervisor call */
178 #define	XMC_BS	9		/* Read-write BSS */
179 #define	XMC_DS	10		/* Read-write descriptor csect */
180 #define	XMC_UC	11		/* Read-write unnamed Fortran common */
181 #define	XMC_TI	12		/* Read-only traceback index csect */
182 #define	XMC_TB	13		/* Read-only traceback table csect */
183 /* 		14	??? */
184 #define	XMC_TC0	15		/* Read-write TOC anchor */
185 #define XMC_TD	16		/* Read-write data in TOC */
186 #define	XMC_SV64   17		/* Read-only 64 bit supervisor call */
187 #define	XMC_SV3264 18		/* Read-only 32 or 64 bit supervisor call */
188 /*                19   ??? */
189 #define XMC_TL     20          /* Read-write initialized TLS data */
190 #define XMC_UL     21          /* Read-write uninitialized TLS data */
191 #define XMC_TE     22          /* Same as XMC_TC but mapped after it */
192 
193 /* The ldhdr structure.  This appears at the start of the .loader
194    section.  */
195 
196 struct internal_ldhdr
197 {
198   /* The version number:
199      1 : 32 bit
200      2 : 64 bit */
201   unsigned long l_version;
202 
203   /* The number of symbol table entries.  */
204   bfd_size_type l_nsyms;
205 
206   /* The number of relocation table entries.  */
207   bfd_size_type l_nreloc;
208 
209   /* The length of the import file string table.  */
210   bfd_size_type l_istlen;
211 
212   /* The number of import files.  */
213   bfd_size_type l_nimpid;
214 
215   /* The offset from the start of the .loader section to the first
216      entry in the import file table.  */
217   bfd_size_type l_impoff;
218 
219   /* The length of the string table.  */
220   bfd_size_type l_stlen;
221 
222   /* The offset from the start of the .loader section to the first
223      entry in the string table.  */
224   bfd_size_type l_stoff;
225 
226   /* The offset to start of the symbol table, only in XCOFF64 */
227   bfd_vma l_symoff;
228 
229   /* The offset to the start of the relocation table, only in XCOFF64 */
230   bfd_vma l_rldoff;
231 };
232 
233 /* The ldsym structure.  This is used to represent a symbol in the
234    .loader section.  */
235 
236 struct internal_ldsym
237 {
238   union
239   {
240     /* The symbol name if <= SYMNMLEN characters.  */
241     char _l_name[SYMNMLEN];
242     struct
243     {
244       /* Zero if the symbol name is more than SYMNMLEN characters.  */
245 	long _l_zeroes;
246 
247       /* The offset in the string table if the symbol name is more
248 	 than SYMNMLEN characters.  */
249       long _l_offset;
250     }
251     _l_l;
252   }
253   _l;
254 
255   /* The symbol value.  */
256   bfd_vma l_value;
257 
258   /* The symbol section number.  */
259   short l_scnum;
260 
261   /* The symbol type and flags.  */
262   char l_smtype;
263 
264   /* The symbol storage class.  */
265   char l_smclas;
266 
267   /* The import file ID.  */
268   bfd_size_type l_ifile;
269 
270   /* Offset to the parameter type check string.  */
271   bfd_size_type l_parm;
272 };
273 
274 /* These flags are for the l_smtype field (the lower three bits are an
275    XTY_* value).  */
276 
277 /* Imported symbol.  */
278 #define L_IMPORT (0x40)
279 /* Entry point.  */
280 #define L_ENTRY (0x20)
281 /* Exported symbol.  */
282 #define L_EXPORT (0x10)
283 /* Weak symbol.  */
284 #define L_WEAK (0x08)
285 
286 /* The ldrel structure.  This is used to represent a reloc in the
287    .loader section.  */
288 
289 struct internal_ldrel
290 {
291   /* The reloc address.  */
292   bfd_vma l_vaddr;
293 
294   /* The symbol table index in the .loader section symbol table.  */
295   bfd_size_type l_symndx;
296 
297   /* The relocation type and size.  */
298   short l_rtype;
299 
300   /* The section number this relocation applies to.  */
301   short l_rsecnm;
302 };
303 
304 /* An entry in the XCOFF linker hash table.  */
305 struct xcoff_link_hash_entry
306 {
307   struct bfd_link_hash_entry root;
308 
309   /* Symbol index in output file.  Set to -1 initially.  Set to -2 if
310      there is a reloc against this symbol.  */
311   long indx;
312 
313   /* If we have created a TOC entry for this symbol, this is the .tc
314      section which holds it.  */
315   asection *toc_section;
316 
317   union
318   {
319     /* If we have created a TOC entry (the XCOFF_SET_TOC flag is
320        set), this is the offset in toc_section.  */
321     bfd_vma toc_offset;
322 
323     /* If the TOC entry comes from an input file, this is set to the
324        symbol index of the C_HIDEXT XMC_TC or XMC_TD symbol.  */
325     long toc_indx;
326   }
327   u;
328 
329   /* If this symbol is a function entry point which is called, this
330      field holds a pointer to the function descriptor.  If this symbol
331      is a function descriptor, this field holds a pointer to the
332      function entry point.  */
333   struct xcoff_link_hash_entry *descriptor;
334 
335   /* The .loader symbol table entry, if there is one.  */
336   struct internal_ldsym *ldsym;
337 
338   /* If XCOFF_BUILT_LDSYM is set, this is the .loader symbol table
339      index.  If XCOFF_BUILD_LDSYM is clear, and XCOFF_IMPORT is set,
340      this is the l_ifile value.  */
341   long ldindx;
342 
343   /* Some linker flags.  */
344   unsigned long flags;
345 
346   /* The storage mapping class.  */
347   unsigned char smclas;
348 };
349 
350 /*  Flags for xcoff_link_hash_entry.  */
351 
352 /* Symbol is referenced by a regular object. */
353 #define XCOFF_REF_REGULAR      0x00000001
354 /* Symbol is defined by a regular object. */
355 #define XCOFF_DEF_REGULAR      0x00000002
356 /* Symbol is defined by a dynamic object. */
357 #define XCOFF_DEF_DYNAMIC      0x00000004
358 /* Symbol is used in a reloc being copied into the .loader section.  */
359 #define XCOFF_LDREL            0x00000008
360 /* Symbol is the entry point.  */
361 #define XCOFF_ENTRY            0x00000010
362 /* Symbol is for a function and is the target of a relocation.
363    The relocation may or may not be a branch-type relocation.  */
364 #define XCOFF_CALLED           0x00000020
365 /* Symbol needs the TOC entry filled in.  */
366 #define XCOFF_SET_TOC          0x00000040
367 /* Symbol is implicitly or explicitly imported.  */
368 #define XCOFF_IMPORT           0x00000080
369 /* Symbol is explicitly exported.  */
370 #define XCOFF_EXPORT           0x00000100
371 /* Symbol has been processed by xcoff_build_ldsyms.  */
372 #define XCOFF_BUILT_LDSYM      0x00000200
373 /* Symbol is mentioned by a section which was not garbage collected. */
374 #define XCOFF_MARK             0x00000400
375 /* Symbol size is recorded in size_list list from hash table.  */
376 #define XCOFF_HAS_SIZE         0x00000800
377 /* Symbol is a function descriptor.  */
378 #define XCOFF_DESCRIPTOR       0x00001000
379 /* Multiple definitions have been for the symbol. */
380 #define XCOFF_MULTIPLY_DEFINED 0x00002000
381 /* Symbol is the __rtinit symbol.  */
382 #define XCOFF_RTINIT           0x00004000
383 /* Symbol is an imported 32 bit syscall.  */
384 #define XCOFF_SYSCALL32        0x00008000
385 /* Symbol is an imported 64 bit syscall.  */
386 #define XCOFF_SYSCALL64        0x00010000
387 /* Symbol was not explicitly defined by the time it was marked.  */
388 #define XCOFF_WAS_UNDEFINED    0x00020000
389 /* We have assigned an output XCOFF entry to this symbol.  */
390 #define XCOFF_ALLOCATED	       0x00040000
391 
392 /* The XCOFF linker hash table.  */
393 
394 #define XCOFF_NUMBER_OF_SPECIAL_SECTIONS 6
395 #define XCOFF_SPECIAL_SECTION_TEXT       0
396 #define XCOFF_SPECIAL_SECTION_ETEXT      1
397 #define XCOFF_SPECIAL_SECTION_DATA       2
398 #define XCOFF_SPECIAL_SECTION_EDATA      3
399 #define XCOFF_SPECIAL_SECTION_END        4
400 #define XCOFF_SPECIAL_SECTION_END2       5
401 
402 /* These flags indicate which of -bexpall and -bexpfull are in effect.  */
403 #define XCOFF_EXPALL 1
404 #define XCOFF_EXPFULL 2
405 
406 /* This structure is used to pass information through
407    xcoff_link_hash_traverse.  */
408 
409 struct xcoff_loader_info
410 {
411   /* Set if a problem occurred.  */
412   bool failed;
413 
414   /* Output BFD.  */
415   bfd *output_bfd;
416 
417   /* Link information structure.  */
418   struct bfd_link_info *info;
419 
420   /* A mask of XCOFF_EXPALL and XCOFF_EXPFULL flags.  */
421   unsigned int auto_export_flags;
422 
423   /* Number of ldsym structures.  */
424   size_t ldsym_count;
425 
426   /* Size of string table.  */
427   size_t string_size;
428 
429   /* String table.  */
430   char *strings;
431 
432   /* Allocated size of string table.  */
433   size_t string_alc;
434 };
435 
436 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
437    from smaller values.  Start with zero, widen, *then* decrement.  */
438 #define MINUS_ONE       (((bfd_vma) 0) - 1)
439 
440 /* __rtinit, from /usr/include/rtinit.h.  */
441 struct __rtinit
442 {
443   /* Pointer to runtime linker.
444      XXX: Is the parameter really void?  */
445   int	(*rtl) (void);
446 
447   /* Offset to array of init functions, 0 if none. */
448   int	init_offset;
449 
450   /* Offset to array of fini functions, 0 if none. */
451   int	fini_offset;
452 
453   /* Size of __RTINIT_DESCRIPTOR. This value should be used instead of
454      sizeof(__RTINIT_DESCRIPTOR). */
455   int	__rtinit_descriptor_size;
456 };
457 
458 #define RTINIT_DESCRIPTOR_SIZE (12)
459 
460 struct __rtinit_descriptor
461 {
462   /* Init/fini function. */
463   int	f;
464 
465   /* Offset, relative to the start of the __rtinit symbol, to name of the
466      function. */
467 
468   int	name_offset;
469 
470   /* Flags */
471   unsigned char	flags;
472 };
473 
474 /* Archive */
475 
476 #define XCOFFARMAG    "<aiaff>\012"
477 #define XCOFFARMAGBIG "<bigaf>\012"
478 #define SXCOFFARMAG   8
479 
480 /* The size of the ascii archive elements */
481 #define XCOFFARMAG_ELEMENT_SIZE 12
482 #define XCOFFARMAGBIG_ELEMENT_SIZE 20
483 
484 /* This terminates an XCOFF archive member name.  */
485 
486 #define XCOFFARFMAG "`\012"
487 #define SXCOFFARFMAG 2
488 
489 /* XCOFF archives start with this (printable) structure.  */
490 
491 struct xcoff_ar_file_hdr
492 {
493   /* Magic string.  */
494   char magic[SXCOFFARMAG];
495 
496   /* Offset of the member table (decimal ASCII string).  */
497   char memoff[XCOFFARMAG_ELEMENT_SIZE];
498 
499   /* Offset of the global symbol table (decimal ASCII string).  */
500   char symoff[XCOFFARMAG_ELEMENT_SIZE];
501 
502   /* Offset of the first member in the archive (decimal ASCII string).  */
503   char firstmemoff[XCOFFARMAG_ELEMENT_SIZE];
504 
505   /* Offset of the last member in the archive (decimal ASCII string).  */
506   char lastmemoff[XCOFFARMAG_ELEMENT_SIZE];
507 
508   /* Offset of the first member on the free list (decimal ASCII
509      string).  */
510   char freeoff[XCOFFARMAG_ELEMENT_SIZE];
511 };
512 
513 #define SIZEOF_AR_FILE_HDR (SXCOFFARMAG + 5 * XCOFFARMAG_ELEMENT_SIZE)
514 
515 /* This is the equivalent data structure for the big archive format.  */
516 
517 struct xcoff_ar_file_hdr_big
518 {
519   /* Magic string.  */
520   char magic[SXCOFFARMAG];
521 
522   /* Offset of the member table (decimal ASCII string).  */
523   char memoff[XCOFFARMAGBIG_ELEMENT_SIZE];
524 
525   /* Offset of the global symbol table for 32-bit objects (decimal ASCII
526      string).  */
527   char symoff[XCOFFARMAGBIG_ELEMENT_SIZE];
528 
529   /* Offset of the global symbol table for 64-bit objects (decimal ASCII
530      string).  */
531   char symoff64[XCOFFARMAGBIG_ELEMENT_SIZE];
532 
533   /* Offset of the first member in the archive (decimal ASCII string).  */
534   char firstmemoff[XCOFFARMAGBIG_ELEMENT_SIZE];
535 
536   /* Offset of the last member in the archive (decimal ASCII string).  */
537   char lastmemoff[XCOFFARMAGBIG_ELEMENT_SIZE];
538 
539   /* Offset of the first member on the free list (decimal ASCII
540      string).  */
541   char freeoff[XCOFFARMAGBIG_ELEMENT_SIZE];
542 };
543 
544 #define SIZEOF_AR_FILE_HDR_BIG (SXCOFFARMAG + 6 * XCOFFARMAGBIG_ELEMENT_SIZE)
545 
546 /* Each XCOFF archive member starts with this (printable) structure.  */
547 
548 struct xcoff_ar_hdr
549 {
550   /* File size not including the header (decimal ASCII string).  */
551   char size[XCOFFARMAG_ELEMENT_SIZE];
552 
553   /* File offset of next archive member (decimal ASCII string).  */
554   char nextoff[XCOFFARMAG_ELEMENT_SIZE];
555 
556   /* File offset of previous archive member (decimal ASCII string).  */
557   char prevoff[XCOFFARMAG_ELEMENT_SIZE];
558 
559   /* File mtime (decimal ASCII string).  */
560   char date[12];
561 
562   /* File UID (decimal ASCII string).  */
563   char uid[12];
564 
565   /* File GID (decimal ASCII string).  */
566   char gid[12];
567 
568   /* File mode (octal ASCII string).  */
569   char mode[12];
570 
571   /* Length of file name (decimal ASCII string).  */
572   char namlen[4];
573 
574   /* This structure is followed by the file name.  The length of the
575      name is given in the namlen field.  If the length of the name is
576      odd, the name is followed by a null byte.  The name and optional
577      null byte are followed by XCOFFARFMAG, which is not included in
578      namlen.  The contents of the archive member follow; the number of
579      bytes is given in the size field.  */
580 };
581 
582 #define SIZEOF_AR_HDR (3 * XCOFFARMAG_ELEMENT_SIZE + 4 * 12 + 4)
583 
584 /* The equivalent for the big archive format.  */
585 
586 struct xcoff_ar_hdr_big
587 {
588   /* File size not including the header (decimal ASCII string).  */
589   char size[XCOFFARMAGBIG_ELEMENT_SIZE];
590 
591   /* File offset of next archive member (decimal ASCII string).  */
592   char nextoff[XCOFFARMAGBIG_ELEMENT_SIZE];
593 
594   /* File offset of previous archive member (decimal ASCII string).  */
595   char prevoff[XCOFFARMAGBIG_ELEMENT_SIZE];
596 
597   /* File mtime (decimal ASCII string).  */
598   char date[12];
599 
600   /* File UID (decimal ASCII string).  */
601   char uid[12];
602 
603   /* File GID (decimal ASCII string).  */
604   char gid[12];
605 
606   /* File mode (octal ASCII string).  */
607   char mode[12];
608 
609   /* Length of file name (decimal ASCII string).  */
610   char namlen[4];
611 
612   /* This structure is followed by the file name.  The length of the
613      name is given in the namlen field.  If the length of the name is
614      odd, the name is followed by a null byte.  The name and optional
615      null byte are followed by XCOFFARFMAG, which is not included in
616      namlen.  The contents of the archive member follow; the number of
617      bytes is given in the size field.  */
618 };
619 
620 #define SIZEOF_AR_HDR_BIG (3 * XCOFFARMAGBIG_ELEMENT_SIZE + 4 * 12 + 4)
621 
622 /* We often have to distinguish between the old and big file format.
623    Make it a bit cleaner.  We can use `xcoff_ardata' here because the
624    `hdr' member has the same size and position in both formats.
625    <bigaf> is the default format, return TRUE even when xcoff_ardata is
626    NULL. */
627 #ifndef SMALL_ARCHIVE
628 /* Creates big archives by default */
629 #define xcoff_big_format_p(abfd) \
630   ((NULL != bfd_ardata (abfd) && NULL == xcoff_ardata (abfd)) || \
631    ((NULL != bfd_ardata (abfd)) && \
632     (NULL != xcoff_ardata (abfd)) && \
633     (xcoff_ardata (abfd)->magic[1] == 'b')))
634 #else
635 /* Creates small archives by default. */
636 #define xcoff_big_format_p(abfd) \
637   (((NULL != bfd_ardata (abfd)) && \
638     (NULL != xcoff_ardata (abfd)) && \
639     (xcoff_ardata (abfd)->magic[1] == 'b')))
640 #endif
641 
642 /* We store a copy of the xcoff_ar_file_hdr in the tdata field of the
643    artdata structure.  Similar for the big archive.  */
644 #define xcoff_ardata(abfd) \
645   ((struct xcoff_ar_file_hdr *) bfd_ardata (abfd)->tdata)
646 #define xcoff_ardata_big(abfd) \
647   ((struct xcoff_ar_file_hdr_big *) bfd_ardata (abfd)->tdata)
648 
649 /* We store a copy of the xcoff_ar_hdr in the arelt_data field of an
650    archive element.  Similar for the big archive.  */
651 #define arch_eltdata(bfd) ((struct areltdata *) ((bfd)->arelt_data))
652 #define arch_xhdr(bfd) \
653   ((struct xcoff_ar_hdr *) arch_eltdata (bfd)->arch_header)
654 #define arch_xhdr_big(bfd) \
655   ((struct xcoff_ar_hdr_big *) arch_eltdata (bfd)->arch_header)
656 
657 /* True if symbols of class CLASS are external.  */
658 #define EXTERN_SYM_P(CLASS) \
659   ((CLASS) == C_EXT || (CLASS) == C_AIX_WEAKEXT)
660 
661 #endif /* _INTERNAL_XCOFF_H */
662