Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
compact_reloc.h
Go to the documentation of this file.
00001 /*
00002 
00003   Copyright (C) 2000, 2001 Silicon Graphics, Inc.  All Rights Reserved.
00004 
00005   This program is free software; you can redistribute it and/or modify it
00006   under the terms of version 2 of the GNU General Public License as
00007   published by the Free Software Foundation.
00008 
00009   This program is distributed in the hope that it would be useful, but
00010   WITHOUT ANY WARRANTY; without even the implied warranty of
00011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
00012 
00013   Further, this software is distributed without any warranty that it is
00014   free of the rightful claim of any third person regarding infringement 
00015   or the like.  Any license provided herein, whether implied or 
00016   otherwise, applies only to this software file.  Patent licenses, if 
00017   any, provided herein do not apply to combinations of this program with 
00018   other software, or any other product whatsoever.  
00019 
00020   You should have received a copy of the GNU General Public License along
00021   with this program; if not, write the Free Software Foundation, Inc., 59
00022   Temple Place - Suite 330, Boston MA 02111-1307, USA.
00023 
00024   Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pky,
00025   Mountain View, CA 94043, or:
00026 
00027   http://www.sgi.com
00028 
00029   For further information regarding this notice, see:
00030 
00031   http://oss.sgi.com/projects/GenInfo/NoticeExplan
00032 
00033 */
00034 
00035 
00036 #ifndef __COMPACT_RELOC_H__
00037 #define __COMPACT_RELOC_H__
00038 
00039 #ifdef __cplusplus
00040 extern "C" {
00041 #endif
00042 
00043 /* compact relocation format for o32 */
00044 
00045 #include <sgidefs.h>
00046 
00047 typedef struct {
00048     unsigned cm_tag;
00049     union {
00050         __uint32_t cm_val;
00051         __uint32_t cm_ptr;
00052     } cm_un;
00053 } CM;
00054 
00055 #define CM_NULL            0x00000000
00056 #define CM_RELOC_NO        0x00000001
00057 #define CM_RELOC_PTR       0x00000002  
00058 
00059 struct full_rlc {
00060     int type;
00061     __uint32_t konst;
00062     __uint32_t vaddr;
00063     __uint32_t dist2lo;
00064 };
00065 
00066 #define CM_R_TYPE_NULL      0
00067 #define CM_R_TYPE_ABS       1
00068 #define CM_R_TYPE_REL32     2
00069 #define CM_R_TYPE_WORD      3
00070 #define CM_R_TYPE_GPHI_LO   4
00071 #define CM_R_TYPE_GOTHI_LO  5
00072 #define CM_R_TYPE_JMPADDR   5   /* this is obsolete and should go away */
00073 #define CM_R_TYPE_GPHI_LO2  6
00074 #define CM_R_TYPE_HI_LO     7
00075 
00076 typedef struct {
00077     char *scn_praw;
00078     char *rlc_ptr;
00079     char *cur_rlc_ptr;
00080     __uint32_t  rlc_no;
00081     __uint32_t  cur_rlc_no;
00082     __uint32_t last_base;
00083     struct full_rlc rlc_entry;
00084 } cm_struct ;
00085 
00086 
00087 /* this struct must be the same as next, except for the last item, */
00088 /* which is the constant for the addend */
00089 struct COMPACT_RELOC {
00090     unsigned addend:  2;
00091 #define        ADDEND_NOCONST  0
00092 #define        ADDEND_CONST    1   /* if an addend included, e.g. sym + k */
00093 #define        ADDEND_BASE     2   /* base of address to be relocated */
00094     unsigned type:    3;           /* relocation type */
00095     unsigned del_lo:  8;           /* delta to ref_lo from ref_hi, shifted 2 */
00096     
00097     signed del_vaddr: 19;          /* delta addr, from previous entry */
00098                                    /* to be relocated */
00099 #define        DEL_VADDR_MASK   0xFFFF8000
00100 };
00101 
00102 
00103 struct COMPACT_RELOC_C {
00104     struct COMPACT_RELOC _rlc;
00105     __uint32_t addend_const;         /* k of addend */
00106 };
00107 
00108 struct COMPACT_RELOC_C_BASE {
00109     struct COMPACT_RELOC _rlc;
00110     __uint32_t addend_const;         /* k of addend */
00111     __uint32_t base;                 /* base for next delta */
00112 };
00113 
00114 struct COMPACT_RELOC_BASE {
00115     struct COMPACT_RELOC _rlc;
00116     __uint32_t base;                 /* base for next delta */
00117 };
00118 
00119 
00120 union cm_rlc {
00121     struct COMPACT_RELOC            r;
00122     struct COMPACT_RELOC_C_BASE    cb;
00123     struct COMPACT_RELOC_C          c;
00124     struct COMPACT_RELOC_BASE       b;
00125 };
00126 
00127 
00128 #define VADDR_OVFL(delta)  (((delta & DEL_VADDR_MASK) != 0) && \
00129                             ((delta & DEL_VADDR_MASK) != DEL_VADDR_MASK))
00130 
00131 #define VADDR_DELTA(delta) (delta & ~DEL_VADDR_MASK)
00132 
00133     
00134 #ifdef __cplusplus
00135 }
00136 #endif
00137 
00138 #endif  /* __COMPACT_RELOC_H__ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines