Back to index

cell-binutils  2.17cvs20070401
alpha.h
Go to the documentation of this file.
00001 /* ECOFF support on Alpha machines.
00002    coff/ecoff.h must be included before this file.
00003 
00004    Copyright 2001, 2005 Free Software Foundation, Inc.
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010    
00011    This program is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014    GNU General Public License for more details.
00015    
00016    You should have received a copy of the GNU General Public License
00017    along with this program; if not, write to the Free Software
00018    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
00019    
00020 /********************** FILE HEADER **********************/
00021 
00022 struct external_filehdr
00023 {
00024   unsigned char f_magic[2]; /* magic number                    */
00025   unsigned char f_nscns[2]; /* number of sections              */
00026   unsigned char f_timdat[4];       /* time & date stamp        */
00027   unsigned char f_symptr[8];       /* file pointer to symtab   */
00028   unsigned char f_nsyms[4]; /* number of symtab entries */
00029   unsigned char f_opthdr[2];       /* sizeof(optional hdr)            */
00030   unsigned char f_flags[2]; /* flags                    */
00031 };
00032 
00033 /* Magic numbers are defined in coff/ecoff.h.  */
00034 #define ALPHA_ECOFF_BADMAG(x) \
00035   ((x).f_magic != ALPHA_MAGIC && (x).f_magic != ALPHA_MAGIC_BSD)
00036 
00037 #define ALPHA_ECOFF_COMPRESSEDMAG(x) \
00038   ((x).f_magic == ALPHA_MAGIC_COMPRESSED)
00039 
00040 /* The object type is encoded in the f_flags.  */
00041 #define F_ALPHA_OBJECT_TYPE_MASK   0x3000
00042 #define F_ALPHA_NO_SHARED          0x1000
00043 #define F_ALPHA_SHARABLE           0x2000
00044 #define F_ALPHA_CALL_SHARED        0x3000
00045 
00046 #define       FILHDR struct external_filehdr
00047 #define       FILHSZ 24
00048 
00049 /********************** AOUT "OPTIONAL HEADER" **********************/
00050 
00051 typedef struct external_aouthdr
00052 {
00053   unsigned char magic[2];   /* type of file                           */
00054   unsigned char      vstamp[2];    /* version stamp                   */
00055   unsigned char bldrev[2];  /* ?? */
00056   unsigned char padding[2]; /* pad to quadword boundary        */
00057   unsigned char      tsize[8];     /* text size in bytes                     */
00058   unsigned char      dsize[8];     /* initialized data "  "           */
00059   unsigned char      bsize[8];     /* uninitialized data "   "        */
00060   unsigned char      entry[8];     /* entry pt.                       */
00061   unsigned char text_start[8];     /* base of text used for this file */
00062   unsigned char data_start[8];     /* base of data used for this file */
00063   unsigned char bss_start[8];      /* base of bss used for this file */
00064   unsigned char gprmask[4]; /* bitmask of general registers used */
00065   unsigned char fprmask[4]; /* bitmask of floating point registers used */
00066   unsigned char gp_value[8];       /* value for gp register */
00067 } AOUTHDR;
00068 
00069 /* compute size of a header */
00070 
00071 #define AOUTSZ 80
00072 #define AOUTHDRSZ 80
00073 
00074 /********************** SECTION HEADER **********************/
00075 
00076 struct external_scnhdr
00077 {
00078   unsigned char      s_name[8];    /* section name                    */
00079   unsigned char      s_paddr[8];   /* physical address, aliased s_nlib */
00080   unsigned char      s_vaddr[8];   /* virtual address          */
00081   unsigned char      s_size[8];    /* section size                    */
00082   unsigned char      s_scnptr[8];  /* file ptr to raw data for section */
00083   unsigned char      s_relptr[8];  /* file ptr to relocation   */
00084   unsigned char      s_lnnoptr[8]; /* file ptr to line numbers */
00085   unsigned char      s_nreloc[2];  /* number of relocation entries    */
00086   unsigned char      s_nlnno[2];   /* number of line number entries*/
00087   unsigned char      s_flags[4];   /* flags                    */
00088 };
00089 
00090 #define       SCNHDR struct external_scnhdr
00091 #define       SCNHSZ 64
00092 
00093 /********************** RELOCATION DIRECTIVES **********************/
00094 
00095 struct external_reloc 
00096 {
00097   unsigned char r_vaddr[8];
00098   unsigned char r_symndx[4];
00099   unsigned char r_bits[4];
00100 };
00101 
00102 #define RELOC struct external_reloc
00103 #define RELSZ 16
00104 
00105 /* Constants to unpack the r_bits field.  The Alpha seems to always be
00106    little endian, so I haven't bothered to define big endian variants
00107    of these.  */
00108 
00109 #define RELOC_BITS0_TYPE_LITTLE                  0xff
00110 #define RELOC_BITS0_TYPE_SH_LITTLE        0
00111 
00112 #define RELOC_BITS1_EXTERN_LITTLE         0x01
00113 
00114 #define RELOC_BITS1_OFFSET_LITTLE         0x7e
00115 #define RELOC_BITS1_OFFSET_SH_LITTLE             1
00116 
00117 #define RELOC_BITS1_RESERVED_LITTLE              0x80
00118 #define RELOC_BITS1_RESERVED_SH_LITTLE           7
00119 #define RELOC_BITS2_RESERVED_LITTLE              0xff
00120 #define RELOC_BITS2_RESERVED_SH_LEFT_LITTLE      1
00121 #define RELOC_BITS3_RESERVED_LITTLE              0x03
00122 #define RELOC_BITS3_RESERVED_SH_LEFT_LITTLE      9
00123 
00124 #define RELOC_BITS3_SIZE_LITTLE                  0xfc
00125 #define RELOC_BITS3_SIZE_SH_LITTLE        2
00126 
00127 /* The r_type field in a reloc is one of the following values.  */
00128 #define ALPHA_R_IGNORE             0
00129 #define ALPHA_R_REFLONG            1
00130 #define ALPHA_R_REFQUAD            2
00131 #define ALPHA_R_GPREL32            3
00132 #define ALPHA_R_LITERAL            4
00133 #define ALPHA_R_LITUSE             5
00134 #define ALPHA_R_GPDISP             6
00135 #define ALPHA_R_BRADDR             7
00136 #define ALPHA_R_HINT        8
00137 #define ALPHA_R_SREL16             9
00138 #define ALPHA_R_SREL32             10
00139 #define ALPHA_R_SREL64             11
00140 #define ALPHA_R_OP_PUSH            12
00141 #define ALPHA_R_OP_STORE       13
00142 #define ALPHA_R_OP_PSUB            14
00143 #define ALPHA_R_OP_PRSHIFT     15
00144 #define ALPHA_R_GPVALUE            16
00145 #define ALPHA_R_GPRELHIGH      17
00146 #define ALPHA_R_GPRELLOW       18
00147 #define ALPHA_R_IMMED          19
00148 
00149 /* Overloaded reloc value used by Net- and OpenBSD.  */
00150 #define ALPHA_R_LITERALSLEAZY  17
00151 
00152 /* With ALPHA_R_LITUSE, the r_size field is one of the following values.  */
00153 #define ALPHA_R_LU_BASE         1
00154 #define ALPHA_R_LU_BYTOFF       2
00155 #define ALPHA_R_LU_JSR          3
00156 
00157 /* With ALPHA_R_IMMED, the r_size field is one of the following values.  */
00158 #define ALPHA_R_IMMED_GP_16     1
00159 #define ALPHA_R_IMMED_GP_HI32   2
00160 #define ALPHA_R_IMMED_SCN_HI32  3
00161 #define ALPHA_R_IMMED_BR_HI32   4
00162 #define ALPHA_R_IMMED_LO32      5
00163 
00164 /********************** SYMBOLIC INFORMATION **********************/
00165 
00166 /* Written by John Gilmore.  */
00167 
00168 /* ECOFF uses COFF-like section structures, but its own symbol format.
00169    This file defines the symbol format in fields whose size and alignment
00170    will not vary on different host systems.  */
00171 
00172 /* File header as a set of bytes */
00173 
00174 struct hdr_ext
00175 {
00176        unsigned char        h_magic[2];
00177        unsigned char h_vstamp[2];
00178        unsigned char h_ilineMax[4];
00179        unsigned char h_idnMax[4];
00180        unsigned char h_ipdMax[4];
00181        unsigned char h_isymMax[4];
00182        unsigned char h_ioptMax[4];
00183        unsigned char h_iauxMax[4];
00184        unsigned char h_issMax[4];
00185        unsigned char h_issExtMax[4];
00186        unsigned char h_ifdMax[4];
00187        unsigned char h_crfd[4];
00188        unsigned char h_iextMax[4];
00189        unsigned char h_cbLine[8];
00190        unsigned char h_cbLineOffset[8];
00191        unsigned char h_cbDnOffset[8];
00192        unsigned char h_cbPdOffset[8];
00193        unsigned char h_cbSymOffset[8];
00194        unsigned char h_cbOptOffset[8];
00195        unsigned char h_cbAuxOffset[8];
00196        unsigned char h_cbSsOffset[8];
00197        unsigned char h_cbSsExtOffset[8];
00198        unsigned char h_cbFdOffset[8];
00199        unsigned char h_cbRfdOffset[8];
00200        unsigned char h_cbExtOffset[8];
00201 };
00202 
00203 /* File descriptor external record */
00204 
00205 struct fdr_ext
00206 {
00207        unsigned char f_adr[8];
00208        unsigned char f_cbLineOffset[8];
00209        unsigned char f_cbLine[8];
00210        unsigned char f_cbSs[8];
00211        unsigned char f_rss[4];
00212        unsigned char f_issBase[4];
00213        unsigned char f_isymBase[4];
00214        unsigned char f_csym[4];
00215        unsigned char f_ilineBase[4];
00216        unsigned char f_cline[4];
00217        unsigned char f_ioptBase[4];
00218        unsigned char f_copt[4];
00219        unsigned char f_ipdFirst[4];
00220        unsigned char f_cpd[4];
00221        unsigned char f_iauxBase[4];
00222        unsigned char f_caux[4];
00223        unsigned char f_rfdBase[4];
00224        unsigned char f_crfd[4];
00225        unsigned char f_bits1[1];
00226        unsigned char f_bits2[3];
00227        unsigned char f_padding[4];
00228 };
00229 
00230 #define       FDR_BITS1_LANG_BIG          0xF8
00231 #define       FDR_BITS1_LANG_SH_BIG              3
00232 #define       FDR_BITS1_LANG_LITTLE              0x1F
00233 #define       FDR_BITS1_LANG_SH_LITTLE    0
00234 
00235 #define       FDR_BITS1_FMERGE_BIG        0x04
00236 #define       FDR_BITS1_FMERGE_LITTLE            0x20
00237 
00238 #define       FDR_BITS1_FREADIN_BIG              0x02
00239 #define       FDR_BITS1_FREADIN_LITTLE    0x40
00240 
00241 #define       FDR_BITS1_FBIGENDIAN_BIG    0x01
00242 #define       FDR_BITS1_FBIGENDIAN_LITTLE 0x80
00243 
00244 #define       FDR_BITS2_GLEVEL_BIG        0xC0
00245 #define       FDR_BITS2_GLEVEL_SH_BIG            6
00246 #define       FDR_BITS2_GLEVEL_LITTLE            0x03
00247 #define       FDR_BITS2_GLEVEL_SH_LITTLE  0
00248 
00249 /* We ignore the `reserved' field in bits2. */
00250 
00251 /* Procedure descriptor external record */
00252 
00253 struct pdr_ext {
00254        unsigned char p_adr[8];
00255        unsigned char p_cbLineOffset[8];
00256        unsigned char p_isym[4];
00257        unsigned char p_iline[4];
00258        unsigned char p_regmask[4];
00259        unsigned char p_regoffset[4];
00260        unsigned char p_iopt[4];
00261        unsigned char p_fregmask[4];
00262        unsigned char p_fregoffset[4];
00263        unsigned char p_frameoffset[4];
00264        unsigned char p_lnLow[4];
00265        unsigned char p_lnHigh[4];
00266        unsigned char p_gp_prologue[1];
00267        unsigned char p_bits1[1];
00268        unsigned char p_bits2[1];
00269        unsigned char p_localoff[1];
00270        unsigned char p_framereg[2];
00271        unsigned char p_pcreg[2];
00272 };
00273 
00274 #define PDR_BITS1_GP_USED_BIG             0x80
00275 #define PDR_BITS1_REG_FRAME_BIG           0x40
00276 #define PDR_BITS1_PROF_BIG         0x20
00277 #define PDR_BITS1_RESERVED_BIG            0x1f
00278 #define PDR_BITS1_RESERVED_SH_LEFT_BIG    8
00279 #define PDR_BITS2_RESERVED_BIG            0xff
00280 #define PDR_BITS2_RESERVED_SH_BIG  0
00281 
00282 #define PDR_BITS1_GP_USED_LITTLE   0x01
00283 #define PDR_BITS1_REG_FRAME_LITTLE 0x02
00284 #define PDR_BITS1_PROF_LITTLE             0x04
00285 #define PDR_BITS1_RESERVED_LITTLE  0xf8
00286 #define PDR_BITS1_RESERVED_SH_LITTLE      3
00287 #define PDR_BITS2_RESERVED_LITTLE  0xff
00288 #define PDR_BITS2_RESERVED_SH_LEFT_LITTLE 5
00289 
00290 /* Line numbers */
00291 
00292 struct line_ext {
00293        unsigned char l_line[4];
00294 };
00295 
00296 /* Symbol external record */
00297 
00298 struct sym_ext {
00299        unsigned char s_value[8];
00300        unsigned char s_iss[4];
00301        unsigned char s_bits1[1];
00302        unsigned char s_bits2[1];
00303        unsigned char s_bits3[1];
00304        unsigned char s_bits4[1];
00305 };
00306 
00307 #define       SYM_BITS1_ST_BIG            0xFC
00308 #define       SYM_BITS1_ST_SH_BIG         2
00309 #define       SYM_BITS1_ST_LITTLE         0x3F
00310 #define       SYM_BITS1_ST_SH_LITTLE             0
00311 
00312 #define       SYM_BITS1_SC_BIG            0x03
00313 #define       SYM_BITS1_SC_SH_LEFT_BIG    3
00314 #define       SYM_BITS1_SC_LITTLE         0xC0
00315 #define       SYM_BITS1_SC_SH_LITTLE             6
00316 
00317 #define       SYM_BITS2_SC_BIG            0xE0
00318 #define       SYM_BITS2_SC_SH_BIG         5
00319 #define       SYM_BITS2_SC_LITTLE         0x07
00320 #define       SYM_BITS2_SC_SH_LEFT_LITTLE 2
00321 
00322 #define       SYM_BITS2_RESERVED_BIG             0x10
00323 #define       SYM_BITS2_RESERVED_LITTLE   0x08
00324 
00325 #define       SYM_BITS2_INDEX_BIG         0x0F
00326 #define       SYM_BITS2_INDEX_SH_LEFT_BIG 16
00327 #define       SYM_BITS2_INDEX_LITTLE             0xF0
00328 #define       SYM_BITS2_INDEX_SH_LITTLE   4
00329 
00330 #define       SYM_BITS3_INDEX_SH_LEFT_BIG 8
00331 #define       SYM_BITS3_INDEX_SH_LEFT_LITTLE     4
00332 
00333 #define       SYM_BITS4_INDEX_SH_LEFT_BIG 0
00334 #define       SYM_BITS4_INDEX_SH_LEFT_LITTLE     12
00335 
00336 /* External symbol external record */
00337 
00338 struct ext_ext {
00339        struct sym_ext es_asym;
00340        unsigned char es_bits1[1];
00341        unsigned char es_bits2[3];
00342        unsigned char es_ifd[4];
00343 };
00344 
00345 #define       EXT_BITS1_JMPTBL_BIG        0x80
00346 #define       EXT_BITS1_JMPTBL_LITTLE            0x01
00347 
00348 #define       EXT_BITS1_COBOL_MAIN_BIG    0x40
00349 #define       EXT_BITS1_COBOL_MAIN_LITTLE 0x02
00350 
00351 #define       EXT_BITS1_WEAKEXT_BIG              0x20
00352 #define       EXT_BITS1_WEAKEXT_LITTLE    0x04
00353 
00354 /* Dense numbers external record */
00355 
00356 struct dnr_ext {
00357        unsigned char d_rfd[4];
00358        unsigned char d_index[4];
00359 };
00360 
00361 /* Relative file descriptor */
00362 
00363 struct rfd_ext {
00364   unsigned char      rfd[4];
00365 };
00366 
00367 /* Optimizer symbol external record */
00368 
00369 struct opt_ext {
00370   unsigned char o_bits1[1];
00371   unsigned char o_bits2[1];
00372   unsigned char o_bits3[1];
00373   unsigned char o_bits4[1];
00374   struct rndx_ext o_rndx;
00375   unsigned char o_offset[4];
00376 };
00377 
00378 #define OPT_BITS2_VALUE_SH_LEFT_BIG       16
00379 #define OPT_BITS2_VALUE_SH_LEFT_LITTLE    0
00380 
00381 #define OPT_BITS3_VALUE_SH_LEFT_BIG       8
00382 #define OPT_BITS3_VALUE_SH_LEFT_LITTLE    8
00383 
00384 #define OPT_BITS4_VALUE_SH_LEFT_BIG       0
00385 #define OPT_BITS4_VALUE_SH_LEFT_LITTLE    16