radare2/shlr/capstone-patches/fix-x86-16.patch
2015-10-07 13:08:23 +02:00

31 lines
1017 B
Diff

diff --git a/arch/X86/X86ATTInstPrinter.c b/arch/X86/X86ATTInstPrinter.c
index 7e19b4e..062eef8 100644
--- a/arch/X86/X86ATTInstPrinter.c
+++ b/arch/X86/X86ATTInstPrinter.c
@@ -576,6 +576,10 @@ static void printPCRelImm(MCInst *MI, unsigned OpNo, SStream *O)
if (MI->Opcode == X86_CALLpcrel16 || MI->Opcode == X86_JMP_2)
imm = imm & 0xffff;
+ if (MI->csh->mode == CS_MODE_16) {
+ imm |= (MI->address >> 16) << 16;
+ }
+
if (imm < 0) {
SStream_concat(O, "0x%"PRIx64, imm);
} else {
diff --git a/arch/X86/X86IntelInstPrinter.c b/arch/X86/X86IntelInstPrinter.c
index c455725..eb60586 100644
--- a/arch/X86/X86IntelInstPrinter.c
+++ b/arch/X86/X86IntelInstPrinter.c
@@ -756,6 +756,10 @@ static void printPCRelImm(MCInst *MI, unsigned OpNo, SStream *O)
if (MI->Opcode == X86_CALLpcrel16 || MI->Opcode == X86_JMP_2)
imm = imm & 0xffff;
+ if (MI->csh->mode == CS_MODE_16) {
+ imm |= (MI->address >> 16) << 16;
+ }
+
printImm(MI->csh->syntax, O, imm, true);
if (MI->csh->detail) {