[LLVMdev] [X86 Disassembler] Instruction Prefixes

Aaron Lint alint at arxan.com
Sat Mar 15 21:35:53 PDT 2014


I’m using the MCDisassembler for x86, and I’m having a really hard time handling instruction prefixes properly.

Here’s a concise example of the types of problems I am having:

66 F2 AF        REPNE SCASW WORD PTR ES:[EDI]
F2 66 AF        REPNE SCASW WORD PTR ES:[EDI]

llvm-mc does fine when the REPNE prefix is first, but gives incorrect disassembly when it follows the OPSIZE override.

With ToT, this is what I get:

     scasl %es:(%edi), %eax <-- incorrect (ignored osz)
     repne
     scasw %es:(%edi), %ax <-- correct

>From my take, these should be equivalent instructions.

I have followed through the getID function, where it uses the attrMask of ATTR_XD, and then ands in the ATTR_OPSIZE to see if there is an equivalent.

However, that second call to getIDWithAttrMask returns PHI.  For some reason there isn’t a way I’ve found to indicate that certain instructions are allowed in that IC_XD_OPSIZE context.

I’ve tried a couple different things to change this, but it seems to break things all over the place.  I’m currently pretty much stymied by this, butI’m willing to put in effort to make this better if someone can help me point in the right direction.

Thanks,
Aaron
_____________________________________________________________________
Aaron Lint
Director of Product Development, GuardIT
Arxan Technologies, Inc.
w:765-889-4756 x81 m:330-327-7524
alint at arxan.com<mailto:alint at arxan.com>     www.arxan.com<http://www.arxan.com/>
Protecting the App Economy™.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140315/7ad2a56e/attachment.html>


More information about the llvm-dev mailing list