Coder Social home page Coder Social logo

troll's Introduction

Troll

Troll is an analyzer of the DWARF information embeded in ELF binary. This is inspired by fromelf, and written in Rust.

Features

  • Output static variable information

Install

Examples

$ git clone https://github.com/forestaa/troll.git
$ cat examples/simple.c
#include <stdio.h>

typedef struct hoge {
  int hoge;
  char hogehoge;
  int array[2];
} Hoge;

Hoge hoges[3];

int main(void) {
  return 0;
}
$ gcc -O0 -g -o examples/simple examples/simple.c
$ cargo run examples/simple  # You can run `./troll examples/simple` if you install a binary.
...

address    size  variable_name        type
0x00004060 0x030 hoges                Hoge[2]
0x00004060 0x010 hoges[0]             Hoge
0x00004060 0x004 hoges[0].hoge        int
0x00004064 0x001 hoges[0].hogehoge    char
0x00004068 0x008 hoges[0].array       int[1]
0x00004068 0x004 hoges[0].array[0]    int
0x0000406c 0x004 hoges[0].array[1]    int
0x00004070 0x010 hoges[1]             Hoge
0x00004070 0x004 hoges[1].hoge        int
0x00004074 0x001 hoges[1].hogehoge    char
0x00004078 0x008 hoges[1].array       int[1]
0x00004078 0x004 hoges[1].array[0]    int
0x0000407c 0x004 hoges[1].array[1]    int
0x00004080 0x010 hoges[2]             Hoge
0x00004080 0x004 hoges[2].hoge        int
0x00004084 0x001 hoges[2].hogehoge    char
0x00004088 0x008 hoges[2].array       int[1]
0x00004088 0x004 hoges[2].array[0]    int
0x0000408c 0x004 hoges[2].array[1]    int

troll's People

Contributors

forestaa avatar

Stargazers

 avatar Yusuke Sangenya avatar

Watchers

James Cloos avatar  avatar

troll's Issues

char variable is not aligned and upper_bound of an array is interpreted differently

A char variable in a structure should be aligned.
The type has size 1, but the variable can have size 4.

Moreover, the variable should have 3 children when the upper_bound of an array is 2.
Currently, it has 3 children.

The output of eu-readlef is below.
The byte_size is 16 and data_member_location is aligned even though the member has the type char.

 [    2d]    structure_type       abbrev: 2
             name                 (strp) "hoge"
             byte_size            (data1) 16
             decl_file            (data1) simple.c (1)
             decl_line            (data1) 1
             decl_column          (data1) 16
             sibling              (ref4) [    62]
 [    3a]      member               abbrev: 3
               name                 (strp) "hoge"
               decl_file            (data1) simple.c (1)
               decl_line            (data1) 2
               decl_column          (data1) 7
               type                 (ref4) [    62]
               data_member_location (data1) 0
 [    47]      member               abbrev: 3
               name                 (strp) "hogehoge"
               decl_file            (data1) simple.c (1)
               decl_line            (data1) 3
               decl_column          (data1) 8
               type                 (ref4) [    69]
               data_member_location (data1) 4
 [    54]      member               abbrev: 3
               name                 (strp) "array"
               decl_file            (data1) simple.c (1)
               decl_line            (data1) 4
               decl_column          (data1) 7
               type                 (ref4) [    70]
               data_member_location (data1) 8

Current output is below.
The size is different and char variable is not aligned.

address    size  variable_name        type
0x00004060 0x012 hoges                Hoge[2]
0x00004060 0x009 hoges[0]             Hoge
0x00004060 0x004 hoges[0].hoge        int
0x00004064 0x001 hoges[0].hogehoge    char
0x00004065 0x004 hoges[0].array       int[1]
0x00004065 0x004 hoges[0].array[0]    int
0x00004069 0x009 hoges[1]             Hoge
0x00004069 0x004 hoges[1].hoge        int
0x0000406d 0x001 hoges[1].hogehoge    char
0x0000406e 0x004 hoges[1].array       int[1]
0x0000406e 0x004 hoges[1].array[0]    int

CI

  • test
  • release

maybe use Github Actions?

Error handling

Currently does not provide an appropriate error message.
Define custom error and provide messages.

enum value is not printed when typedef enum

Assume the input is like this:

typedef enum {
A,
B,
} AB;
AB ab;

The output is as follows:

address    size  variable_name        type
0x0000402c 0x004 ab                   AB

But, it is desired to print the enum value A = 0, B = 1.

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.