Commit c0765a3e authored by Andrea Gussoni's avatar Andrea Gussoni
Browse files

Add main IDA driver for decompiled normalization

parent ebe715d5
#!/bin/bash
if [ $# -eq 0 ]; then
echo "No arguments supplied"
exit 1
fi
filename=$1
iteration=0
max_iteration=15
# Invoke a script which performs ad-hoc normalization for this decompiled output.
./ida-normalizer-pre.sh $filename
# First invocation of the compiler
clang-7 -ferror-limit=0 -S -emit-llvm -w $filename &> clang.log
# While we have errors output from the compiler, continue our fixed-point purge.
while [ -s clang.log ]; do
# Invoke the script that, on the basis of the compiler output generated at the previous iteration, purges the decompiled file.
./ida-normalizer.sh $filename clang.log
# Invoke the compiler.
clang-7 -ferror-limit=0 -S -emit-llvm -w $filename &> clang.log
iteration=$((iteration + 1))
# Exit if we did not reach stability in an high number of runs (cheap way to detect instability).
if [ "$iteration" -gt "$max_iteration" ]; then
echo "Stability not reached"
break
fi
done
# Finally, create the output adding an adequate suffix.
cp $filename $filename.normalized.c
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment