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