Open64 (mfef90, whirl2f, and IR tools)
TAG: version-openad; SVN changeset: 916
|
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 _LIBXLATE_H 00037 #define _LIBXLATE_H 00038 #ifdef __cplusplus 00039 extern "C" { 00040 #endif 00041 00042 /* 00043 libXlate.h 00044 00045 00046 All external symbols and macros begin with one of the following 00047 XLATE_ 00048 _XLATE_ 00049 xlate_ 00050 _xlate_ 00051 00052 Link in the functions with -lelfutil 00053 00054 */ 00055 00056 #include <libelf.h> /* sets _LIBELF_XTND_EXPANDED_DATA if appropriate */ 00057 #include <dwarf.h> 00058 #include <libdwarf.h> 00059 00060 #ifndef _XLATE_TABLEKIND_DEF 00061 #define _XLATE_TABLEKIND_DEF 00062 typedef enum { 00063 xlate_tk_general, 00064 xlate_tk_preserve_size, 00065 xlate_tk_preserve_order 00066 } xlate_tablekind; 00067 #endif 00068 00069 #ifdef _LIBELF_XTND_EXPANDED_DATA 00070 #define xlate_init_fd _xlate_init_fd_xtnd 00071 #define xlate_init_elf _xlate_init_elf_xtnd 00072 #define xlate_named_init_fd _xlate_named_init_fd_xtnd 00073 #define xlate_named_init_elf _xlate_named_init_elf_xtnd 00074 #define xlate_get_info _xlate_get_info_xtnd 00075 #define xlate_address _xlate_address_xtnd 00076 #define xlate_get_reg_rule _xlate_get_reg_rule_xtnd 00077 #define xlate_get_all_reg_rules _xlate_get_all_reg_rules_xtnd 00078 #define xlate_expand_reg_info _xlate_expand_reg_info_xtnd 00079 #define xlate_expand_reg_info2 _xlate_expand_reg_info2_xtnd 00080 #define xlate_finish _xlate_finish_xtnd 00081 00082 #define xlate_pro_init _xlate_pro_init_xtnd 00083 #define xlate_pro_add_info _xlate_pro_add_info_xtnd 00084 #define xlate_pro_add_reg_info _xlate_pro_add_reg_info_xtnd 00085 #define xlate_pro_add_range _xlate_pro_add_range_xtnd 00086 #define xlate_pro_disk_header _xlate_pro_disk_header_xtnd 00087 #define xlate_pro_disk_next_block _xlate_pro_disk_next_block_xtnd 00088 #define xlate_pro_finish _xlate_pro_finish_xtnd 00089 #endif 00090 00091 00092 /* 00093 We use different opaque structs as handles for the 00094 Producer and Consumer. 00095 */ 00096 typedef struct xlate_table_con_s *xlate_table_con; 00097 typedef struct xlate_table_pro_s *xlate_table_pro; 00098 00099 /* 00100 This struct is used to return pieces of the fully expanded 00101 table to the user. It is used to return the ranges that 00102 correspond to a given contiguous range. 00103 00104 Shared by all versions. 00105 */ 00106 typedef struct xlate_block_s { 00107 Elf64_Addr xe_new_address; 00108 Elf64_Xword xe_new_range; 00109 Elf64_Addr xe_old_address; 00110 Elf64_Xword xe_old_range; 00111 } xlate_block; 00112 00113 00114 /******************** Consumer Interface *************************/ 00115 00116 #define XLATE_OPEN_STD_TABLE 0 00117 #define XLATE_OPEN_DEBUG_TABLE 1 00118 00119 int xlate_init_fd(int /*fd*/, 00120 int /*open_debug_table*/, 00121 xlate_table_con * /*returned_table_pointer*/); 00122 00123 int xlate_init_elf(Elf * /*elf*/, 00124 int /*open_debug_table*/, 00125 xlate_table_con * /*table*/); 00126 00127 int xlate_named_init_fd(int /*fd*/, 00128 const char * /*section_name*/, 00129 xlate_table_con * /*returned_table_pointer*/); 00130 00131 int xlate_named_init_elf(Elf * /*elf*/, 00132 const char * /*section_name*/, 00133 xlate_table_con * /*table*/); 00134 00135 int xlate_get_info(xlate_table_con /*table*/, 00136 Elf64_Sxword * /*dataMoved*/, 00137 Elf64_Addr * /*new_low_addr*/, 00138 Elf64_Addr * /*old_low_addr*/, 00139 Elf64_Addr * /*new_high_addr*/, 00140 Elf64_Addr * /*old_high_addr*/, 00141 Elf64_Addr * /*startup_fwa*/, 00142 Elf64_Addr * /*startup_lwa*/, 00143 Elf64_Xword * /*number_of_ranges*/, 00144 int * /*old_text_exists*/, 00145 int * /*old_text_alloc*/, 00146 int * /*is64bit */, 00147 xlate_tablekind * /*tablekind */, 00148 int * /*tableversion */); 00149 00150 #define XLATE_ADDRESS_INPUT_NEW_ADDRESS 1 00151 #define XLATE_ADDRESS_INPUT_OLD_ADDRESS 0 00152 int xlate_address(xlate_table_con /*table*/, 00153 int /*is_new_address*/, 00154 Elf64_Addr /*address_in*/, 00155 Elf64_Addr * /*address_out*/, 00156 xlate_block * /*range*/); 00157 00158 int xlate_get_reg_rule(xlate_table_con /*table*/, 00159 Elf64_Addr /*pc*/, 00160 Elf32_Word /*reg*/, 00161 Elf32_Word * /*rule_register*/, 00162 Elf64_Xword * /*rule_offset*/, 00163 Elf32_Word * /*rule_is_offset*/); 00164 00165 int xlate_get_all_reg_rules(xlate_table_con /*table*/, 00166 Elf64_Addr /*pc*/, 00167 Dwarf_Regtable * /*reg_table*/); 00168 00169 typedef struct xlate_reg_instr_s{ 00170 Dwarf_Small sr_op; 00171 Dwarf_Unsigned sr_val1; 00172 Dwarf_Unsigned sr_val2; 00173 } xlate_reg_instr; 00174 00175 /* xlate_expand_reg_info is obsolescent call: 00176 ** use xlate_expand_reg_info2 instead. 00177 */ 00178 int xlate_expand_reg_info(xlate_table_con /*table*/, 00179 Elf64_Xword * /*num_instrs*/, 00180 xlate_reg_instr ** /*instructions*/); 00181 00182 /* xlate_reg_instr2_s is identical to 00183 ** xlate_reg_instr_s except it has a new field and 00184 ** uses a new interface function 00185 ** to preserve binary compatibility for old xlate_expand_reg_info 00186 ** calling code. 00187 ** The sr_instr_offset is the byte offset in the register instructions 00188 ** of the register instruction involved. 00189 */ 00190 typedef struct xlate_reg_instr2_s{ 00191 Dwarf_Small sr_op; 00192 Dwarf_Unsigned sr_val1; 00193 Dwarf_Unsigned sr_val2; 00194 Dwarf_Unsigned sr_instr_offset; 00195 } xlate_reg_instr2; 00196 00197 int xlate_expand_reg_info2(xlate_table_con /*table*/, 00198 Elf64_Xword * /*num_instrs*/, 00199 xlate_reg_instr2 ** /*instructions*/); 00200 00201 int xlate_finish(xlate_table_con /*table*/); 00202 00203 00204 /***************** special rqs interface *******************/ 00205 00206 /* 00207 Interface to xlate section fixer. 00208 Called only by rqs. 00209 Updates the bytes pointed to by pxlate, which must 00210 be a valid .MIPS.xlate section (read in by the caller). 00211 This routine does no file io and writes no messages. 00212 00213 Returns value indicating success/failure. 00214 00215 Returns XLATE_TB_STATUS_NO_ERROR 00216 in case of successful updating. 00217 00218 Returns XLATE_TB_STATUS_INVALID_TABLE 00219 if the table passed in is improper (perhaps partly trashed). 00220 00221 Returns XLATE_TB_STATUS_XLATE_BAD if the table has an improper 00222 version number. 00223 00224 Updating can only fail if the section is illogical/incomplete 00225 (corruputed in some way). 00226 00227 */ 00228 int _xlate_fix_addresses_for_dso_movement( 00229 void* pxlate, /* memory address of the section: 00230 The caller must read or map in the section 00231 and pass pxlate as 00232 a pointer to the memory. 00233 No particular alignment of the section 00234 in memory is required by this routine. 00235 */ 00236 unsigned long long len, /* Length of the xlate 00237 section. If largerthan 00238 the space pointed to by pxlate 00239 chaos will surely follow*/ 00240 unsigned long long movement /* Amount that the 00241 text moved. 00242 This value will be added to the appropriate 00243 vm addresses in the section. */ 00244 ); 00245 00246 /***************** Producer Interface *******************/ 00247 00248 int xlate_pro_init(xlate_table_pro * /*ret_table*/, 00249 xlate_tablekind /*tablekind*/, 00250 xlate_table_con /*compose_with_table*/, 00251 int /*is64Bit*/); 00252 00253 int xlate_pro_add_info(xlate_table_pro /*table*/, 00254 Elf64_Sxword /*data_moved*/, 00255 Elf64_Addr /*startup_fwa*/, 00256 Elf64_Addr /*startup_lwa*/, 00257 Elf32_Word /*old_text_exists*/, 00258 Elf32_Word /*old_text_alloc*/); 00259 00260 int xlate_pro_add_reg_info(xlate_table_pro /*table*/, 00261 Dwarf_Small /*op*/, 00262 Dwarf_Unsigned /*val1*/, 00263 Dwarf_Unsigned /*val2*/); 00264 00265 int xlate_pro_add_range(xlate_table_pro /*table*/, 00266 Elf64_Addr /*new_address*/, 00267 Elf64_Xword /*new_range*/, 00268 Elf64_Addr /*old_address*/, 00269 Elf64_Xword /*old_range*/); 00270 00271 /* these are the legal values passed to xlate_pro_disk_header */ 00272 #define XLATE_PRO_STANDARD_SETUP 1 00273 #define XLATE_PRO_DEBUG_SETUP 2 00274 00275 int xlate_pro_disk_header(xlate_table_pro /*table*/, 00276 int /*standard_or_debug*/, 00277 Elf64_Xword * /*total_memory_req*/, 00278 Elf64_Xword * /*num_blocks*/); 00279 00280 int xlate_pro_disk_next_block(xlate_table_pro /*table*/, 00281 char ** /*data*/, 00282 Elf64_Xword * /*data_size*/); 00283 00284 00285 int xlate_pro_finish(xlate_table_pro /*table*/); 00286 00287 00288 /***************** Return values *******************/ 00289 00290 00291 /* 00292 0 means no error. 00293 All errors are negative numbers. Defined here. 00294 Positive number never returned. 00295 */ 00296 #define XLATE_TB_STATUS_NO_ERROR 0 00297 #define XLATE_TB_STATUS_ALLOC_FAIL -1 00298 #define XLATE_TB_STATUS_NULL_TABLE -2 00299 #define XLATE_TB_STATUS_BAD_TABLEKIND -3 00300 #define XLATE_TB_STATUS_BAD_ADD_ADDR -4 00301 #define XLATE_TB_STATUS_RET_ADDR_NULL -6 00302 #define XLATE_TB_STATUS_NO_MORE_BLOCKS -7 00303 #define XLATE_TB_STATUS_NOT_YET_IMPLEMENT -8 00304 #define XLATE_TB_STATUS_NO_DEBUG -9 00305 #define XLATE_TB_STATUS_ALREADY_DONE -10 00306 00307 #define XLATE_TB_STATUS_ADDR_UNALIGNED -11 00308 #define XLATE_TB_STATUS_RANGE_BAD -12 00309 #define XLATE_TB_STATUS_FSTAT_ERROR -13 00310 #define XLATE_TB_STATUS_MMAP_ERROR -14 00311 #define XLATE_TB_STATUS_BAD_VERSION -15 00312 #define XLATE_TB_STATUS_NULL_HEADER -16 00313 #define XLATE_TB_STATUS_NO_HEADER -17 00314 #define XLATE_TB_STATUS_BAD_FILE_SIZE -18 00315 #define XLATE_TB_STATUS_NEW_ADDR_ERROR -19 /* unused */ 00316 #define XLATE_TB_STATUS_DECODE_ERROR -20 00317 00318 #define XLATE_TB_STATUS_BAD_BLOCK_INDEX -21 00319 #define XLATE_TB_STATUS_UPPER_ADDR_BAD -22 00320 #define XLATE_TB_STATUS_TABLE_NOT_PO -23 00321 #define XLATE_TB_STATUS_MUNMAP_ERROR -24 00322 #define XLATE_TB_STATUS_ELF_IDENT_BAD -25 00323 #define XLATE_TB_STATUS_ELF_SHDR_BAD -26 00324 #define XLATE_TB_STATUS_NO_XLATE -27 00325 #define XLATE_TB_STATUS_NO_XLATE_DATA -28 00326 #define XLATE_TB_STATUS_XLATE_BAD -29 00327 #define XLATE_TB_STATUS_XLATE_DEBUG_BAD -30 00328 00329 #define XLATE_TB_STATUS_ELF_VERSION_BAD -31 00330 #define XLATE_TB_STATUS_ELF_BEGIN_BAD -32 00331 #define XLATE_TB_STATUS_NOT_ELF -33 00332 #define XLATE_TB_STATUS_OLD_ADDR_ERROR -34 /* unused */ 00333 #define XLATE_TB_STATUS_ADD_TOO_LATE -35 00334 #define XLATE_TB_STATUS_BAD_REG_VAL -36 00335 #define XLATE_TB_STATUS_BAD_REG_OP -37 00336 #define XLATE_TB_STATUS_BAD_FRAME_OP -38 00337 #define XLATE_TB_STATUS_NO_REG_INFO -39 00338 00339 #define XLATE_TB_STATUS_SECTION_TOO_BIG -42 00340 #define XLATE_TB_STATUS_INVALID_TABLE -43 00341 #define XLATE_TB_STATUS_SECTION_TOO_SMALL -44 00342 #define XLATE_TB_STATUS_INCONSISTENT_64_BIT_INFO -45 00343 #define XLATE_TB_STATUS_NO_SUCH_ADDR_IN_TABLE -46 00344 #define XLATE_TB_STATUS_INVALID_BLOCK_INDEX -47 00345 #define XLATE_TB_STATUS_REG_REQUEST_BOGUS -48 00346 #define XLATE_TB_STATUS_PRO_CON_TABLE_MISMATCH -59 00347 #define XLATE_TB_STATUS_PRO_REQ_INVALID -50 00348 #define XLATE_TB_STATUS_BLOCK_REQ_SEQ_ERR -51 00349 #define XLATE_TB_STATUS_FRAME_RESTORE_INVALID -52 00350 #define XLATE_TB_STATUS_UNEQUAL_RANGE -53 00351 #define XLATE_TB_STATUS_INVALID_PO_INPUT -54 00352 #define XLATE_TB_STATUS_INVALID_SEQUENCE -55 00353 #define XLATE_TB_STATUS_ELF_EHDR_BAD -56 00354 #define XLATE_TB_STATUS_ELF_STRPTR_BAD -57 00355 00356 00357 #ifdef __cplusplus 00358 } 00359 #endif 00360 #endif /* _LIBXLATE_H */