185815Sobrien/* IBM RS/6000 "XCOFF64" file definitions for BFD. 2218822Sdim Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc. 385815Sobrien 485815Sobrien This program is free software; you can redistribute it and/or modify 585815Sobrien it under the terms of the GNU General Public License as published by 685815Sobrien the Free Software Foundation; either version 2 of the License, or 785815Sobrien (at your option) any later version. 885815Sobrien 985815Sobrien This program is distributed in the hope that it will be useful, 1085815Sobrien but WITHOUT ANY WARRANTY; without even the implied warranty of 1185815Sobrien MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1285815Sobrien GNU General Public License for more details. 1385815Sobrien 1485815Sobrien You should have received a copy of the GNU General Public License 1585815Sobrien along with this program; if not, write to the Free Software 16218822Sdim Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ 1785815Sobrien 1885815Sobrien/********************** FILE HEADER **********************/ 1985815Sobrien 20104834Sobrienstruct external_filehdr 21104834Sobrien{ 22104834Sobrien char f_magic[2]; /* magic number */ 23104834Sobrien char f_nscns[2]; /* number of sections */ 24104834Sobrien char f_timdat[4]; /* time & date stamp */ 25104834Sobrien char f_symptr[8]; /* file pointer to symtab */ 26104834Sobrien char f_opthdr[2]; /* sizeof(optional hdr) */ 27104834Sobrien char f_flags[2]; /* flags */ 28104834Sobrien char f_nsyms[4]; /* number of symtab entries */ 2985815Sobrien}; 3085815Sobrien 31104834Sobrien/* IBM RS/6000. */ 32104834Sobrien#define U803XTOCMAGIC 0757 /* Aix 4.3 64-bit XCOFF */ 33104834Sobrien#define U64_TOCMAGIC 0767 /* AIX 5+ 64-bit XCOFF */ 34104834Sobrien#define BADMAG(x) ((x).f_magic != U803XTOCMAGIC && (x).f_magic != U64_TOCMAGIC) 3585815Sobrien 3685815Sobrien#define FILHDR struct external_filehdr 3785815Sobrien#define FILHSZ 24 3885815Sobrien 3985815Sobrien/********************** AOUT "OPTIONAL HEADER" **********************/ 4085815Sobrien 4185815Sobrientypedef struct 4285815Sobrien{ 4385815Sobrien unsigned char magic[2]; /* type of file */ 4485815Sobrien unsigned char vstamp[2]; /* version stamp */ 4585815Sobrien unsigned char o_debugger[4]; /* reserved */ 46104834Sobrien unsigned char text_start[8]; /* base of text used for this file */ 47104834Sobrien unsigned char data_start[8]; /* base of data used for this file */ 48104834Sobrien unsigned char o_toc[8]; /* address of TOC */ 4985815Sobrien unsigned char o_snentry[2]; /* section number of entry point */ 5085815Sobrien unsigned char o_sntext[2]; /* section number of .text section */ 5185815Sobrien unsigned char o_sndata[2]; /* section number of .data section */ 5285815Sobrien unsigned char o_sntoc[2]; /* section number of TOC */ 5385815Sobrien unsigned char o_snloader[2]; /* section number of .loader section */ 5485815Sobrien unsigned char o_snbss[2]; /* section number of .bss section */ 5585815Sobrien unsigned char o_algntext[2]; /* .text alignment */ 5685815Sobrien unsigned char o_algndata[2]; /* .data alignment */ 5785815Sobrien unsigned char o_modtype[2]; /* module type (??) */ 5885815Sobrien unsigned char o_cputype[2]; /* cpu type */ 5985815Sobrien unsigned char o_resv2[4]; /* reserved */ 6085815Sobrien unsigned char tsize[8]; /* text size bytes, padded to FW bdry */ 6185815Sobrien unsigned char dsize[8]; /* initialized data " " */ 6285815Sobrien unsigned char bsize[8]; /* uninitialized data " " */ 6385815Sobrien unsigned char entry[8]; /* entry pt. */ 64104834Sobrien unsigned char o_maxstack[8]; /* max stack size (??) */ 65104834Sobrien unsigned char o_maxdata[8]; /* max data size (??) */ 6685815Sobrien unsigned char o_resv3[16]; /* reserved */ 6785815Sobrien} 6885815SobrienAOUTHDR; 6985815Sobrien 7085815Sobrien#define AOUTSZ 120 7185815Sobrien#define SMALL_AOUTSZ (0) 7285815Sobrien#define AOUTHDRSZ 72 7385815Sobrien 7485815Sobrien/********************** SECTION HEADER **********************/ 7585815Sobrien 76104834Sobrienstruct external_scnhdr 77104834Sobrien{ 78104834Sobrien char s_name[8]; /* section name */ 79104834Sobrien char s_paddr[8]; /* physical address, aliased s_nlib */ 80104834Sobrien char s_vaddr[8]; /* virtual address */ 81104834Sobrien char s_size[8]; /* section size */ 82104834Sobrien char s_scnptr[8]; /* file ptr to raw data for section */ 83104834Sobrien char s_relptr[8]; /* file ptr to relocation */ 84104834Sobrien char s_lnnoptr[8]; /* file ptr to line numbers */ 85104834Sobrien char s_nreloc[4]; /* number of relocation entries */ 86104834Sobrien char s_nlnno[4]; /* number of line number entries*/ 87104834Sobrien char s_flags[4]; /* flags */ 88104834Sobrien char s_pad[4]; /* padding */ 8985815Sobrien}; 9085815Sobrien 9185815Sobrien#define SCNHDR struct external_scnhdr 9285815Sobrien 9385815Sobrien#define SCNHSZ 72 9485815Sobrien 9585815Sobrien/********************** LINE NUMBERS **********************/ 9685815Sobrien 9785815Sobrien/* 1 line number entry for every "breakpointable" source line in a section. 98104834Sobrien Line numbers are grouped on a per function basis; first entry in a function 99104834Sobrien grouping will have l_lnno = 0 and in place of physical address will be the 100104834Sobrien symbol table index of the function name. */ 101104834Sobrien 102104834Sobrienstruct external_lineno 103104834Sobrien{ 104104834Sobrien union 105104834Sobrien { 106104834Sobrien char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/ 107104834Sobrien char l_paddr[8]; /* (physical) address of line number */ 108104834Sobrien } l_addr; 109104834Sobrien 110104834Sobrien char l_lnno[4]; /* line number */ 11185815Sobrien}; 11285815Sobrien 11385815Sobrien#define LINENO struct external_lineno 11485815Sobrien 11585815Sobrien#define LINESZ 12 11685815Sobrien 11785815Sobrien/********************** SYMBOLS **********************/ 11885815Sobrien 11985815Sobrien#define E_SYMNMLEN 8 /* # characters in a symbol name */ 12085815Sobrien#define E_FILNMLEN 14 /* # characters in a file name */ 12185815Sobrien#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */ 12285815Sobrien 12385815Sobrienstruct external_syment 12485815Sobrien{ 12589857Sobrien char e_value[8]; 12685815Sobrien char e_offset[4]; 12785815Sobrien char e_scnum[2]; 12885815Sobrien char e_type[2]; 12985815Sobrien char e_sclass[1]; 13085815Sobrien char e_numaux[1]; 13185815Sobrien}; 13285815Sobrien 13385815Sobrien#define N_BTMASK (017) 13485815Sobrien#define N_TMASK (060) 13585815Sobrien#define N_BTSHFT (4) 13685815Sobrien#define N_TSHIFT (2) 13785815Sobrien 138104834Sobrienunion external_auxent 139104834Sobrien{ 14085815Sobrien struct { 14185815Sobrien union { 14285815Sobrien struct { 14385815Sobrien char x_lnno[4]; /* declaration line number */ 14485815Sobrien char x_size[2]; /* str/union/array size */ 14585815Sobrien } x_lnsz; 14685815Sobrien struct { 14785815Sobrien char x_lnnoptr[8];/* ptr to fcn line */ 14885815Sobrien char x_fsize[4]; /* size of function */ 14985815Sobrien char x_endndx[4]; /* entry ndx past block end */ 15085815Sobrien } x_fcn; 15185815Sobrien } x_fcnary; 15285815Sobrien } x_sym; 15385815Sobrien 15485815Sobrien union { 15585815Sobrien char x_fname[E_FILNMLEN]; 15685815Sobrien struct { 15785815Sobrien char x_zeroes[4]; 15885815Sobrien char x_offset[4]; 15985815Sobrien char x_pad[6]; 16085815Sobrien unsigned char x_ftype[1]; 16185815Sobrien unsigned char x_resv[2]; 16285815Sobrien } x_n; 16385815Sobrien } x_file; 16485815Sobrien 16585815Sobrien struct { 16685815Sobrien char x_exptr[8]; 16785815Sobrien char x_fsize[4]; 16885815Sobrien char x_endndx[4]; 16985815Sobrien char x_pad[1]; 17085815Sobrien } x_except; 17185815Sobrien 17285815Sobrien struct { 17385815Sobrien unsigned char x_scnlen_lo[4]; 17485815Sobrien unsigned char x_parmhash[4]; 17585815Sobrien unsigned char x_snhash[2]; 17685815Sobrien unsigned char x_smtyp[1]; 17785815Sobrien unsigned char x_smclas[1]; 17885815Sobrien unsigned char x_scnlen_hi[4]; 17985815Sobrien unsigned char x_pad[1]; 18085815Sobrien } x_csect; 18185815Sobrien 18285815Sobrien struct { 18385815Sobrien char x_pad[17]; 18485815Sobrien char x_auxtype[1]; 18585815Sobrien } x_auxtype; 18685815Sobrien}; 18785815Sobrien 18885815Sobrien#define SYMENT struct external_syment 18985815Sobrien#define SYMESZ 18 19085815Sobrien#define AUXENT union external_auxent 19185815Sobrien#define AUXESZ 18 19285815Sobrien#define DBXMASK 0x80 /* for dbx storage mask */ 19385815Sobrien#define SYMNAME_IN_DEBUG(symptr) ((symptr)->n_sclass & DBXMASK) 19485815Sobrien 195104834Sobrien/* Values for auxtype field in XCOFF64, taken from AIX 4.3 sym.h. */ 19685815Sobrien#define _AUX_EXCEPT 255 19785815Sobrien#define _AUX_FCN 254 19885815Sobrien#define _AUX_SYM 253 19985815Sobrien#define _AUX_FILE 252 20085815Sobrien#define _AUX_CSECT 251 20185815Sobrien 20285815Sobrien/********************** RELOCATION DIRECTIVES **********************/ 20385815Sobrien 204104834Sobrienstruct external_reloc 205104834Sobrien{ 20685815Sobrien char r_vaddr[8]; 20785815Sobrien char r_symndx[4]; 20885815Sobrien char r_size[1]; 20985815Sobrien char r_type[1]; 21085815Sobrien}; 21185815Sobrien 21285815Sobrien#define RELOC struct external_reloc 21385815Sobrien#define RELSZ 14 21485815Sobrien 21585815Sobrien#define DEFAULT_DATA_SECTION_ALIGNMENT 4 21685815Sobrien#define DEFAULT_BSS_SECTION_ALIGNMENT 4 21785815Sobrien#define DEFAULT_TEXT_SECTION_ALIGNMENT 4 21885815Sobrien/* For new sections we havn't heard of before */ 21985815Sobrien#define DEFAULT_SECTION_ALIGNMENT 4 22089857Sobrien 22189857Sobrien/* The ldhdr structure. This appears at the start of the .loader 22289857Sobrien section. */ 22389857Sobrien 22489857Sobrienstruct external_ldhdr 22589857Sobrien{ 22689857Sobrien bfd_byte l_version[4]; 22789857Sobrien bfd_byte l_nsyms[4]; 22889857Sobrien bfd_byte l_nreloc[4]; 22989857Sobrien bfd_byte l_istlen[4]; 23089857Sobrien bfd_byte l_nimpid[4]; 23189857Sobrien bfd_byte l_stlen[4]; 23289857Sobrien bfd_byte l_impoff[8]; 23389857Sobrien bfd_byte l_stoff[8]; 23489857Sobrien bfd_byte l_symoff[8]; 23589857Sobrien bfd_byte l_rldoff[8]; 23689857Sobrien}; 23789857Sobrien#define LDHDRSZ (56) 23889857Sobrien 23989857Sobrienstruct external_ldsym 24089857Sobrien{ 24189857Sobrien bfd_byte l_value[8]; 24289857Sobrien bfd_byte l_offset[4]; 24389857Sobrien bfd_byte l_scnum[2]; 24489857Sobrien bfd_byte l_smtype[1]; 24589857Sobrien bfd_byte l_smclas[1]; 24689857Sobrien bfd_byte l_ifile[4]; 24789857Sobrien bfd_byte l_parm[4]; 24889857Sobrien}; 24989857Sobrien 25089857Sobrien#define LDSYMSZ (24) 25189857Sobrien 25289857Sobrienstruct external_ldrel 25389857Sobrien{ 25489857Sobrien bfd_byte l_vaddr[8]; 25589857Sobrien bfd_byte l_rtype[2]; 25689857Sobrien bfd_byte l_rsecnm[2]; 25789857Sobrien bfd_byte l_symndx[4]; 25889857Sobrien}; 25989857Sobrien 26089857Sobrien#define LDRELSZ (16) 261