Back to index

cell-binutils  2.17cvs20070401
bout.h
Go to the documentation of this file.
00001 /* This file is a modified version of 'a.out.h'.  It is to be used in all
00002    GNU tools modified to support the i80960 (or tools that operate on
00003    object files created by such tools).
00004    
00005    Copyright 2001 Free Software Foundation, Inc.
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 2 of the License, or
00010    (at your option) any later version.
00011    
00012    This program is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016    
00017    You should have received a copy of the GNU General Public License
00018    along with this program; if not, write to the Free Software
00019    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
00020  
00021 /* All i80960 development is done in a CROSS-DEVELOPMENT environment.  I.e.,
00022    object code is generated on, and executed under the direction of a symbolic
00023    debugger running on, a host system.  We do not want to be subject to the
00024    vagaries of which host it is or whether it supports COFF or a.out format,
00025    or anything else.  We DO want to:
00026   
00027        o always generate the same format object files, regardless of host.
00028  
00029        o have an 'a.out' header that we can modify for our own purposes
00030          (the 80960 is typically an embedded processor and may require
00031          enhanced linker support that the normal a.out.h header can't
00032          accommodate).
00033  
00034   As for byte-ordering, the following rules apply:
00035  
00036        o Text and data that is actually downloaded to the target is always
00037          in i80960 (little-endian) order.
00038  
00039        o All other numbers (in the header, symbols, relocation directives)
00040          are in host byte-order:  object files CANNOT be lifted from a
00041          little-end host and used on a big-endian (or vice versa) without
00042          modification.
00043   ==> THIS IS NO LONGER TRUE USING BFD.  WE CAN GENERATE ANY BYTE ORDER
00044       FOR THE HEADER, AND READ ANY BYTE ORDER.  PREFERENCE WOULD BE TO
00045       USE LITTLE-ENDIAN BYTE ORDER THROUGHOUT, REGARDLESS OF HOST.  <==
00046  
00047        o The downloader ('comm960') takes care to generate a pseudo-header
00048          with correct (i80960) byte-ordering before shipping text and data
00049          off to the NINDY monitor in the target systems.  Symbols and
00050          relocation info are never sent to the target.  */
00051 
00052 #define BMAGIC       0415
00053 /* We don't accept the following (see N_BADMAG macro).
00054    They're just here so GNU code will compile.  */
00055 #define       OMAGIC 0407          /* old impure format */
00056 #define       NMAGIC 0410          /* read-only text */
00057 #define       ZMAGIC 0413          /* demand load format */
00058 
00059 /* FILE HEADER
00060        All 'lengths' are given as a number of bytes.
00061        All 'alignments' are for relinkable files only;  an alignment of
00062               'n' indicates the corresponding segment must begin at an
00063               address that is a multiple of (2**n).  */
00064 struct external_exec
00065   {
00066     /* Standard stuff */
00067     unsigned char e_info[4];       /* Identifies this as a b.out file */
00068     unsigned char e_text[4];       /* Length of text */
00069     unsigned char e_data[4];       /* Length of data */
00070     unsigned char e_bss[4]; /* Length of uninitialized data area */
00071     unsigned char e_syms[4];       /* Length of symbol table */
00072     unsigned char e_entry[4];      /* Runtime start address */
00073     unsigned char e_trsize[4];     /* Length of text relocation info */
00074     unsigned char e_drsize[4];     /* Length of data relocation info */
00075 
00076     /* Added for i960 */
00077     unsigned char e_tload[4];      /* Text runtime load address */
00078     unsigned char e_dload[4];      /* Data runtime load address */
00079     unsigned char e_talign[1];     /* Alignment of text segment */
00080     unsigned char e_dalign[1];     /* Alignment of data segment */
00081     unsigned char e_balign[1];     /* Alignment of bss segment */
00082     unsigned char e_relaxable[1];/* Assembled with enough info to allow linker to relax */
00083   };
00084 
00085 #define       EXEC_BYTES_SIZE      (sizeof (struct external_exec))
00086 
00087 /* These macros use the a_xxx field names, since they operate on the exec
00088    structure after it's been byte-swapped and realigned on the host machine.  */
00089 #define N_BADMAG(x)  (((x).a_info)!=BMAGIC)
00090 #define N_TXTOFF(x)  EXEC_BYTES_SIZE
00091 #define N_DATOFF(x)  ( N_TXTOFF(x) + (x).a_text )
00092 #define N_TROFF(x)   ( N_DATOFF(x) + (x).a_data )
00093 #define N_TRELOFF    N_TROFF
00094 #define N_DROFF(x)   ( N_TROFF(x) + (x).a_trsize )
00095 #define N_DRELOFF    N_DROFF
00096 #define N_SYMOFF(x)  ( N_DROFF(x) + (x).a_drsize )
00097 #define N_STROFF(x)  ( N_SYMOFF(x) + (x).a_syms )
00098 #define N_DATADDR(x) ( (x).a_dload )    
00099 
00100 /* Address of text segment in memory after it is loaded.  */
00101 #if !defined (N_TXTADDR)
00102 #define N_TXTADDR(x) 0
00103 #endif
00104 
00105 /* A single entry in the symbol table.  */
00106 struct nlist
00107   {
00108     union
00109       {
00110        char*          n_name;
00111        struct nlist * n_next;
00112        long          n_strx;       /* Index into string table  */
00113       } n_un;
00114 
00115     unsigned char n_type;   /* See below                       */
00116     char        n_other;    /* Used in i80960 support -- see below    */
00117     short       n_desc;
00118     unsigned long n_value;
00119   };
00120 
00121 
00122 /* Legal values of n_type.  */
00123 #define N_UNDF       0      /* Undefined symbol  */
00124 #define N_ABS 2      /* Absolute symbol   */
00125 #define N_TEXT       4      /* Text symbol              */
00126 #define N_DATA       6      /* Data symbol              */
00127 #define N_BSS 8      /* BSS symbol        */
00128 #define N_FN  31     /* Filename symbol   */
00129 
00130 #define N_EXT 1      /* External symbol (OR'd in with one of above)   */
00131 #define N_TYPE       036    /* Mask for all the type bits                    */
00132 #define N_STAB       0340   /* Mask for all bits used for SDB entries        */
00133 
00134 /* MEANING OF 'n_other'
00135  
00136   If non-zero, the 'n_other' fields indicates either a leaf procedure or
00137   a system procedure, as follows:
00138  
00139        1 <= n_other <= 32 :
00140               The symbol is the entry point to a system procedure.
00141               'n_value' is the address of the entry, as for any other
00142               procedure.  The system procedure number (which can be used in
00143               a 'calls' instruction) is (n_other-1).  These entries come from
00144               '.sysproc' directives.
00145  
00146        n_other == N_CALLNAME
00147               the symbol is the 'call' entry point to a leaf procedure.
00148               The *next* symbol in the symbol table must be the corresponding
00149               'bal' entry point to the procedure (see following).  These
00150               entries come from '.leafproc' directives in which two different
00151               symbols are specified (the first one is represented here).
00152        
00153  
00154        n_other == N_BALNAME
00155               the symbol is the 'bal' entry point to a leaf procedure.
00156               These entries result from '.leafproc' directives in which only
00157               one symbol is specified, or in which the same symbol is
00158               specified twice.
00159  
00160   Note that an N_CALLNAME entry *must* have a corresponding N_BALNAME entry,
00161   but not every N_BALNAME entry must have an N_CALLNAME entry.  */
00162 #define N_CALLNAME   ((char)-1)
00163 #define N_BALNAME    ((char)-2)
00164 #define IS_CALLNAME(x)      (N_CALLNAME == (x))
00165 #define IS_BALNAME(x)       (N_BALNAME == (x))
00166 #define IS_OTHER(x)  ((x)>0 && (x) <=32)
00167 
00168 #define b_out_relocation_info relocation_info
00169 struct relocation_info
00170   {
00171     int        r_address;   /* File address of item to be relocated.  */
00172     unsigned
00173 #define r_index r_symbolnum
00174     r_symbolnum:24,  /* Index of symbol on which relocation is based,
00175                         if r_extern is set.  Otherwise set to
00176                         either N_TEXT, N_DATA, or N_BSS to
00177                         indicate section on which relocation is
00178                         based.  */
00179       r_pcrel:1,     /* 1 => relocate PC-relative; else absolute
00180                         On i960, pc-relative implies 24-bit
00181                         address, absolute implies 32-bit.  */
00182       r_length:2,    /* Number of bytes to relocate:
00183                         0 => 1 byte
00184                         1 => 2 bytes -- used for 13 bit pcrel
00185                         2 => 4 bytes.  */
00186       r_extern:1,
00187       r_bsr:1,              /* Something for the GNU NS32K assembler.  */
00188       r_disp:1,             /* Something for the GNU NS32K assembler.  */
00189       r_callj:1,     /* 1 if relocation target is an i960 'callj'.  */
00190       r_relaxable:1; /* 1 if enough info is left to relax the data.  */
00191 };