184865Sobrien/* IBM RS/6000 "XCOFF" file definitions for BFD. 2218822Sdim Copyright (C) 1990, 1991, 2001 Free Software Foundation, Inc. 3218822Sdim Written by Mimi Phuong-Thao Vo of IBM 484865Sobrien and John Gilmore of Cygnus Support. */ 584865Sobrien 684865Sobrien/********************** FILE HEADER **********************/ 784865Sobrien 884865Sobrienstruct external_filehdr { 984865Sobrien char f_magic[2]; /* magic number */ 1084865Sobrien char f_nscns[2]; /* number of sections */ 1184865Sobrien char f_timdat[4]; /* time & date stamp */ 1284865Sobrien char f_symptr[4]; /* file pointer to symtab */ 1384865Sobrien char f_nsyms[4]; /* number of symtab entries */ 1484865Sobrien char f_opthdr[2]; /* sizeof(optional hdr) */ 1584865Sobrien char f_flags[2]; /* flags */ 1684865Sobrien}; 1784865Sobrien 1884865Sobrien /* IBM RS/6000 */ 1984865Sobrien#define U802WRMAGIC 0730 /* writeable text segments **chh** */ 2084865Sobrien#define U802ROMAGIC 0735 /* readonly sharable text segments */ 2184865Sobrien#define U802TOCMAGIC 0737 /* readonly text segments and TOC */ 2284865Sobrien 2384865Sobrien#define BADMAG(x) \ 2484865Sobrien ((x).f_magic != U802ROMAGIC && (x).f_magic != U802WRMAGIC && \ 2584865Sobrien (x).f_magic != U802TOCMAGIC) 2684865Sobrien 2784865Sobrien#define FILHDR struct external_filehdr 2884865Sobrien#define FILHSZ 20 2984865Sobrien 3084865Sobrien 3184865Sobrien/********************** AOUT "OPTIONAL HEADER" **********************/ 3284865Sobrien 3384865Sobrien 3484865Sobrientypedef struct 3584865Sobrien{ 3684865Sobrien unsigned char magic[2]; /* type of file */ 3784865Sobrien unsigned char vstamp[2]; /* version stamp */ 3884865Sobrien unsigned char tsize[4]; /* text size in bytes, padded to FW bdry */ 3984865Sobrien unsigned char dsize[4]; /* initialized data " " */ 4084865Sobrien unsigned char bsize[4]; /* uninitialized data " " */ 4184865Sobrien unsigned char entry[4]; /* entry pt. */ 4284865Sobrien unsigned char text_start[4]; /* base of text used for this file */ 4384865Sobrien unsigned char data_start[4]; /* base of data used for this file */ 4484865Sobrien unsigned char o_toc[4]; /* address of TOC */ 4584865Sobrien unsigned char o_snentry[2]; /* section number of entry point */ 4684865Sobrien unsigned char o_sntext[2]; /* section number of .text section */ 4784865Sobrien unsigned char o_sndata[2]; /* section number of .data section */ 4884865Sobrien unsigned char o_sntoc[2]; /* section number of TOC */ 4984865Sobrien unsigned char o_snloader[2]; /* section number of .loader section */ 5084865Sobrien unsigned char o_snbss[2]; /* section number of .bss section */ 5184865Sobrien unsigned char o_algntext[2]; /* .text alignment */ 5284865Sobrien unsigned char o_algndata[2]; /* .data alignment */ 5384865Sobrien unsigned char o_modtype[2]; /* module type (??) */ 5484865Sobrien unsigned char o_cputype[2]; /* cpu type */ 5584865Sobrien unsigned char o_maxstack[4]; /* max stack size (??) */ 5684865Sobrien unsigned char o_maxdata[4]; /* max data size (??) */ 5784865Sobrien unsigned char o_resv2[12]; /* reserved */ 5884865Sobrien} 5984865SobrienAOUTHDR; 6084865Sobrien 6184865Sobrien#define AOUTSZ 72 6284865Sobrien#define SMALL_AOUTSZ (28) 6384865Sobrien#define AOUTHDRSZ 72 6484865Sobrien 6584865Sobrien/********************** SECTION HEADER **********************/ 6684865Sobrien 6784865Sobrien 6884865Sobrienstruct external_scnhdr { 6984865Sobrien char s_name[8]; /* section name */ 7084865Sobrien char s_paddr[4]; /* physical address, aliased s_nlib */ 7184865Sobrien char s_vaddr[4]; /* virtual address */ 7284865Sobrien char s_size[4]; /* section size */ 7384865Sobrien char s_scnptr[4]; /* file ptr to raw data for section */ 7484865Sobrien char s_relptr[4]; /* file ptr to relocation */ 7584865Sobrien char s_lnnoptr[4]; /* file ptr to line numbers */ 7684865Sobrien char s_nreloc[2]; /* number of relocation entries */ 7784865Sobrien char s_nlnno[2]; /* number of line number entries*/ 7884865Sobrien char s_flags[4]; /* flags */ 7984865Sobrien}; 8084865Sobrien 8184865Sobrien#define SCNHDR struct external_scnhdr 8284865Sobrien#define SCNHSZ 40 8384865Sobrien 8484865Sobrien/********************** LINE NUMBERS **********************/ 8584865Sobrien 8684865Sobrien/* 1 line number entry for every "breakpointable" source line in a section. 8784865Sobrien * Line numbers are grouped on a per function basis; first entry in a function 8884865Sobrien * grouping will have l_lnno = 0 and in place of physical address will be the 8984865Sobrien * symbol table index of the function name. 9084865Sobrien */ 9184865Sobrienstruct external_lineno { 9284865Sobrien union { 9384865Sobrien char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/ 9484865Sobrien char l_paddr[4]; /* (physical) address of line number */ 9584865Sobrien } l_addr; 9684865Sobrien char l_lnno[2]; /* line number */ 9784865Sobrien}; 9884865Sobrien 9984865Sobrien 10084865Sobrien#define LINENO struct external_lineno 10184865Sobrien#define LINESZ 6 10284865Sobrien 10384865Sobrien 10484865Sobrien/********************** SYMBOLS **********************/ 10584865Sobrien 10684865Sobrien#define E_SYMNMLEN 8 /* # characters in a symbol name */ 10784865Sobrien#define E_FILNMLEN 14 /* # characters in a file name */ 10884865Sobrien#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */ 10984865Sobrien 11084865Sobrienstruct external_syment 11184865Sobrien{ 11284865Sobrien union { 11384865Sobrien char e_name[E_SYMNMLEN]; 11484865Sobrien struct { 11584865Sobrien char e_zeroes[4]; 11684865Sobrien char e_offset[4]; 11784865Sobrien } e; 11884865Sobrien } e; 11984865Sobrien char e_value[4]; 12084865Sobrien char e_scnum[2]; 12184865Sobrien char e_type[2]; 12284865Sobrien char e_sclass[1]; 12384865Sobrien char e_numaux[1]; 12484865Sobrien}; 12584865Sobrien 12684865Sobrien 12784865Sobrien 12884865Sobrien#define N_BTMASK (017) 12984865Sobrien#define N_TMASK (060) 13084865Sobrien#define N_BTSHFT (4) 13184865Sobrien#define N_TSHIFT (2) 13284865Sobrien 13384865Sobrien 13484865Sobrienunion external_auxent { 13584865Sobrien struct { 13684865Sobrien char x_tagndx[4]; /* str, un, or enum tag indx */ 13784865Sobrien union { 13884865Sobrien struct { 13984865Sobrien char x_lnno[2]; /* declaration line number */ 14084865Sobrien char x_size[2]; /* str/union/array size */ 14184865Sobrien } x_lnsz; 14284865Sobrien char x_fsize[4]; /* size of function */ 14384865Sobrien } x_misc; 14484865Sobrien union { 14584865Sobrien struct { /* if ISFCN, tag, or .bb */ 14684865Sobrien char x_lnnoptr[4]; /* ptr to fcn line # */ 14784865Sobrien char x_endndx[4]; /* entry ndx past block end */ 14884865Sobrien } x_fcn; 14984865Sobrien struct { /* if ISARY, up to 4 dimen. */ 15084865Sobrien char x_dimen[E_DIMNUM][2]; 15184865Sobrien } x_ary; 15284865Sobrien } x_fcnary; 15384865Sobrien char x_tvndx[2]; /* tv index */ 15484865Sobrien } x_sym; 15584865Sobrien 15684865Sobrien union { 15784865Sobrien char x_fname[E_FILNMLEN]; 15884865Sobrien struct { 15984865Sobrien char x_zeroes[4]; 16084865Sobrien char x_offset[4]; 16184865Sobrien } x_n; 16284865Sobrien } x_file; 16384865Sobrien 16484865Sobrien struct { 16584865Sobrien char x_scnlen[4]; /* section length */ 16684865Sobrien char x_nreloc[2]; /* # relocation entries */ 16784865Sobrien char x_nlinno[2]; /* # line numbers */ 16884865Sobrien } x_scn; 16984865Sobrien 17084865Sobrien struct { 17184865Sobrien char x_tvfill[4]; /* tv fill value */ 17284865Sobrien char x_tvlen[2]; /* length of .tv */ 17384865Sobrien char x_tvran[2][2]; /* tv range */ 17484865Sobrien } x_tv; /* info about .tv section (in auxent of symbol .tv)) */ 17584865Sobrien 17684865Sobrien struct { 17784865Sobrien unsigned char x_scnlen[4]; 17884865Sobrien unsigned char x_parmhash[4]; 17984865Sobrien unsigned char x_snhash[2]; 18084865Sobrien unsigned char x_smtyp[1]; 18184865Sobrien unsigned char x_smclas[1]; 18284865Sobrien unsigned char x_stab[4]; 18384865Sobrien unsigned char x_snstab[2]; 18484865Sobrien } x_csect; 18584865Sobrien 18684865Sobrien}; 18784865Sobrien 18884865Sobrien#define SYMENT struct external_syment 18984865Sobrien#define SYMESZ 18 19084865Sobrien#define AUXENT union external_auxent 19184865Sobrien#define AUXESZ 18 19284865Sobrien#define DBXMASK 0x80 /* for dbx storage mask */ 19384865Sobrien#define SYMNAME_IN_DEBUG(symptr) ((symptr)->n_sclass & DBXMASK) 19484865Sobrien 19584865Sobrien 19684865Sobrien 19784865Sobrien/********************** RELOCATION DIRECTIVES **********************/ 19884865Sobrien 19984865Sobrien 20084865Sobrienstruct external_reloc { 20184865Sobrien char r_vaddr[4]; 20284865Sobrien char r_symndx[4]; 20384865Sobrien char r_size[1]; 20484865Sobrien char r_type[1]; 20584865Sobrien}; 20684865Sobrien 20784865Sobrien 20884865Sobrien#define RELOC struct external_reloc 20984865Sobrien#define RELSZ 10 21084865Sobrien 21184865Sobrien#define DEFAULT_DATA_SECTION_ALIGNMENT 4 21284865Sobrien#define DEFAULT_BSS_SECTION_ALIGNMENT 4 21384865Sobrien#define DEFAULT_TEXT_SECTION_ALIGNMENT 4 21484865Sobrien/* For new sections we havn't heard of before */ 21584865Sobrien#define DEFAULT_SECTION_ALIGNMENT 4 21689857Sobrien 21789857Sobrien/* The ldhdr structure. This appears at the start of the .loader 21889857Sobrien section. */ 21989857Sobrien 22089857Sobrienstruct external_ldhdr 22189857Sobrien{ 22289857Sobrien bfd_byte l_version[4]; 22389857Sobrien bfd_byte l_nsyms[4]; 22489857Sobrien bfd_byte l_nreloc[4]; 22589857Sobrien bfd_byte l_istlen[4]; 22689857Sobrien bfd_byte l_nimpid[4]; 22789857Sobrien bfd_byte l_impoff[4]; 22889857Sobrien bfd_byte l_stlen[4]; 22989857Sobrien bfd_byte l_stoff[4]; 23089857Sobrien}; 23189857Sobrien 23289857Sobrien#define LDHDRSZ (8 * 4) 23389857Sobrien 23489857Sobrienstruct external_ldsym 23589857Sobrien{ 23689857Sobrien union 23789857Sobrien { 23889857Sobrien bfd_byte _l_name[SYMNMLEN]; 23989857Sobrien struct 24089857Sobrien { 24189857Sobrien bfd_byte _l_zeroes[4]; 24289857Sobrien bfd_byte _l_offset[4]; 24389857Sobrien } _l_l; 24489857Sobrien } _l; 24589857Sobrien bfd_byte l_value[4]; 24689857Sobrien bfd_byte l_scnum[2]; 24789857Sobrien bfd_byte l_smtype[1]; 24889857Sobrien bfd_byte l_smclas[1]; 24989857Sobrien bfd_byte l_ifile[4]; 25089857Sobrien bfd_byte l_parm[4]; 25189857Sobrien}; 25289857Sobrien 25389857Sobrien#define LDSYMSZ (8 + 3 * 4 + 2 + 2) 25489857Sobrien 25589857Sobrienstruct external_ldrel 25689857Sobrien{ 25789857Sobrien bfd_byte l_vaddr[4]; 25889857Sobrien bfd_byte l_symndx[4]; 25989857Sobrien bfd_byte l_rtype[2]; 26089857Sobrien bfd_byte l_rsecnm[2]; 26189857Sobrien}; 26289857Sobrien 26389857Sobrien#define LDRELSZ (2 * 4 + 2 * 2) 264