GithubHelp home page GithubHelp logo

onlyuser / gen-callgraph Goto Github PK

View Code? Open in Web Editor NEW
49.0 8.0 4.0 22 KB

gen-callgraph is a script to generate call graph from elf binary

Home Page: http://onlyuser.github.io/

Shell 100.00%
callgraph graphviz-dot readelf objdump dot

gen-callgraph's Introduction

gen-callgraph

Copyright (C) 2011-2017 mailto:[email protected]

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

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:

picture alt

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

gen-callgraph's People

Contributors

onlyuser avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.