Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
sections.cxx
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 #include <iostream>
00036 #include <elf.h>       /* Open64 version */
00037 #include "sections.h"
00038 
00039 #define INST_BYTES 16
00040 
00041 
00042 SECTION Sections[_SEC_INDEX_MAX] = {
00043   {_SEC_UNKNOWN,NULL,
00044      0,
00045         0, 0, 
00046      0, ".unknown", 0},
00047   {_SEC_TEXT,   NULL,
00048      0|SHF_EXECINSTR|SHF_ALLOC,
00049         SHT_PROGBITS, INST_BYTES, 
00050      INT64_MAX, ELF_TEXT, 0},
00051   {_SEC_DATA,   NULL,
00052      0|SHF_WRITE|SHF_ALLOC, 
00053         SHT_PROGBITS, 0, 
00054      INT64_MAX, ELF_DATA, 0},
00055   {_SEC_SDATA,  NULL,
00056      0|SHF_WRITE|SHF_IA_64_SHORT|SHF_ALLOC,
00057         SHT_PROGBITS, 0, 
00058      INT32_MAX, MIPS_SDATA, 0},
00059   {_SEC_LDATA,  NULL,
00060      0|SHF_WRITE|SHF_ALLOC|SHF_MIPS_LOCAL,
00061         SHT_PROGBITS, 0, 
00062      INT64_MAX, ".MIPS.ldata", 0},
00063   {_SEC_RDATA,  NULL,
00064      0|SHF_ALLOC,
00065         SHT_PROGBITS, 0, 
00066      INT64_MAX, ELF_RODATA, 0},
00067   {_SEC_SRDATA, NULL,
00068      0|SHF_IA_64_SHORT|SHF_ALLOC,
00069         SHT_PROGBITS, 0, 
00070      INT32_MAX, MIPS_SRDATA, 0},
00071   {_SEC_LIT4,   NULL,
00072      0|SHF_IA_64_SHORT|SHF_ALLOC|SHF_MIPS_MERGE,
00073         SHT_PROGBITS, 4, 
00074      INT32_MAX, MIPS_LIT4, 0},
00075   {_SEC_LIT8,   NULL,
00076      0|SHF_IA_64_SHORT|SHF_ALLOC|SHF_MIPS_MERGE,
00077         SHT_PROGBITS, 8, 
00078      INT32_MAX, MIPS_LIT8, 0},
00079   {_SEC_LIT16,  NULL,
00080      0|SHF_IA_64_SHORT|SHF_ALLOC|SHF_MIPS_MERGE,
00081         SHT_PROGBITS, 16, 
00082      INT32_MAX, MIPS_LIT16, 0},
00083   {_SEC_BSS,    NULL,
00084      0|SHF_WRITE|SHF_ALLOC,
00085         SHT_NOBITS, 0, 
00086      INT64_MAX, ELF_BSS, 0},
00087   {_SEC_SBSS,   NULL,
00088      0|SHF_WRITE|SHF_IA_64_SHORT|SHF_ALLOC,
00089         SHT_NOBITS, 0, 
00090      INT32_MAX, MIPS_SBSS, 0},
00091 
00092 #if defined(__mips)
00093   {_SEC_LBSS,   NULL,
00094      0|SHF_WRITE|SHF_ALLOC|SHF_MIPS_LOCAL,
00095         SHT_NOBITS, 0, 
00096      INT64_MAX, MIPS_LBSS, 0},
00097 #else
00098   // There is no MIPS_LBSS section on non-IRIX systems, but we need a
00099   // space holder
00100   {_SEC_LBSS,   NULL,
00101      0,
00102         0, 0,
00103      0, ".unknown", 0},
00104 #endif
00105 
00106   {_SEC_GOT,    NULL,
00107      0|SHF_IA_64_SHORT|SHF_ALLOC,
00108         SHT_PROGBITS, 0, 
00109      INT32_MAX, ELF_GOT, 0},
00110   {_SEC_CPLINIT,        NULL,
00111      0|SHF_WRITE|SHF_ALLOC|SHF_MIPS_NAMES,
00112         SHT_PROGBITS, 0, 
00113      INT64_MAX, "__cplinit", 0},
00114 
00115 #if defined(__mips)
00116   {_SEC_EH_REGION,      NULL,
00117      0|SHF_WRITE|SHF_ALLOC|SHF_MIPS_NAMES,
00118         SHT_PROGBITS, 0, 
00119      INT64_MAX, MIPS_EH_REGION, 0},
00120   {_SEC_EH_REGION_SUPP, NULL,
00121      0|SHF_WRITE|SHF_ALLOC|SHF_MIPS_NAMES,
00122         SHT_PROGBITS, 0, 
00123      INT64_MAX, MIPS_EH_REGION_SUPP, 0},
00124 #else
00125   // It's not yet clear what to do about the EH_REGION sections on
00126   // non-IRIX systems.
00127   {_SEC_EH_REGION,      NULL,
00128      0,
00129         0, 0,
00130      0, ".unknown", 0},
00131   {_SEC_EH_REGION_SUPP, NULL,
00132      0,
00133         0, 0,
00134      0, ".unknown", 0},
00135 #endif
00136 
00137   {_SEC_DISTR_ARRAY,  NULL,
00138      0|SHF_WRITE|SHF_ALLOC|SHF_MIPS_NAMES,
00139         SHT_PROGBITS, 0,
00140      INT64_MAX, "_MIPS_distr_array", 0},
00141 };
00142 
00143 extern SECTION_IDX
00144 Corresponding_Short_Section (SECTION_IDX sec)
00145 {
00146    switch ( sec ) {
00147    case _SEC_DATA:      return _SEC_SDATA;
00148    // cygnus doesn't handle srdata
00149    // case _SEC_RDATA:     return _SEC_SRDATA;
00150    case _SEC_BSS:       return _SEC_SBSS;
00151    default:             return sec;
00152    }
00153 }
00154 
00155 extern BOOL
00156 SEC_is_gprel (SECTION_IDX sec)
00157 {
00158         return (SEC_flags(sec) & SHF_IA_64_SHORT);
00159 }
00160 
00161 extern BOOL
00162 SEC_is_merge (SECTION_IDX sec)
00163 {
00164         return (SEC_flags(sec) & SHF_MIPS_MERGE);
00165 }
00166 
00167 extern BOOL
00168 SEC_is_exec (SECTION_IDX sec)
00169 {
00170         return (SEC_flags(sec) & SHF_EXECINSTR);
00171 }
00172 
00173 extern BOOL
00174 SEC_is_nobits (SECTION_IDX sec)
00175 {
00176         return (SEC_type(sec) & SHT_NOBITS);
00177 }
00178 
00179 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines