Back to index

cell-binutils  2.17cvs20070401
external.h
Go to the documentation of this file.
00001 /* external.h  -- External COFF structures
00002    
00003    Copyright 2001, 2006 Free Software Foundation, Inc.
00004 
00005    This program is free software; you can redistribute it and/or modify
00006    it under the terms of the GNU General Public License as published by
00007    the Free Software Foundation; either version 2 of the License, or
00008    (at your option) any later version.
00009    
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013    GNU General Public License for more details.
00014    
00015    You should have received a copy of the GNU General Public License
00016    along with this program; if not, write to the Free Software
00017    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
00018 
00019 #ifndef COFF_EXTERNAL_H
00020 #define COFF_EXTERNAL_H
00021 
00022 #ifndef DO_NOT_DEFINE_FILHDR
00023 /********************** FILE HEADER **********************/
00024 
00025 struct external_filehdr
00026   {
00027     char f_magic[2]; /* magic number                    */
00028     char f_nscns[2]; /* number of sections              */
00029     char f_timdat[4];       /* time & date stamp        */
00030     char f_symptr[4];       /* file pointer to symtab   */
00031     char f_nsyms[4]; /* number of symtab entries */
00032     char f_opthdr[2];       /* sizeof(optional hdr)            */
00033     char f_flags[2]; /* flags                    */
00034   };
00035 
00036 #define       FILHDR struct external_filehdr
00037 #define       FILHSZ 20
00038 #endif
00039 
00040 #ifndef DO_NOT_DEFINE_AOUTHDR
00041 /********************** AOUT "OPTIONAL HEADER" **********************/
00042 
00043 typedef struct external_aouthdr
00044   {
00045     char magic[2];   /* type of file                           */
00046     char vstamp[2];  /* version stamp                   */
00047     char tsize[4];   /* text size in bytes, padded to FW bdry*/
00048     char dsize[4];   /* initialized data "  "           */
00049     char bsize[4];   /* uninitialized data "   "        */
00050     char entry[4];   /* entry pt.                       */
00051     char text_start[4];     /* base of text used for this file        */
00052     char data_start[4];     /* base of data used for this file        */
00053   } ATTRIBUTE_PACKED
00054 AOUTHDR;
00055 
00056 #define AOUTHDRSZ 28
00057 #define AOUTSZ 28
00058 
00059 typedef struct external_aouthdr64
00060 {
00061   char magic[2];     /* Type of file.                   */
00062   char vstamp[2];    /* Version stamp.                  */
00063   char tsize[4];     /* Text size in bytes, padded to FW bdry*/
00064   char dsize[4];     /* Initialized data "  ".          */
00065   char bsize[4];     /* Uninitialized data "   ".              */
00066   char entry[4];     /* Entry pt.                       */
00067   char text_start[4];       /* Base of text used for this file.       */
00068 }
00069 AOUTHDR64;
00070 #define AOUTHDRSZ64  24
00071 
00072 #endif /* not DO_NOT_DEFINE_AOUTHDR */
00073 
00074 #ifndef DO_NOT_DEFINE_SCNHDR
00075 /********************** SECTION HEADER **********************/
00076 
00077 struct external_scnhdr
00078   {
00079     char s_name[8];  /* section name                           */
00080     char s_paddr[4]; /* physical address, aliased s_nlib       */
00081     char s_vaddr[4]; /* virtual address                 */
00082     char s_size[4];  /* section size                           */
00083     char s_scnptr[4];       /* file ptr to raw data for section       */
00084     char s_relptr[4];       /* file ptr to relocation          */
00085     char s_lnnoptr[4];      /* file ptr to line numbers        */
00086     char s_nreloc[2];       /* number of relocation entries           */
00087     char s_nlnno[2]; /* number of line number entries   */
00088     char s_flags[4]; /* flags                           */
00089   };
00090 
00091 #define       SCNHDR struct external_scnhdr
00092 #define       SCNHSZ 40
00093 
00094 /* Names of "special" sections.  */
00095 
00096 #define _TEXT  ".text"
00097 #define _DATA  ".data"
00098 #define _BSS   ".bss"
00099 #define _COMMENT ".comment"
00100 #define _LIB     ".lib"
00101 #endif /* not DO_NOT_DEFINE_SCNHDR */
00102 
00103 #ifndef DO_NOT_DEFINE_LINENO
00104 
00105 /********************** LINE NUMBERS **********************/
00106 
00107 #ifndef L_LNNO_SIZE
00108 #error  L_LNNO_SIZE needs to be defined
00109 #endif
00110 
00111 /* 1 line number entry for every "breakpointable" source line in a section.
00112    Line numbers are grouped on a per function basis; first entry in a function
00113    grouping will have l_lnno = 0 and in place of physical address will be the
00114    symbol table index of the function name.  */
00115 struct external_lineno
00116 {
00117   union
00118   {
00119     char l_symndx[4];       /* function name symbol index, iff l_lnno == 0*/
00120     char l_paddr[4]; /* (physical) address of line number      */
00121   } l_addr;
00122 
00123   char l_lnno[L_LNNO_SIZE]; /* line number              */
00124 };
00125 
00126 #define       LINENO struct external_lineno
00127 #define       LINESZ (4 + L_LNNO_SIZE)
00128 
00129 #if L_LNNO_SIZE == 4
00130 #define GET_LINENO_LNNO(abfd, ext)      H_GET_32 (abfd,      (ext->l_lnno))
00131 #define PUT_LINENO_LNNO(abfd, val, ext) H_PUT_32 (abfd, val, (ext->l_lnno))
00132 #endif
00133 #if L_LNNO_SIZE == 2
00134 #define GET_LINENO_LNNO(abfd, ext)      H_GET_16 (abfd,      (ext->l_lnno))
00135 #define PUT_LINENO_LNNO(abfd, val, ext) H_PUT_16 (abfd, val, (ext->l_lnno))
00136 #endif
00137 
00138 #endif /* not DO_NOT_DEFINE_LINENO */
00139 
00140 #ifndef DO_NOT_DEFINE_SYMENT
00141 /********************** SYMBOLS **********************/
00142 
00143 #define E_SYMNMLEN   8      /* # characters in a symbol name   */
00144 #ifndef E_FILNMLEN
00145 #define E_FILNMLEN   14
00146 #endif
00147 #define E_DIMNUM     4      /* # array dimensions in auxiliary entry */
00148 
00149 struct external_syment 
00150 {
00151   union
00152   {
00153     char e_name[E_SYMNMLEN];
00154 
00155     struct
00156     {
00157       char e_zeroes[4];
00158       char e_offset[4];
00159     } e;
00160   } e;
00161 
00162   char e_value[4];
00163   char e_scnum[2];
00164   char e_type[2];
00165   char e_sclass[1];
00166   char e_numaux[1];
00167 } ATTRIBUTE_PACKED ;
00168 
00169 #define       SYMENT struct external_syment
00170 #define       SYMESZ 18     
00171 
00172 #ifndef N_BTMASK
00173 #define N_BTMASK     0xf
00174 #endif
00175 
00176 #ifndef N_TMASK
00177 #define N_TMASK             0x30
00178 #endif
00179 
00180 #ifndef N_BTSHFT
00181 #define N_BTSHFT     4
00182 #endif
00183 
00184 #ifndef N_TSHIFT
00185 #define N_TSHIFT     2
00186 #endif
00187 
00188 #endif /* not DO_NOT_DEFINE_SYMENT */
00189 
00190 #ifndef DO_NOT_DEFINE_AUXENT
00191 
00192 union external_auxent
00193 {
00194   struct
00195   {
00196     char x_tagndx[4];              /* str, un, or enum tag indx */
00197     
00198     union
00199     {
00200       struct
00201       {
00202        char  x_lnno[2]; /* declaration line number */
00203        char  x_size[2]; /* str/union/array size */
00204       } x_lnsz;
00205       
00206       char x_fsize[4];      /* size of function */
00207       
00208     } x_misc;
00209     
00210     union
00211     {
00212       struct         /* if ISFCN, tag, or .bb */
00213       {
00214        char x_lnnoptr[4];   /* ptr to fcn line # */
00215        char x_endndx[4];    /* entry ndx past block end */
00216       } x_fcn;
00217       
00218       struct         /* if ISARY, up to 4 dimen. */
00219       {
00220        char x_dimen[E_DIMNUM][2];
00221       } x_ary;
00222       
00223     } x_fcnary;
00224     
00225     char x_tvndx[2]; /* tv index */
00226     
00227   } x_sym;
00228   
00229   union
00230   {
00231     char x_fname[E_FILNMLEN];
00232     
00233     struct
00234     {
00235       char x_zeroes[4];
00236       char x_offset[4];
00237     } x_n;
00238     
00239   } x_file;
00240   
00241   struct
00242   {
00243     char x_scnlen[4];       /* section length */
00244     char x_nreloc[2];       /* # relocation entries */
00245     char x_nlinno[2];       /* # line numbers */
00246 #ifdef INCLUDE_COMDAT_FIELDS_IN_AUXENT
00247     char x_checksum[4];               /* section COMDAT checksum            */
00248     char x_associated[2];      /* COMDAT associated section index */
00249     char x_comdat[1];                 /* COMDAT selection number            */
00250 #endif    
00251   } x_scn;
00252   
00253   struct
00254   {
00255     char x_tvfill[4];       /* tv fill value */
00256     char x_tvlen[2]; /* length of .tv */
00257     char x_tvran[2][2];     /* tv range */
00258   } x_tv;            /* info about .tv section (in auxent of symbol .tv)) */
00259 } ATTRIBUTE_PACKED ;
00260 
00261 #define       AUXENT union external_auxent
00262 #define       AUXESZ 18
00263 
00264 #define _ETEXT       "etext"
00265 
00266 #endif /* not DO_NOT_DEFINE_AUXENT */
00267 
00268 #endif /* COFF_EXTERNAL_H */