00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef _LIBXLATE_H
00037 #define _LIBXLATE_H
00038 #ifdef __cplusplus
00039 extern "C" {
00040 #endif
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056 #include <libelf.h>
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
00094
00095
00096 typedef struct xlate_table_con_s *xlate_table_con;
00097 typedef struct xlate_table_pro_s *xlate_table_pro;
00098
00099
00100
00101
00102
00103
00104
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
00115
00116 #define XLATE_OPEN_STD_TABLE 0
00117 #define XLATE_OPEN_DEBUG_TABLE 1
00118
00119 int xlate_init_fd(int ,
00120 int ,
00121 xlate_table_con * );
00122
00123 int xlate_init_elf(Elf * ,
00124 int ,
00125 xlate_table_con * );
00126
00127 int xlate_named_init_fd(int ,
00128 const char * ,
00129 xlate_table_con * );
00130
00131 int xlate_named_init_elf(Elf * ,
00132 const char * ,
00133 xlate_table_con * );
00134
00135 int xlate_get_info(xlate_table_con ,
00136 Elf64_Sxword * ,
00137 Elf64_Addr * ,
00138 Elf64_Addr * ,
00139 Elf64_Addr * ,
00140 Elf64_Addr * ,
00141 Elf64_Addr * ,
00142 Elf64_Addr * ,
00143 Elf64_Xword * ,
00144 int * ,
00145 int * ,
00146 int * ,
00147 xlate_tablekind * ,
00148 int * );
00149
00150 #define XLATE_ADDRESS_INPUT_NEW_ADDRESS 1
00151 #define XLATE_ADDRESS_INPUT_OLD_ADDRESS 0
00152 int xlate_address(xlate_table_con ,
00153 int ,
00154 Elf64_Addr ,
00155 Elf64_Addr * ,
00156 xlate_block * );
00157
00158 int xlate_get_reg_rule(xlate_table_con ,
00159 Elf64_Addr ,
00160 Elf32_Word ,
00161 Elf32_Word * ,
00162 Elf64_Xword * ,
00163 Elf32_Word * );
00164
00165 int xlate_get_all_reg_rules(xlate_table_con ,
00166 Elf64_Addr ,
00167 Dwarf_Regtable * );
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
00176
00177
00178 int xlate_expand_reg_info(xlate_table_con ,
00179 Elf64_Xword * ,
00180 xlate_reg_instr ** );
00181
00182
00183
00184
00185
00186
00187
00188
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 ,
00198 Elf64_Xword * ,
00199 xlate_reg_instr2 ** );
00200
00201 int xlate_finish(xlate_table_con );
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228 int _xlate_fix_addresses_for_dso_movement(
00229 void* pxlate,
00230
00231
00232
00233
00234
00235
00236 unsigned long long len,
00237
00238
00239
00240 unsigned long long movement
00241
00242
00243
00244 );
00245
00246
00247
00248 int xlate_pro_init(xlate_table_pro * ,
00249 xlate_tablekind ,
00250 xlate_table_con ,
00251 int );
00252
00253 int xlate_pro_add_info(xlate_table_pro ,
00254 Elf64_Sxword ,
00255 Elf64_Addr ,
00256 Elf64_Addr ,
00257 Elf32_Word ,
00258 Elf32_Word );
00259
00260 int xlate_pro_add_reg_info(xlate_table_pro ,
00261 Dwarf_Small ,
00262 Dwarf_Unsigned ,
00263 Dwarf_Unsigned );
00264
00265 int xlate_pro_add_range(xlate_table_pro ,
00266 Elf64_Addr ,
00267 Elf64_Xword ,
00268 Elf64_Addr ,
00269 Elf64_Xword );
00270
00271
00272 #define XLATE_PRO_STANDARD_SETUP 1
00273 #define XLATE_PRO_DEBUG_SETUP 2
00274
00275 int xlate_pro_disk_header(xlate_table_pro ,
00276 int ,
00277 Elf64_Xword * ,
00278 Elf64_Xword * );
00279
00280 int xlate_pro_disk_next_block(xlate_table_pro ,
00281 char ** ,
00282 Elf64_Xword * );
00283
00284
00285 int xlate_pro_finish(xlate_table_pro );
00286
00287
00288
00289
00290
00291
00292
00293
00294
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
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
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