Code Monkey home page Code Monkey logo

unjit's Introduction

unjit

Overview

Features

  • disassemble code from a living process;

  • based on LLVM disassembler;

  • by default disassemble all (JITed) subprograms found in /tmp/perf-$pid.map;

  • symbolication of JIT-ed symbols using /tmp/perf-$pid.map;

  • symbolication of AOT symbols using ELF SHT_SYMTAB and SHT_DYNSYM sections;

  • does not ptrace, does not stop the process;

  • output similar to the output of objdump and compatible with what Linux perf expects.

Compatibility

  • currently working on Linux 3.2 (process_vm_readv()) and a suitable libc

Limitations

  • Currently do not decompile code which does not have an associated symbol.

Usage

Basic usage

unjit -p $pid > dis.txt
  1. Find the JIT-ed function from a process from /tmp/perf-$pid.map;

  2. Read the corresponding instructions from the remote process memory;

  3. Disassemble them to stdout.

Using with perf

perf top -p $pid --objdump ./perfobjdump

Discussion

Linux perf map (/tmp/perf-${pid}.map)

The /tmp/perf-${pid}.map is a file used by JIT compilers to tell Linux perf the location and name of JITed subprograms. The format is:

$startAddressInHexa $sizeInHexa $name

Example:

41f3ae82 34 foo
41f3aec6 52 bar

Roadmap

Without any specific order:

  • better detection of modules (DT_DEBUG);

  • disassemble by symbol name;

  • symbolicate GOT and PLT addresses;

  • load symbols from DT_SYMTAB;

  • load symbols from DWARF (optional);

  • load DWARF info from a separate file;

  • do not hardcode the CPU model (CLI option);

  • select the native CPU model by default;

  • Capstone support.

unjit's People

Contributors

randomstuff avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

unjit's Issues

Option_SetInstrComments causes LLVM to choke on certain methods.

I'm using this tool against .NET Core, to great success. However for some reason it just hangs on certain methods and then memory leaks until LLVM runs out of memory.

I nailed down the cause to LLVMDisassembler_Option_SetInstrComments being passed as option to the dissasembler. When that option isn't there it's fine.

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.