xoreaxeaxeax / movfuscator

The single instruction C compiler
Other
9.39k stars 396 forks source link

Bug fix with post scripts #40

Open elikaski opened 3 years ago

elikaski commented 3 years ago

Compiling a simple Hello World program generates assembly code that contains:

    # (external call)
    movl (sp), %esp  # <REQ>
    movl $printf, (external)

When using post/xor.py (and other post scripts), the corresponding instructions generated are:

    # (external call)
    #xor> movl (sp), %esp  # <REQ>
    xorl %ebx, %ebx
    xorl (sp), %ebx
    xorl %esp  # <REQ>, %ebx
    xorl %ebx, %esp  # <REQ>

The third instruction is the problematic: xorl %esp # <REQ>, %ebx

The root cause is that the comment (# <REQ>) is also being identified as the "destination" register My change makes it discard the comment