]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - include/coff/xcoff.h
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / include / coff / xcoff.h
CommitLineData
3dd657b1
TR
1/* Internal format of XCOFF object file data structures for BFD.
2
a2c58332 3 Copyright (C) 1995-2022 Free Software Foundation, Inc.
3dd657b1
TR
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
e4e42b45 10 the Free Software Foundation; either version 3 of the License, or
3dd657b1
TR
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
e4e42b45
NC
20 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 MA 02110-1301, USA. */
3dd657b1
TR
22
23#ifndef _INTERNAL_XCOFF_H
24#define _INTERNAL_XCOFF_H
25
8db6dd6a
TG
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
54c95892 43/* Linker */
3dd657b1 44
54c95892 45/* Names of "special" sections. */
3dd657b1
TR
46#define _TEXT ".text"
47#define _DATA ".data"
48#define _BSS ".bss"
1b2cb8e2
CC
49#define _TDATA ".tdata"
50#define _TBSS ".tbss"
3dd657b1
TR
51#define _PAD ".pad"
52#define _LOADER ".loader"
f94cac65
TR
53#define _EXCEPT ".except"
54#define _TYPCHK ".typchk"
3dd657b1 55
8db6dd6a
TG
56/* XCOFF uses special .dwXXX sections with the type STYP_DWARF. */
57#define STYP_DWARF 0x0010
3dd657b1 58
8db6dd6a
TG
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
97834047
CC
68#define SSUBTYP_DWLOC 0x90000
69#define SSUBTYP_DWFRAME 0xA0000
70#define SSUBTYP_DWMAC 0xB0000
3dd657b1 71
8db6dd6a
TG
72/* XCOFF uses a special .loader section with type STYP_LOADER. */
73#define STYP_LOADER 0x1000
3dd657b1 74
67fdeebe
TR
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
8db6dd6a
TG
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
67fdeebe
TR
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
8db6dd6a
TG
93/* XCOFF handles line number or relocation overflow by creating
94 another section header with STYP_OVRFLO set. */
95#define STYP_OVRFLO 0x8000
96
3dd657b1
TR
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
1b2cb8e2
CC
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
3dd657b1
TR
114 xcoff[64]_ppc_relocate_section in coff64-rs6000.c and coff-rs6000.c */
115
2c1bef53
CC
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)
8db6dd6a
TG
138#define R_TLS_IE (0x21)
139#define R_TLS_LD (0x22)
140#define R_TLS_LE (0x23)
2c1bef53
CC
141#define R_TLSM (0x24)
142#define R_TLSML (0x25)
143#define R_TOCU (0x30)
144#define R_TOCL (0x31)
3dd657b1 145
54c95892
TR
146/* Storage class #defines, from /usr/include/storclass.h that are not already
147 defined in internal.h */
3dd657b1 148
54c95892
TR
149/* Comment string in .info section */
150#define C_INFO 110
3dd657b1 151
8db6dd6a
TG
152/* Dwarf symbol. */
153#define C_DWARF 112
154
54c95892 155/* Auxillary Symbol Entries */
3dd657b1
TR
156
157/* x_smtyp values: */
3dd657b1
TR
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: */
3dd657b1
TR
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 */
1fdf0249
TR
186#define XMC_SV64 17 /* Read-only 64 bit supervisor call */
187#define XMC_SV3264 18 /* Read-only 32 or 64 bit supervisor call */
9d3056cd
TG
188/* 19 ??? */
189#define XMC_TL 20 /* Read-write initialized TLS data */
1b2cb8e2 190#define XMC_UL 21 /* Read-write uninitialized TLS data */
9d3056cd 191#define XMC_TE 22 /* Same as XMC_TC but mapped after it */
3dd657b1 192
e86fc4a5
CC
193/* x_ftype values: */
194#define XFT_FN 0 /* Specifies the source-file name */
195#define XFT_CT 1 /* Specifies the compiler time stamp */
196#define XFT_CV 2 /* Specifies the compiler version number */
197#define XFT_CD 128 /*Specifies compiler-defined information */
198
3dd657b1
TR
199/* The ldhdr structure. This appears at the start of the .loader
200 section. */
201
202struct internal_ldhdr
203{
54c95892
TR
204 /* The version number:
205 1 : 32 bit
206 2 : 64 bit */
3dd657b1 207 unsigned long l_version;
54c95892 208
3dd657b1
TR
209 /* The number of symbol table entries. */
210 bfd_size_type l_nsyms;
54c95892 211
3dd657b1
TR
212 /* The number of relocation table entries. */
213 bfd_size_type l_nreloc;
54c95892 214
3dd657b1
TR
215 /* The length of the import file string table. */
216 bfd_size_type l_istlen;
54c95892 217
3dd657b1
TR
218 /* The number of import files. */
219 bfd_size_type l_nimpid;
54c95892 220
3dd657b1
TR
221 /* The offset from the start of the .loader section to the first
222 entry in the import file table. */
223 bfd_size_type l_impoff;
54c95892 224
3dd657b1
TR
225 /* The length of the string table. */
226 bfd_size_type l_stlen;
54c95892 227
3dd657b1
TR
228 /* The offset from the start of the .loader section to the first
229 entry in the string table. */
230 bfd_size_type l_stoff;
54c95892 231
3dd657b1
TR
232 /* The offset to start of the symbol table, only in XCOFF64 */
233 bfd_vma l_symoff;
54c95892 234
3dd657b1
TR
235 /* The offset to the start of the relocation table, only in XCOFF64 */
236 bfd_vma l_rldoff;
237};
238
239/* The ldsym structure. This is used to represent a symbol in the
240 .loader section. */
241
242struct internal_ldsym
243{
244 union
54c95892
TR
245 {
246 /* The symbol name if <= SYMNMLEN characters. */
247 char _l_name[SYMNMLEN];
248 struct
3dd657b1 249 {
54c95892
TR
250 /* Zero if the symbol name is more than SYMNMLEN characters. */
251 long _l_zeroes;
252
253 /* The offset in the string table if the symbol name is more
254 than SYMNMLEN characters. */
255 long _l_offset;
256 }
257 _l_l;
258 }
259 _l;
260
3dd657b1
TR
261 /* The symbol value. */
262 bfd_vma l_value;
54c95892 263
3dd657b1
TR
264 /* The symbol section number. */
265 short l_scnum;
54c95892 266
3dd657b1
TR
267 /* The symbol type and flags. */
268 char l_smtype;
54c95892 269
3dd657b1
TR
270 /* The symbol storage class. */
271 char l_smclas;
54c95892 272
3dd657b1
TR
273 /* The import file ID. */
274 bfd_size_type l_ifile;
54c95892 275
3dd657b1
TR
276 /* Offset to the parameter type check string. */
277 bfd_size_type l_parm;
278};
279
280/* These flags are for the l_smtype field (the lower three bits are an
281 XTY_* value). */
282
283/* Imported symbol. */
284#define L_IMPORT (0x40)
285/* Entry point. */
286#define L_ENTRY (0x20)
287/* Exported symbol. */
288#define L_EXPORT (0x10)
8602d4fe
RS
289/* Weak symbol. */
290#define L_WEAK (0x08)
3dd657b1
TR
291
292/* The ldrel structure. This is used to represent a reloc in the
293 .loader section. */
294
295struct internal_ldrel
296{
297 /* The reloc address. */
298 bfd_vma l_vaddr;
54c95892 299
3dd657b1
TR
300 /* The symbol table index in the .loader section symbol table. */
301 bfd_size_type l_symndx;
54c95892 302
3dd657b1
TR
303 /* The relocation type and size. */
304 short l_rtype;
54c95892 305
3dd657b1
TR
306 /* The section number this relocation applies to. */
307 short l_rsecnm;
308};
309
310/* An entry in the XCOFF linker hash table. */
311struct xcoff_link_hash_entry
312{
313 struct bfd_link_hash_entry root;
314
315 /* Symbol index in output file. Set to -1 initially. Set to -2 if
316 there is a reloc against this symbol. */
317 long indx;
318
319 /* If we have created a TOC entry for this symbol, this is the .tc
320 section which holds it. */
321 asection *toc_section;
322
323 union
54c95892
TR
324 {
325 /* If we have created a TOC entry (the XCOFF_SET_TOC flag is
326 set), this is the offset in toc_section. */
327 bfd_vma toc_offset;
328
329 /* If the TOC entry comes from an input file, this is set to the
330 symbol index of the C_HIDEXT XMC_TC or XMC_TD symbol. */
331 long toc_indx;
332 }
333 u;
3dd657b1
TR
334
335 /* If this symbol is a function entry point which is called, this
336 field holds a pointer to the function descriptor. If this symbol
337 is a function descriptor, this field holds a pointer to the
338 function entry point. */
339 struct xcoff_link_hash_entry *descriptor;
340
341 /* The .loader symbol table entry, if there is one. */
342 struct internal_ldsym *ldsym;
343
344 /* If XCOFF_BUILT_LDSYM is set, this is the .loader symbol table
345 index. If XCOFF_BUILD_LDSYM is clear, and XCOFF_IMPORT is set,
346 this is the l_ifile value. */
347 long ldindx;
348
349 /* Some linker flags. */
350 unsigned long flags;
351
352 /* The storage mapping class. */
353 unsigned char smclas;
354};
355
54c95892 356/* Flags for xcoff_link_hash_entry. */
3dd657b1 357
54c95892 358/* Symbol is referenced by a regular object. */
3dd657b1 359#define XCOFF_REF_REGULAR 0x00000001
54c95892 360/* Symbol is defined by a regular object. */
3dd657b1 361#define XCOFF_DEF_REGULAR 0x00000002
54c95892 362/* Symbol is defined by a dynamic object. */
3dd657b1 363#define XCOFF_DEF_DYNAMIC 0x00000004
54c95892 364/* Symbol is used in a reloc being copied into the .loader section. */
3dd657b1 365#define XCOFF_LDREL 0x00000008
54c95892 366/* Symbol is the entry point. */
3dd657b1 367#define XCOFF_ENTRY 0x00000010
858ef0ce
RS
368/* Symbol is for a function and is the target of a relocation.
369 The relocation may or may not be a branch-type relocation. */
3dd657b1 370#define XCOFF_CALLED 0x00000020
54c95892 371/* Symbol needs the TOC entry filled in. */
3dd657b1 372#define XCOFF_SET_TOC 0x00000040
858ef0ce 373/* Symbol is implicitly or explicitly imported. */
3dd657b1 374#define XCOFF_IMPORT 0x00000080
54c95892 375/* Symbol is explicitly exported. */
3dd657b1 376#define XCOFF_EXPORT 0x00000100
54c95892 377/* Symbol has been processed by xcoff_build_ldsyms. */
3dd657b1 378#define XCOFF_BUILT_LDSYM 0x00000200
54c95892 379/* Symbol is mentioned by a section which was not garbage collected. */
3dd657b1 380#define XCOFF_MARK 0x00000400
54c95892 381/* Symbol size is recorded in size_list list from hash table. */
3dd657b1 382#define XCOFF_HAS_SIZE 0x00000800
54c95892 383/* Symbol is a function descriptor. */
3dd657b1 384#define XCOFF_DESCRIPTOR 0x00001000
54c95892 385/* Multiple definitions have been for the symbol. */
3dd657b1 386#define XCOFF_MULTIPLY_DEFINED 0x00002000
54c95892 387/* Symbol is the __rtinit symbol. */
3dd657b1 388#define XCOFF_RTINIT 0x00004000
54c95892 389/* Symbol is an imported 32 bit syscall. */
1fdf0249 390#define XCOFF_SYSCALL32 0x00008000
54c95892 391/* Symbol is an imported 64 bit syscall. */
1fdf0249 392#define XCOFF_SYSCALL64 0x00010000
858ef0ce
RS
393/* Symbol was not explicitly defined by the time it was marked. */
394#define XCOFF_WAS_UNDEFINED 0x00020000
5b49f6dc
RS
395/* We have assigned an output XCOFF entry to this symbol. */
396#define XCOFF_ALLOCATED 0x00040000
3dd657b1
TR
397
398/* The XCOFF linker hash table. */
399
400#define XCOFF_NUMBER_OF_SPECIAL_SECTIONS 6
401#define XCOFF_SPECIAL_SECTION_TEXT 0
402#define XCOFF_SPECIAL_SECTION_ETEXT 1
403#define XCOFF_SPECIAL_SECTION_DATA 2
404#define XCOFF_SPECIAL_SECTION_EDATA 3
405#define XCOFF_SPECIAL_SECTION_END 4
406#define XCOFF_SPECIAL_SECTION_END2 5
407
b64232cc
RS
408/* These flags indicate which of -bexpall and -bexpfull are in effect. */
409#define XCOFF_EXPALL 1
410#define XCOFF_EXPFULL 2
3dd657b1
TR
411
412/* This structure is used to pass information through
413 xcoff_link_hash_traverse. */
414
415struct xcoff_loader_info
416{
417 /* Set if a problem occurred. */
9193bc42 418 bool failed;
54c95892 419
3dd657b1
TR
420 /* Output BFD. */
421 bfd *output_bfd;
54c95892 422
3dd657b1
TR
423 /* Link information structure. */
424 struct bfd_link_info *info;
54c95892 425
b64232cc
RS
426 /* A mask of XCOFF_EXPALL and XCOFF_EXPFULL flags. */
427 unsigned int auto_export_flags;
54c95892 428
3dd657b1
TR
429 /* Number of ldsym structures. */
430 size_t ldsym_count;
54c95892 431
3dd657b1
TR
432 /* Size of string table. */
433 size_t string_size;
54c95892 434
3dd657b1 435 /* String table. */
f075ee0c 436 char *strings;
54c95892 437
3dd657b1
TR
438 /* Allocated size of string table. */
439 size_t string_alc;
440};
441
442/* In case we're on a 32-bit machine, construct a 64-bit "-1" value
443 from smaller values. Start with zero, widen, *then* decrement. */
2eda3bbc 444#define MINUS_ONE (((bfd_vma) 0) - 1)
3dd657b1 445
54c95892
TR
446/* __rtinit, from /usr/include/rtinit.h. */
447struct __rtinit
448{
449 /* Pointer to runtime linker.
450 XXX: Is the parameter really void? */
a6f5b2c3 451 int (*rtl) (void);
54c95892
TR
452
453 /* Offset to array of init functions, 0 if none. */
454 int init_offset;
455
456 /* Offset to array of fini functions, 0 if none. */
457 int fini_offset;
3dd657b1 458
54c95892
TR
459 /* Size of __RTINIT_DESCRIPTOR. This value should be used instead of
460 sizeof(__RTINIT_DESCRIPTOR). */
461 int __rtinit_descriptor_size;
3dd657b1
TR
462};
463
464#define RTINIT_DESCRIPTOR_SIZE (12)
465
54c95892
TR
466struct __rtinit_descriptor
467{
468 /* Init/fini function. */
469 int f;
3dd657b1 470
54c95892
TR
471 /* Offset, relative to the start of the __rtinit symbol, to name of the
472 function. */
3dd657b1 473
54c95892
TR
474 int name_offset;
475
476 /* Flags */
477 unsigned char flags;
478};
3dd657b1 479
54c95892 480/* Archive */
3dd657b1
TR
481
482#define XCOFFARMAG "<aiaff>\012"
483#define XCOFFARMAGBIG "<bigaf>\012"
484#define SXCOFFARMAG 8
485
2fff1126
TR
486/* The size of the ascii archive elements */
487#define XCOFFARMAG_ELEMENT_SIZE 12
488#define XCOFFARMAGBIG_ELEMENT_SIZE 20
489
3dd657b1
TR
490/* This terminates an XCOFF archive member name. */
491
492#define XCOFFARFMAG "`\012"
493#define SXCOFFARFMAG 2
494
495/* XCOFF archives start with this (printable) structure. */
496
497struct xcoff_ar_file_hdr
498{
499 /* Magic string. */
500 char magic[SXCOFFARMAG];
501
502 /* Offset of the member table (decimal ASCII string). */
2fff1126 503 char memoff[XCOFFARMAG_ELEMENT_SIZE];
3dd657b1
TR
504
505 /* Offset of the global symbol table (decimal ASCII string). */
2fff1126 506 char symoff[XCOFFARMAG_ELEMENT_SIZE];
3dd657b1
TR
507
508 /* Offset of the first member in the archive (decimal ASCII string). */
2fff1126 509 char firstmemoff[XCOFFARMAG_ELEMENT_SIZE];
3dd657b1
TR
510
511 /* Offset of the last member in the archive (decimal ASCII string). */
2fff1126 512 char lastmemoff[XCOFFARMAG_ELEMENT_SIZE];
3dd657b1
TR
513
514 /* Offset of the first member on the free list (decimal ASCII
515 string). */
2fff1126 516 char freeoff[XCOFFARMAG_ELEMENT_SIZE];
3dd657b1
TR
517};
518
2fff1126 519#define SIZEOF_AR_FILE_HDR (SXCOFFARMAG + 5 * XCOFFARMAG_ELEMENT_SIZE)
3dd657b1
TR
520
521/* This is the equivalent data structure for the big archive format. */
522
523struct xcoff_ar_file_hdr_big
524{
525 /* Magic string. */
526 char magic[SXCOFFARMAG];
527
528 /* Offset of the member table (decimal ASCII string). */
2fff1126 529 char memoff[XCOFFARMAGBIG_ELEMENT_SIZE];
3dd657b1
TR
530
531 /* Offset of the global symbol table for 32-bit objects (decimal ASCII
532 string). */
2fff1126 533 char symoff[XCOFFARMAGBIG_ELEMENT_SIZE];
3dd657b1
TR
534
535 /* Offset of the global symbol table for 64-bit objects (decimal ASCII
536 string). */
2fff1126 537 char symoff64[XCOFFARMAGBIG_ELEMENT_SIZE];
3dd657b1
TR
538
539 /* Offset of the first member in the archive (decimal ASCII string). */
2fff1126 540 char firstmemoff[XCOFFARMAGBIG_ELEMENT_SIZE];
3dd657b1
TR
541
542 /* Offset of the last member in the archive (decimal ASCII string). */
2fff1126 543 char lastmemoff[XCOFFARMAGBIG_ELEMENT_SIZE];
3dd657b1
TR
544
545 /* Offset of the first member on the free list (decimal ASCII
546 string). */
2fff1126 547 char freeoff[XCOFFARMAGBIG_ELEMENT_SIZE];
3dd657b1
TR
548};
549
2fff1126 550#define SIZEOF_AR_FILE_HDR_BIG (SXCOFFARMAG + 6 * XCOFFARMAGBIG_ELEMENT_SIZE)
3dd657b1
TR
551
552/* Each XCOFF archive member starts with this (printable) structure. */
553
554struct xcoff_ar_hdr
555{
556 /* File size not including the header (decimal ASCII string). */
2fff1126 557 char size[XCOFFARMAG_ELEMENT_SIZE];
3dd657b1
TR
558
559 /* File offset of next archive member (decimal ASCII string). */
2fff1126 560 char nextoff[XCOFFARMAG_ELEMENT_SIZE];
3dd657b1
TR
561
562 /* File offset of previous archive member (decimal ASCII string). */
2fff1126 563 char prevoff[XCOFFARMAG_ELEMENT_SIZE];
3dd657b1
TR
564
565 /* File mtime (decimal ASCII string). */
566 char date[12];
567
568 /* File UID (decimal ASCII string). */
569 char uid[12];
570
571 /* File GID (decimal ASCII string). */
572 char gid[12];
573
574 /* File mode (octal ASCII string). */
575 char mode[12];
576
577 /* Length of file name (decimal ASCII string). */
578 char namlen[4];
579
580 /* This structure is followed by the file name. The length of the
581 name is given in the namlen field. If the length of the name is
582 odd, the name is followed by a null byte. The name and optional
583 null byte are followed by XCOFFARFMAG, which is not included in
584 namlen. The contents of the archive member follow; the number of
585 bytes is given in the size field. */
586};
587
2fff1126 588#define SIZEOF_AR_HDR (3 * XCOFFARMAG_ELEMENT_SIZE + 4 * 12 + 4)
3dd657b1
TR
589
590/* The equivalent for the big archive format. */
591
592struct xcoff_ar_hdr_big
593{
594 /* File size not including the header (decimal ASCII string). */
2fff1126 595 char size[XCOFFARMAGBIG_ELEMENT_SIZE];
3dd657b1
TR
596
597 /* File offset of next archive member (decimal ASCII string). */
2fff1126 598 char nextoff[XCOFFARMAGBIG_ELEMENT_SIZE];
3dd657b1
TR
599
600 /* File offset of previous archive member (decimal ASCII string). */
2fff1126 601 char prevoff[XCOFFARMAGBIG_ELEMENT_SIZE];
3dd657b1
TR
602
603 /* File mtime (decimal ASCII string). */
604 char date[12];
605
606 /* File UID (decimal ASCII string). */
607 char uid[12];
608
609 /* File GID (decimal ASCII string). */
610 char gid[12];
611
612 /* File mode (octal ASCII string). */
613 char mode[12];
614
615 /* Length of file name (decimal ASCII string). */
616 char namlen[4];
617
618 /* This structure is followed by the file name. The length of the
619 name is given in the namlen field. If the length of the name is
620 odd, the name is followed by a null byte. The name and optional
621 null byte are followed by XCOFFARFMAG, which is not included in
622 namlen. The contents of the archive member follow; the number of
623 bytes is given in the size field. */
624};
625
2fff1126 626#define SIZEOF_AR_HDR_BIG (3 * XCOFFARMAGBIG_ELEMENT_SIZE + 4 * 12 + 4)
3dd657b1
TR
627
628/* We often have to distinguish between the old and big file format.
629 Make it a bit cleaner. We can use `xcoff_ardata' here because the
2fff1126 630 `hdr' member has the same size and position in both formats.
b34976b6 631 <bigaf> is the default format, return TRUE even when xcoff_ardata is
2fff1126 632 NULL. */
3e36d993
TR
633#ifndef SMALL_ARCHIVE
634/* Creates big archives by default */
2fff1126
TR
635#define xcoff_big_format_p(abfd) \
636 ((NULL != bfd_ardata (abfd) && NULL == xcoff_ardata (abfd)) || \
637 ((NULL != bfd_ardata (abfd)) && \
638 (NULL != xcoff_ardata (abfd)) && \
639 (xcoff_ardata (abfd)->magic[1] == 'b')))
3e36d993
TR
640#else
641/* Creates small archives by default. */
3dd657b1 642#define xcoff_big_format_p(abfd) \
2fff1126
TR
643 (((NULL != bfd_ardata (abfd)) && \
644 (NULL != xcoff_ardata (abfd)) && \
3e36d993
TR
645 (xcoff_ardata (abfd)->magic[1] == 'b')))
646#endif
3dd657b1
TR
647
648/* We store a copy of the xcoff_ar_file_hdr in the tdata field of the
649 artdata structure. Similar for the big archive. */
650#define xcoff_ardata(abfd) \
651 ((struct xcoff_ar_file_hdr *) bfd_ardata (abfd)->tdata)
652#define xcoff_ardata_big(abfd) \
653 ((struct xcoff_ar_file_hdr_big *) bfd_ardata (abfd)->tdata)
654
655/* We store a copy of the xcoff_ar_hdr in the arelt_data field of an
656 archive element. Similar for the big archive. */
657#define arch_eltdata(bfd) ((struct areltdata *) ((bfd)->arelt_data))
658#define arch_xhdr(bfd) \
659 ((struct xcoff_ar_hdr *) arch_eltdata (bfd)->arch_header)
660#define arch_xhdr_big(bfd) \
661 ((struct xcoff_ar_hdr_big *) arch_eltdata (bfd)->arch_header)
662
8602d4fe
RS
663/* True if symbols of class CLASS are external. */
664#define EXTERN_SYM_P(CLASS) \
665 ((CLASS) == C_EXT || (CLASS) == C_AIX_WEAKEXT)
666
3dd657b1 667#endif /* _INTERNAL_XCOFF_H */