[PATCH] [llvm-mc] Fix bad sign extension on callw immediate
Matthew Barney
m4b.github.io at gmail.com
Tue May 5 22:32:22 PDT 2015
Hi dougk,
An instruction sequence like 0x66 0xe8 0x59 0xcf was incorrectly disassembled due to a missing TYPE_REL16 in the translateImmediate type switch, and resulted in a signed short relative immediate in callw, like 0xcf59, to disassemble to 53081 instead of -12455.
REPOSITORY
rL LLVM
http://reviews.llvm.org/D9514
Files:
lib/Target/X86/Disassembler/X86Disassembler.cpp
Index: lib/Target/X86/Disassembler/X86Disassembler.cpp
===================================================================
--- lib/Target/X86/Disassembler/X86Disassembler.cpp
+++ lib/Target/X86/Disassembler/X86Disassembler.cpp
@@ -553,6 +553,12 @@
if(immediate & 0x80)
immediate |= ~(0xffull);
break;
+ case TYPE_REL16:
+ isBranch = true;
+ pcrel = insn.startLocation + insn.immediateOffset + insn.immediateSize;
+ if(immediate & 0x8000)
+ immediate |= ~(0xffffull);
+ break;
case TYPE_REL32:
case TYPE_REL64:
isBranch = true;
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9514.25009.patch
Type: text/x-patch
Size: 573 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150506/42ac46f9/attachment.bin>
More information about the llvm-commits
mailing list