Home | History | Annotate | Line # | Download | only in coff
rs6k64.h revision 1.8
      1  1.1  christos /* IBM RS/6000 "XCOFF64" file definitions for BFD.
      2  1.8  christos    Copyright (C) 2000-2022 Free Software Foundation, Inc.
      3  1.1  christos 
      4  1.1  christos    This program is free software; you can redistribute it and/or modify
      5  1.1  christos    it under the terms of the GNU General Public License as published by
      6  1.1  christos    the Free Software Foundation; either version 3 of the License, or
      7  1.1  christos    (at your option) any later version.
      8  1.1  christos 
      9  1.1  christos    This program is distributed in the hope that it will be useful,
     10  1.1  christos    but WITHOUT ANY WARRANTY; without even the implied warranty of
     11  1.1  christos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12  1.1  christos    GNU General Public License for more details.
     13  1.1  christos 
     14  1.1  christos    You should have received a copy of the GNU General Public License
     15  1.1  christos    along with this program; if not, write to the Free Software
     16  1.1  christos    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
     17  1.1  christos    MA 02110-1301, USA.  */
     18  1.1  christos 
     19  1.1  christos /********************** FILE HEADER **********************/
     20  1.1  christos 
     21  1.1  christos struct external_filehdr
     22  1.1  christos {
     23  1.1  christos   char f_magic[2];	/* magic number			*/
     24  1.1  christos   char f_nscns[2];	/* number of sections		*/
     25  1.1  christos   char f_timdat[4];	/* time & date stamp		*/
     26  1.1  christos   char f_symptr[8];	/* file pointer to symtab 	*/
     27  1.1  christos   char f_opthdr[2];	/* sizeof(optional hdr)		*/
     28  1.1  christos   char f_flags[2];	/* flags			*/
     29  1.1  christos   char f_nsyms[4];	/* number of symtab entries	*/
     30  1.1  christos };
     31  1.1  christos 
     32  1.1  christos /* IBM RS/6000.  */
     33  1.1  christos #define U803XTOCMAGIC 0757	/* Aix 4.3 64-bit XCOFF */
     34  1.1  christos #define	U64_TOCMAGIC  0767	/* AIX 5+ 64-bit XCOFF */
     35  1.1  christos #define BADMAG(x) ((x).f_magic != U803XTOCMAGIC && (x).f_magic != U64_TOCMAGIC)
     36  1.1  christos 
     37  1.1  christos #define	FILHDR	struct external_filehdr
     38  1.1  christos #define	FILHSZ	24
     39  1.1  christos 
     40  1.1  christos /********************** AOUT "OPTIONAL HEADER" **********************/
     41  1.1  christos 
     42  1.8  christos typedef struct
     43  1.1  christos {
     44  1.8  christos   unsigned char magic[2];		/* type of file			*/
     45  1.8  christos   unsigned char vstamp[2];		/* version stamp		*/
     46  1.8  christos   unsigned char o_debugger[4];		/* reserved			*/
     47  1.8  christos   unsigned char text_start[8];		/* base of text used for this file */
     48  1.8  christos   unsigned char data_start[8];		/* base of data used for this file */
     49  1.8  christos   unsigned char o_toc[8];		/* address of TOC */
     50  1.8  christos   unsigned char o_snentry[2];		/* section number of entry point */
     51  1.8  christos   unsigned char o_sntext[2];		/* section number of .text section */
     52  1.8  christos   unsigned char o_sndata[2];		/* section number of .data section */
     53  1.8  christos   unsigned char o_sntoc[2];		/* section number of TOC */
     54  1.8  christos   unsigned char o_snloader[2];		/* section number of .loader section */
     55  1.8  christos   unsigned char o_snbss[2];		/* section number of .bss section */
     56  1.8  christos   unsigned char o_algntext[2];		/* .text alignment */
     57  1.8  christos   unsigned char o_algndata[2];		/* .data alignment */
     58  1.8  christos   unsigned char o_modtype[2];		/* module type (??) */
     59  1.1  christos   unsigned char o_cputype[2];		/* cpu type */
     60  1.8  christos   unsigned char o_textpsize[1]; 	/* text page size */
     61  1.8  christos   unsigned char o_datapsize[1]; 	/* data page size */
     62  1.8  christos   unsigned char o_stackpsize[1];	/* stack page size */
     63  1.8  christos   unsigned char o_flags[1];		/* Flags and TLS alignment */
     64  1.8  christos   unsigned char tsize[8];		/* text size bytes, padded to FW bdry */
     65  1.8  christos   unsigned char dsize[8];		/* initialized data "  "	*/
     66  1.8  christos   unsigned char bsize[8];		/* uninitialized data "	  "	*/
     67  1.8  christos   unsigned char entry[8];		/* entry pt.			*/
     68  1.8  christos   unsigned char o_maxstack[8];		/* max stack size (??)		*/
     69  1.8  christos   unsigned char o_maxdata[8];		/* max data size (??)		*/
     70  1.8  christos   unsigned char o_sntdata[2];		/* section number of .tdata section */
     71  1.8  christos   unsigned char o_sntbss[2];		/* section number of .tbss section */
     72  1.8  christos   unsigned char o_x64flags[2];		/* XCOFF64 flags */
     73  1.8  christos   unsigned char o_resv3[10];		/* reserved			*/
     74  1.1  christos }
     75  1.1  christos AOUTHDR;
     76  1.1  christos 
     77  1.1  christos #define AOUTSZ 120
     78  1.1  christos #define SMALL_AOUTSZ (0)
     79  1.1  christos #define AOUTHDRSZ 72
     80  1.1  christos 
     81  1.1  christos /********************** SECTION HEADER **********************/
     82  1.1  christos 
     83  1.1  christos struct external_scnhdr
     84  1.1  christos {
     85  1.1  christos   char	s_name[8];	/* section name			*/
     86  1.1  christos   char	s_paddr[8];	/* physical address, aliased s_nlib */
     87  1.1  christos   char	s_vaddr[8];	/* virtual address		*/
     88  1.1  christos   char	s_size[8];	/* section size			*/
     89  1.1  christos   char	s_scnptr[8];	/* file ptr to raw data for section */
     90  1.1  christos   char	s_relptr[8];	/* file ptr to relocation	*/
     91  1.1  christos   char	s_lnnoptr[8];	/* file ptr to line numbers	*/
     92  1.1  christos   char	s_nreloc[4];	/* number of relocation entries	*/
     93  1.1  christos   char	s_nlnno[4];	/* number of line number entries*/
     94  1.1  christos   char	s_flags[4];	/* flags			*/
     95  1.1  christos   char  s_pad[4];	/* padding */
     96  1.1  christos };
     97  1.1  christos 
     98  1.1  christos #define	SCNHDR	struct external_scnhdr
     99  1.1  christos 
    100  1.1  christos #define	SCNHSZ	72
    101  1.1  christos 
    102  1.1  christos /********************** LINE NUMBERS **********************/
    103  1.1  christos 
    104  1.1  christos /* 1 line number entry for every "breakpointable" source line in a section.
    105  1.1  christos    Line numbers are grouped on a per function basis; first entry in a function
    106  1.1  christos    grouping will have l_lnno = 0 and in place of physical address will be the
    107  1.1  christos    symbol table index of the function name.  */
    108  1.1  christos 
    109  1.1  christos struct external_lineno
    110  1.1  christos {
    111  1.1  christos   union
    112  1.1  christos   {
    113  1.1  christos     char l_symndx[4];	/* function name symbol index, iff l_lnno == 0*/
    114  1.1  christos     char l_paddr[8];	/* (physical) address of line number	*/
    115  1.1  christos   } l_addr;
    116  1.1  christos 
    117  1.1  christos   char l_lnno[4];	/* line number		*/
    118  1.1  christos };
    119  1.1  christos 
    120  1.1  christos #define	LINENO	struct external_lineno
    121  1.1  christos 
    122  1.1  christos #define	LINESZ	12
    123  1.1  christos 
    124  1.1  christos /********************** SYMBOLS **********************/
    125  1.1  christos 
    126  1.1  christos #define E_SYMNMLEN	8	/* # characters in a symbol name	*/
    127  1.1  christos #define E_FILNMLEN	14	/* # characters in a file name		*/
    128  1.1  christos #define E_DIMNUM	4	/* # array dimensions in auxiliary entry */
    129  1.1  christos 
    130  1.1  christos struct external_syment
    131  1.1  christos {
    132  1.1  christos   char e_value[8];
    133  1.1  christos   char e_offset[4];
    134  1.1  christos   char e_scnum[2];
    135  1.1  christos   char e_type[2];
    136  1.1  christos   char e_sclass[1];
    137  1.1  christos   char e_numaux[1];
    138  1.1  christos };
    139  1.1  christos 
    140  1.1  christos #define N_BTMASK	(017)
    141  1.1  christos #define N_TMASK		(060)
    142  1.1  christos #define N_BTSHFT	(4)
    143  1.1  christos #define N_TSHIFT	(2)
    144  1.1  christos 
    145  1.1  christos union external_auxent
    146  1.1  christos {
    147  1.8  christos   struct {
    148  1.8  christos     char x_lnno[4]; 	/* declaration line number */
    149  1.8  christos     char x_pad[13];
    150  1.8  christos     char x_auxtype[1];
    151  1.8  christos   } x_sym;
    152  1.8  christos 
    153  1.8  christos   struct {
    154  1.8  christos     char x_lnnoptr[8];/* ptr to fcn line */
    155  1.8  christos     char x_fsize[4];	 /* size of function */
    156  1.8  christos     char x_endndx[4];	 /* entry ndx past block end */
    157  1.8  christos     char x_pad[1];
    158  1.8  christos     char x_auxtype[1];
    159  1.8  christos   } x_fcn;
    160  1.8  christos 
    161  1.8  christos   struct {
    162  1.8  christos     union {
    163  1.8  christos       char x_fname[E_FILNMLEN];
    164  1.8  christos       struct {
    165  1.8  christos 	char x_zeroes[4];
    166  1.8  christos 	char x_offset[4];
    167  1.8  christos 	char x_pad[6];
    168  1.8  christos       } x_n;
    169  1.8  christos     } x_n;
    170  1.8  christos     unsigned char x_ftype[1];
    171  1.8  christos     unsigned char x_resv[2];
    172  1.8  christos     char x_auxtype[1];
    173  1.8  christos   } x_file;
    174  1.8  christos 
    175  1.8  christos   struct {
    176  1.8  christos     char x_exptr[8];
    177  1.8  christos     char x_fsize[4];
    178  1.8  christos     char x_endndx[4];
    179  1.8  christos     char x_pad[1];
    180  1.8  christos     char x_auxtype[1];
    181  1.8  christos   } x_except;
    182  1.8  christos 
    183  1.8  christos   struct {
    184  1.8  christos     char x_scnlen_lo[4];
    185  1.8  christos     char x_parmhash[4];
    186  1.8  christos     char x_snhash[2];
    187  1.8  christos     char x_smtyp[1];
    188  1.8  christos     char x_smclas[1];
    189  1.8  christos     char x_scnlen_hi[4];
    190  1.8  christos     char x_pad[1];
    191  1.8  christos     char x_auxtype[1];
    192  1.8  christos   } x_csect;
    193  1.8  christos 
    194  1.8  christos   struct {
    195  1.8  christos     char x_scnlen[8];
    196  1.8  christos     char x_nreloc[8];
    197  1.8  christos     char x_pad[1];
    198  1.8  christos     char x_auxtype[1];
    199  1.8  christos   } x_sect;
    200  1.1  christos };
    201  1.1  christos 
    202  1.1  christos #define	SYMENT	struct external_syment
    203  1.1  christos #define	SYMESZ	18
    204  1.1  christos #define	AUXENT	union external_auxent
    205  1.1  christos #define	AUXESZ	18
    206  1.1  christos #define DBXMASK 0x80		/* for dbx storage mask */
    207  1.1  christos #define SYMNAME_IN_DEBUG(symptr) ((symptr)->n_sclass & DBXMASK)
    208  1.1  christos 
    209  1.1  christos /* Values for auxtype field in XCOFF64, taken from AIX 4.3 sym.h.  */
    210  1.1  christos #define _AUX_EXCEPT     255
    211  1.1  christos #define _AUX_FCN        254
    212  1.1  christos #define _AUX_SYM        253
    213  1.1  christos #define _AUX_FILE       252
    214  1.1  christos #define _AUX_CSECT      251
    215  1.8  christos #define _AUX_SECT       250
    216  1.1  christos 
    217  1.1  christos /********************** RELOCATION DIRECTIVES **********************/
    218  1.1  christos 
    219  1.1  christos struct external_reloc
    220  1.1  christos {
    221  1.1  christos   char r_vaddr[8];
    222  1.1  christos   char r_symndx[4];
    223  1.1  christos   char r_size[1];
    224  1.1  christos   char r_type[1];
    225  1.1  christos };
    226  1.1  christos 
    227  1.1  christos #define RELOC struct external_reloc
    228  1.1  christos #define RELSZ 14
    229  1.1  christos 
    230  1.1  christos #define DEFAULT_DATA_SECTION_ALIGNMENT 4
    231  1.1  christos #define DEFAULT_BSS_SECTION_ALIGNMENT 4
    232  1.1  christos #define DEFAULT_TEXT_SECTION_ALIGNMENT 4
    233  1.1  christos /* For new sections we havn't heard of before */
    234  1.1  christos #define DEFAULT_SECTION_ALIGNMENT 4
    235  1.1  christos 
    236  1.1  christos /* The ldhdr structure.  This appears at the start of the .loader
    237  1.1  christos    section.  */
    238  1.1  christos 
    239  1.1  christos struct external_ldhdr
    240  1.1  christos {
    241  1.1  christos   bfd_byte l_version[4];
    242  1.1  christos   bfd_byte l_nsyms[4];
    243  1.1  christos   bfd_byte l_nreloc[4];
    244  1.1  christos   bfd_byte l_istlen[4];
    245  1.1  christos   bfd_byte l_nimpid[4];
    246  1.1  christos   bfd_byte l_stlen[4];
    247  1.1  christos   bfd_byte l_impoff[8];
    248  1.1  christos   bfd_byte l_stoff[8];
    249  1.1  christos   bfd_byte l_symoff[8];
    250  1.1  christos   bfd_byte l_rldoff[8];
    251  1.1  christos };
    252  1.1  christos #define LDHDRSZ (56)
    253  1.1  christos 
    254  1.1  christos struct external_ldsym
    255  1.1  christos {
    256  1.1  christos   bfd_byte l_value[8];
    257  1.1  christos   bfd_byte l_offset[4];
    258  1.1  christos   bfd_byte l_scnum[2];
    259  1.1  christos   bfd_byte l_smtype[1];
    260  1.1  christos   bfd_byte l_smclas[1];
    261  1.1  christos   bfd_byte l_ifile[4];
    262  1.1  christos   bfd_byte l_parm[4];
    263  1.1  christos };
    264  1.1  christos 
    265  1.1  christos #define LDSYMSZ (24)
    266  1.1  christos 
    267  1.1  christos struct external_ldrel
    268  1.1  christos {
    269  1.1  christos   bfd_byte l_vaddr[8];
    270  1.1  christos   bfd_byte l_rtype[2];
    271  1.1  christos   bfd_byte l_rsecnm[2];
    272  1.1  christos   bfd_byte l_symndx[4];
    273  1.1  christos };
    274  1.1  christos 
    275  1.1  christos #define LDRELSZ (16)
    276  1.1  christos 
    277  1.1  christos struct external_exceptab
    278  1.1  christos {
    279  1.1  christos   union {
    280  1.1  christos     bfd_byte e_symndx[4];
    281  1.1  christos     bfd_byte e_paddr[8];
    282  1.1  christos   } e_addr;
    283  1.1  christos   bfd_byte e_lang[1];
    284  1.1  christos   bfd_byte e_reason[1];
    285  1.1  christos };
    286  1.1  christos 
    287  1.1  christos #define EXCEPTSZ (10)
    288