decimalst/optimice

Can't handle instruction pushfw (66h 9ch)

Closed this issue · 2 comments


Starting optimization @ [0040d62c]
NOTE: INSTRUCTION NOT RECOGNIZED [PUSHFW] @ [0040d62d] [['PUSHFW']]
PUSHFW
[]
-------------
Traceback (most recent call last):
  File "E:/Programme/ida61adv/Optimice v0.13/code/Main.py", line 64, in wrapper
    optimice()
  File "E:/Programme/ida61adv/Optimice v0.13/code/Main.py", line 19, in optimice
    f = Function.Function(ea)
  File "E:/Programme/ida61adv/Optimice v0.13/code\Function.py", line 92, in __init__
    self.startAnalysis(self.start_ea)
  File "E:/Programme/ida61adv/Optimice v0.13/code\Function.py", line 468, in startAnalysis
    modified |= dead_code.ReduceBB(self.basic_blocks[prev_block_ea])
  File "E:/Programme/ida61adv/Optimice v0.13/code\CodeOptimization.py", line 108, in ReduceBB
    delta_taint = bb[delta].GetTaintInfo()
  File "E:/Programme/ida61adv/Optimice v0.13/code\Instruction.py", line 82, in GetTaintInfo
    self.taint = self.CalculateInstructionTaint()
  File "E:/Programme/ida61adv/Optimice v0.13/code\Instruction.py", line 448, in CalculateInstructionTaint
    if x86InstructionData[mnem].has_key(op):
KeyError: 'PUSHFW'
-------------

Original issue reported on code.google.com by Ralf_Bra...@gmx.de on 14 Dec 2011 at 11:10

Fixed in latest version support for PUSHFW.
One thing that is left is support for removing PUSHF/POPF pairs.
Everything except PUSHF/POPF removal works and was tested with following code:

[BITS 32]

;test 1 - optimize push/pop pair
o16 push word 0x85e
mov bx, 0x7b
mov eax, 1
o16 pop bx
ret
;result:
;mov eax, 1
;mov bx, 0x85e

;test 2 - remove dead push/pop pair
o16 push word 0x85e
o16 pop bx
mov ebx, 0x7b
mov eax, 1
ret
;result:
;mov ebx, 0x7b
;mov eax, 1


;test 3 - remove mov, leave push/pop
o32 push 0x12dc0de
mov bx, 0x7b
mov eax, 1
o16 pop bx
ret
;result:
;o32 push 0xbadcode
;mov eax, 1
;o16 pop bx

;test 4 - cmp,pushf
cmp     ecx, eax
pushf
xor     eax, eax
ret
;result:
;cmp ecx, eax
;pushf
;xor eax, eax

;test 5 - test,pushf
test     eax, eax
pushf
xor     eax, eax
ret
;result:
;test ecx, eax
;pushf
;xor eax, eax


;test 6 - pushf, no opt
pushf
mov eax, eax
popf
ret
;result:
;pushf
;mov eax, eax
;popf

;test 7 - pushf, no opt
pushf
test eax, eax
mov ebx, 2
popf
ret
;result:
;mov ebx, 2

;test 8 - no opt
cmp     ecx, eax
pushfw
xor     eax, eax
ret
;result:
;cmp ecx, eax
;pushfw
;xor eax, eax

;test 8 - no opt
cmp     ecx, eax
pushfw
popfw
xor     eax, eax
ret
;result:
;cmp ecx, eax
;xor eax, eax

Original comment by glj...@gmail.com on 18 Jan 2012 at 9:47

  • Changed state: Started
Fixed, handles all cases correctly.

Original comment by glj...@gmail.com on 22 Feb 2012 at 10:59

  • Changed state: Verified