Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
targ_em_elf.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 
00036 /* ====================================================================
00037  * ====================================================================
00038  *
00039  *
00040  * Description:
00041  *
00042  * Generate the elf headers and sections for the object file.
00043  *
00044  * ====================================================================
00045  * ====================================================================
00046  */
00047 
00048 
00049 #include <stdio.h>
00050 #include <unistd.h>
00051 #include <fcntl.h>
00052 #include <sys/stat.h>
00053 #include <errno.h>
00054 #include <bstring.h>
00055 #include <elf.h>
00056 #include <elfaccess.h>
00057 #include <libelf.h>
00058 #include <stamp.h>
00059 #include <alloca.h>
00060 #include <cmplrs/leb128.h>
00061 #include <cmplrs/elf_interfaces.h>
00062 #include <sys/unwindP.h>
00063 
00064 #define USE_STANDARD_TYPES 1
00065 #include "defs.h"
00066 #include "erlib.h"
00067 #include "erglob.h"
00068 #include "config.h"
00069 #include "targ_const.h"
00070 #include "glob.h"
00071 #include "config.h"
00072 #include "config_elf_targ.h"
00073 #include "em_elf.h"
00074 
00075 INT GP_DISP = 0;
00076 
00077 pSCNINFO Interface_Scn;
00078 
00079 void Em_Write_Reginfo (
00080     Elf64_Addr gprvalue, 
00081     Elf64_Word gprmask, 
00082     Elf64_Word fprmask,
00083     BOOL pure_abi)
00084 {
00085     /* should we put reginfo into the .options section? */
00086     /* A:  no */
00087     return;
00088 
00089 #if 0
00090     if (Sixtyfour_Bit) {
00091         if (Get_Elf_Target_Machine() == EM_IA_64) {
00092           Elf_IA64_RegInfo reginfo_ia64;
00093           reginfo_ia64.ri_gp_value = gprvalue;
00094           Em_Add_New_Option (ODK_IA64_REGINFO, SHN_UNDEF,0, &reginfo_ia64, sizeof(reginfo_ia64));
00095         }
00096     }
00097     else {
00098         ErrMsg(EC_Assertion, __FILE__, __LINE__, "NYI - n32 reginfo");
00099     }
00100 #endif
00101 }
00102 
00103 /* Add new entry to the .options section. */
00104 void
00105 Em_Add_New_Option (
00106     Elf32_Byte option_kind, 
00107     Elf32_Section option_section, 
00108     Elf32_Word option_info, 
00109     void *buffer, 
00110     Elf32_Byte length)
00111 {
00112     Elf_Options option;
00113 #if 0 // don't put out options period. Its not defined in ABI
00114     if (Options_Scn == NULL) {
00115         Options_Scn = Em_New_Section (IA64_OPTIONS, SHT_IRIX_OPTIONS, 
00116                           SHF_ALLOC | SHF_IRIX_NOSTRIP, 0, 
00117                           ELF64_FSZ_XWORD);
00118     }
00119     option.kind = option_kind;
00120     option.size = sizeof (Elf_Options);
00121     option.section = option_section;
00122     option.info = option_info;
00123     option.size += Roundup (length, 8);
00124     Em_Add_Bytes_To_Scn (Options_Scn, &option, sizeof(option), ELF64_FSZ_WORD);
00125     if (length != 0) {
00126       Em_Add_Bytes_To_Scn (Options_Scn, buffer, length, ELF64_FSZ_WORD);
00127     }
00128 #else
00129     return;
00130 #endif
00131 }
00132 
00133 
00134 /* Add a new event to the .events section. The operand1 and operand2
00135    parameters are used to pass additional information needed for 
00136    certain event kinds.
00137 
00138      EK_IF_ENTRY:               operand1 is offset in interface scn.
00139 
00140      EK_FCALL_LOCAL,
00141      EK_FCALL_EXTERN,
00142      EX_FCALL_EXTERN_BIG:       operand1 is elf symbol index of called proc.
00143 */
00144 void
00145 Em_Add_New_Event (
00146     Elf64_Word ev_kind, 
00147     Elf64_Word ev_ofst, 
00148     Elf64_Word operand1,
00149     Elf64_Word operand2,
00150     Elf64_Word operand3,
00151     pSCNINFO scn)
00152 {
00153   return;
00154 }
00155 
00156 
00157 /* Add a new entry to the .contents section. */
00158 void
00159 Em_Add_New_Content (
00160     Elf64_Word con_kind, 
00161     Elf64_Xword con_ofst, 
00162     Elf64_Word operand1,
00163     Elf64_Word operand2,
00164     pSCNINFO scn)
00165 {
00166   return;
00167 }
00168 
00169 void
00170 Em_End_Unwind (FILE *trace_file, pSCNINFO text_scn)
00171 {
00172   if (trace_file) {
00173         // dump unwind table and unwind info
00174         // should be trace file
00175         unwind_process (unwind_dump2ascii, (void *) trace_file);
00176   }
00177   unwind_process (unwind_dump2elf, text_scn);
00178 }
00179 
00180 void
00181 Em_Cleanup_Unwind (void)
00182 {
00183   unwind_cleanup();
00184 }
00185 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines