Back to index

cell-binutils  2.17cvs20070401
or32.h
Go to the documentation of this file.
00001 /* COFF specification for OpenRISC 1000.
00002    Copyright (C) 1993-2000, 2002 Free Software Foundation, Inc.
00003    Contributed by David Wood @ New York University.
00004    Modified by Johan Rydberg, <johan.rydberg@netinsight.se>
00005 
00006    This file is part of BFD, the Binary File Descriptor library.
00007 
00008    This program is free software; you can redistribute it and/or modify
00009    it under the terms of the GNU General Public License as published by
00010    the Free Software Foundation; either version 2 of the License, or
00011    (at your option) any later version.
00012 
00013    This program is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016    GNU General Public License for more details.
00017 
00018    You should have received a copy of the GNU General Public License
00019    along with this program; if not, write to the Free Software
00020    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
00021 
00022 #ifndef OR32
00023 # define OR32
00024 #endif
00025 
00026 /* File Header and related definitions.  */
00027 struct external_filehdr
00028 {
00029   char f_magic[2];   /* magic number                 */
00030   char f_nscns[2];   /* number of sections           */
00031   char f_timdat[4];     /* time & date stamp         */
00032   char f_symptr[4];     /* file pointer to symtab   */
00033   char f_nsyms[4];   /* number of symtab entries */
00034   char f_opthdr[2];     /* sizeof(optional hdr)      */
00035   char f_flags[2];   /* flags                 */
00036 };
00037 
00038 #define FILHDR  struct external_filehdr
00039 #define FILHSZ       20
00040 
00041 /* Magic numbers for OpenRISC 1000. As it is know we use the
00042    numbers for Am29000.
00043 
00044    (AT&T will assign the "real" magic number).  */
00045 #define SIPFBOMAGIC     0572    /* Am29000 (Byte 0 is MSB).  */
00046 #define SIPRBOMAGIC     0573    /* Am29000 (Byte 0 is LSB).  */
00047 
00048 #define OR32_MAGIC_BIG             SIPFBOMAGIC   
00049 #define OR32_MAGIC_LITTLE   SIPRBOMAGIC   
00050 #define OR32BADMAG(x)     (((x).f_magic!=OR32_MAGIC_BIG) && \
00051                                            ((x).f_magic!=OR32_MAGIC_LITTLE))
00052 
00053 #define OMAGIC OR32_MAGIC_BIG
00054 
00055 /* Optional (a.out) header.  */
00056 typedef       struct external_aouthdr 
00057 {
00058   char  magic[2];         /* type of file                     */
00059   char  vstamp[2];     /* version stamp                    */
00060   char  tsize[4];      /* text size in bytes, padded to FW bdry */
00061   char  dsize[4];      /* initialized data "  "            */
00062   char  bsize[4];      /* uninitialized data "   "         */
00063   char  entry[4];      /* entry pt.                        */
00064   char  text_start[4];        /* base of text used for this file  */
00065   char  data_start[4];        /* base of data used for this file  */
00066 } AOUTHDR;
00067 
00068 #define AOUTSZ      28
00069 #define AOUTHDRSZ   28
00070 
00071 /* aouthdr magic numbers.  */
00072 #define NMAGIC    0410        /* separate i/d executable.  */
00073 #define SHMAGIC   0406        /* NYU/Ultra3 shared data executable 
00074                              (writable text).  */
00075 
00076 #define _ETEXT       "_etext"
00077 
00078 /* Section header and related definitions.  */
00079 struct external_scnhdr 
00080 {
00081   char     s_name[8];      /* section name                   */
00082   char     s_paddr[4];     /* physical address, aliased s_nlib */
00083   char     s_vaddr[4];     /* virtual address                */
00084   char     s_size[4];      /* section size                   */
00085   char     s_scnptr[4];    /* file ptr to raw data for section */
00086   char     s_relptr[4];    /* file ptr to relocation         */
00087   char     s_lnnoptr[4];   /* file ptr to line numbers       */
00088   char     s_nreloc[2];    /* number of relocation entries   */
00089   char     s_nlnno[2];     /* number of line number entries  */
00090   char     s_flags[4];     /* flags                          */
00091 };
00092 
00093 #define       SCNHDR struct external_scnhdr
00094 #define       SCNHSZ 40
00095 
00096 /* Names of "special" sections:  */
00097 #define _TEXT   ".text"
00098 #define _DATA   ".data"
00099 #define _BSS    ".bss"
00100 #define _LIT    ".lit"
00101 
00102 /* Section types - with additional section type for global 
00103    registers which will be relocatable for the OpenRISC 1000.
00104 
00105    In instances where it is necessary for a linker to produce an
00106    output file which contains text or data not based at virtual
00107    address 0, e.g. for a ROM, then the linker should accept
00108    address base information as command input and use PAD sections
00109    to skip over unused addresses.  */
00110 #define       STYP_BSSREG 0x1200   /* Global register area (like STYP_INFO) */
00111 #define STYP_ENVIR  0x2200  /* Environment (like STYP_INFO) */
00112 #define STYP_ABS    0x4000  /* Absolute (allocated, not reloc, loaded) */
00113 
00114 /* Relocation information declaration and related definitions:  */
00115 struct external_reloc
00116 {
00117   char r_vaddr[4];    /* (virtual) address of reference */
00118   char r_symndx[4];   /* index into symbol table */
00119   char r_type[2];     /* relocation type */
00120 };
00121 
00122 #define       RELOC         struct external_reloc
00123 #define       RELSZ         10            /* sizeof (RELOC) */ 
00124 
00125 /* Relocation types for the OpenRISC 1000: */
00126 
00127 #define       R_ABS     0     /* reference is absolute */
00128 #define       R_IREL    030 /* instruction relative (jmp/call) */
00129 #define       R_IABS    031 /* instruction absolute (jmp/call) */
00130 #define       R_ILOHALF 032 /* instruction low half  (const)  */
00131 #define       R_IHIHALF 033 /* instruction high half (consth) part 1 */
00132 #define       R_IHCONST 034 /* instruction high half (consth) part 2 */
00133                         /* constant offset of R_IHIHALF relocation */
00134 #define       R_BYTE    035 /* relocatable byte value */
00135 #define R_HWORD   036       /* relocatable halfword value */
00136 #define R_WORD    037       /* relocatable word value */
00137 
00138 #define       R_IGLBLRC 040 /* instruction global register RC */
00139 #define       R_IGLBLRA 041 /* instruction global register RA */
00140 #define       R_IGLBLRB 042 /* instruction global register RB */
00141  
00142 /*
00143   NOTE:
00144   All the "I" forms refer to 29000 instruction formats.  The linker is 
00145   expected to know how the numeric information is split and/or aligned
00146   within the instruction word(s).  R_BYTE works for instructions, too.
00147 
00148   If the parameter to a CONSTH instruction is a relocatable type, two 
00149   relocation records are written.  The first has an r_type of R_IHIHALF 
00150   (33 octal) and a normal r_vaddr and r_symndx.  The second relocation 
00151   record has an r_type of R_IHCONST (34 octal), a normal r_vaddr (which 
00152   is redundant), and an r_symndx containing the 32-bit constant offset 
00153   to the relocation instead of the actual symbol table index.  This 
00154   second record is always written, even if the constant offset is zero.
00155   The constant fields of the instruction are set to zero.  */
00156 
00157 /* Line number entry declaration and related definitions:  */
00158 struct external_lineno 
00159 {
00160   union
00161   {
00162     char l_symndx[4];  /* function name symbol index, iff l_lnno == 0*/
00163     char l_paddr[4];   /* (physical) address of line number    */
00164   }
00165   l_addr;
00166 
00167   char l_lnno[2];      /* line number       */
00168 };
00169 
00170 #define       LINENO        struct external_lineno
00171 #define       LINESZ        6               /* sizeof (LINENO) */
00172 
00173 /* Symbol entry declaration and related definitions:  */
00174 #define       E_SYMNMLEN    8        /* Number of characters in a symbol name */
00175 
00176 struct external_syment
00177 {
00178   union
00179   {
00180     char e_name[E_SYMNMLEN];
00181     struct
00182     {
00183       char e_zeroes[4];
00184       char e_offset[4];
00185     }
00186     e;
00187   }
00188   e;
00189 
00190   char e_value[4];
00191   char e_scnum[2];
00192   char e_type[2];
00193   char e_sclass[1];
00194   char e_numaux[1];
00195 };
00196 
00197 #define       SYMENT struct external_syment
00198 #define       SYMESZ        18
00199 
00200 /* Storage class definitions - new classes for global registers:  */
00201 #define C_GLBLREG    19            /* global register */
00202 #define C_EXTREG     20            /* external global register */
00203 #define       C_DEFREG      21            /* ext. def. of global register */
00204 
00205 /* Derived symbol mask/shifts:  */
00206 #define N_BTMASK     (0xf)
00207 #define N_BTSHFT     (4)
00208 #define N_TMASK             (0x30)
00209 #define N_TSHIFT     (2)
00210 
00211 /* Auxiliary symbol table entry declaration and related 
00212    definitions.  */
00213 #define E_FILNMLEN  14  /* # characters in a file name    */
00214 #define E_DIMNUM    4   /* # array dimensions in auxiliary entry */
00215 
00216 union external_auxent
00217 {
00218   struct
00219   {
00220     char x_tagndx[4];       /* str, un, or enum tag indx */
00221     union
00222     {
00223       struct
00224       {
00225        char  x_lnno[2];    /* declaration line number */
00226         char  x_size[2];    /* str/union/array size */
00227       }
00228       x_lnsz;
00229 
00230       char x_fsize[4];      /* size of function */
00231     }
00232     x_misc;
00233 
00234     union
00235     {
00236       struct                   /* if ISFCN, tag, or .bb */
00237       {
00238        char x_lnnoptr[4];  /* ptr to fcn line # */
00239         char x_endndx[4];   /* entry ndx past block end */
00240       }
00241       x_fcn;
00242 
00243       struct                   /* if ISARY, up to 4 dimen. */
00244       {
00245        char x_dimen[E_DIMNUM][2];
00246       }
00247       x_ary;
00248     }
00249     x_fcnary;
00250 
00251     char x_tvndx[2];        /* tv index */
00252   }
00253   x_sym;
00254 
00255   union
00256   {
00257     char x_fname[E_FILNMLEN];
00258 
00259     struct
00260     {
00261       char x_zeroes[4];
00262       char x_offset[4];
00263     }
00264     x_n;
00265   }
00266   x_file;
00267 
00268   struct
00269   {
00270     char x_scnlen[4];       /* section length */
00271     char x_nreloc[2];       /* # relocation entries */
00272     char x_nlinno[2];       /* # line numbers */
00273   }
00274   x_scn;
00275 
00276   struct
00277   {
00278     char x_tvfill[4];       /* tv fill value */
00279     char x_tvlen[2];        /* length of .tv */
00280     char x_tvran[2][2];     /* tv range */
00281   }
00282   x_tv;                   /* info about .tv section 
00283                           (in auxent of symbol .tv)) */
00284 };
00285 
00286 #define       AUXENT        union external_auxent
00287 #define       AUXESZ        18