mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-01-22 22:06:58 +00:00
x64 disasm: properly symbolize rip-relative addresses
This commit is contained in:
parent
27a124dcff
commit
b7db15225f
@ -161,10 +161,25 @@ const char *ppsspp_resolver(struct ud*,
|
||||
if (addr >= (uint64_t)(¤tMIPS->r[0]) && addr < (uint64_t)¤tMIPS->r[32]) {
|
||||
*offset = addr - (uint64_t)(¤tMIPS->r[0]);
|
||||
return "mips.r";
|
||||
}
|
||||
if (addr >= (uint64_t)(¤tMIPS->v[0]) && addr < (uint64_t)¤tMIPS->v[128]) {
|
||||
} else if (addr >= (uint64_t)(¤tMIPS->v[0]) && addr < (uint64_t)¤tMIPS->v[128]) {
|
||||
*offset = addr - (uint64_t)(¤tMIPS->v[0]);
|
||||
return "mips.v";
|
||||
} else if (addr == (uint64_t)(¤tMIPS->downcount)) {
|
||||
return "mips.downcount";
|
||||
} else if (addr == (uint64_t)(¤tMIPS->fpcond)) {
|
||||
return "mips.fpcond";
|
||||
} else if (addr == (uint64_t)(¤tMIPS->temp)) {
|
||||
return "mips.temp";
|
||||
} else if (addr == (uint64_t)(¤tMIPS->pc)) {
|
||||
return "mips.pc";
|
||||
} else if (addr == (uint64_t)(¤tMIPS->hi)) {
|
||||
return "mips.hi";
|
||||
} else if (addr == (uint64_t)(¤tMIPS->lo)) {
|
||||
return "mips.lo";
|
||||
} else if (addr == (uint64_t)(¤tMIPS->fcr31)) {
|
||||
return "mips.fcr31";
|
||||
} else if (addr >= (uint64_t)(¤tMIPS->vfpuCtrl[0]) && addr < (uint64_t)(¤tMIPS->vfpuCtrl[16])) {
|
||||
return "mips.vfpuCtrl";
|
||||
}
|
||||
|
||||
// But these do.
|
||||
|
@ -442,6 +442,8 @@ void Jit::AddContinuedBlock(u32 dest)
|
||||
}
|
||||
|
||||
bool Jit::DescribeCodePtr(const u8 *ptr, std::string &name) {
|
||||
if (ptr == (const u8 *)&saved_flags)
|
||||
name = "saved_flags";
|
||||
if (ptr == applyRoundingMode)
|
||||
name = "applyRoundingMode";
|
||||
else if (ptr == updateRoundingMode)
|
||||
|
@ -71,7 +71,7 @@ static void gen_operand(struct ud* u, struct ud_operand* op, int syn_cast)
|
||||
if (u->pfx_seg) {
|
||||
ud_asmprintf(u, "%s:", ud_reg_tab[u->pfx_seg - UD_R_AL]);
|
||||
}
|
||||
if (op->base) {
|
||||
if (op->base && op->base != UD_R_RIP) {
|
||||
ud_asmprintf(u, "%s", ud_reg_tab[op->base - UD_R_AL]);
|
||||
}
|
||||
if (op->index) {
|
||||
|
@ -174,12 +174,16 @@ ud_syn_print_imm(struct ud* u, const struct ud_operand *op)
|
||||
ud_asmprintf(u, "0x%" FMT64 "x", v);
|
||||
}
|
||||
|
||||
uint64_t
|
||||
ud_syn_rip_target(struct ud *u, struct ud_operand *opr) {
|
||||
return (u->pc + opr->lval.sdword);
|
||||
}
|
||||
|
||||
void
|
||||
ud_syn_print_mem_disp(struct ud* u, const struct ud_operand *op, int sign)
|
||||
{
|
||||
UD_ASSERT(op->offset != 0);
|
||||
if (op->base == UD_NONE && op->index == UD_NONE) {
|
||||
if (op->base == UD_NONE && op->index == UD_NONE) {
|
||||
uint64_t v;
|
||||
UD_ASSERT(op->scale == UD_NONE && op->offset != 8);
|
||||
/* unsigned mem-offset */
|
||||
@ -199,7 +203,9 @@ ud_syn_print_mem_disp(struct ud* u, const struct ud_operand *op, int sign)
|
||||
case 32: v = op->lval.sdword; break;
|
||||
default: UD_ASSERT(!"invalid offset"); v = 0; /* keep cc happy */
|
||||
}
|
||||
if (v < 0) {
|
||||
if (op->base == UD_R_RIP) {
|
||||
ud_syn_print_addr(u, ud_syn_rip_target(u, op));
|
||||
} else if (v < 0) {
|
||||
ud_asmprintf(u, "-0x%" FMT64 "x", -v);
|
||||
} else if (v > 0) {
|
||||
ud_asmprintf(u, "%s0x%" FMT64 "x", sign? "+" : "", v);
|
||||
|
Loading…
x
Reference in New Issue
Block a user