Jun Koi via llvm-dev
2017-May-07 07:22 UTC
[llvm-dev] X86 disassembler fails to handle 0x66 prefix?
Hello, I have seen this bug for quite a while, and even in the latest code it is still there: that is X86 disassembler does not handle 0x66 prefix properly, if it is put behind 0xF3 prefix. The below commands should return the same output, but not. $ echo "0xf3 0x66 0xa5"|./build/bin/llvm-mc --disassemble -triple=x86_64 -output-asm-variant=1 .text rep movsw word ptr es:[rdi], word ptr [rsi] $ echo "0x66 0xf3 0xa6"|./build/bin/llvm-mc --disassemble -triple=x86_64 -output-asm-variant=1 .text cmpsb byte ptr [rsi], byte ptr es:[rdi] You can see just by exchanging the order of 0xf3 & 0x66, we get different result. F3 in this case is not really a prefix for REP I think. Is there any solution to fix this? Thanks. Jun
Jun Koi via llvm-dev
2017-May-07 07:40 UTC
[llvm-dev] X86 disassembler fails to handle 0x66 prefix?
On Sun, May 7, 2017 at 3:22 PM, Jun Koi <junkoi2004 at gmail.com> wrote:> Hello, > > I have seen this bug for quite a while, and even in the latest code it > is still there: that is X86 disassembler does not handle 0x66 prefix > properly, if it is put behind 0xF3 prefix. > > The below commands should return the same output, but not. > > $ echo "0xf3 0x66 0xa5"|./build/bin/llvm-mc --disassemble > -triple=x86_64 -output-asm-variant=1 > .text > rep > movsw word ptr es:[rdi], word ptr [rsi] > > $ echo "0x66 0xf3 0xa6"|./build/bin/llvm-mc --disassemble > -triple=x86_64 -output-asm-variant=1 > .text > cmpsb byte ptr [rsi], byte ptr es:[rdi] > > > You can see just by exchanging the order of 0xf3 & 0x66, we get > different result. F3 in this case is not really a prefix for REP I > think.Just to clarify, the correct output for both cases would be: "rep movsw word ptr es:[rdi], word ptr [rsi]" Thanks.
Flamedoge via llvm-dev
2017-May-07 08:25 UTC
[llvm-dev] X86 disassembler fails to handle 0x66 prefix?
> F3 in this case is not really a prefix for REP I think.http://x86.renejeschke.de/html/file_module_x86_id_279.html Intel arch. manual shows REP uses F3 and F2 as starting prefixes. Kevin On Sun, May 7, 2017 at 12:40 AM, Jun Koi via llvm-dev < llvm-dev at lists.llvm.org> wrote:> On Sun, May 7, 2017 at 3:22 PM, Jun Koi <junkoi2004 at gmail.com> wrote: > > Hello, > > > > I have seen this bug for quite a while, and even in the latest code it > > is still there: that is X86 disassembler does not handle 0x66 prefix > > properly, if it is put behind 0xF3 prefix. > > > > The below commands should return the same output, but not. > > > > $ echo "0xf3 0x66 0xa5"|./build/bin/llvm-mc --disassemble > > -triple=x86_64 -output-asm-variant=1 > > .text > > rep > > movsw word ptr es:[rdi], word ptr [rsi] > > > > $ echo "0x66 0xf3 0xa6"|./build/bin/llvm-mc --disassemble > > -triple=x86_64 -output-asm-variant=1 > > .text > > cmpsb byte ptr [rsi], byte ptr es:[rdi] > > > > > > You can see just by exchanging the order of 0xf3 & 0x66, we get > > different result. F3 in this case is not really a prefix for REP I > > think. > > Just to clarify, the correct output for both cases would be: "rep > movsw word ptr es:[rdi], word ptr [rsi]" > > > Thanks. > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170507/225b8da6/attachment.html>
Possibly Parallel Threads
- [LLVMdev] X86 disassembler is quite broken on handling REX
- [LLVMdev] registerSize on X86 confused?
- [BUG] Mismatch between assembler & disassembler of X86 RIP-relative instruction
- [LLVMdev] X86 disassembler & assembler mismatch
- [BUG] Mismatch between assembler & disassembler of X86 RIP-relative instruction