Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
elfaccess.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 /* ====================================================================
00037  * ====================================================================
00038  *
00039  *
00040  * Revision history:
00041  *  03-Jun-93 - Original Version
00042  *
00043  * Description:
00044  *
00045  * This file provides access macros for the ELF structures defined in
00046  * /usr/include/elf.h and /usr/include/sys/elf.h
00047  *
00048  * In general, we define 32-bit and 64-bit versions of the access
00049  * macros; where they are identical, we also define a common macro.
00050  *
00051  * Names follow the convention:   an all-caps
00052  * prefix indicating the struct type, with a 32 or 64 if appropriate,
00053  * and a lower-case suffix matching the field name.  (However, the
00054  * field name prefixes commonly used in the ELF definitions are not
00055  * part of this name.)  For macros which are not common to 32-bit and
00056  * 64-bit versions, we define a non-specific version for the "current"
00057  * model, as indicated by the cpp symbol _64BIT_OBJECTS.
00058  *
00059  * We follow the practice of not shifting flags into
00060  * the lower bit in the macros, for maximum test efficiency.  We also
00061  * favor efficiency over robustness in other cases.
00062  *
00063  * ====================================================================
00064  * ====================================================================
00065  */
00066 
00067 #ifndef elfaccess_INCLUDED
00068 #define elfaccess_INCLUDED
00069 
00070 
00071 /* ====================================================================
00072  *
00073  * .rel, .rela Section
00074  *
00075  * ====================================================================
00076  */
00077 
00078 /* r_info masks for 32-bit: */
00079 #define REL32_SYM_MASK  0xffffff00
00080 #define REL32_SYM_SHIFT 8
00081 #define REL32_TYPE_MASK 0x000000ff
00082 
00083 /* Field access macros, for either .rel or .rela sections: */
00084 #define     REL_offset(r)       ((r).r_offset)
00085 #define     REL32_offset(r)     REL_offset(r)
00086 #define     REL32_offset(r)     REL_offset(r)
00087 
00088 #define     REL32_sym(r)        ELF32_R_SYM((r).r_info)
00089 #define Set_REL32_sym(r,v) \
00090     ((r).r_info = ((r).r_info & ~REL32_SYM_MASK) + (v<<REL32_SYM_SHIFT))
00091 #define     REL32_type(r)       ELF32_R_TYPE((r).r_info)
00092 #define Set_REL32_type(r,v) \
00093     ((r).r_info = ((r).r_info & ~REL32_TYPE_MASK) + (v&REL32_TYPE_MASK))
00094 #define Set_REL32_info(r,s,t) \
00095     ((r).r_info = ((s)<<REL32_SYM_SHIFT) | ((t)&REL32_TYPE_MASK))
00096 
00097 #define     REL64_sym(r)        ((r).r_sym)
00098 #define Set_REL64_sym(r,v)      (REL64_sym(r)=v)
00099 #define     REL64_type(r)       ((r).r_type)
00100 #define Set_REL64_type(r,v)     (REL64_type(r)=v)
00101 #define Set_REL64_info(r,s,t)   (Set_REL64_sym(r,s),Set_REL64_type(r,t))
00102 
00103 /* 64-bit only: */
00104 #define     REL64_ssym(r)       ((r).r_ssym)
00105 #define     REL64_type2(r)      ((r).r_type2)
00106 #define     REL64_type3(r)      ((r).r_type3)
00107 
00108 /* .rela only: */
00109 #define     REL_addend(r)       ((r).r_addend)
00110 #define     REL32_addend(r)     REL_addend(r)
00111 #define     REL32_addend(r)     REL_addend(r)
00112 
00113 /* Model-specific selection: */
00114 #ifdef _64BIT_OBJECTS
00115 
00116 #define     REL_sym     REL64_sym
00117 #define Set_REL_sym     Set_REL64_sym
00118 #define     REL_type    REL64_type
00119 #define Set_REL_type    Set_REL64_type
00120 #define Set_REL_info    Set_REL64_info
00121 
00122 #else /* 32-bit objects: */
00123 
00124 #define     REL_sym     REL32_sym
00125 #define Set_REL_sym     Set_REL32_sym
00126 #define     REL_type    REL32_type
00127 #define Set_REL_type    Set_REL32_type
00128 #define Set_REL_info    Set_REL32_info
00129 
00130 #endif
00131 
00132 #endif /* elfaccess_INCLUDED */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines