Back to index

cell-binutils  2.17cvs20070401
mips.h
Go to the documentation of this file.
00001 /* ECOFF support on MIPS machines.
00002    coff/ecoff.h must be included before this file.
00003    
00004    Copyright 1999, 2004 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 #define DO_NOT_DEFINE_AOUTHDR
00021 #define L_LNNO_SIZE 4
00022 #include "coff/external.h"
00023 
00024 /* Magic numbers are defined in coff/ecoff.h.  */
00025 #define MIPS_ECOFF_BADMAG(x) (((x).f_magic!=MIPS_MAGIC_1) && \
00026                            ((x).f_magic!=MIPS_MAGIC_LITTLE) &&\
00027                            ((x).f_magic!=MIPS_MAGIC_BIG) && \
00028                            ((x).f_magic!=MIPS_MAGIC_LITTLE2) && \
00029                            ((x).f_magic!=MIPS_MAGIC_BIG2) && \
00030                            ((x).f_magic!=MIPS_MAGIC_LITTLE3) && \
00031                            ((x).f_magic!=MIPS_MAGIC_BIG3))
00032 
00033 
00034 /********************** AOUT "OPTIONAL HEADER" **********************/
00035 
00036 typedef struct external_aouthdr
00037 {
00038   unsigned char magic[2];   /* type of file                           */
00039   unsigned char      vstamp[2];    /* version stamp                   */
00040   unsigned char      tsize[4];     /* text size in bytes, padded to FW bdry*/
00041   unsigned char      dsize[4];     /* initialized data "  "           */
00042   unsigned char      bsize[4];     /* uninitialized data "   "        */
00043   unsigned char      entry[4];     /* entry pt.                       */
00044   unsigned char text_start[4];     /* base of text used for this file */
00045   unsigned char data_start[4];     /* base of data used for this file */
00046   unsigned char bss_start[4];      /* base of bss used for this file */
00047   unsigned char gprmask[4]; /* ?? */
00048   unsigned char cprmask[4][4];     /* ?? */
00049   unsigned char gp_value[4];       /* value for gp register */
00050 } AOUTHDR;
00051 
00052 /* compute size of a header */
00053 
00054 #define AOUTSZ 56
00055 #define AOUTHDRSZ 56
00056 
00057 /********************** RELOCATION DIRECTIVES **********************/
00058 
00059 struct external_reloc
00060   {
00061     unsigned char r_vaddr[4];
00062     unsigned char r_bits[4];
00063   };
00064 
00065 #define RELOC struct external_reloc
00066 #define RELSZ 8
00067 
00068 /* MIPS ECOFF uses a packed 8 byte format for relocs.  These constants
00069    are used to unpack the r_bits field.  */
00070 
00071 #define RELOC_BITS0_SYMNDX_SH_LEFT_BIG           16
00072 #define RELOC_BITS0_SYMNDX_SH_LEFT_LITTLE 0
00073 
00074 #define RELOC_BITS1_SYMNDX_SH_LEFT_BIG           8
00075 #define RELOC_BITS1_SYMNDX_SH_LEFT_LITTLE 8
00076 
00077 #define RELOC_BITS2_SYMNDX_SH_LEFT_BIG           0
00078 #define RELOC_BITS2_SYMNDX_SH_LEFT_LITTLE 16
00079 
00080 /* Originally, ECOFF used four bits for the reloc type and had three
00081    reserved bits.  Irix 4 added another bit for the reloc type, which
00082    was easy because it was big endian and one of the spare bits became
00083    the new most significant bit.  To make this also work for little
00084    endian ECOFF, we need to wrap one of the reserved bits around to
00085    become the most significant bit of the reloc type.  */
00086 #define RELOC_BITS3_TYPE_BIG                     0x3E
00087 #define RELOC_BITS3_TYPE_SH_BIG                  1
00088 #define RELOC_BITS3_TYPE_LITTLE                  0x78
00089 #define RELOC_BITS3_TYPE_SH_LITTLE        3
00090 #define RELOC_BITS3_TYPEHI_LITTLE         0x04
00091 #define RELOC_BITS3_TYPEHI_SH_LITTLE             2
00092 
00093 #define RELOC_BITS3_EXTERN_BIG                   0x01
00094 #define RELOC_BITS3_EXTERN_LITTLE         0x80
00095 
00096 /* The r_type field in a reloc is one of the following values.  I
00097    don't know if any other values can appear.  These seem to be all
00098    that occur in the Ultrix 4.2 libraries.  */
00099 #define MIPS_R_IGNORE       0
00100 #define MIPS_R_REFHALF      1
00101 #define MIPS_R_REFWORD      2
00102 #define MIPS_R_JMPADDR      3
00103 #define MIPS_R_REFHI 4
00104 #define MIPS_R_REFLO 5
00105 #define MIPS_R_GPREL 6
00106 #define MIPS_R_LITERAL      7
00107 
00108 /* FIXME: This relocation is used (internally only) to represent branches
00109    when assembling.  It should never appear in output files, and  
00110    be removed.  (It used to be used for embedded-PIC support.)  */
00111 #define MIPS_R_PCREL16      12
00112 
00113 /********************** STABS **********************/
00114 
00115 #define MIPS_IS_STAB ECOFF_IS_STAB
00116 #define MIPS_MARK_STAB ECOFF_MARK_STAB
00117 #define MIPS_UNMARK_STAB ECOFF_UNMARK_STAB
00118 
00119 /********************** SYMBOLIC INFORMATION **********************/
00120 
00121 /* Written by John Gilmore.  */
00122 
00123 /* ECOFF uses COFF-like section structures, but its own symbol format.
00124    This file defines the symbol format in fields whose size and alignment
00125    will not vary on different host systems.  */
00126 
00127 /* File header as a set of bytes */
00128 
00129 struct hdr_ext
00130 {
00131        unsigned char        h_magic[2];
00132        unsigned char h_vstamp[2];
00133        unsigned char h_ilineMax[4];
00134        unsigned char h_cbLine[4];
00135        unsigned char h_cbLineOffset[4];
00136        unsigned char h_idnMax[4];
00137        unsigned char h_cbDnOffset[4];
00138        unsigned char h_ipdMax[4];
00139        unsigned char h_cbPdOffset[4];
00140        unsigned char h_isymMax[4];
00141        unsigned char h_cbSymOffset[4];
00142        unsigned char h_ioptMax[4];
00143        unsigned char h_cbOptOffset[4];
00144        unsigned char h_iauxMax[4];
00145        unsigned char h_cbAuxOffset[4];
00146        unsigned char h_issMax[4];
00147        unsigned char h_cbSsOffset[4];
00148        unsigned char h_issExtMax[4];
00149        unsigned char h_cbSsExtOffset[4];
00150        unsigned char h_ifdMax[4];
00151        unsigned char h_cbFdOffset[4];
00152        unsigned char h_crfd[4];
00153        unsigned char h_cbRfdOffset[4];
00154        unsigned char h_iextMax[4];
00155        unsigned char h_cbExtOffset[4];
00156 };
00157 
00158 /* File descriptor external record */
00159 
00160 struct fdr_ext
00161 {
00162        unsigned char f_adr[4];
00163        unsigned char f_rss[4];
00164        unsigned char f_issBase[4];
00165        unsigned char f_cbSs[4];
00166        unsigned char f_isymBase[4];
00167        unsigned char f_csym[4];
00168        unsigned char f_ilineBase[4];
00169        unsigned char f_cline[4];
00170        unsigned char f_ioptBase[4];
00171        unsigned char f_copt[4];
00172        unsigned char f_ipdFirst[2];
00173        unsigned char f_cpd[2];
00174        unsigned char f_iauxBase[4];
00175        unsigned char f_caux[4];
00176        unsigned char f_rfdBase[4];
00177        unsigned char f_crfd[4];
00178        unsigned char f_bits1[1];
00179        unsigned char f_bits2[3];
00180        unsigned char f_cbLineOffset[4];
00181        unsigned char f_cbLine[4];
00182 };
00183 
00184 #define       FDR_BITS1_LANG_BIG          0xF8
00185 #define       FDR_BITS1_LANG_SH_BIG              3
00186 #define       FDR_BITS1_LANG_LITTLE              0x1F
00187 #define       FDR_BITS1_LANG_SH_LITTLE    0
00188 
00189 #define       FDR_BITS1_FMERGE_BIG        0x04
00190 #define       FDR_BITS1_FMERGE_LITTLE            0x20
00191 
00192 #define       FDR_BITS1_FREADIN_BIG              0x02
00193 #define       FDR_BITS1_FREADIN_LITTLE    0x40
00194 
00195 #define       FDR_BITS1_FBIGENDIAN_BIG    0x01
00196 #define       FDR_BITS1_FBIGENDIAN_LITTLE 0x80
00197 
00198 #define       FDR_BITS2_GLEVEL_BIG        0xC0
00199 #define       FDR_BITS2_GLEVEL_SH_BIG            6
00200 #define       FDR_BITS2_GLEVEL_LITTLE            0x03
00201 #define       FDR_BITS2_GLEVEL_SH_LITTLE  0
00202 
00203 /* We ignore the `reserved' field in bits2. */
00204 
00205 /* Procedure descriptor external record */
00206 
00207 struct pdr_ext
00208 {
00209        unsigned char p_adr[4];
00210        unsigned char p_isym[4];
00211        unsigned char p_iline[4];
00212        unsigned char p_regmask[4];
00213        unsigned char p_regoffset[4];
00214        unsigned char p_iopt[4];
00215        unsigned char p_fregmask[4];
00216        unsigned char p_fregoffset[4];
00217        unsigned char p_frameoffset[4];
00218        unsigned char p_framereg[2];
00219        unsigned char p_pcreg[2];
00220        unsigned char p_lnLow[4];
00221        unsigned char p_lnHigh[4];
00222        unsigned char p_cbLineOffset[4];
00223 };
00224 
00225 /* Runtime procedure table */
00226 
00227 struct rpdr_ext
00228 {
00229        unsigned char p_adr[4];
00230        unsigned char p_regmask[4];
00231        unsigned char p_regoffset[4];
00232        unsigned char p_fregmask[4];
00233        unsigned char p_fregoffset[4];
00234        unsigned char p_frameoffset[4];
00235        unsigned char p_framereg[2];
00236        unsigned char p_pcreg[2];
00237        unsigned char p_irpss[4];
00238        unsigned char p_reserved[4];
00239        unsigned char p_exception_info[4];
00240 };
00241 
00242 /* Line numbers */
00243 
00244 struct line_ext
00245 {
00246        unsigned char l_line[4];
00247 };
00248 
00249 /* Symbol external record */
00250 
00251 struct sym_ext
00252 {
00253        unsigned char s_iss[4];
00254        unsigned char s_value[4];
00255        unsigned char s_bits1[1];
00256        unsigned char s_bits2[1];
00257        unsigned char s_bits3[1];
00258        unsigned char s_bits4[1];
00259 };
00260 
00261 #define       SYM_BITS1_ST_BIG            0xFC
00262 #define       SYM_BITS1_ST_SH_BIG         2
00263 #define       SYM_BITS1_ST_LITTLE         0x3F
00264 #define       SYM_BITS1_ST_SH_LITTLE             0
00265 
00266 #define       SYM_BITS1_SC_BIG            0x03
00267 #define       SYM_BITS1_SC_SH_LEFT_BIG    3
00268 #define       SYM_BITS1_SC_LITTLE         0xC0
00269 #define       SYM_BITS1_SC_SH_LITTLE             6
00270 
00271 #define       SYM_BITS2_SC_BIG            0xE0
00272 #define       SYM_BITS2_SC_SH_BIG         5
00273 #define       SYM_BITS2_SC_LITTLE         0x07
00274 #define       SYM_BITS2_SC_SH_LEFT_LITTLE 2
00275 
00276 #define       SYM_BITS2_RESERVED_BIG             0x10
00277 #define       SYM_BITS2_RESERVED_LITTLE   0x08
00278 
00279 #define       SYM_BITS2_INDEX_BIG         0x0F
00280 #define       SYM_BITS2_INDEX_SH_LEFT_BIG 16
00281 #define       SYM_BITS2_INDEX_LITTLE             0xF0
00282 #define       SYM_BITS2_INDEX_SH_LITTLE   4
00283 
00284 #define       SYM_BITS3_INDEX_SH_LEFT_BIG 8
00285 #define       SYM_BITS3_INDEX_SH_LEFT_LITTLE     4
00286 
00287 #define       SYM_BITS4_INDEX_SH_LEFT_BIG 0
00288 #define       SYM_BITS4_INDEX_SH_LEFT_LITTLE     12
00289 
00290 /* External symbol external record */
00291 
00292 struct ext_ext
00293 {
00294        unsigned char es_bits1[1];
00295        unsigned char es_bits2[1];
00296        unsigned char es_ifd[2];
00297        struct sym_ext es_asym;
00298 };
00299 
00300 #define       EXT_BITS1_JMPTBL_BIG        0x80
00301 #define       EXT_BITS1_JMPTBL_LITTLE            0x01
00302 
00303 #define       EXT_BITS1_COBOL_MAIN_BIG    0x40
00304 #define       EXT_BITS1_COBOL_MAIN_LITTLE 0x02
00305 
00306 #define       EXT_BITS1_WEAKEXT_BIG              0x20
00307 #define       EXT_BITS1_WEAKEXT_LITTLE    0x04
00308 
00309 /* Dense numbers external record */
00310 
00311 struct dnr_ext
00312 {
00313        unsigned char d_rfd[4];
00314        unsigned char d_index[4];
00315 };
00316 
00317 /* Relative file descriptor */
00318 
00319 struct rfd_ext
00320 {
00321   unsigned char      rfd[4];
00322 };
00323 
00324 /* Optimizer symbol external record */
00325 
00326 struct opt_ext
00327 {
00328   unsigned char o_bits1[1];
00329   unsigned char o_bits2[1];
00330   unsigned char o_bits3[1];
00331   unsigned char o_bits4[1];
00332   struct rndx_ext o_rndx;
00333   unsigned char o_offset[4];
00334 };
00335 
00336 #define OPT_BITS2_VALUE_SH_LEFT_BIG       16
00337 #define OPT_BITS2_VALUE_SH_LEFT_LITTLE    0
00338 
00339 #define OPT_BITS3_VALUE_SH_LEFT_BIG       8
00340 #define OPT_BITS3_VALUE_SH_LEFT_LITTLE    8
00341 
00342 #define OPT_BITS4_VALUE_SH_LEFT_BIG       0
00343 #define OPT_BITS4_VALUE_SH_LEFT_LITTLE    16