https://github.com/onlyuser/gen-callgraph
gen-callgraph is a script to generate call graph from elf binary
https://github.com/onlyuser/gen-callgraph
callgraph dot graphviz-dot objdump readelf
Last synced: about 1 month ago
JSON representation
gen-callgraph is a script to generate call graph from elf binary
- Host: GitHub
- URL: https://github.com/onlyuser/gen-callgraph
- Owner: onlyuser
- Created: 2015-02-11T18:56:38.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2018-12-31T03:01:59.000Z (over 6 years ago)
- Last Synced: 2023-10-20T22:11:19.985Z (over 1 year ago)
- Topics: callgraph, dot, graphviz-dot, objdump, readelf
- Language: Shell
- Homepage: http://onlyuser.github.io/
- Size: 21.5 KB
- Stars: 48
- Watchers: 8
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
gen-callgraph
=============Copyright (C) 2011-2017
About
-----gen-callgraph is a script to generate call graph from elf binary.
See sister project for generating c-tags from elf binary: [gen-ctags](https://github.com/onlyuser/gen-ctags)
A Motivating Example
--------------------input: elf binary from below source:
class QWE
{
public:
QWE() {}
~QWE() {}
void f() {}
};void A();
void C() {A();}
void B() {C(); QWE qwe; qwe.f();}
void A() {B(); C();}int main(int argc, char** argv)
{
A();
return 0;
}output: graphviz dot for below graph:

Requirements
------------bash readelf objdump c++filt graphviz
Limitations
-----------
- Only supports statically linked functions within one x86_64 binary.
- Only supports function calls invoked by assembly commands callq/jmpq/jmp and conditional jump variants on literal (non-register) destinations.
- Naive algorithm. Only tested on small binaries.
Installation (Debian)
---------------------
1. git clone https://github.com/onlyuser/gen-callgraph.git
Usage
-----
gen-callgraph <BINARY> [DEBUG={0*/1}] | dot -Tpng -ocallgraph.png
Recommended gcc Options
-----------------------
- -g
- -O0
- -fno-function-cse
- -fomit-frame-pointer
References
----------
- "Disassemble raw x64 machine code"
- http://stackoverflow.com/questions/19071461/disassemble-raw-x64-machine-code
- "Graphviz - Graph Visualization Software"
- http://www.graphviz.org/
- "Trying to understand gcc option -fomit-frame-pointer"
- http://stackoverflow.com/questions/14666665/trying-to-understand-gcc-option-fomit-frame-pointer
- "3.10 Options That Control Optimization"
- https://gcc.gnu.org/onlinedocs/gcc-4.5.2/gcc/Optimize-Options.html
Keywords
--------
call graph, asm, disassembly, elf, graphviz, name mangling