I am working on some x86 (32/64 bits) ELF binary code. These binaries are compiled from C and C++ program code and I am trying to detect loops inside the binaries. I am newbie to this area, and I am wondering, what is the standard way to identify a loop in binary code? I prefer to use some static methods to detect the loop instances, as I am not able to generate well-performing dynamic test cases.
What is the standard approach to find loop in binary code?
binary analysis;binary
The classic, compiler theoretic answer to this question is to build a control flow graph and then do a graph analysis to identify natural loops. I believe algorithms for this can be found in the Dragon Book, and a summary is given in these slides:http://www.cs.cmu.edu/afs/cs/academic/class/15745-s03/public/lectures/L7_handouts.pdfYou can also see how LLVM implements its loop detection:http://llvm.org/docs/doxygen/html/LoopInfo_8h_source.htmlThe search terms you want to find more information are things like natural loop and back edge.