Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions example/disasm/full.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from miasm2.analysis.machine import Machine
from miasm2.analysis.data_flow import dead_simp, DiGraphDefUse, ReachingDefinitions
from miasm2.expression.simplifications import expr_simp
from miasm2.analysis.ssa import SSAPath, SSADiGraph

log = logging.getLogger("dis")
console_handler = logging.StreamHandler()
Expand Down Expand Up @@ -52,6 +53,8 @@
parser.add_argument('-d', "--defuse", action="store_true",
help="Dump the def-use graph in file 'defuse.dot'."
"The defuse is dumped after simplifications if -s option is specified")
parser.add_argument('-p', "--ssa", action="store_true",
help="Generate the ssa form in 'ssa.dot'.")

args = parser.parse_args()

Expand Down Expand Up @@ -236,3 +239,13 @@
modified |= ircfg_a.merge_blocks()

open('graph_irflow_reduced.dot', 'w').write(ircfg_a.dot())

if args.ssa:
heads = ircfg_a.heads()
if len(heads) != 1:
raise RuntimeError("Your graph should have only one head")
head = list(heads)[0]
ssa = SSADiGraph(ircfg_a)
ssa.transform(head)

open("ssa.dot", "wb").write(ssa.graph.dot())
Loading