$ r2 /bin/ls
-- We fix bugs while you sleep.
[0x004049a0]> aaa
[x] Analyze all flags starting with sym. and entry0 (aa)
[x] Analyze len bytes of instructions for references (aar)
[x] Analyze function calls (aac)
[x] Use -AAAnalyze orlen aaaabytes toof performinstructions additionalfor experimentalreferences analysis.(aar)
[x] Constructing a function name for fcn.* and sym.func.* functions (aan)
[x] Type matching analysis for all functions (afta)
[x] Use -AA or aaaa to perform additional experimental analysis.
[0x00000000]> ag?
|UsageUsage: ag[?f]Graphviz/graphag<graphtype><format> code[addr]
Graph commands:
| agaga[format] [addr] Data outputreferences graphvizgraph
| codeagA[format] (bb at addr and children) Global data references graph
| ag-agc[format] Function callgraph
| agC[format] Reset the current ASCII art graph (see agn, age, agg?)Global callgraph
| agaagd[format] [addr][fcn addr] Diff graph
| agf[format] idem, but only addresses Basic blocks function graph
| agc[j]agi[format] [addr] output graphviz call Imports graph
| ofagr[format] function References graph
| agC[j]agR[format] Global references graph
| Sameagx[format] as agc Cross references graph
| agg[format] Custom graph
| ag-1. full program callgraph Clear the custom graph
| agdagn[?] [fcntitle name]body Add outputa graphviznode codeto ofthe diffedcustom functiongraph
| age[?] title1 title2 Add an edge to the currentcustom graph
Output formats:
| agf<blank> [addr] Show ASCII Ascii art
| graph* of given function r2 commands
| d Graphviz dot
... <truncated> ...
| agvw [path] Write to Showpath functionor graphdisplay ingraph web/pngimage (see graph.webgv.format and cmd.graph.web) or agf for asciiart
You're searching for the agCagCd
command which will. The C
specifies to output a full ("global") call-graph of the program. The d
specifies to output in Graphviz dot format.
[0x004049a0]> agCagCd > output.dot
$ r2 /bin/ls
[0x004049a0]> aa
[x] Analyze all flags starting with sym. and entry0 (aa)
[0x004049a0]> agCagCd > output.dot
[0x004049a0]> !!dot -Tpng -o callgraph.png output.dot