radareorg / radare2

UNIX-like reverse engineering framework and command-line toolset
https://www.radare.org/
GNU Lesser General Public License v3.0
20.64k stars 3k forks source link

Wrong assembler output for x86 #11724

Open ZhangZhuoSJTU opened 6 years ago

ZhangZhuoSJTU commented 6 years ago

Work environment

Questions Answers
OS/arch/bits (mandatory) Ubuntu x86 64
File format of the file you reverse (mandatory) None
Architecture/bits of the file (mandatory) x86/32
r2 -v full output, not truncated (mandatory) radare2 3.0.0-git 19606 @ linux-x86-64 git.2.9.0-271-g237e6c294 commit: 237e6c2947599c90a1dc76b986044e642d270386 build: 2018-10-03__15:56:23

Expected behavior

$ rasm2 -d -a x86 -b 32 8b444b10 # used for test the right result
$ mov eax, dword [ebx + ecx*2 + 0x10] # This is right
$ rasm2 -a x86 -b 32 "mov eax, dword [ebx + ecx*2 + 0x10]"
$ 8b444b10

Actual behavior

$ rasm2 -d -a x86 -b 32 8b444b10 # used for test the right result
$ mov eax, dword [ebx + ecx*2 + 0x10] # This is right
$ rasm2 -a x86 -b 32 "mov eax, dword [ebx + ecx*2 + 0x10]"
$ 8b040b # This is wrong
radare commented 6 years ago

the probem is not the disassembler. but the assembler. fix the title pls

you can use keystone or try to fix it if you have some spare time. look at libr/asm/p/asm_x86_nz.c

On 3 Oct 2018, at 22:07, izhuer notifications@github.com wrote:

Work environment

Questions Answers OS/arch/bits (mandatory) Ubuntu x86 64 File format of the file you reverse (mandatory) None Architecture/bits of the file (mandatory) x86/32 r2 -v full output, not truncated (mandatory) radare2 3.0.0-git 19606 @ linux-x86-64 git.2.9.0-271-g237e6c294 commit: 237e6c2 https://github.com/radare/radare2/commit/237e6c2947599c90a1dc76b986044e642d270386 build: 2018-10-03__15:56:23 Expected behavior

$ rasm2 -d -a x86 -b 32 8b444b10 # used for test the right result $ mov eax, dword [ebx + ecx2 + 0x10] # This is right $ rasm2 -a x86 -b 32 "mov eax, dword [ebx + ecx2 + 0x10]" $ 8b444b10 Actual behavior

$ rasm2 -d -a x86 -b 32 8b444b10 # used for test the right result $ mov eax, dword [ebx + ecx2 + 0x10] # This is right $ rasm2 -a x86 -b 32 "mov eax, dword [ebx + ecx2 + 0x10]" $ 8b040b # This is wrong — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/radare/radare2/issues/11724, or mute the thread https://github.com/notifications/unsubscribe-auth/AA3-luiVLpxPss9ucgaeh_pZJMjWNE7-ks5uhRkHgaJpZM4XGxk-.

Maijin commented 6 years ago

Greetings,

x86.nz (x86 handmade assembler) is one of the many x86 assemblers available in radare2 and is updated frequently. Please add a test case so we can fix x86.nz in https://github.com/radare/radare2-regressions/tree/master/new/db/asm (See https://github.com/radare/radare2-regressions/blob/master/new/README.md) You can do so with github web editor without even cloning the repo.

You can contribute to x86.nz by completing the following file https://github.com/radare/radare2/blob/master/libr/asm/p/asm_x86_nz.c. You can also use keystone(http://keystone-engine.org) within radare2/rasm2 by installing the radare2 plugin via r2pm :

    r2pm -i keystone-lib
    r2pm -i keystone
then
    rasm2 -a x86.ks…
or in radare2 session
    e asm.assembler = x86.ks

Others x86 assemblers are also available trough r2pm or master (see rasm2 -L list):

a___  16 32 64   x86.as      LGPL3   Intel X86 GNU Assembler
a___  16 32 64   x86.nasm    LGPL3   X86 nasm assembler
a___  16 32 64   x86.nz      LGPL3   x86 handmade assembler
ad__  32         x86.olly    GPL2    OllyDBG X86 disassembler
radare commented 6 years ago

nobody is gonna fix this for today

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. Considering a lot has changed since its creation, we kindly ask you to check again if the issue you reported is still relevant in the current version of radare2. If it is, update this issue with a comment, otherwise it will be automatically closed if no further activity occurs. Thank you for your contributions.