Commit | Line | Data |
---|---|---|
3dd657b1 TR |
1 | /* Internal format of XCOFF object file data structures for BFD. |
2 | ||
2eda3bbc AM |
3 | Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001 |
4 | Free Software Foundation, Inc. | |
3dd657b1 TR |
5 | Written by Ian Lance Taylor <ian@cygnus.com>, Cygnus Support. |
6 | ||
7 | This file is part of BFD, the Binary File Descriptor library. | |
8 | ||
9 | This program is free software; you can redistribute it and/or modify | |
10 | it under the terms of the GNU General Public License as published by | |
11 | the Free Software Foundation; either version 2 of the License, or | |
12 | (at your option) any later version. | |
13 | ||
14 | This program is distributed in the hope that it will be useful, | |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | GNU General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU General Public License | |
20 | along with this program; if not, write to the Free Software | |
21 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |
22 | ||
23 | #ifndef _INTERNAL_XCOFF_H | |
24 | #define _INTERNAL_XCOFF_H | |
25 | ||
54c95892 | 26 | /* Linker */ |
3dd657b1 | 27 | |
54c95892 | 28 | /* Names of "special" sections. */ |
3dd657b1 TR |
29 | #define _TEXT ".text" |
30 | #define _DATA ".data" | |
31 | #define _BSS ".bss" | |
32 | #define _PAD ".pad" | |
33 | #define _LOADER ".loader" | |
34 | ||
35 | /* XCOFF uses a special .loader section with type STYP_LOADER. */ | |
36 | #define STYP_LOADER 0x1000 | |
37 | ||
38 | /* XCOFF uses a special .debug section with type STYP_DEBUG. */ | |
39 | #define STYP_DEBUG 0x2000 | |
40 | ||
41 | /* XCOFF handles line number or relocation overflow by creating | |
42 | another section header with STYP_OVRFLO set. */ | |
43 | #define STYP_OVRFLO 0x8000 | |
44 | ||
45 | #define RS6K_AOUTHDR_OMAGIC 0x0107 /* old: text & data writeable */ | |
46 | #define RS6K_AOUTHDR_NMAGIC 0x0108 /* new: text r/o, data r/w */ | |
47 | #define RS6K_AOUTHDR_ZMAGIC 0x010B /* paged: text r/o, both page-aligned */ | |
48 | ||
3dd657b1 TR |
49 | /* XCOFF relocation types. |
50 | The relocations are described in the function | |
51 | xcoff[64]_ppc_relocate_section in coff64-rs6000.c and coff-rs6000.c */ | |
52 | ||
53 | #define R_POS (0x00) | |
54 | #define R_NEG (0x01) | |
55 | #define R_REL (0x02) | |
56 | #define R_TOC (0x03) | |
57 | #define R_RTB (0x04) | |
58 | #define R_GL (0x05) | |
59 | #define R_TCL (0x06) | |
60 | #define R_BA (0x08) | |
61 | #define R_BR (0x0a) | |
62 | #define R_RL (0x0c) | |
63 | #define R_RLA (0x0d) | |
64 | #define R_REF (0x0f) | |
65 | #define R_TRL (0x12) | |
66 | #define R_TRLA (0x13) | |
67 | #define R_RRTBI (0x14) | |
68 | #define R_RRTBA (0x15) | |
69 | #define R_CAI (0x16) | |
70 | #define R_CREL (0x17) | |
71 | #define R_RBA (0x18) | |
72 | #define R_RBAC (0x19) | |
73 | #define R_RBR (0x1a) | |
74 | #define R_RBRC (0x1b) | |
75 | ||
54c95892 TR |
76 | /* Storage class #defines, from /usr/include/storclass.h that are not already |
77 | defined in internal.h */ | |
3dd657b1 | 78 | |
54c95892 TR |
79 | /* Comment string in .info section */ |
80 | #define C_INFO 110 | |
3dd657b1 | 81 | |
54c95892 | 82 | /* Auxillary Symbol Entries */ |
3dd657b1 TR |
83 | |
84 | /* x_smtyp values: */ | |
3dd657b1 TR |
85 | #define SMTYP_ALIGN(x) ((x) >> 3) /* log2 of alignment */ |
86 | #define SMTYP_SMTYP(x) ((x) & 0x7) /* symbol type */ | |
87 | /* Symbol type values: */ | |
88 | #define XTY_ER 0 /* External reference */ | |
89 | #define XTY_SD 1 /* Csect definition */ | |
90 | #define XTY_LD 2 /* Label definition */ | |
91 | #define XTY_CM 3 /* .BSS */ | |
92 | #define XTY_EM 4 /* Error message */ | |
93 | #define XTY_US 5 /* "Reserved for internal use" */ | |
94 | ||
95 | /* x_smclas values: */ | |
3dd657b1 TR |
96 | #define XMC_PR 0 /* Read-only program code */ |
97 | #define XMC_RO 1 /* Read-only constant */ | |
98 | #define XMC_DB 2 /* Read-only debug dictionary table */ | |
99 | #define XMC_TC 3 /* Read-write general TOC entry */ | |
100 | #define XMC_UA 4 /* Read-write unclassified */ | |
101 | #define XMC_RW 5 /* Read-write data */ | |
102 | #define XMC_GL 6 /* Read-only global linkage */ | |
103 | #define XMC_XO 7 /* Read-only extended operation */ | |
104 | #define XMC_SV 8 /* Read-only supervisor call */ | |
105 | #define XMC_BS 9 /* Read-write BSS */ | |
106 | #define XMC_DS 10 /* Read-write descriptor csect */ | |
107 | #define XMC_UC 11 /* Read-write unnamed Fortran common */ | |
108 | #define XMC_TI 12 /* Read-only traceback index csect */ | |
109 | #define XMC_TB 13 /* Read-only traceback table csect */ | |
110 | /* 14 ??? */ | |
111 | #define XMC_TC0 15 /* Read-write TOC anchor */ | |
112 | #define XMC_TD 16 /* Read-write data in TOC */ | |
1fdf0249 TR |
113 | #define XMC_SV64 17 /* Read-only 64 bit supervisor call */ |
114 | #define XMC_SV3264 18 /* Read-only 32 or 64 bit supervisor call */ | |
3dd657b1 TR |
115 | |
116 | /* The ldhdr structure. This appears at the start of the .loader | |
117 | section. */ | |
118 | ||
119 | struct internal_ldhdr | |
120 | { | |
54c95892 TR |
121 | /* The version number: |
122 | 1 : 32 bit | |
123 | 2 : 64 bit */ | |
3dd657b1 | 124 | unsigned long l_version; |
54c95892 | 125 | |
3dd657b1 TR |
126 | /* The number of symbol table entries. */ |
127 | bfd_size_type l_nsyms; | |
54c95892 | 128 | |
3dd657b1 TR |
129 | /* The number of relocation table entries. */ |
130 | bfd_size_type l_nreloc; | |
54c95892 | 131 | |
3dd657b1 TR |
132 | /* The length of the import file string table. */ |
133 | bfd_size_type l_istlen; | |
54c95892 | 134 | |
3dd657b1 TR |
135 | /* The number of import files. */ |
136 | bfd_size_type l_nimpid; | |
54c95892 | 137 | |
3dd657b1 TR |
138 | /* The offset from the start of the .loader section to the first |
139 | entry in the import file table. */ | |
140 | bfd_size_type l_impoff; | |
54c95892 | 141 | |
3dd657b1 TR |
142 | /* The length of the string table. */ |
143 | bfd_size_type l_stlen; | |
54c95892 | 144 | |
3dd657b1 TR |
145 | /* The offset from the start of the .loader section to the first |
146 | entry in the string table. */ | |
147 | bfd_size_type l_stoff; | |
54c95892 | 148 | |
3dd657b1 TR |
149 | /* The offset to start of the symbol table, only in XCOFF64 */ |
150 | bfd_vma l_symoff; | |
54c95892 | 151 | |
3dd657b1 TR |
152 | /* The offset to the start of the relocation table, only in XCOFF64 */ |
153 | bfd_vma l_rldoff; | |
154 | }; | |
155 | ||
156 | /* The ldsym structure. This is used to represent a symbol in the | |
157 | .loader section. */ | |
158 | ||
159 | struct internal_ldsym | |
160 | { | |
161 | union | |
54c95892 TR |
162 | { |
163 | /* The symbol name if <= SYMNMLEN characters. */ | |
164 | char _l_name[SYMNMLEN]; | |
165 | struct | |
3dd657b1 | 166 | { |
54c95892 TR |
167 | /* Zero if the symbol name is more than SYMNMLEN characters. */ |
168 | long _l_zeroes; | |
169 | ||
170 | /* The offset in the string table if the symbol name is more | |
171 | than SYMNMLEN characters. */ | |
172 | long _l_offset; | |
173 | } | |
174 | _l_l; | |
175 | } | |
176 | _l; | |
177 | ||
3dd657b1 TR |
178 | /* The symbol value. */ |
179 | bfd_vma l_value; | |
54c95892 | 180 | |
3dd657b1 TR |
181 | /* The symbol section number. */ |
182 | short l_scnum; | |
54c95892 | 183 | |
3dd657b1 TR |
184 | /* The symbol type and flags. */ |
185 | char l_smtype; | |
54c95892 | 186 | |
3dd657b1 TR |
187 | /* The symbol storage class. */ |
188 | char l_smclas; | |
54c95892 | 189 | |
3dd657b1 TR |
190 | /* The import file ID. */ |
191 | bfd_size_type l_ifile; | |
54c95892 | 192 | |
3dd657b1 TR |
193 | /* Offset to the parameter type check string. */ |
194 | bfd_size_type l_parm; | |
195 | }; | |
196 | ||
197 | /* These flags are for the l_smtype field (the lower three bits are an | |
198 | XTY_* value). */ | |
199 | ||
200 | /* Imported symbol. */ | |
201 | #define L_IMPORT (0x40) | |
202 | /* Entry point. */ | |
203 | #define L_ENTRY (0x20) | |
204 | /* Exported symbol. */ | |
205 | #define L_EXPORT (0x10) | |
206 | ||
207 | /* The ldrel structure. This is used to represent a reloc in the | |
208 | .loader section. */ | |
209 | ||
210 | struct internal_ldrel | |
211 | { | |
212 | /* The reloc address. */ | |
213 | bfd_vma l_vaddr; | |
54c95892 | 214 | |
3dd657b1 TR |
215 | /* The symbol table index in the .loader section symbol table. */ |
216 | bfd_size_type l_symndx; | |
54c95892 | 217 | |
3dd657b1 TR |
218 | /* The relocation type and size. */ |
219 | short l_rtype; | |
54c95892 | 220 | |
3dd657b1 TR |
221 | /* The section number this relocation applies to. */ |
222 | short l_rsecnm; | |
223 | }; | |
224 | ||
225 | /* An entry in the XCOFF linker hash table. */ | |
226 | struct xcoff_link_hash_entry | |
227 | { | |
228 | struct bfd_link_hash_entry root; | |
229 | ||
230 | /* Symbol index in output file. Set to -1 initially. Set to -2 if | |
231 | there is a reloc against this symbol. */ | |
232 | long indx; | |
233 | ||
234 | /* If we have created a TOC entry for this symbol, this is the .tc | |
235 | section which holds it. */ | |
236 | asection *toc_section; | |
237 | ||
238 | union | |
54c95892 TR |
239 | { |
240 | /* If we have created a TOC entry (the XCOFF_SET_TOC flag is | |
241 | set), this is the offset in toc_section. */ | |
242 | bfd_vma toc_offset; | |
243 | ||
244 | /* If the TOC entry comes from an input file, this is set to the | |
245 | symbol index of the C_HIDEXT XMC_TC or XMC_TD symbol. */ | |
246 | long toc_indx; | |
247 | } | |
248 | u; | |
3dd657b1 TR |
249 | |
250 | /* If this symbol is a function entry point which is called, this | |
251 | field holds a pointer to the function descriptor. If this symbol | |
252 | is a function descriptor, this field holds a pointer to the | |
253 | function entry point. */ | |
254 | struct xcoff_link_hash_entry *descriptor; | |
255 | ||
256 | /* The .loader symbol table entry, if there is one. */ | |
257 | struct internal_ldsym *ldsym; | |
258 | ||
259 | /* If XCOFF_BUILT_LDSYM is set, this is the .loader symbol table | |
260 | index. If XCOFF_BUILD_LDSYM is clear, and XCOFF_IMPORT is set, | |
261 | this is the l_ifile value. */ | |
262 | long ldindx; | |
263 | ||
264 | /* Some linker flags. */ | |
265 | unsigned long flags; | |
266 | ||
267 | /* The storage mapping class. */ | |
268 | unsigned char smclas; | |
269 | }; | |
270 | ||
54c95892 | 271 | /* Flags for xcoff_link_hash_entry. */ |
3dd657b1 | 272 | |
54c95892 | 273 | /* Symbol is referenced by a regular object. */ |
3dd657b1 | 274 | #define XCOFF_REF_REGULAR 0x00000001 |
54c95892 | 275 | /* Symbol is defined by a regular object. */ |
3dd657b1 | 276 | #define XCOFF_DEF_REGULAR 0x00000002 |
54c95892 | 277 | /* Symbol is defined by a dynamic object. */ |
3dd657b1 | 278 | #define XCOFF_DEF_DYNAMIC 0x00000004 |
54c95892 | 279 | /* Symbol is used in a reloc being copied into the .loader section. */ |
3dd657b1 | 280 | #define XCOFF_LDREL 0x00000008 |
54c95892 | 281 | /* Symbol is the entry point. */ |
3dd657b1 | 282 | #define XCOFF_ENTRY 0x00000010 |
54c95892 | 283 | /* Symbol is called; this is, it appears in a R_BR reloc. */ |
3dd657b1 | 284 | #define XCOFF_CALLED 0x00000020 |
54c95892 | 285 | /* Symbol needs the TOC entry filled in. */ |
3dd657b1 | 286 | #define XCOFF_SET_TOC 0x00000040 |
54c95892 | 287 | /* Symbol is explicitly imported. */ |
3dd657b1 | 288 | #define XCOFF_IMPORT 0x00000080 |
54c95892 | 289 | /* Symbol is explicitly exported. */ |
3dd657b1 | 290 | #define XCOFF_EXPORT 0x00000100 |
54c95892 | 291 | /* Symbol has been processed by xcoff_build_ldsyms. */ |
3dd657b1 | 292 | #define XCOFF_BUILT_LDSYM 0x00000200 |
54c95892 | 293 | /* Symbol is mentioned by a section which was not garbage collected. */ |
3dd657b1 | 294 | #define XCOFF_MARK 0x00000400 |
54c95892 | 295 | /* Symbol size is recorded in size_list list from hash table. */ |
3dd657b1 | 296 | #define XCOFF_HAS_SIZE 0x00000800 |
54c95892 | 297 | /* Symbol is a function descriptor. */ |
3dd657b1 | 298 | #define XCOFF_DESCRIPTOR 0x00001000 |
54c95892 | 299 | /* Multiple definitions have been for the symbol. */ |
3dd657b1 | 300 | #define XCOFF_MULTIPLY_DEFINED 0x00002000 |
54c95892 | 301 | /* Symbol is the __rtinit symbol. */ |
3dd657b1 | 302 | #define XCOFF_RTINIT 0x00004000 |
54c95892 | 303 | /* Symbol is an imported 32 bit syscall. */ |
1fdf0249 | 304 | #define XCOFF_SYSCALL32 0x00008000 |
54c95892 | 305 | /* Symbol is an imported 64 bit syscall. */ |
1fdf0249 | 306 | #define XCOFF_SYSCALL64 0x00010000 |
3dd657b1 TR |
307 | |
308 | /* The XCOFF linker hash table. */ | |
309 | ||
310 | #define XCOFF_NUMBER_OF_SPECIAL_SECTIONS 6 | |
311 | #define XCOFF_SPECIAL_SECTION_TEXT 0 | |
312 | #define XCOFF_SPECIAL_SECTION_ETEXT 1 | |
313 | #define XCOFF_SPECIAL_SECTION_DATA 2 | |
314 | #define XCOFF_SPECIAL_SECTION_EDATA 3 | |
315 | #define XCOFF_SPECIAL_SECTION_END 4 | |
316 | #define XCOFF_SPECIAL_SECTION_END2 5 | |
317 | ||
318 | struct xcoff_link_hash_table | |
319 | { | |
320 | struct bfd_link_hash_table root; | |
321 | ||
322 | /* The .debug string hash table. We need to compute this while | |
323 | reading the input files, so that we know how large the .debug | |
324 | section will be before we assign section positions. */ | |
325 | struct bfd_strtab_hash *debug_strtab; | |
326 | ||
327 | /* The .debug section we will use for the final output. */ | |
328 | asection *debug_section; | |
329 | ||
330 | /* The .loader section we will use for the final output. */ | |
331 | asection *loader_section; | |
332 | ||
333 | /* A count of non TOC relative relocs which will need to be | |
334 | allocated in the .loader section. */ | |
335 | size_t ldrel_count; | |
336 | ||
337 | /* The .loader section header. */ | |
338 | struct internal_ldhdr ldhdr; | |
339 | ||
340 | /* The .gl section we use to hold global linkage code. */ | |
341 | asection *linkage_section; | |
342 | ||
343 | /* The .tc section we use to hold toc entries we build for global | |
344 | linkage code. */ | |
345 | asection *toc_section; | |
346 | ||
347 | /* The .ds section we use to hold function descriptors which we | |
348 | create for exported symbols. */ | |
349 | asection *descriptor_section; | |
350 | ||
351 | /* The list of import files. */ | |
352 | struct xcoff_import_file *imports; | |
353 | ||
354 | /* Required alignment of sections within the output file. */ | |
355 | unsigned long file_align; | |
356 | ||
357 | /* Whether the .text section must be read-only. */ | |
358 | boolean textro; | |
359 | ||
360 | /* Whether garbage collection was done. */ | |
361 | boolean gc; | |
362 | ||
363 | /* A linked list of symbols for which we have size information. */ | |
364 | struct xcoff_link_size_list | |
54c95892 TR |
365 | { |
366 | struct xcoff_link_size_list *next; | |
367 | struct xcoff_link_hash_entry *h; | |
368 | bfd_size_type size; | |
369 | } | |
370 | *size_list; | |
3dd657b1 TR |
371 | |
372 | /* Magic sections: _text, _etext, _data, _edata, _end, end. */ | |
373 | asection *special_sections[XCOFF_NUMBER_OF_SPECIAL_SECTIONS]; | |
374 | }; | |
375 | ||
376 | ||
377 | /* This structure is used to pass information through | |
378 | xcoff_link_hash_traverse. */ | |
379 | ||
380 | struct xcoff_loader_info | |
381 | { | |
382 | /* Set if a problem occurred. */ | |
383 | boolean failed; | |
54c95892 | 384 | |
3dd657b1 TR |
385 | /* Output BFD. */ |
386 | bfd *output_bfd; | |
54c95892 | 387 | |
3dd657b1 TR |
388 | /* Link information structure. */ |
389 | struct bfd_link_info *info; | |
54c95892 | 390 | |
3dd657b1 TR |
391 | /* Whether all defined symbols should be exported. */ |
392 | boolean export_defineds; | |
54c95892 | 393 | |
3dd657b1 TR |
394 | /* Number of ldsym structures. */ |
395 | size_t ldsym_count; | |
54c95892 | 396 | |
3dd657b1 TR |
397 | /* Size of string table. */ |
398 | size_t string_size; | |
54c95892 | 399 | |
3dd657b1 TR |
400 | /* String table. */ |
401 | bfd_byte *strings; | |
54c95892 | 402 | |
3dd657b1 TR |
403 | /* Allocated size of string table. */ |
404 | size_t string_alc; | |
405 | }; | |
406 | ||
407 | /* In case we're on a 32-bit machine, construct a 64-bit "-1" value | |
408 | from smaller values. Start with zero, widen, *then* decrement. */ | |
2eda3bbc | 409 | #define MINUS_ONE (((bfd_vma) 0) - 1) |
3dd657b1 | 410 | |
54c95892 TR |
411 | /* __rtinit, from /usr/include/rtinit.h. */ |
412 | struct __rtinit | |
413 | { | |
414 | /* Pointer to runtime linker. | |
415 | XXX: Is the parameter really void? */ | |
416 | int (*rtl) PARAMS ((void)); | |
417 | ||
418 | /* Offset to array of init functions, 0 if none. */ | |
419 | int init_offset; | |
420 | ||
421 | /* Offset to array of fini functions, 0 if none. */ | |
422 | int fini_offset; | |
3dd657b1 | 423 | |
54c95892 TR |
424 | /* Size of __RTINIT_DESCRIPTOR. This value should be used instead of |
425 | sizeof(__RTINIT_DESCRIPTOR). */ | |
426 | int __rtinit_descriptor_size; | |
3dd657b1 TR |
427 | }; |
428 | ||
429 | #define RTINIT_DESCRIPTOR_SIZE (12) | |
430 | ||
54c95892 TR |
431 | struct __rtinit_descriptor |
432 | { | |
433 | /* Init/fini function. */ | |
434 | int f; | |
3dd657b1 | 435 | |
54c95892 TR |
436 | /* Offset, relative to the start of the __rtinit symbol, to name of the |
437 | function. */ | |
3dd657b1 | 438 | |
54c95892 TR |
439 | int name_offset; |
440 | ||
441 | /* Flags */ | |
442 | unsigned char flags; | |
443 | }; | |
3dd657b1 | 444 | |
54c95892 | 445 | /* Archive */ |
3dd657b1 TR |
446 | |
447 | #define XCOFFARMAG "<aiaff>\012" | |
448 | #define XCOFFARMAGBIG "<bigaf>\012" | |
449 | #define SXCOFFARMAG 8 | |
450 | ||
451 | /* This terminates an XCOFF archive member name. */ | |
452 | ||
453 | #define XCOFFARFMAG "`\012" | |
454 | #define SXCOFFARFMAG 2 | |
455 | ||
456 | /* XCOFF archives start with this (printable) structure. */ | |
457 | ||
458 | struct xcoff_ar_file_hdr | |
459 | { | |
460 | /* Magic string. */ | |
461 | char magic[SXCOFFARMAG]; | |
462 | ||
463 | /* Offset of the member table (decimal ASCII string). */ | |
464 | char memoff[12]; | |
465 | ||
466 | /* Offset of the global symbol table (decimal ASCII string). */ | |
467 | char symoff[12]; | |
468 | ||
469 | /* Offset of the first member in the archive (decimal ASCII string). */ | |
470 | char firstmemoff[12]; | |
471 | ||
472 | /* Offset of the last member in the archive (decimal ASCII string). */ | |
473 | char lastmemoff[12]; | |
474 | ||
475 | /* Offset of the first member on the free list (decimal ASCII | |
476 | string). */ | |
477 | char freeoff[12]; | |
478 | }; | |
479 | ||
480 | #define SIZEOF_AR_FILE_HDR (5 * 12 + SXCOFFARMAG) | |
481 | ||
482 | /* This is the equivalent data structure for the big archive format. */ | |
483 | ||
484 | struct xcoff_ar_file_hdr_big | |
485 | { | |
486 | /* Magic string. */ | |
487 | char magic[SXCOFFARMAG]; | |
488 | ||
489 | /* Offset of the member table (decimal ASCII string). */ | |
490 | char memoff[20]; | |
491 | ||
492 | /* Offset of the global symbol table for 32-bit objects (decimal ASCII | |
493 | string). */ | |
494 | char symoff[20]; | |
495 | ||
496 | /* Offset of the global symbol table for 64-bit objects (decimal ASCII | |
497 | string). */ | |
498 | char symoff64[20]; | |
499 | ||
500 | /* Offset of the first member in the archive (decimal ASCII string). */ | |
501 | char firstmemoff[20]; | |
502 | ||
503 | /* Offset of the last member in the archive (decimal ASCII string). */ | |
504 | char lastmemoff[20]; | |
505 | ||
506 | /* Offset of the first member on the free list (decimal ASCII | |
507 | string). */ | |
508 | char freeoff[20]; | |
509 | }; | |
510 | ||
511 | #define SIZEOF_AR_FILE_HDR_BIG (6 * 20 + SXCOFFARMAG) | |
512 | ||
513 | ||
514 | /* Each XCOFF archive member starts with this (printable) structure. */ | |
515 | ||
516 | struct xcoff_ar_hdr | |
517 | { | |
518 | /* File size not including the header (decimal ASCII string). */ | |
519 | char size[12]; | |
520 | ||
521 | /* File offset of next archive member (decimal ASCII string). */ | |
522 | char nextoff[12]; | |
523 | ||
524 | /* File offset of previous archive member (decimal ASCII string). */ | |
525 | char prevoff[12]; | |
526 | ||
527 | /* File mtime (decimal ASCII string). */ | |
528 | char date[12]; | |
529 | ||
530 | /* File UID (decimal ASCII string). */ | |
531 | char uid[12]; | |
532 | ||
533 | /* File GID (decimal ASCII string). */ | |
534 | char gid[12]; | |
535 | ||
536 | /* File mode (octal ASCII string). */ | |
537 | char mode[12]; | |
538 | ||
539 | /* Length of file name (decimal ASCII string). */ | |
540 | char namlen[4]; | |
541 | ||
542 | /* This structure is followed by the file name. The length of the | |
543 | name is given in the namlen field. If the length of the name is | |
544 | odd, the name is followed by a null byte. The name and optional | |
545 | null byte are followed by XCOFFARFMAG, which is not included in | |
546 | namlen. The contents of the archive member follow; the number of | |
547 | bytes is given in the size field. */ | |
548 | }; | |
549 | ||
550 | #define SIZEOF_AR_HDR (7 * 12 + 4) | |
551 | ||
552 | /* The equivalent for the big archive format. */ | |
553 | ||
554 | struct xcoff_ar_hdr_big | |
555 | { | |
556 | /* File size not including the header (decimal ASCII string). */ | |
557 | char size[20]; | |
558 | ||
559 | /* File offset of next archive member (decimal ASCII string). */ | |
560 | char nextoff[20]; | |
561 | ||
562 | /* File offset of previous archive member (decimal ASCII string). */ | |
563 | char prevoff[20]; | |
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 | ||
588 | #define SIZEOF_AR_HDR_BIG (3 * 20 + 4 * 12 + 4) | |
589 | ||
590 | /* We often have to distinguish between the old and big file format. | |
591 | Make it a bit cleaner. We can use `xcoff_ardata' here because the | |
592 | `hdr' member has the same size and position in both formats. */ | |
593 | #define xcoff_big_format_p(abfd) \ | |
594 | (xcoff_ardata (abfd)->magic[1] == 'b') | |
595 | ||
596 | /* We store a copy of the xcoff_ar_file_hdr in the tdata field of the | |
597 | artdata structure. Similar for the big archive. */ | |
598 | #define xcoff_ardata(abfd) \ | |
599 | ((struct xcoff_ar_file_hdr *) bfd_ardata (abfd)->tdata) | |
600 | #define xcoff_ardata_big(abfd) \ | |
601 | ((struct xcoff_ar_file_hdr_big *) bfd_ardata (abfd)->tdata) | |
602 | ||
603 | /* We store a copy of the xcoff_ar_hdr in the arelt_data field of an | |
604 | archive element. Similar for the big archive. */ | |
605 | #define arch_eltdata(bfd) ((struct areltdata *) ((bfd)->arelt_data)) | |
606 | #define arch_xhdr(bfd) \ | |
607 | ((struct xcoff_ar_hdr *) arch_eltdata (bfd)->arch_header) | |
608 | #define arch_xhdr_big(bfd) \ | |
609 | ((struct xcoff_ar_hdr_big *) arch_eltdata (bfd)->arch_header) | |
610 | ||
611 | #endif /* _INTERNAL_XCOFF_H */ |