BoomerangDecompiler / boomerang

Boomerang Decompiler - Fighting the code-rot :)
Other
370 stars 59 forks source link

Possibly wrong decompilation of switch statements #256

Open ceeac opened 4 years ago

ceeac commented 4 years ago

Boomerang version: v0.5.1 (d4d9aea84)

Steps to reproduce:

  1. Decompile an executable containing a switch statement that is propagated to

Additional comments: When decompiling an executable containing a switch statement, the following may happen:

  1. The RTL for the switch statement is created. After conversion to SSA form, the computed jump from the switch statement references statement a.
  2. Statement propagation is applied. The computed jump now contains a reference to statement b.
  3. After switch/case analysis, the switch expression is saved by IFrontEnd::saveDecodedRTL.
  4. The whole CFG is re-created. When re-creating the RTL for the switch statement, the previously-saved RTL referencing statement b is re-loaded. This is a different statement and after propagation the switch expression may be different from before re-decoding, which is incorrect.

The best solution would be to separate disassembly and lifting of instructions and just clearing and re-lifting the IR for each machine instruction after analyzing switch statements and other computed CTIs.