keystone-engine / keystone

Keystone assembler framework: Core (Arm, Arm64, Hexagon, Mips, PowerPC, Sparc, SystemZ & X86) + bindings
http://www.keystone-engine.org
GNU General Public License v2.0
2.3k stars 458 forks source link

under intel style, Invalid operand (KS_ERR_ASM_INVALIDOPERAND) when same Label is accessed second time. #570

Open bbqz007 opened 11 months ago

bbqz007 commented 11 months ago

code generated by gcc

    .align 4
_MessageBoxA:
    .long   19089016
LC0:
    .ascii "\0"
    push    ebp
    mov ebp, esp
    sub esp, 24
    mov eax, DWORD PTR _MessageBoxA
    mov ecx, OFFSET FLAT:LC0   ;  OK
    mov edx, OFFSET FLAT:LC0   ;  Not Fine
    mov DWORD PTR [esp+12], 0
    mov DWORD PTR [esp+8], ecx  
    mov DWORD PTR [esp+4], edx  
    mov DWORD PTR [esp], 0
    call    eax
    nop
    leave
    ret

the first time, mov ecx, OFFSET FLAT:LC0 is ok

then the second time accession to LC0, mov edx, OFFSET FLAT:LC0 is not fine. it throws Invalid operand (KS_ERR_ASM_INVALIDOPERAND)

i try assemble the partial codes by increasing one line every time. and address wrong spot where it accesses to LC0 second time.

my using keystone is 0.92 from pypi.