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