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
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 #include "xlateincl.h"
00047
00048 #ifdef _LIBELF_XTND_EXPANDED_DATA
00049 #pragma weak xlate_address_xtnd = _xlate_address_xtnd
00050 #elif defined(BUILD_OS_DARWIN)
00051 #else
00052 #pragma weak xlate_address = _xlate_address
00053 #endif
00054 int
00055 xlate_address(xlate_table_con tab,
00056 int isNewAddress,
00057 Elf64_Addr addr_in,
00058 Elf64_Addr *addr_out,
00059 xlate_block *range)
00060 {
00061
00062 int retstatus = XLATE_TB_STATUS_NO_ERROR;
00063 if(tab->xc_valid_table != VALID_TABLE_MAGIC) {
00064 return XLATE_TB_STATUS_INVALID_TABLE;
00065 }
00066
00067
00068 if(isNewAddress) {
00069 if(addr_in < tab->xc_hdr.ich_new_addr_low ||
00070 addr_in >= tab->xc_hdr.ich_new_addr_high) {
00071 retstatus = XLATE_TB_STATUS_NO_SUCH_ADDR_IN_TABLE;
00072 } else {
00073 retstatus = tab->xc_search_for_addr_new(tab,
00074 isNewAddress,
00075 addr_in, addr_out,
00076 range);
00077 }
00078
00079
00080
00081 } else {
00082 if(addr_in < tab->xc_hdr.ich_old_addr_low ||
00083 addr_in >= tab->xc_hdr.ich_old_addr_high) {
00084 retstatus = XLATE_TB_STATUS_NO_SUCH_ADDR_IN_TABLE;
00085 } else {
00086 retstatus = tab->xc_search_for_addr_old(tab,
00087 isNewAddress,
00088 addr_in, addr_out,
00089 range);
00090 }
00091 }
00092 if(retstatus == XLATE_TB_STATUS_NO_SUCH_ADDR_IN_TABLE) {
00093 #ifdef DEBUG
00094 printf("XLATE_TB_STATUS_NO_SUCH_ADDR_IN_TABLE fabricate range\n");
00095 #endif
00096 *addr_out = addr_in;
00097 if(range) {
00098 range->xe_new_address = addr_in;
00099 range->xe_old_address = addr_in;
00100 range->xe_old_range = INSTRUCTION_SIZE;
00101 range->xe_new_range = INSTRUCTION_SIZE;
00102 }
00103 retstatus = XLATE_TB_STATUS_NO_ERROR;
00104 }
00105 return retstatus;
00106 }