1

I am desperately looking for a way to get the control-flow graph in assembly. I have the source code written in C and the processor is x86. I have already looked at the gcc's documentation and it does provide cfg in only gimple and rtl format. Any idea how to get it in assembly format?

user3684042
  • 651
  • 2
  • 6
  • 16
  • 1
    What does it mean to "get the control flow graph in assembly"? A CFG is a set of nodes associated with actions, and conditional transfer arcs between those nodes. Assembly isn't a CFG. What precisely are you looking for, and why do you want it in this form? Provide examples. – Ira Baxter Aug 18 '14 at 17:40
  • I am particularly looking for a CFG with basic blocks containing assembly code, rather than gimple format which gcc -fdump-tree-gimple provides. Something like the output of (http://www.debasish.in/2014/02/building-assembly-control-flow-graphcfg.html) but statically based on high level source code rather than dynamic execution of binary. – user3684042 Aug 18 '14 at 22:22
  • In short, CFG for the .s generated by GCC. – user3684042 Aug 18 '14 at 22:32
  • 1
    I assume (no specific knowledge of GCC) that the RTL still contains control flow information. Since it presumably contains abstract, low level machine operations, why isn't that adequaute? And you didn't answer why you wanted this. (You could always parse the .s file, and build control flow from that, modulo indirect function calls). – Ira Baxter Aug 18 '14 at 23:44
  • I want to do some analysis on the control flow graph of some open source programs and indirect branches are very important for me. I cannot exclude them from the control-flow at all. – user3684042 Aug 19 '14 at 01:42
  • Even GCC isn't going to tell you accurate where all indirect branches go. To the extent it *generated* and indirect branch (e.g., for a switch statement) it may know, but an indirect function call it probably can't trace. – Ira Baxter Aug 19 '14 at 02:16

1 Answers1

0

If all you need is to view a control flow graph of the program I can suggest to use the free evaluation version of the Interactive Disassembler, more commonly known as IDA.

If you visit their website, under the screenshots section it displays the graph view of a compiled method from the binary itself.

  • 1
    Thanks for your response. But, I am looking for something based on source code (top-down) not binary (reverse engineering). – user3684042 Aug 20 '14 at 14:40