Coder Social home page Coder Social logo

sfencevma / callgraph-gen Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kuopinghsu/callgraph-gen

0.0 0.0 0.0 7.21 MB

Generating the call graph from elf binary file

License: MIT License

C++ 12.47% C 40.83% Assembly 46.10% Makefile 0.60%

callgraph-gen's Introduction

Codacy Badge

Callgraph Generator

Generating the call graph from elf binary file

Binary Released

Getting Started

It requires following library to build the code.

Install the PCRE library and libxml2 directory. Or insatall libpcre2-dev and libxml2-dev package on Ubuntu.

$ sudo apt install libpcre2-dev libxml2-dev

Checkout the repository and initialize all submodules

$ git clone https://github.com/kuopinghsu/callgraph-gen.git
$ cd callgraph-gen
$ git submodule update --init --recursive

build

$ make

build on Visual Studio 2019

% mkdir {somewhere} && cd {somewhere}
% git clone https://github.com/kiyolee/libxml2-win-build.git
% git clone https://github.com/kiyolee/pcre2-win-build.git
% git clone --recursive https://github.com/kuopinghsu/callgraph-gen.git

Modify the file ./libxml2-win-build/include/libxml/xmlversion.h, keep the following and remove all other LIBXML_xxxx_ENABLED settings.

LIBXML_THREAD_ENABLED
LIBXML_READER_ENABLED
LIBXML_SAX1_ENABLED

Build libxml2-static and libpcre2-8-static, and then build callgraph.

Features

  • Generate call graph
  • Generate call tree
  • Recursive detection
  • Calculate the stack usage

Usage

Call graph generator. May 15 2020 build, written by Kuoping Hsu, MIT license
https://github.com/kuopinghsu/callgraph-gen

Usage:
    graphgen [-v] [-a target] [-x file] [-r function_name] [-m n]
             [-g | -t] [-c | -d] [-r name] [-i list] [-h]
             asm_file [vcg_file]

    --verbose, -v           verbose output
    --target name, -a name  specify the target (see support target
                            below)
    --xml file, -x file     read config file
    --root func, -r func    specify the root function
    --max n, -m n           max depth (default 256)
    --graph, -g             generate call graph (default)
    --tree, -t              generate call tree
    --nostack, -k           do not gather statck size
    --vcg, -c               generate vcg graph (default)
    --dot, -d               generate dot graph
    --ignore list, -i list  ignore list
    --help, -h              help

Support target:
    riscv
    arm
    openrisc
    xtensa
    xtensa_call0

Example:

    $ graphgen --max 10 --tree --ignore abort,exit infile.s

      maximun tree depth is 10, generate a call tree, ignore functions
      abort(), and exit().

    $ graphgen --xml mycore.xml --tree --root init infile.s

      Use a user-defined processor to generate a call tree from
      init() function.

This is an example to show the call tree of RISC-V's dhrystone diag. Using binutils to generate the assembly file

$ riscv64-unknown-elf-objdump -d dhrystone.riscv > dhrystone.s

Generate the Call-Graph of VCG file

$ graphgen --target riscv --graph dhrystone.s dhrystone.vcg

This is an example of call graph of RISC-V's dhrystone.
Dhrystone Call Graph

Generate the Call-Tree of VCG file

$ graphgen --target riscv --tree dhrystone.s dhrystone.vcg

This is an example of a call tree of RISC-V's dhrystone, and the red arc represents the call path used by the largest stack
Dhrystone Call Tree

(Note: This is a static analysis and is inaccurate if an indirect function call or recursion is detected.)

Recomment use yComp to browse the VCG file.

yComp

Limitations

  • Generating the call stack for ARM (experimental)

License

MIT license

callgraph-gen's People

Contributors

kuopinghsu 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.