mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-24 05:40:10 +00:00
Fix #382 - Refactor 16bit addressing issue to fix rel32 calculation
This commit is contained in:
parent
f0a45a556a
commit
239203d8d9
@ -95,8 +95,7 @@ gen_operand(struct ud* u, struct ud_operand* op)
|
||||
break;
|
||||
|
||||
case UD_OP_JIMM:
|
||||
//ud_syn_print_addr(u, ud_syn_rel_target(u, op));
|
||||
ud_syn_print_addr(u, ud_syn_rel_target(u, op, u->dis_mode!=64? 1: 0));
|
||||
ud_syn_print_addr(u, ud_syn_rel_target(u, op));
|
||||
break;
|
||||
|
||||
case UD_OP_PTR:
|
||||
|
@ -94,8 +94,7 @@ static void gen_operand(struct ud* u, struct ud_operand* op, int syn_cast)
|
||||
|
||||
|
||||
case UD_OP_JIMM:
|
||||
//ud_syn_print_addr(u, ud_syn_rel_target(u, op));
|
||||
ud_syn_print_addr(u, ud_syn_rel_target(u, op, u->dis_mode!=64? 1: 0));
|
||||
ud_syn_print_addr(u, ud_syn_rel_target(u, op));
|
||||
break;
|
||||
|
||||
case UD_OP_PTR:
|
||||
|
@ -88,40 +88,23 @@ const char* ud_reg_tab[] =
|
||||
};
|
||||
|
||||
|
||||
#if 0
|
||||
uint64_t
|
||||
ud_syn_rel_target(struct ud *u, struct ud_operand *opr)
|
||||
{
|
||||
const uint64_t trunc_mask = 0xffffffffffffffffull >> (64 - u->opr_mode);
|
||||
uint64_t trunc_mask = 0xffffffffffffffffull >> (64 - u->opr_mode);
|
||||
switch (opr->size) {
|
||||
case 8 : return (u->pc + opr->lval.sbyte) & trunc_mask;
|
||||
case 16: return (u->pc + opr->lval.sword) & trunc_mask;
|
||||
case 16: {
|
||||
int delta = (opr->lval.sword & trunc_mask);
|
||||
if ((u->pc + delta)>0xffff)
|
||||
return (u->pc & 0xf0000) + (u->pc+delta&0xffff);
|
||||
return (u->pc + delta);
|
||||
}
|
||||
case 32: return (u->pc + opr->lval.sdword) & trunc_mask;
|
||||
default: UD_ASSERT(!"invalid relative offset size.");
|
||||
return 0ull;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
uint64_t
|
||||
ud_syn_rel_target(struct ud *u, struct ud_operand *opr, int mask)
|
||||
{
|
||||
uint64_t trunc_mask = 0xffffffffffffffffull;
|
||||
if (mask) trunc_mask >>= (64 - u->opr_mode);
|
||||
switch (opr->size) {
|
||||
case 8 : return (u->pc + (opr->lval.sbyte & trunc_mask));
|
||||
case 16: {
|
||||
int delta = (opr->lval.sword & trunc_mask);
|
||||
if ((u->pc + delta)>0xffff) {
|
||||
return (u->pc & 0xf0000) + (u->pc+delta&0xffff);
|
||||
}
|
||||
return (u->pc + delta);
|
||||
}
|
||||
case 32: return (u->pc + (opr->lval.sdword & trunc_mask));
|
||||
default: UD_ASSERT(!"invalid relative offset size.");
|
||||
}
|
||||
return 0LL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
@ -33,7 +33,7 @@
|
||||
|
||||
extern const char* ud_reg_tab[];
|
||||
|
||||
uint64_t ud_syn_rel_target(struct ud*, struct ud_operand*, int n);
|
||||
uint64_t ud_syn_rel_target(struct ud*, struct ud_operand*);
|
||||
|
||||
#ifdef __GNUC__
|
||||
int ud_asmprintf(struct ud *u, const char *fmt, ...)
|
||||
|
Loading…
Reference in New Issue
Block a user