Decode jump targets as offset if address is NULL

Addresses relative to the actual address of the instruction are decoded
as new offset operand, where the RIP has to be added to obtain the real
value. For backwards compatibility, the new behavior is only exposed if
the address of the instruction is specified as zero.
This commit is contained in:
Alexis Engelke
2020-03-07 14:30:07 +01:00
parent dc286b14f2
commit afc574503f
2 changed files with 5 additions and 1 deletions

View File

@@ -597,7 +597,10 @@ fd_decode(const uint8_t* buffer, size_t len_sz, int mode_int, uintptr_t address,
if (imm_control == 4) if (imm_control == 4)
{ {
instr->imm += instr->address + off; if (instr->address != 0)
instr->imm += instr->address + off;
else
operand->type = FD_OT_OFF;
#if defined(ARCH_X86_64) #if defined(ARCH_X86_64)
// On x86-64, jumps always have an operand size of 64 bit. // On x86-64, jumps always have an operand size of 64 bit.
if (mode == DECODE_64) if (mode == DECODE_64)

View File

@@ -50,6 +50,7 @@ typedef enum {
FD_OT_REG = 1, FD_OT_REG = 1,
FD_OT_IMM = 2, FD_OT_IMM = 2,
FD_OT_MEM = 3, FD_OT_MEM = 3,
FD_OT_OFF = 4,
} FdOpType; } FdOpType;
typedef enum { typedef enum {