| 1 |
/* Internal format of XCOFF object file data structures for BFD. |
| 2 |
|
| 3 |
Copyright (C) 1995-2025 Free Software Foundation, Inc. |
| 4 |
Written by Ian Lance Taylor <[email protected]>, 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 |
/* 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 |
|
| 199 |
/* The ldhdr structure. This appears at the start of the .loader |
| 200 |
section. */ |
| 201 |
|
| 202 |
struct internal_ldhdr |
| 203 |
{ |
| 204 |
/* The version number: |
| 205 |
1 : 32 bit |
| 206 |
2 : 64 bit */ |
| 207 |
unsigned int l_version; |
| 208 |
|
| 209 |
/* The number of symbol table entries. */ |
| 210 |
size_t l_nsyms; |
| 211 |
|
| 212 |
/* The number of relocation table entries. */ |
| 213 |
size_t l_nreloc; |
| 214 |
|
| 215 |
/* The length of the import file string table. */ |
| 216 |
size_t l_istlen; |
| 217 |
|
| 218 |
/* The number of import files. */ |
| 219 |
size_t l_nimpid; |
| 220 |
|
| 221 |
/* The length of the string table. */ |
| 222 |
size_t l_stlen; |
| 223 |
|
| 224 |
/* The offset from the start of the .loader section to the first |
| 225 |
entry in the import file table. */ |
| 226 |
bfd_vma l_impoff; |
| 227 |
|
| 228 |
/* The offset from the start of the .loader section to the first |
| 229 |
entry in the string table. */ |
| 230 |
bfd_vma l_stoff; |
| 231 |
|
| 232 |
/* The offset to start of the symbol table, only in XCOFF64 */ |
| 233 |
bfd_vma l_symoff; |
| 234 |
|
| 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 |
|
| 242 |
struct internal_ldsym |
| 243 |
{ |
| 244 |
union |
| 245 |
{ |
| 246 |
/* The symbol name if <= SYMNMLEN characters. */ |
| 247 |
char _l_name[SYMNMLEN]; |
| 248 |
struct |
| 249 |
{ |
| 250 |
/* Zero if the symbol name is more than SYMNMLEN characters. */ |
| 251 |
uint32_t _l_zeroes; |
| 252 |
|
| 253 |
/* The offset in the string table if the symbol name is more |
| 254 |
than SYMNMLEN characters. */ |
| 255 |
uint32_t _l_offset; |
| 256 |
} |
| 257 |
_l_l; |
| 258 |
} |
| 259 |
_l; |
| 260 |
|
| 261 |
/* The symbol value. */ |
| 262 |
bfd_vma l_value; |
| 263 |
|
| 264 |
/* The symbol section number. */ |
| 265 |
short l_scnum; |
| 266 |
|
| 267 |
/* The symbol type and flags. */ |
| 268 |
char l_smtype; |
| 269 |
|
| 270 |
/* The symbol storage class. */ |
| 271 |
char l_smclas; |
| 272 |
|
| 273 |
/* The import file ID. */ |
| 274 |
bfd_size_type l_ifile; |
| 275 |
|
| 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) |
| 289 |
/* Weak symbol. */ |
| 290 |
#define L_WEAK (0x08) |
| 291 |
|
| 292 |
/* The ldrel structure. This is used to represent a reloc in the |
| 293 |
.loader section. */ |
| 294 |
|
| 295 |
struct internal_ldrel |
| 296 |
{ |
| 297 |
/* The reloc address. */ |
| 298 |
bfd_vma l_vaddr; |
| 299 |
|
| 300 |
/* The symbol table index in the .loader section symbol table. */ |
| 301 |
uint32_t l_symndx; |
| 302 |
|
| 303 |
/* The relocation type and size. */ |
| 304 |
int16_t l_rtype; |
| 305 |
|
| 306 |
/* The section number this relocation applies to. */ |
| 307 |
int16_t l_rsecnm; |
| 308 |
}; |
| 309 |
|
| 310 |
/* An entry in the XCOFF linker hash table. */ |
| 311 |
struct 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 |
| 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; |
| 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 |
/* Symbol visibility, using the same define than n_type. */ |
| 353 |
unsigned short visibility; |
| 354 |
|
| 355 |
/* The storage mapping class. */ |
| 356 |
unsigned char smclas; |
| 357 |
}; |
| 358 |
|
| 359 |
/* Flags for xcoff_link_hash_entry. */ |
| 360 |
|
| 361 |
/* Symbol is referenced by a regular object. */ |
| 362 |
#define XCOFF_REF_REGULAR 0x00000001 |
| 363 |
/* Symbol is defined by a regular object. */ |
| 364 |
#define XCOFF_DEF_REGULAR 0x00000002 |
| 365 |
/* Symbol is defined by a dynamic object. */ |
| 366 |
#define XCOFF_DEF_DYNAMIC 0x00000004 |
| 367 |
/* Symbol is used in a reloc being copied into the .loader section. */ |
| 368 |
#define XCOFF_LDREL 0x00000008 |
| 369 |
/* Symbol is the entry point. */ |
| 370 |
#define XCOFF_ENTRY 0x00000010 |
| 371 |
/* Symbol is for a function and is the target of a relocation. |
| 372 |
The relocation may or may not be a branch-type relocation. */ |
| 373 |
#define XCOFF_CALLED 0x00000020 |
| 374 |
/* Symbol needs the TOC entry filled in. */ |
| 375 |
#define XCOFF_SET_TOC 0x00000040 |
| 376 |
/* Symbol is implicitly or explicitly imported. */ |
| 377 |
#define XCOFF_IMPORT 0x00000080 |
| 378 |
/* Symbol is explicitly exported. */ |
| 379 |
#define XCOFF_EXPORT 0x00000100 |
| 380 |
/* Symbol has been processed by xcoff_build_ldsyms. */ |
| 381 |
#define XCOFF_BUILT_LDSYM 0x00000200 |
| 382 |
/* Symbol is mentioned by a section which was not garbage collected. */ |
| 383 |
#define XCOFF_MARK 0x00000400 |
| 384 |
/* Symbol size is recorded in size_list list from hash table. */ |
| 385 |
#define XCOFF_HAS_SIZE 0x00000800 |
| 386 |
/* Symbol is a function descriptor. */ |
| 387 |
#define XCOFF_DESCRIPTOR 0x00001000 |
| 388 |
/* Multiple definitions have been for the symbol. */ |
| 389 |
#define XCOFF_MULTIPLY_DEFINED 0x00002000 |
| 390 |
/* Symbol is the __rtinit symbol. */ |
| 391 |
#define XCOFF_RTINIT 0x00004000 |
| 392 |
/* Symbol is an imported 32 bit syscall. */ |
| 393 |
#define XCOFF_SYSCALL32 0x00008000 |
| 394 |
/* Symbol is an imported 64 bit syscall. */ |
| 395 |
#define XCOFF_SYSCALL64 0x00010000 |
| 396 |
/* Symbol was not explicitly defined by the time it was marked. */ |
| 397 |
#define XCOFF_WAS_UNDEFINED 0x00020000 |
| 398 |
/* We have assigned an output XCOFF entry to this symbol. */ |
| 399 |
#define XCOFF_ALLOCATED 0x00040000 |
| 400 |
|
| 401 |
/* The XCOFF linker hash table. */ |
| 402 |
|
| 403 |
#define XCOFF_NUMBER_OF_SPECIAL_SECTIONS 6 |
| 404 |
#define XCOFF_SPECIAL_SECTION_TEXT 0 |
| 405 |
#define XCOFF_SPECIAL_SECTION_ETEXT 1 |
| 406 |
#define XCOFF_SPECIAL_SECTION_DATA 2 |
| 407 |
#define XCOFF_SPECIAL_SECTION_EDATA 3 |
| 408 |
#define XCOFF_SPECIAL_SECTION_END 4 |
| 409 |
#define XCOFF_SPECIAL_SECTION_END2 5 |
| 410 |
|
| 411 |
/* These flags indicate which of -bexpall and -bexpfull are in effect. */ |
| 412 |
#define XCOFF_EXPALL 1 |
| 413 |
#define XCOFF_EXPFULL 2 |
| 414 |
|
| 415 |
/* This structure is used to pass information through |
| 416 |
xcoff_link_hash_traverse. */ |
| 417 |
|
| 418 |
struct xcoff_loader_info |
| 419 |
{ |
| 420 |
/* Set if a problem occurred. */ |
| 421 |
bool failed; |
| 422 |
|
| 423 |
/* Output BFD. */ |
| 424 |
bfd *output_bfd; |
| 425 |
|
| 426 |
/* Link information structure. */ |
| 427 |
struct bfd_link_info *info; |
| 428 |
|
| 429 |
/* A mask of XCOFF_EXPALL and XCOFF_EXPFULL flags. */ |
| 430 |
unsigned int auto_export_flags; |
| 431 |
|
| 432 |
/* Number of ldsym structures. */ |
| 433 |
size_t ldsym_count; |
| 434 |
|
| 435 |
/* A count of non TOC relative relocs which will need to be |
| 436 |
allocated in the .loader section. */ |
| 437 |
size_t ldrel_count; |
| 438 |
|
| 439 |
/* Size of string table. */ |
| 440 |
size_t string_size; |
| 441 |
|
| 442 |
/* String table. */ |
| 443 |
char *strings; |
| 444 |
|
| 445 |
/* Allocated size of string table. */ |
| 446 |
size_t string_alc; |
| 447 |
|
| 448 |
/* The libpath being used. */ |
| 449 |
const char *libpath; |
| 450 |
}; |
| 451 |
|
| 452 |
/* In case we're on a 32-bit machine, construct a 64-bit "-1" value |
| 453 |
from smaller values. Start with zero, widen, *then* decrement. */ |
| 454 |
#define MINUS_ONE (((bfd_vma) 0) - 1) |
| 455 |
|
| 456 |
/* __rtinit, from /usr/include/rtinit.h. */ |
| 457 |
struct __rtinit |
| 458 |
{ |
| 459 |
/* Pointer to runtime linker. |
| 460 |
XXX: Is the parameter really void? */ |
| 461 |
int (*rtl) (void); |
| 462 |
|
| 463 |
/* Offset to array of init functions, 0 if none. */ |
| 464 |
int init_offset; |
| 465 |
|
| 466 |
/* Offset to array of fini functions, 0 if none. */ |
| 467 |
int fini_offset; |
| 468 |
|
| 469 |
/* Size of __RTINIT_DESCRIPTOR. This value should be used instead of |
| 470 |
sizeof(__RTINIT_DESCRIPTOR). */ |
| 471 |
int __rtinit_descriptor_size; |
| 472 |
}; |
| 473 |
|
| 474 |
#define RTINIT_DESCRIPTOR_SIZE (12) |
| 475 |
|
| 476 |
struct __rtinit_descriptor |
| 477 |
{ |
| 478 |
/* Init/fini function. */ |
| 479 |
int f; |
| 480 |
|
| 481 |
/* Offset, relative to the start of the __rtinit symbol, to name of the |
| 482 |
function. */ |
| 483 |
|
| 484 |
int name_offset; |
| 485 |
|
| 486 |
/* Flags */ |
| 487 |
unsigned char flags; |
| 488 |
}; |
| 489 |
|
| 490 |
/* Archive */ |
| 491 |
|
| 492 |
#define XCOFFARMAG "<aiaff>\012" |
| 493 |
#define XCOFFARMAGBIG "<bigaf>\012" |
| 494 |
#define SXCOFFARMAG 8 |
| 495 |
|
| 496 |
/* The size of the ascii archive elements */ |
| 497 |
#define XCOFFARMAG_ELEMENT_SIZE 12 |
| 498 |
#define XCOFFARMAGBIG_ELEMENT_SIZE 20 |
| 499 |
|
| 500 |
/* This terminates an XCOFF archive member name. */ |
| 501 |
|
| 502 |
#define XCOFFARFMAG "`\012" |
| 503 |
#define SXCOFFARFMAG 2 |
| 504 |
|
| 505 |
/* XCOFF archives start with this (printable) structure. */ |
| 506 |
|
| 507 |
struct xcoff_ar_file_hdr |
| 508 |
{ |
| 509 |
/* Magic string. */ |
| 510 |
char magic[SXCOFFARMAG]; |
| 511 |
|
| 512 |
/* Offset of the member table (decimal ASCII string). */ |
| 513 |
char memoff[XCOFFARMAG_ELEMENT_SIZE]; |
| 514 |
|
| 515 |
/* Offset of the global symbol table (decimal ASCII string). */ |
| 516 |
char symoff[XCOFFARMAG_ELEMENT_SIZE]; |
| 517 |
|
| 518 |
/* Offset of the first member in the archive (decimal ASCII string). */ |
| 519 |
char firstmemoff[XCOFFARMAG_ELEMENT_SIZE]; |
| 520 |
|
| 521 |
/* Offset of the last member in the archive (decimal ASCII string). */ |
| 522 |
char lastmemoff[XCOFFARMAG_ELEMENT_SIZE]; |
| 523 |
|
| 524 |
/* Offset of the first member on the free list (decimal ASCII |
| 525 |
string). */ |
| 526 |
char freeoff[XCOFFARMAG_ELEMENT_SIZE]; |
| 527 |
}; |
| 528 |
|
| 529 |
#define SIZEOF_AR_FILE_HDR (sizeof (struct xcoff_ar_file_hdr)) |
| 530 |
|
| 531 |
/* This is the equivalent data structure for the big archive format. */ |
| 532 |
|
| 533 |
struct xcoff_ar_file_hdr_big |
| 534 |
{ |
| 535 |
/* Magic string. */ |
| 536 |
char magic[SXCOFFARMAG]; |
| 537 |
|
| 538 |
/* Offset of the member table (decimal ASCII string). */ |
| 539 |
char memoff[XCOFFARMAGBIG_ELEMENT_SIZE]; |
| 540 |
|
| 541 |
/* Offset of the global symbol table for 32-bit objects (decimal ASCII |
| 542 |
string). */ |
| 543 |
char symoff[XCOFFARMAGBIG_ELEMENT_SIZE]; |
| 544 |
|
| 545 |
/* Offset of the global symbol table for 64-bit objects (decimal ASCII |
| 546 |
string). */ |
| 547 |
char symoff64[XCOFFARMAGBIG_ELEMENT_SIZE]; |
| 548 |
|
| 549 |
/* Offset of the first member in the archive (decimal ASCII string). */ |
| 550 |
char firstmemoff[XCOFFARMAGBIG_ELEMENT_SIZE]; |
| 551 |
|
| 552 |
/* Offset of the last member in the archive (decimal ASCII string). */ |
| 553 |
char lastmemoff[XCOFFARMAGBIG_ELEMENT_SIZE]; |
| 554 |
|
| 555 |
/* Offset of the first member on the free list (decimal ASCII |
| 556 |
string). */ |
| 557 |
char freeoff[XCOFFARMAGBIG_ELEMENT_SIZE]; |
| 558 |
}; |
| 559 |
|
| 560 |
#define SIZEOF_AR_FILE_HDR_BIG (sizeof (struct xcoff_ar_file_hdr_big)) |
| 561 |
|
| 562 |
/* Each XCOFF archive member starts with this (printable) structure. */ |
| 563 |
|
| 564 |
struct xcoff_ar_hdr |
| 565 |
{ |
| 566 |
/* File size not including the header (decimal ASCII string). */ |
| 567 |
char size[XCOFFARMAG_ELEMENT_SIZE]; |
| 568 |
|
| 569 |
/* File offset of next archive member (decimal ASCII string). */ |
| 570 |
char nextoff[XCOFFARMAG_ELEMENT_SIZE]; |
| 571 |
|
| 572 |
/* File offset of previous archive member (decimal ASCII string). */ |
| 573 |
char prevoff[XCOFFARMAG_ELEMENT_SIZE]; |
| 574 |
|
| 575 |
/* File mtime (decimal ASCII string). */ |
| 576 |
char date[12]; |
| 577 |
|
| 578 |
/* File UID (decimal ASCII string). */ |
| 579 |
char uid[12]; |
| 580 |
|
| 581 |
/* File GID (decimal ASCII string). */ |
| 582 |
char gid[12]; |
| 583 |
|
| 584 |
/* File mode (octal ASCII string). */ |
| 585 |
char mode[12]; |
| 586 |
|
| 587 |
/* Length of file name (decimal ASCII string). */ |
| 588 |
char namlen[4]; |
| 589 |
|
| 590 |
/* This structure is followed by the file name. The length of the |
| 591 |
name is given in the namlen field. If the length of the name is |
| 592 |
odd, the name is followed by a null byte. The name and optional |
| 593 |
null byte are followed by XCOFFARFMAG, which is not included in |
| 594 |
namlen. The contents of the archive member follow; the number of |
| 595 |
bytes is given in the size field. */ |
| 596 |
}; |
| 597 |
|
| 598 |
#define SIZEOF_AR_HDR (sizeof (struct xcoff_ar_hdr)) |
| 599 |
|
| 600 |
/* The equivalent for the big archive format. */ |
| 601 |
|
| 602 |
struct xcoff_ar_hdr_big |
| 603 |
{ |
| 604 |
/* File size not including the header (decimal ASCII string). */ |
| 605 |
char size[XCOFFARMAGBIG_ELEMENT_SIZE]; |
| 606 |
|
| 607 |
/* File offset of next archive member (decimal ASCII string). */ |
| 608 |
char nextoff[XCOFFARMAGBIG_ELEMENT_SIZE]; |
| 609 |
|
| 610 |
/* File offset of previous archive member (decimal ASCII string). */ |
| 611 |
char prevoff[XCOFFARMAGBIG_ELEMENT_SIZE]; |
| 612 |
|
| 613 |
/* File mtime (decimal ASCII string). */ |
| 614 |
char date[12]; |
| 615 |
|
| 616 |
/* File UID (decimal ASCII string). */ |
| 617 |
char uid[12]; |
| 618 |
|
| 619 |
/* File GID (decimal ASCII string). */ |
| 620 |
char gid[12]; |
| 621 |
|
| 622 |
/* File mode (octal ASCII string). */ |
| 623 |
char mode[12]; |
| 624 |
|
| 625 |
/* Length of file name (decimal ASCII string). */ |
| 626 |
char namlen[4]; |
| 627 |
|
| 628 |
/* This structure is followed by the file name. The length of the |
| 629 |
name is given in the namlen field. If the length of the name is |
| 630 |
odd, the name is followed by a null byte. The name and optional |
| 631 |
null byte are followed by XCOFFARFMAG, which is not included in |
| 632 |
namlen. The contents of the archive member follow; the number of |
| 633 |
bytes is given in the size field. */ |
| 634 |
}; |
| 635 |
|
| 636 |
#define SIZEOF_AR_HDR_BIG (sizeof (struct xcoff_ar_hdr_big)) |
| 637 |
|
| 638 |
/* Track archive file offsets used by elements and the header. */ |
| 639 |
struct ar_ranges |
| 640 |
{ |
| 641 |
ufile_ptr start, end; |
| 642 |
struct ar_ranges *next; |
| 643 |
}; |
| 644 |
|
| 645 |
/* An archive bfd has tdata pointing to a struct artdata. The xcoff |
| 646 |
backend has artdata.tdata pointing to the following. */ |
| 647 |
struct xcoff_artdata |
| 648 |
{ |
| 649 |
union |
| 650 |
{ |
| 651 |
struct xcoff_ar_file_hdr hdr; |
| 652 |
struct xcoff_ar_file_hdr_big bhdr; |
| 653 |
} u; |
| 654 |
struct ar_ranges ranges; |
| 655 |
/* Anything less than this size can't hold an archive element. */ |
| 656 |
unsigned int ar_hdr_size; |
| 657 |
}; |
| 658 |
|
| 659 |
#define x_artdata(abfd) ((struct xcoff_artdata *) bfd_ardata (abfd)->tdata) |
| 660 |
|
| 661 |
/* We often have to distinguish between the old and big file format. |
| 662 |
u.hdr.magic and u.bhdr.magic have the same size and position. */ |
| 663 |
#ifndef SMALL_ARCHIVE |
| 664 |
/* Creates big archives by default */ |
| 665 |
#define xcoff_big_format_p(abfd) \ |
| 666 |
(bfd_ardata (abfd) == NULL \ |
| 667 |
|| x_artdata (abfd) == NULL \ |
| 668 |
|| x_artdata (abfd)->u.hdr.magic[1] != 'a') |
| 669 |
#else |
| 670 |
/* Creates small archives by default. */ |
| 671 |
#define xcoff_big_format_p(abfd) \ |
| 672 |
(bfd_ardata (abfd) != NULL \ |
| 673 |
&& x_artdata (abfd) != NULL \ |
| 674 |
&& x_artdata (abfd)->u.hdr.magic[1] == 'b') |
| 675 |
#endif |
| 676 |
|
| 677 |
/* We store a copy of the xcoff_ar_hdr in the arelt_data field of an |
| 678 |
archive element. Similar for the big archive. */ |
| 679 |
#define arch_eltdata(bfd) ((struct areltdata *) ((bfd)->arelt_data)) |
| 680 |
#define arch_xhdr(bfd) \ |
| 681 |
((struct xcoff_ar_hdr *) arch_eltdata (bfd)->arch_header) |
| 682 |
#define arch_xhdr_big(bfd) \ |
| 683 |
((struct xcoff_ar_hdr_big *) arch_eltdata (bfd)->arch_header) |
| 684 |
|
| 685 |
/* True if symbols of class CLASS are external. */ |
| 686 |
#define EXTERN_SYM_P(CLASS) \ |
| 687 |
((CLASS) == C_EXT || (CLASS) == C_AIX_WEAKEXT) |
| 688 |
|
| 689 |
#endif /* _INTERNAL_XCOFF_H */ |